* [PATCH 1/1] meta/classes/image: implement ROOTFS_POSTPROCESS_COMMAND
2019-03-26 7:32 [PATCH 0/1] Implement ROOTFS postprocess commands claudius.heine.ext
@ 2019-03-26 7:32 ` claudius.heine.ext
2019-03-28 12:51 ` [PATCH 0/1] Implement ROOTFS postprocess commands Claudius Heine
1 sibling, 0 replies; 3+ messages in thread
From: claudius.heine.ext @ 2019-03-26 7:32 UTC (permalink / raw)
To: isar-users; +Cc: Claudius Heine
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 0/1] Implement ROOTFS postprocess commands
2019-03-26 7:32 [PATCH 0/1] Implement ROOTFS postprocess commands claudius.heine.ext
2019-03-26 7:32 ` [PATCH 1/1] meta/classes/image: implement ROOTFS_POSTPROCESS_COMMAND claudius.heine.ext
@ 2019-03-28 12:51 ` Claudius Heine
1 sibling, 0 replies; 3+ messages in thread
From: Claudius Heine @ 2019-03-28 12:51 UTC (permalink / raw)
To: isar-users; +Cc: Claudius Heine
Hi,
On 26/03/2019 08.32, [ext] claudius.heine.ext@siemens.com wrote:
> From: Claudius Heine <ch@denx.de>
>
> Hi,
>
> this is the first draft of the ROOTFS postprocess implementation.
>
> I switched some of the currently done task over to it as well.
>
> This patchset depends on the 'Clean image pipeline' one, which in turn
> depends on the 'Move isar-image into image class' patchset.
>
> What do you think about this solution?
I am currently working on implementing a preprocessing feature for the
rootfs, e.g. allowing to run commands before any custom packages are
installed and that effected this patch a smidge. So I will first
implement that before sending v2 of this patch.
But since I will be using the same mechanism as shown here, please give
feedback about it.
Thanks,
Claudius
>
> Cheers,
> Claudius
>
> Claudius Heine (1):
> meta/classes/image: implement ROOTFS_POSTPROCESS_COMMAND
>
> meta/classes/image.bbclass | 86 +++++++++++++++++++-------------------
> 1 file changed, 43 insertions(+), 43 deletions(-)
>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-54 Fax: (+49)-8142-66989-80 Email: ch@denx.de
^ permalink raw reply [flat|nested] 3+ messages in thread