From b43e3b84f4c9100379f4686f80699929c7657056 Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Tue, 22 Aug 2023 13:16:52 -0700 Subject: [PATCH] Reset /var/lib/snapd in the upper layers before calling snap prepare-image --- debian/changelog | 2 ++ live-build/functions | 11 +++++++++++ live-build/ubuntu/hooks/020-canary-enhanced-sb.binary | 4 ++++ live-build/ubuntu/hooks/020-canary-live.binary | 4 ++++ 4 files changed, 21 insertions(+) diff --git a/debian/changelog b/debian/changelog index 8b04bb67..cc092c15 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,8 @@ livecd-rootfs (23.10.21) UNRELEASED; urgency=medium [ Steve Langasek ] * Deduplicate snaps between squashfs layers on classic: - Consolidate canary layers to merge 'classic' back into 'standard' + - Reset /var/lib/snapd in the upper layers before calling snap + prepare-image -- Michael Hudson-Doyle Wed, 23 Aug 2023 11:15:26 +1200 diff --git a/live-build/functions b/live-build/functions index dea971dc..01ea76f8 100644 --- a/live-build/functions +++ b/live-build/functions @@ -1230,3 +1230,14 @@ EOF undivert_grub "${mountpoint}" fi } + +# find all files under /var/lib/snapd in the target directory that aren't +# shipped by the snapd package itself, and remove them +reset_snapd_state() { + rootdir="$1" + + rm -rf "$rootdir/var/lib/snapd" + setup_mountpoint "$rootdir" + chroot "$rootdir" apt-get install --reinstall -y snapd + teardown_mountpoint "$rootdir" +} diff --git a/live-build/ubuntu/hooks/020-canary-enhanced-sb.binary b/live-build/ubuntu/hooks/020-canary-enhanced-sb.binary index e1b41ad8..0beffc23 100644 --- a/live-build/ubuntu/hooks/020-canary-enhanced-sb.binary +++ b/live-build/ubuntu/hooks/020-canary-enhanced-sb.binary @@ -20,6 +20,7 @@ case ${SUBPROJECT:-} in esac . config/binary +. config/functions # env SNAPPY_STORE_NO_CDN=1 snap known --remote model series=16 brand-id=canonical model=ubuntu-classic-2310-amd64 > config/classic-model.model cat < config/classic-model.model @@ -134,6 +135,9 @@ channel="" if [ -n "${CHANNEL:-}" ]; then channel="--channel $CHANNEL" fi + +reset_snapd_state chroot + env SNAPPY_STORE_NO_CDN=1 snap prepare-image \ --classic config/classic-model.model $channel chroot mv chroot/system-seed/systems/* chroot/system-seed/systems/enhanced-secureboot-desktop diff --git a/live-build/ubuntu/hooks/020-canary-live.binary b/live-build/ubuntu/hooks/020-canary-live.binary index a382587f..40e630dd 100755 --- a/live-build/ubuntu/hooks/020-canary-live.binary +++ b/live-build/ubuntu/hooks/020-canary-live.binary @@ -20,6 +20,7 @@ case ${SUBPROJECT:-} in esac . config/binary +. config/functions # env SNAPPY_STORE_NO_CDN=1 snap known --remote model series=16 brand-id=canonical model=ubuntu-installer-classic-2310-amd64 > config/classic-model-installer.model cat < config/classic-model-installer.model @@ -130,6 +131,9 @@ channel="" if [ -n "${CHANNEL:-}" ]; then channel="--channel $CHANNEL" fi + +reset_snapd_state chroot + env SNAPPY_STORE_NO_CDN=1 snap prepare-image \ --classic config/classic-model-installer.model $channel chroot mv chroot/system-seed/systems/* chroot/system-seed/systems/classic-installer