[bootlin/training-materials updates] master: yocto: slides: move "Using Python code in metadata" earlier (cfad4b78)
Luca Ceresoli
luca.ceresoli at bootlin.com
Thu Aug 18 10:19:13 CEST 2022
Repository : https://github.com/bootlin/training-materials
On branch : master
Link : https://github.com/bootlin/training-materials/commit/cfad4b780d9d15d4c645d6968a949906aba9a750
>---------------------------------------------------------------
commit cfad4b780d9d15d4c645d6968a949906aba9a750
Author: Luca Ceresoli <luca.ceresoli at bootlin.com>
Date: Wed Aug 17 14:57:04 2022 +0200
yocto: slides: move "Using Python code in metadata" earlier
This topic is used in a preceding subsection ("Package features"), thus
move it earlier.
The subsection sequence was:
- Variable flags
- Packages features
- Conditional features
- Using Python code in metadata <--
- Root filesystem creation
- Splitting packages
and becomes:
- Using Python code in metadata <--
- Variable flags
- Packages features
- Conditional features
- Root filesystem creation
- Splitting packages
with the goal of having all syntax-related topics first but still keeping
"Variable flags" just before "Packages features" where it is used.
Signed-off-by: Luca Ceresoli <luca.ceresoli at bootlin.com>
>---------------------------------------------------------------
cfad4b780d9d15d4c645d6968a949906aba9a750
slides/yocto-recipe-extra/yocto-recipe-extra.tex | 126 +++++++++++------------
1 file changed, 63 insertions(+), 63 deletions(-)
diff --git a/slides/yocto-recipe-extra/yocto-recipe-extra.tex b/slides/yocto-recipe-extra/yocto-recipe-extra.tex
index 9f36a70a..94b05960 100644
--- a/slides/yocto-recipe-extra/yocto-recipe-extra.tex
+++ b/slides/yocto-recipe-extra/yocto-recipe-extra.tex
@@ -1,5 +1,68 @@
\section{Writing recipes - going further}
+\subsection{Using Python code in metadata}
+
+\begin{frame}
+ \frametitle{Tasks in Python}
+ \begin{itemize}
+ \item Tasks can be written in Python when using the keyword
+ \code{python}.
+ \item The \code{d} variable is accessible, and represents the
+ BitBake datastore (where variables are stored).
+ \item Two modules are automatically imported:
+ \begin{itemize}
+ \item \code{bb}: to access BitBake's internal functions.
+ \item \code{os}: Python's operating system interfaces.
+ \end{itemize}
+ \item You can import other modules using the keyword
+ \code{import}.
+ \item Anonymous Python functions are executed during parsing.
+ \item Short Python code snippets can be written inline with the {\tt
+ \$\{@<python code>\}} syntax.
+ \end{itemize}
+\end{frame}
+
+\begin{frame}
+ \frametitle{Accessing the datastore with Python}
+ \begin{itemize}
+ \item The \code{d} variable is accessible within Python tasks.
+ \end{itemize}
+ \begin{description}
+ \item[\code{d.getVar("X", expand=False)}] Returns the value of
+ \code{X}.
+ \item[\code{d.setVar("X", "value")}] Set \code{X}.
+ \item[\code{d.appendVar("X", "value")}] Append \code{value} to
+ \code{X}.
+ \item[\code{d.prependVar("X", "value")}] Prepend \code{value} to
+ \code{X}.
+ \item[\code{d.expand(expression)}] Expand variables in
+ \code{expression}.
+ \end{description}
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Python code examples}
+ \begin{minted}{python}
+# Anonymous function
+python __anonymous() {
+ if d.getVar("FOO", True) == "example":
+ d.setVar("BAR", "Hello, World.")
+}
+# Task
+python do_settime() {
+ import time
+ d.setVar("TIME", time.strftime('%Y%m%d', time.gmtime()))
+}
+ \end{minted}
+ \begin{minted}{sh}
+# Inline
+do_install() {
+ echo "Build OS: ${@os.uname()[0].lower()}"
+}
+
+ \end{minted}
+\end{frame}
+
\subsection{Variable flags}
\begin{frame}[fragile]
@@ -114,69 +177,6 @@ PACKAGECONFIG ??= "wispr iptables client\
\end{itemize}
\end{frame}
-\subsection{Using Python code in metadata}
-
-\begin{frame}
- \frametitle{Tasks in Python}
- \begin{itemize}
- \item Tasks can be written in Python when using the keyword
- \code{python}.
- \item The \code{d} variable is accessible, and represents the
- BitBake datastore (where variables are stored).
- \item Two modules are automatically imported:
- \begin{itemize}
- \item \code{bb}: to access BitBake's internal functions.
- \item \code{os}: Python's operating system interfaces.
- \end{itemize}
- \item You can import other modules using the keyword
- \code{import}.
- \item Anonymous Python functions are executed during parsing.
- \item Short Python code snippets can be written inline with the {\tt
- \$\{@<python code>\}} syntax.
- \end{itemize}
-\end{frame}
-
-\begin{frame}
- \frametitle{Accessing the datastore with Python}
- \begin{itemize}
- \item The \code{d} variable is accessible within Python tasks.
- \end{itemize}
- \begin{description}
- \item[\code{d.getVar("X", expand=False)}] Returns the value of
- \code{X}.
- \item[\code{d.setVar("X", "value")}] Set \code{X}.
- \item[\code{d.appendVar("X", "value")}] Append \code{value} to
- \code{X}.
- \item[\code{d.prependVar("X", "value")}] Prepend \code{value} to
- \code{X}.
- \item[\code{d.expand(expression)}] Expand variables in
- \code{expression}.
- \end{description}
-\end{frame}
-
-\begin{frame}[fragile]
- \frametitle{Python code examples}
- \begin{minted}{python}
-# Anonymous function
-python __anonymous() {
- if d.getVar("FOO", True) == "example":
- d.setVar("BAR", "Hello, World.")
-}
-# Task
-python do_settime() {
- import time
- d.setVar("TIME", time.strftime('%Y%m%d', time.gmtime()))
-}
- \end{minted}
- \begin{minted}{sh}
-# Inline
-do_install() {
- echo "Build OS: ${@os.uname()[0].lower()}"
-}
-
- \end{minted}
-\end{frame}
-
\subsection{Root filesystem creation}
\begin{frame}[fragile]
More information about the training-materials-updates
mailing list