From: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
To: <isar-users@googlegroups.com>
Cc: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
Subject: [PATCH v6 01/13] rootfs: Make rootfs finalize a separate task
Date: Wed, 30 Sep 2020 11:32:47 +0530 [thread overview]
Message-ID: <20200930060259.12422-2-Vijaikumar_Kanagarajan@mentor.com> (raw)
In-Reply-To: <20200930060259.12422-1-Vijaikumar_Kanagarajan@mentor.com>
With the current implementation it is difficult to append a
postprocess function which requires a chroot environment.
For example, to add a postprocess function which runs apt-get to
download all source of packages installed in the target.
rootfs_postprocess_finalize is not actually an optional feature
but instead a necessary cleanup function for image class.
So, move the implementation to image class and make it as a task.
Signed-off-by: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
---
meta/classes/image.bbclass | 41 ++++++++++++++++++++++++++++++++++++-
meta/classes/rootfs.bbclass | 39 -----------------------------------
2 files changed, 40 insertions(+), 40 deletions(-)
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index a296cc0..2391529 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -63,7 +63,7 @@ image_do_mounts() {
}
ROOTFSDIR = "${IMAGE_ROOTFS}"
-ROOTFS_FEATURES += "clean-package-cache finalize-rootfs generate-manifest"
+ROOTFS_FEATURES += "clean-package-cache generate-manifest"
ROOTFS_PACKAGES += "${IMAGE_PREINSTALL} ${IMAGE_INSTALL}"
ROOTFS_MANIFEST_DEPLOY_DIR ?= "${DEPLOY_DIR_IMAGE}"
@@ -173,5 +173,44 @@ python do_deploy() {
}
addtask deploy before do_build after do_image
+do_rootfs_finalize() {
+ sudo -s <<'EOSUDO'
+ test -e "${ROOTFSDIR}/chroot-setup.sh" && \
+ "${ROOTFSDIR}/chroot-setup.sh" "cleanup" "${ROOTFSDIR}"
+ rm -f "${ROOTFSDIR}/chroot-setup.sh"
+
+ test ! -e "${ROOTFSDIR}/usr/share/doc/qemu-user-static" && \
+ find "${ROOTFSDIR}/usr/bin" \
+ -maxdepth 1 -name 'qemu-*-static' -type f -delete
+
+ mountpoint -q '${ROOTFSDIR}/isar-apt' && \
+ umount -l ${ROOTFSDIR}/isar-apt
+ rmdir --ignore-fail-on-non-empty ${ROOTFSDIR}/isar-apt
+
+ mountpoint -q '${ROOTFSDIR}/base-apt' && \
+ umount -l ${ROOTFSDIR}/base-apt
+ rmdir --ignore-fail-on-non-empty ${ROOTFSDIR}/base-apt
+
+ mountpoint -q '${ROOTFSDIR}/dev' && \
+ umount -l ${ROOTFSDIR}/dev
+ mountpoint -q '${ROOTFSDIR}/sys' && \
+ umount -l ${ROOTFSDIR}/proc
+ mountpoint -q '${ROOTFSDIR}/sys' && \
+ umount -l ${ROOTFSDIR}/sys
+
+ rm -f "${ROOTFSDIR}/etc/apt/apt.conf.d/55isar-fallback.conf"
+
+ rm -f "${ROOTFSDIR}/etc/apt/sources.list.d/isar-apt.list"
+ rm -f "${ROOTFSDIR}/etc/apt/preferences.d/isar-apt"
+ rm -f "${ROOTFSDIR}/etc/apt/sources.list.d/base-apt.list"
+
+ mv "${ROOTFSDIR}/etc/apt/sources-list" \
+ "${ROOTFSDIR}/etc/apt/sources.list.d/bootstrap.list"
+
+ rm -f "${ROOTFSDIR}/etc/apt/sources-list"
+EOSUDO
+}
+addtask rootfs_finalize before do_rootfs after do_rootfs_postprocess
+
# Last so that the image type can overwrite tasks if needed
inherit ${IMAGE_TYPE}
diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
index afec1cb..eae14d5 100644
--- a/meta/classes/rootfs.bbclass
+++ b/meta/classes/rootfs.bbclass
@@ -201,45 +201,6 @@ rootfs_generate_manifest () {
${ROOTFS_MANIFEST_DEPLOY_DIR}/"${PF}".manifest
}
-ROOTFS_POSTPROCESS_COMMAND += "${@bb.utils.contains('ROOTFS_FEATURES', 'finalize-rootfs', 'rootfs_postprocess_finalize', '', d)}"
-rootfs_postprocess_finalize() {
- sudo -s <<'EOSUDO'
- test -e "${ROOTFSDIR}/chroot-setup.sh" && \
- "${ROOTFSDIR}/chroot-setup.sh" "cleanup" "${ROOTFSDIR}"
- rm -f "${ROOTFSDIR}/chroot-setup.sh"
-
- test ! -e "${ROOTFSDIR}/usr/share/doc/qemu-user-static" && \
- find "${ROOTFSDIR}/usr/bin" \
- -maxdepth 1 -name 'qemu-*-static' -type f -delete
-
- mountpoint -q '${ROOTFSDIR}/isar-apt' && \
- umount -l ${ROOTFSDIR}/isar-apt
- rmdir --ignore-fail-on-non-empty ${ROOTFSDIR}/isar-apt
-
- mountpoint -q '${ROOTFSDIR}/base-apt' && \
- umount -l ${ROOTFSDIR}/base-apt
- rmdir --ignore-fail-on-non-empty ${ROOTFSDIR}/base-apt
-
- mountpoint -q '${ROOTFSDIR}/dev' && \
- umount -l ${ROOTFSDIR}/dev
- mountpoint -q '${ROOTFSDIR}/sys' && \
- umount -l ${ROOTFSDIR}/proc
- mountpoint -q '${ROOTFSDIR}/sys' && \
- umount -l ${ROOTFSDIR}/sys
-
- rm -f "${ROOTFSDIR}/etc/apt/apt.conf.d/55isar-fallback.conf"
-
- rm -f "${ROOTFSDIR}/etc/apt/sources.list.d/isar-apt.list"
- rm -f "${ROOTFSDIR}/etc/apt/preferences.d/isar-apt"
- rm -f "${ROOTFSDIR}/etc/apt/sources.list.d/base-apt.list"
-
- mv "${ROOTFSDIR}/etc/apt/sources-list" \
- "${ROOTFSDIR}/etc/apt/sources.list.d/bootstrap.list"
-
- rm -f "${ROOTFSDIR}/etc/apt/sources-list"
-EOSUDO
-}
-
do_rootfs_postprocess[vardeps] = "${ROOTFS_POSTPROCESS_COMMAND}"
python do_rootfs_postprocess() {
# Take care that its correctly mounted:
--
2.17.1
next prev parent reply other threads:[~2020-09-30 6:03 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-30 6:02 [PATCH v6 00/13] Deb-src caching Vijai Kumar K
2020-09-30 6:02 ` Vijai Kumar K [this message]
2020-11-24 19:47 ` [PATCH v6 01/13] rootfs: Make rootfs finalize a separate task Baurzhan Ismagulov
2020-09-30 6:02 ` [PATCH v6 02/13] deb-dl-dir: Cache host distro debs separately Vijai Kumar K
2020-09-30 6:02 ` [PATCH v6 03/13] meta: cache deb srcs as part of postprocessing Vijai Kumar K
2020-09-30 6:06 ` [PATCH v6 04/13] deb-dl-dir: Make debsrc_download faster Vijai Kumar K
2020-09-30 6:06 ` [PATCH v6 05/13] deb-dl-dir: Download files only belonging to the current image Vijai Kumar K
2020-09-30 6:07 ` [PATCH v6 06/13] deb-dl-dir: Factor out the mounting part Vijai Kumar K
2020-09-30 6:07 ` [PATCH v6 07/13] deb-dl-dir: Fix skipping of removed files Vijai Kumar K
2020-09-30 6:07 ` [PATCH v6 08/13] repository: Add a sanity test to check missing sources Vijai Kumar K
2020-09-30 6:18 ` [PATCH v6 09/13] base-apt: Introduce BASE_REPO_FEATURES Vijai Kumar K
2020-09-30 6:18 ` [PATCH v6 10/13] repository: Fix failures due to missing section Vijai Kumar K
2020-09-30 6:18 ` [PATCH v6 11/13] scripts/ci_build.sh: Enable deb-src caching Vijai Kumar K
2020-09-30 6:18 ` [PATCH v6 12/13] rootfs: Fix possible overwrite of existing resolv.conf Vijai Kumar K
2020-09-30 6:21 ` [PATCH v6 13/13] rootfs: Handle failures when postprocess is rerun Vijai Kumar K
2020-11-24 19:49 ` [PATCH v6 03/13] meta: cache deb srcs as part of postprocessing Baurzhan Ismagulov
2020-11-26 10:52 ` vijaikumar....@gmail.com
2020-11-26 11:03 ` Baurzhan Ismagulov
2020-11-26 11:07 ` vijaikumar....@gmail.com
2020-11-23 15:08 ` [PATCH v6 00/13] Deb-src caching vijaikumar....@gmail.com
2020-11-23 15:38 ` Jan Kiszka
2020-11-23 15:47 ` vijaikumar....@gmail.com
2020-11-24 5:41 ` Jan Kiszka
2020-11-24 6:30 ` vijaikumar....@gmail.com
2020-11-24 19:45 ` Baurzhan Ismagulov
2020-11-25 5:51 ` Jan Kiszka
2020-11-25 6:04 ` vijaikumar....@gmail.com
2020-11-25 6:48 ` Jan Kiszka
2020-11-25 7:16 ` vijaikumar....@gmail.com
2020-11-26 10:21 ` Baurzhan Ismagulov
2020-11-26 10:43 ` vijaikumar....@gmail.com
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=20200930060259.12422-2-Vijaikumar_Kanagarajan@mentor.com \
--to=vijaikumar_kanagarajan@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