From: Cedric Hombourger <Cedric_Hombourger@mentor.com>
To: <isar-users@googlegroups.com>
Cc: Cedric Hombourger <Cedric_Hombourger@mentor.com>
Subject: [PATCH 4/4] isar-image: add support for OE's ROOTFS_*_COMMAND
Date: Mon, 29 Oct 2018 17:13:03 +0100 [thread overview]
Message-ID: <20181029161303.7410-5-Cedric_Hombourger@mentor.com> (raw)
In-Reply-To: <20181029161303.7410-1-Cedric_Hombourger@mentor.com>
OpenEmbedded allows custom functions to be called at various stages of
the root file-system generation process. Add similar capabilities to
Isar.
Signed-off-by: Cedric Hombourger <Cedric_Hombourger@mentor.com>
---
doc/user_manual.md | 10 ++++++++++
meta-isar/classes/isar-image.bbclass | 17 +++++++++++++++++
meta/lib/oe/utils.py | 11 +++++++++++
3 files changed, 38 insertions(+)
create mode 100644 meta/lib/oe/utils.py
diff --git a/doc/user_manual.md b/doc/user_manual.md
index b702c28..0c4ed4a 100644
--- a/doc/user_manual.md
+++ b/doc/user_manual.md
@@ -527,6 +527,16 @@ was assembled. Isar provides scripts for Debian and Raspbian. In the event where
used, your custom image recipe may need to set `DISTRO_CONFIG_SCRIPT` and use `SRC_URI` and `FILESPATH` for the script to
be copied into the work directory (`WORKDIR`).
+Custom (python) functions may also be called at various steps during the root file-system generation process. They should
+be listed in either `ROOTFS_PREPROCESS_COMMAND` for any functions to be called before the root file-system gets populated,
+`ROOTFS_POSTINSTALL_COMMAND` for functions to be called right after selected packages were installed and finally
+`ROOTFS_POSTPROCESS_COMMAND` after the final configuration script and clean-up tasks were called. Functions listed in these
+variables should be separated by a semi-colon sign (;).
+
+It should also be noted that Isar may no longer execute commands from the created root file-system after it was cleaned-up
+(binaries required to support emulation of foreign architectures would have been removed). Please consider this when
+designing functions to be called from `ROOTFS_POSTPROCESS_COMMAND`.
+
---
## Add a Custom Application
diff --git a/meta-isar/classes/isar-image.bbclass b/meta-isar/classes/isar-image.bbclass
index e0508be..d5358e0 100644
--- a/meta-isar/classes/isar-image.bbclass
+++ b/meta-isar/classes/isar-image.bbclass
@@ -64,9 +64,26 @@ isar_image_cleanup() {
sudo rm -f "${IMAGE_ROOTFS}/etc/apt/apt.conf.d/55isar-fallback.conf"
}
+ROOTFS_PREPROCESS_COMMAND ?= ""
+ROOTFS_POSTINSTALL_COMMAND ?= ""
+ROOTFS_POSTPROCESS_COMMAND ?= ""
+
python do_rootfs() {
+ from oe.utils import execute_pre_post_process
+
bb.build.exec_func("isar_image_gen_fstab", d)
+
+ pre_process_cmds = d.getVar("ROOTFS_PREPROCESS_COMMAND")
+ execute_pre_post_process(d, pre_process_cmds)
+
bb.build.exec_func("isar_image_gen_rootfs", d)
+
+ post_install_cmds = d.getVar("ROOTFS_POSTINSTALL_COMMAND")
+ execute_pre_post_process(d, post_install_cmds)
+
bb.build.exec_func("isar_image_conf_rootfs", d)
bb.build.exec_func("isar_image_cleanup", d)
+
+ post_process_cmds = d.getVar("ROOTFS_POSTPROCESS_COMMAND")
+ execute_pre_post_process(d, post_process_cmds)
}
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
new file mode 100644
index 0000000..dc3a872
--- /dev/null
+++ b/meta/lib/oe/utils.py
@@ -0,0 +1,11 @@
+# heavily stripped-down copy of OE's meta/lib/oe/utils.py
+
+def execute_pre_post_process(d, cmds):
+ if cmds is None:
+ return
+
+ for cmd in cmds.strip().split(';'):
+ cmd = cmd.strip()
+ if cmd != '':
+ bb.note("Executing %s ..." % cmd)
+ bb.build.exec_func(cmd, d)
--
2.11.0
next prev parent reply other threads:[~2018-10-29 16:13 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-29 16:12 [PATCH 0/4] " Cedric Hombourger
2018-10-29 16:13 ` [PATCH 1/4] isar-image-base: introduce and use isar-image class Cedric Hombourger
2018-11-09 13:42 ` Baurzhan Ismagulov
2018-10-29 16:13 ` [PATCH 2/4] isar-image: refactor do_rootfs() Cedric Hombourger
2018-11-29 15:06 ` Jan Kiszka
2018-10-29 16:13 ` [PATCH 3/4] base: add 'lib' folder of each layer to python's module search path Cedric Hombourger
2018-10-29 16:13 ` Cedric Hombourger [this message]
2018-10-29 16:45 ` [PATCH 0/4] add support for OE's ROOTFS_*_COMMAND Henning Schild
2018-10-29 16:55 ` Hombourger, Cedric
2018-10-30 9:25 ` Henning Schild
2018-10-30 11:02 ` Hombourger, Cedric
2018-10-30 12:41 ` Henning Schild
2018-10-30 12:45 ` Hombourger, Cedric
2018-10-31 6:10 ` [PATCH v2 0/2] introduce isar-image class Cedric Hombourger
2018-10-31 6:10 ` [PATCH v2 1/2] isar-image-base: introduce and use " Cedric Hombourger
2018-10-31 6:10 ` [PATCH v2 2/2] isar-image: refactor do_rootfs() Cedric Hombourger
2018-10-31 6:39 ` [PATCH v2 0/2] introduce isar-image class Jan Kiszka
2018-10-31 6:51 ` chombourger
2018-11-01 11:43 ` Maxim Yu. Osipov
2018-11-09 13:26 ` Baurzhan Ismagulov
2018-11-01 10:13 ` [PATCH v3 1/2] isar-image-base: introduce and use " Cedric Hombourger
2018-11-01 10:13 ` [PATCH v3 2/2] isar-image: refactor do_rootfs() Cedric Hombourger
2018-11-07 13:20 ` Jan Kiszka
2018-11-08 7:59 ` Hombourger, Cedric
2018-11-08 8:28 ` Jan Kiszka
2018-11-07 18:45 ` Henning Schild
2018-11-07 19:46 ` Cedric Hombourger
2018-11-07 20:16 ` Cedric Hombourger
2018-11-08 6:52 ` Jan Kiszka
2018-11-08 8:13 ` Henning Schild
2018-11-07 13:07 ` [PATCH v3 1/2] isar-image-base: introduce and use isar-image class Maxim Yu. Osipov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181029161303.7410-5-Cedric_Hombourger@mentor.com \
--to=cedric_hombourger@mentor.com \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox