Message ID | 20230105184328.25277-1-henning.schild@siemens.com |
---|---|
State | Superseded, archived |
Headers | show |
Series | image: make sure do_rootfs_finalize can run multiple times | expand |
Forget this let us take [PATCH] fix rebuild of rootfs_finalize task from Felix It was a drive by mini change, and somehow now we have three people sending patches ... this energy could be used so much better. Henning Am Thu, 5 Jan 2023 19:43:28 +0100 schrieb Henning Schild <henning.schild@siemens.com>: > There have been several places that would not work twice in a row. All > the test && not covering || have been moved to if. The rm at the end > tried to remove a file that was just moved. And that mv would not > work a second time because its source would be gone. > > Signed-off-by: Henning Schild <henning.schild@siemens.com> > --- > meta/classes/image.bbclass | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > > diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass > index 629a0c1daa55..125eba192a65 100644 > --- a/meta/classes/image.bbclass > +++ b/meta/classes/image.bbclass > @@ -396,13 +396,16 @@ addtask deploy before do_build after do_image > do_rootfs_finalize() { > sudo -s <<'EOSUDO' > set -e > - test -e "${ROOTFSDIR}/chroot-setup.sh" && \ > + > + if [ -e "${ROOTFSDIR}/chroot-setup.sh" ]; then > "${ROOTFSDIR}/chroot-setup.sh" "cleanup" "${ROOTFSDIR}" > + fi > rm -f "${ROOTFSDIR}/chroot-setup.sh" > > - test ! -e "${ROOTFSDIR}/usr/share/doc/qemu-user-static" && \ > + if [ ! -e "${ROOTFSDIR}/usr/share/doc/qemu-user-static" ]; > then find "${ROOTFSDIR}/usr/bin" \ > -maxdepth 1 -name 'qemu-*-static' -type f -delete > + fi > > mountpoint -q '${ROOTFSDIR}/isar-apt' && \ > umount -l ${ROOTFSDIR}/isar-apt && \ > @@ -424,10 +427,10 @@ do_rootfs_finalize() { > rm -f "${ROOTFSDIR}/etc/apt/sources.list.d/base-apt.list" > rm -f "${ROOTFSDIR}/etc/apt/apt.conf.d/50isar" > > - mv "${ROOTFSDIR}/etc/apt/sources-list" \ > - "${ROOTFSDIR}/etc/apt/sources.list.d/bootstrap.list" > - > - rm -f "${ROOTFSDIR}/etc/apt/sources-list" > + if [ -e "${ROOTFSDIR}/etc/apt/sources-list" ]; then > + mv "${ROOTFSDIR}/etc/apt/sources-list" \ > + "${ROOTFSDIR}/etc/apt/sources.list.d/bootstrap.list" > + fi > EOSUDO > } > addtask rootfs_finalize before do_rootfs after do_rootfs_postprocess
On Fri, 6 Jan 2023 at 19:19, Henning Schild <henning.schild@siemens.com> wrote: > > Forget this let us take > > [PATCH] fix rebuild of rootfs_finalize task > > from Felix > > It was a drive by mini change, and somehow now we have three people > sending patches ... this energy could be used so much better. The [PATCH v4] image: make sure do_rootfs_finalize can run multiple times, v4 might be worth a look, it uses -f and rationalise the code above plus include the description provided by Felix. Best regards, R-
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass index 629a0c1daa55..125eba192a65 100644 --- a/meta/classes/image.bbclass +++ b/meta/classes/image.bbclass @@ -396,13 +396,16 @@ addtask deploy before do_build after do_image do_rootfs_finalize() { sudo -s <<'EOSUDO' set -e - test -e "${ROOTFSDIR}/chroot-setup.sh" && \ + + if [ -e "${ROOTFSDIR}/chroot-setup.sh" ]; then "${ROOTFSDIR}/chroot-setup.sh" "cleanup" "${ROOTFSDIR}" + fi rm -f "${ROOTFSDIR}/chroot-setup.sh" - test ! -e "${ROOTFSDIR}/usr/share/doc/qemu-user-static" && \ + if [ ! -e "${ROOTFSDIR}/usr/share/doc/qemu-user-static" ]; then find "${ROOTFSDIR}/usr/bin" \ -maxdepth 1 -name 'qemu-*-static' -type f -delete + fi mountpoint -q '${ROOTFSDIR}/isar-apt' && \ umount -l ${ROOTFSDIR}/isar-apt && \ @@ -424,10 +427,10 @@ do_rootfs_finalize() { rm -f "${ROOTFSDIR}/etc/apt/sources.list.d/base-apt.list" rm -f "${ROOTFSDIR}/etc/apt/apt.conf.d/50isar" - mv "${ROOTFSDIR}/etc/apt/sources-list" \ - "${ROOTFSDIR}/etc/apt/sources.list.d/bootstrap.list" - - rm -f "${ROOTFSDIR}/etc/apt/sources-list" + if [ -e "${ROOTFSDIR}/etc/apt/sources-list" ]; then + mv "${ROOTFSDIR}/etc/apt/sources-list" \ + "${ROOTFSDIR}/etc/apt/sources.list.d/bootstrap.list" + fi EOSUDO } addtask rootfs_finalize before do_rootfs after do_rootfs_postprocess
There have been several places that would not work twice in a row. All the test && not covering || have been moved to if. The rm at the end tried to remove a file that was just moved. And that mv would not work a second time because its source would be gone. Signed-off-by: Henning Schild <henning.schild@siemens.com> --- meta/classes/image.bbclass | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)