From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6790334981638979584 Date: Wed, 11 Mar 2020 00:16:51 -0700 (PDT) From: vijai kumar To: isar-users Message-Id: <7a71ebe9-9846-41ed-beae-a02360129b89@googlegroups.com> In-Reply-To: <20200214054801.11870-1-Vijaikumar_Kanagarajan@mentor.com> References: <20200213100820.23444-2-Vijaikumar_Kanagarajan@mentor.com> <20200214054801.11870-1-Vijaikumar_Kanagarajan@mentor.com> Subject: Re: [PATCH v3 1/2] rootfs: Make rootfs finalize a separate task MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_2031_1237605750.1583911011636" X-Google-Token: EOOgovMFb8ASjpUg2Rk0 X-Google-IP: 139.181.36.34 X-TUID: ElrRdYQ3aUGH ------=_Part_2031_1237605750.1583911011636 Content-Type: multipart/alternative; boundary="----=_Part_2032_1349255137.1583911011637" ------=_Part_2032_1349255137.1583911011637 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit As said before, this series, atleast the second patch, depends on Henning's base-apt series. I am going to rebase my changes on top of Hennings v5 and test it out. Also, should we have these changes as part of Hennings series? Or should I wait for the series to get in and address these later? Thanks, Vijai Kumar K On Friday, February 14, 2020 at 11:18:11 AM UTC+5:30, vijai kumar wrote: > > 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 > --- > Changes in v3: > - Take care of non-existent downloads/deb-src directory. > > 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 cfd617a..c5fddba 100644 > --- a/meta/classes/image.bbclass > +++ b/meta/classes/image.bbclass > @@ -60,7 +60,7 @@ image_do_mounts() { > } > > ROOTFSDIR = "${IMAGE_ROOTFS}" > -ROOTFS_FEATURES += "clean-package-cache finalize-rootfs > generate-manifest" > +ROOTFS_FEATURES += "copy-package-cache clean-package-cache > generate-manifest" > ROOTFS_PACKAGES += "${IMAGE_PREINSTALL} ${IMAGE_INSTALL}" > ROOTFS_MANIFEST_DEPLOY_DIR ?= "${DEPLOY_DIR_IMAGE}" > > @@ -168,5 +168,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 54b5e5c..c3af7c1 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 > > ------=_Part_2032_1349255137.1583911011637 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
As said before, this series, atleast the second patch= , depends on Henning's base-apt series.

I am g= oing to rebase my changes on top of Hennings v5 and test it out.
=
Also, should we have these changes as part of Hennings serie= s? Or should I wait for
the series to get in and address these la= ter?

Thanks,
Vijai Kumar K

= On Friday, February 14, 2020 at 11:18:11 AM UTC+5:30, vijai kumar wrote:With the current implementation i= t 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>
---
Changes in v3:
=C2=A0- Take care of non-existent downloads/deb-src directory.

=C2=A0meta/classes/image.bbclass =C2=A0| 41 +++++++++++++++++++++++++++= +++++++++-
=C2=A0meta/classes/rootfs.bbclass | 39 -----------------------------------
=C2=A02 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index cfd617a..c5fddba 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -60,7 +60,7 @@ image_do_mounts() {
=C2=A0}
=C2=A0
=C2=A0ROOTFSDIR =3D "${IMAGE_ROOTFS}"
-ROOTFS_FEATURES +=3D "clean-package-cache finalize-rootfs generat= e-manifest"
+ROOTFS_FEATURES +=3D "copy-package-cache clean-package-cache gene= rate-manifest"
=C2=A0ROOTFS_PACKAGES +=3D "${IMAGE_PREINSTALL} ${IMAGE_INSTALL}&q= uot;
=C2=A0ROOTFS_MANIFEST_DEPLOY_DIR ?=3D "${DEPLOY_DIR_IMAGE}"
=C2=A0
@@ -168,5 +168,44 @@ python do_deploy() {
=C2=A0}
=C2=A0addtask deploy before do_build after do_image
=C2=A0
+do_rootfs_finalize() {
+ =C2=A0 =C2=A0sudo -s <<'EOSUDO'
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0test -e "${ROOTFSDIR}/chroot-setup.sh= " && \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"${ROOTFSDIR}/chroot-se= tup.sh" "cleanup" "${ROOTFSDIR}"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0rm -f "${ROOTFSDIR}/chroot-setup.sh&q= uot;
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0test ! -e "${ROOTFSDIR}/usr/share/doc= /qemu-user-static" && \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0find "${ROOTFSDIR}/usr/= bin" \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-maxdepth 1 -n= ame 'qemu-*-static' -type f -delete
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0mountpoint -q '${ROOTFSDIR}/isar-apt&#= 39; && \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0umount -l ${ROOTFSDIR}/isar-= apt
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0rmdir --ignore-fail-on-non-empty ${ROOTFSD= IR}/isar-apt
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0mountpoint -q '${ROOTFSDIR}/base-apt&#= 39; && \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0umount -l ${ROOTFSDIR}/base-= apt
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0rmdir --ignore-fail-on-non-empty ${ROOTFSD= IR}/base-apt
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0mountpoint -q '${ROOTFSDIR}/dev' &= amp;& \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0umount -l ${ROOTFSDIR}/dev
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0mountpoint -q '${ROOTFSDIR}/sys' &= amp;& \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0umount -l ${ROOTFSDIR}/proc
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0mountpoint -q '${ROOTFSDIR}/sys' &= amp;& \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0umount -l ${ROOTFSDIR}/sys
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0rm -f "${ROOTFSDIR}/etc/apt/apt.= conf.d/55isar-fallback.conf"
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0rm -f "${ROOTFSDIR}/etc/apt/sources.<= wbr>list.d/isar-apt.list"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0rm -f "${ROOTFSDIR}/etc/apt/pref= erences.d/isar-apt"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0rm -f "${ROOTFSDIR}/etc/apt/sources.<= wbr>list.d/base-apt.list"
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0mv "${ROOTFSDIR}/etc/apt/sources-list" \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"${ROOTFSDIR}/etc/apt/<= wbr>sources.list.d/bootstrap.list"
+
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0rm -f "${ROOTFSDIR}/etc/apt/sources-<= wbr>list"
+EOSUDO
+}
+addtask rootfs_finalize before do_rootfs after do_rootfs_postprocess
+
=C2=A0# Last so that the image type can overwrite tasks if needed
=C2=A0inherit ${IMAGE_TYPE}
diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
index 54b5e5c..c3af7c1 100644
--- a/meta/classes/rootfs.bbclass
+++ b/meta/classes/rootfs.bbclass
@@ -201,45 +201,6 @@ rootfs_generate_manifest () {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0${ROOTFS_MANIFEST_DEPLOY_DIR}/&q= uot;${PF}".manifest
=C2=A0}
=C2=A0
-ROOTFS_POSTPROCESS_COMMAND +=3D "${@bb.utils.contains('ROOTFS= _FEATURES', 'finalize-rootfs', 'rootfs_postprocess_fin= alize', '', d)}"
-rootfs_postprocess_finalize() {
- =C2=A0 =C2=A0sudo -s <<'EOSUDO'
- =C2=A0 =C2=A0 =C2=A0 =C2=A0test -e "${ROOTFSDIR}/chroot-setup.sh= " && \
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"${ROOTFSDIR}/chroot-se= tup.sh" "cleanup" "${ROOTFSDIR}"
- =C2=A0 =C2=A0 =C2=A0 =C2=A0rm -f "${ROOTFSDIR}/chroot-setup.sh&q= uot;
-
- =C2=A0 =C2=A0 =C2=A0 =C2=A0test ! -e "${ROOTFSDIR}/usr/share/doc= /qemu-user-static" && \
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0find "${ROOTFSDIR}/usr/= bin" \
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-maxdepth 1 -n= ame 'qemu-*-static' -type f -delete
-
- =C2=A0 =C2=A0 =C2=A0 =C2=A0mountpoint -q '${ROOTFSDIR}/isar-apt&#= 39; && \
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0umount -l ${ROOTFSDIR}/isar-= apt
- =C2=A0 =C2=A0 =C2=A0 =C2=A0rmdir --ignore-fail-on-non-empty ${ROOTFSD= IR}/isar-apt
-
- =C2=A0 =C2=A0 =C2=A0 =C2=A0mountpoint -q '${ROOTFSDIR}/base-apt&#= 39; && \
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0umount -l ${ROOTFSDIR}/base-= apt
- =C2=A0 =C2=A0 =C2=A0 =C2=A0rmdir --ignore-fail-on-non-empty ${ROOTFSD= IR}/base-apt
-
- =C2=A0 =C2=A0 =C2=A0 =C2=A0mountpoint -q '${ROOTFSDIR}/dev' &= amp;& \
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0umount -l ${ROOTFSDIR}/dev
- =C2=A0 =C2=A0 =C2=A0 =C2=A0mountpoint -q '${ROOTFSDIR}/sys' &= amp;& \
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0umount -l ${ROOTFSDIR}/proc
- =C2=A0 =C2=A0 =C2=A0 =C2=A0mountpoint -q '${ROOTFSDIR}/sys' &= amp;& \
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0umount -l ${ROOTFSDIR}/sys
-
- =C2=A0 =C2=A0 =C2=A0 =C2=A0rm -f "${ROOTFSDIR}/etc/apt/apt.= conf.d/55isar-fallback.conf"
-
- =C2=A0 =C2=A0 =C2=A0 =C2=A0rm -f "${ROOTFSDIR}/etc/apt/sources.<= wbr>list.d/isar-apt.list"
- =C2=A0 =C2=A0 =C2=A0 =C2=A0rm -f "${ROOTFSDIR}/etc/apt/pref= erences.d/isar-apt"
- =C2=A0 =C2=A0 =C2=A0 =C2=A0rm -f "${ROOTFSDIR}/etc/apt/sources.<= wbr>list.d/base-apt.list"
-
- =C2=A0 =C2=A0 =C2=A0 =C2=A0mv "${ROOTFSDIR}/etc/apt/sources-list" \
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"${ROOTFSDIR}/etc/apt/<= wbr>sources.list.d/bootstrap.list"
-
- =C2=A0 =C2=A0 =C2=A0 =C2=A0rm -f "${ROOTFSDIR}/etc/apt/sources-<= wbr>list"
-EOSUDO
-}
-
=C2=A0do_rootfs_postprocess[vardeps] =3D "${ROOTFS_POSTPROCES= S_COMMAND}"
=C2=A0python do_rootfs_postprocess() {
=C2=A0 =C2=A0 =C2=A0# Take care that its correctly mounted:
--=20
2.17.1

------=_Part_2032_1349255137.1583911011637-- ------=_Part_2031_1237605750.1583911011636--