From: claudius.heine.ext@siemens.com
To: isar-users@googlegroups.com
Cc: Claudius Heine <ch@denx.de>
Subject: [PATCH 1/1] meta/classes/image: implement ROOTFS_POSTPROCESS_COMMAND
Date: Tue, 26 Mar 2019 08:32:27 +0100 [thread overview]
Message-ID: <20190326073227.11091-2-claudius.heine.ext@siemens.com> (raw)
In-Reply-To: <20190326073227.11091-1-claudius.heine.ext@siemens.com>
From: Claudius Heine <ch@denx.de>
Signed-off-by: Claudius Heine <ch@denx.de>
---
meta/classes/image.bbclass | 86 +++++++++++++++++++-------------------
1 file changed, 43 insertions(+), 43 deletions(-)
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 01c6f3b..cd92fbc 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -118,7 +118,7 @@ python set_image_size () {
d.setVarFlag('ROOTFS_SIZE', 'export', '1')
}
-isar_image_gen_fstab() {
+do_image_gen_fstab() {
cat > ${WORKDIR}/fstab << EOF
# Begin /etc/fstab
/dev/root / auto defaults 0 0
@@ -131,14 +131,44 @@ devtmpfs /dev devtmpfs mode=0755,nosuid 0 0
# End /etc/fstab
EOF
}
+addtask image_gen_fstab before do_rootfs
-isar_image_gen_rootfs() {
+do_rootfs[depends] = "isar-apt:do_cache_config isar-bootstrap-target:do_bootstrap"
+do_rootfs[deptask] = "do_deploy_deb"
+do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
+ ${IMAGE_ROOTFS}/isar-apt"
+do_rootfs() {
setup_root_file_system --clean --keep-apt-cache \
--fstab "${WORKDIR}/fstab" \
"${IMAGE_ROOTFS}" ${IMAGE_PREINSTALL} ${IMAGE_INSTALL}
}
+addtask rootfs before do_build after do_unpack
+
+do_copy_boot_files[dirs] = "${DEPLOY_DIR_IMAGE}"
+do_copy_boot_files() {
+ if [ -n "${KERNEL_IMAGE}" ]; then
+ cp -f ${IMAGE_ROOTFS}/boot/${@get_image_name(d, 'vmlinuz')[0]} ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE}
+ fi
+
+ if [ -n "${INITRD_IMAGE}" ]; then
+ sudo cp -f ${IMAGE_ROOTFS}/boot/${@get_image_name(d, 'initrd.img')[0]} ${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}
+ fi
+
+ # Check DTB_FILE via inline python to handle unset case:
+ if [ -n "${@d.getVar('DTB_FILE', True) or ""}" ]; then
+ dtb="$(find '${IMAGE_ROOTFS}/usr/lib' -type f \
+ -iwholename '*linux-image-*/${DTB_FILE}' | head -1)"
+
+ if [ -z "$dtb" -o ! -e "$dtb" ]; then
+ die "${DTB_FILE} not found"
+ fi
+
+ cp -f "$dtb" "${DEPLOY_DIR_IMAGE}/${DTB_FILE}"
+ fi
+}
+addtask copy_boot_files before do_rootfs_postprocess after do_rootfs
-isar_image_conf_rootfs() {
+postproc_image_conf_rootfs() {
# Configure root filesystem
if [ -n "${DISTRO_CONFIG_SCRIPT}" ]; then
sudo install -m 755 "${WORKDIR}/${DISTRO_CONFIG_SCRIPT}" "${IMAGE_ROOTFS}"
@@ -149,7 +179,7 @@ isar_image_conf_rootfs() {
fi
}
-isar_image_cleanup() {
+postproc_image_cleanup() {
# Cleanup
sudo sh -c ' \
rm "${IMAGE_ROOTFS}/etc/apt/sources.list.d/isar-apt.list"
@@ -175,53 +205,23 @@ isar_image_cleanup() {
'
}
-do_rootfs[depends] = "isar-apt:do_cache_config isar-bootstrap-target:do_bootstrap"
-do_rootfs[deptask] = "do_deploy_deb"
-do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
- ${IMAGE_ROOTFS}/isar-apt"
-do_rootfs() {
- isar_image_gen_fstab
- isar_image_gen_rootfs
- isar_image_conf_rootfs
- isar_image_cleanup
-}
-addtask rootfs before do_build after do_unpack
-
-do_mark_rootfs() {
+postproc_mark_rootfs() {
BUILD_ID=$(get_build_id)
update_etc_os_release \
--build-id "${BUILD_ID}" --variant "${DESCRIPTION}" \
"${IMAGE_ROOTFS}"
}
-addtask mark_rootfs before do_rootfs_postprocess after do_rootfs
-
-do_copy_boot_files[dirs] = "${DEPLOY_DIR_IMAGE}"
-do_copy_boot_files() {
- if [ -n "${KERNEL_IMAGE}" ]; then
- cp -f ${IMAGE_ROOTFS}/boot/${@get_image_name(d, 'vmlinuz')[0]} ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE}
- fi
- if [ -n "${INITRD_IMAGE}" ]; then
- sudo cp -f ${IMAGE_ROOTFS}/boot/${@get_image_name(d, 'initrd.img')[0]} ${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}
- fi
-
- # Check DTB_FILE via inline python to handle unset case:
- if [ -n "${@d.getVar('DTB_FILE', True) or ""}" ]; then
- dtb="$(find '${IMAGE_ROOTFS}/usr/lib' -type f \
- -iwholename '*linux-image-*/${DTB_FILE}' | head -1)"
-
- if [ -z "$dtb" -o ! -e "$dtb" ]; then
- die "${DTB_FILE} not found"
- fi
-
- cp -f "$dtb" "${DEPLOY_DIR_IMAGE}/${DTB_FILE}"
- fi
-}
-addtask copy_boot_files before do_rootfs_postprocess after do_rootfs
+ROOTFS_POSTPROCESS_COMMAND = "postproc_image_conf_rootfs postproc_mark_rootfs postproc_image_cleanup"
+do_rootfs_postprocess[vardeps] = "${ROOTFS_POSTPROCESS_COMMAND}"
python do_rootfs_postprocess() {
- """Virtual task"""
- pass
+ cmds = d.getVar("ROOTFS_POSTPROCESS_COMMAND")
+ if cmds is None or not cmds.strip():
+ return
+ cmds = cmds.split()
+ for cmd in cmds:
+ bb.build.exec_func(cmd, d)
}
addtask rootfs_postprocess before do_build after do_rootfs
--
2.20.1
next prev parent reply other threads:[~2019-03-26 7:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-26 7:32 [PATCH 0/1] Implement ROOTFS postprocess commands claudius.heine.ext
2019-03-26 7:32 ` claudius.heine.ext [this message]
2019-03-28 12:51 ` Claudius Heine
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=20190326073227.11091-2-claudius.heine.ext@siemens.com \
--to=claudius.heine.ext@siemens.com \
--cc=ch@denx.de \
--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