From 711c5c291fcc9f14991639c9d2eb9a4f76bce4d2 Mon Sep 17 00:00:00 2001 From: Philip Roche Date: Thu, 17 Aug 2023 11:48:22 +0100 Subject: [PATCH] fix: Remove dangling symlink /boot/initrd.img.old if exists (LP: #2031640) As a result of not installing recommended packages we have dangling symlink `/boot/initrd.img.old` As per the preceding `/boot/initrd.img` cleanup. Cleanup of `/boot/initrd.img.old` only happens if it is a dangling symlink. These `rm` commands also have `--verbose` flags now to make it easier when debugging logs --- debian/changelog | 1 + .../ubuntu-cpc/hooks.d/chroot/999-cpc-fixes.chroot | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 8e4924af..91852618 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ livecd-rootfs (23.10.16) mantic; urgency=medium * fix: Do not install recommends for ubuntu-cpc minimized project (LP: #2031640) + * fix: Remove dangling symlink /boot/initrd.img.old if exists (LP: #2031640) -- Philip Roche Thu, 17 Aug 2023 11:44:23 +0100 diff --git a/live-build/ubuntu-cpc/hooks.d/chroot/999-cpc-fixes.chroot b/live-build/ubuntu-cpc/hooks.d/chroot/999-cpc-fixes.chroot index 6d7b62ea..12956529 100755 --- a/live-build/ubuntu-cpc/hooks.d/chroot/999-cpc-fixes.chroot +++ b/live-build/ubuntu-cpc/hooks.d/chroot/999-cpc-fixes.chroot @@ -88,7 +88,11 @@ fi # previous steps may have left a dangling symlink here with # SUBPROJECT=minimized and that breaks lb_chroot_hacks step if [ -L "${rootd}/boot/initrd.img" ] && [ ! -e "${rootd}/boot/initrd.img" ]; then - rm "${rootd}/boot/initrd.img" + rm --verbose "${rootd}/boot/initrd.img" +fi + +if [ -L "${rootd}/boot/initrd.img.old" ] && [ ! -e "${rootd}/boot/initrd.img.old" ]; then + rm --verbose "${rootd}/boot/initrd.img.old" fi #### END COMMON ARCH FUNCTIONS @@ -196,8 +200,11 @@ if [ -x "${rootd}/usr/sbin/update-grub" ]; then fi # reconfigure grub so that upgrades to grub-pc do not force a debconf config -# changed prompt (LP: #1009294). This re-runs update-grub -if [ -n "`_xchroot "${rootd}" dpkg-query -W grub-pc 2>/dev/null`" ]; then +# changed prompt (LP: #1009294). This re-runs update-grub. Only do so if grub-pc +# is installed. Determine whether grub-pc is installed by checking for the +# status of the grub-pc package. Only packages installed will result in +# output to the dpkg-query --status command. +if [ -n "`_xchroot "${rootd}" dpkg-query --status grub-pc 2>/dev/null`" ]; then _xchroot "${rootd}" env DEBIAN_FRONTEND=noninteractive \ dpkg-reconfigure grub-pc fi