Message ID | 20241028073231.14162-1-ubely@ilbers.de |
---|---|
State | Accepted, archived |
Headers | show |
Series | isar-bootstrap: Run setup-chroot.sh after dpkg upgraded | expand |
On Mon, 2024-10-28 at 10:32 +0300, Uladzimir Bely wrote: > By calling "chroot-setup.sh setup" right after debootstrap we do > dpkg-divert for `/usr/sbin/start-stop-daemon`. This replaces the > original script with a stub that is called during the build. At > the end of the build, in "rootfs_finalize" task for target image, > the original file is restored so package installation on a real > target should be full-functional. > > But if `apt-get update` followed by debootstrap stage requires an > upgrade of "dpkg" package itself (e.g. if new version exists in > "<distro>-updates"), this may lead for diversion reset and original > script gets restored. > > This results in following things: > - "real" start-stop-daemon is called in all chroots during build; > - start-stop-daemon is removed on target rootfs by > "rootfs_finalize". > > Currently, it happens only for rpi-bookworm targets where > debootsrapped > "dpkg_1.21.22_arm64.deb" package is upgraded with a newer version > "dpkg_1.22.6~bpo12+rpt3_arm64.deb" at "apt-get update" stage. > > With this change, we run "chroot-setup.sh" after explicite upgrade of > "dpkg". Thus we guarantee start-stop-daemon stub is used during build > and undirsion is done only at the end of the rootfs creation. > > Signed-off-by: Uladzimir Bely <ubely@ilbers.de> > --- > meta/recipes-core/isar-bootstrap/isar-bootstrap.inc | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc > b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc > index 92974eb5..e155aade 100644 > --- a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc > +++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc > @@ -370,10 +370,6 @@ do_bootstrap() { > sed -i '/en_US.UTF-8 UTF-8/s/^#//g' > "${ROOTFSDIR}/etc/locale.gen" > chroot "${ROOTFSDIR}" /usr/sbin/locale-gen > > - # setup chroot > - install -v -m755 "${WORKDIR}/chroot-setup.sh" > "${ROOTFSDIR}/chroot-setup.sh" > - "${ROOTFSDIR}/chroot-setup.sh" "setup" "${ROOTFSDIR}" > - > # update APT > mount -o bind,private /dev ${ROOTFSDIR}/dev > mount -o bind,private /dev/pts "${ROOTFSDIR}/dev/pts" > @@ -394,6 +390,13 @@ do_bootstrap() { > > chroot "${ROOTFSDIR}" /usr/bin/apt-get update -y \ > -o APT::Update::Error-Mode=any > + > + chroot "${ROOTFSDIR}" /usr/bin/apt-get install -y dpkg > + > + # setup chroot > + install -v -m755 "${WORKDIR}/chroot-setup.sh" > "${ROOTFSDIR}/chroot-setup.sh" > + "${ROOTFSDIR}/chroot-setup.sh" "setup" "${ROOTFSDIR}" > + > chroot "${ROOTFSDIR}" /usr/bin/apt-get install -y -f > chroot "${ROOTFSDIR}" /usr/bin/apt-get dist-upgrade -y \ > -o Debug::pkgProblemResolver=yes > -- > 2.45.2 > Applied to next.
diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc index 92974eb5..e155aade 100644 --- a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc +++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc @@ -370,10 +370,6 @@ do_bootstrap() { sed -i '/en_US.UTF-8 UTF-8/s/^#//g' "${ROOTFSDIR}/etc/locale.gen" chroot "${ROOTFSDIR}" /usr/sbin/locale-gen - # setup chroot - install -v -m755 "${WORKDIR}/chroot-setup.sh" "${ROOTFSDIR}/chroot-setup.sh" - "${ROOTFSDIR}/chroot-setup.sh" "setup" "${ROOTFSDIR}" - # update APT mount -o bind,private /dev ${ROOTFSDIR}/dev mount -o bind,private /dev/pts "${ROOTFSDIR}/dev/pts" @@ -394,6 +390,13 @@ do_bootstrap() { chroot "${ROOTFSDIR}" /usr/bin/apt-get update -y \ -o APT::Update::Error-Mode=any + + chroot "${ROOTFSDIR}" /usr/bin/apt-get install -y dpkg + + # setup chroot + install -v -m755 "${WORKDIR}/chroot-setup.sh" "${ROOTFSDIR}/chroot-setup.sh" + "${ROOTFSDIR}/chroot-setup.sh" "setup" "${ROOTFSDIR}" + chroot "${ROOTFSDIR}" /usr/bin/apt-get install -y -f chroot "${ROOTFSDIR}" /usr/bin/apt-get dist-upgrade -y \ -o Debug::pkgProblemResolver=yes
By calling "chroot-setup.sh setup" right after debootstrap we do dpkg-divert for `/usr/sbin/start-stop-daemon`. This replaces the original script with a stub that is called during the build. At the end of the build, in "rootfs_finalize" task for target image, the original file is restored so package installation on a real target should be full-functional. But if `apt-get update` followed by debootstrap stage requires an upgrade of "dpkg" package itself (e.g. if new version exists in "<distro>-updates"), this may lead for diversion reset and original script gets restored. This results in following things: - "real" start-stop-daemon is called in all chroots during build; - start-stop-daemon is removed on target rootfs by "rootfs_finalize". Currently, it happens only for rpi-bookworm targets where debootsrapped "dpkg_1.21.22_arm64.deb" package is upgraded with a newer version "dpkg_1.22.6~bpo12+rpt3_arm64.deb" at "apt-get update" stage. With this change, we run "chroot-setup.sh" after explicite upgrade of "dpkg". Thus we guarantee start-stop-daemon stub is used during build and undirsion is done only at the end of the rootfs creation. Signed-off-by: Uladzimir Bely <ubely@ilbers.de> --- meta/recipes-core/isar-bootstrap/isar-bootstrap.inc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)