From 94c2d606ca6c8078ad36701b66a469b8cfb3c9d8 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Thu, 12 Dec 2019 12:55:25 +1300 Subject: [PATCH 1/5] Preserve apt preferences created by any package we install (i.e. ubuntu-advantage-tools) against live-build's attempt to delete them. (LP: #1855354) --- debian/changelog | 8 ++++++++ live-build/auto/build | 6 ++++++ live-build/auto/config | 11 +++++++++++ 3 files changed, 25 insertions(+) diff --git a/debian/changelog b/debian/changelog index 63baa1aa..e68f9f16 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +livecd-rootfs (2.634) UNRELEASED; urgency=medium + + * Preserve apt preferences created by any package we install (i.e. + ubuntu-advantage-tools) against live-build's attempt to delete them. + (LP: #1855354) + + -- Michael Hudson-Doyle Thu, 12 Dec 2019 12:55:17 +1300 + livecd-rootfs (2.633) focal; urgency=medium * Snapd for uc20 model assertions does not support global channel overrides. diff --git a/live-build/auto/build b/live-build/auto/build index 43a706be..c12ba331 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -314,6 +314,12 @@ EOF undivert_grub chroot fi + if [ -d chroot/etc/apt/preferences.d.save ]; then + # https://twitter.com/infinite_scream + mv chroot/etc/apt/preferences.d.save/* chroot/etc/apt/preferences.d/ + rmdir chroot/etc/apt/preferences.d.save + fi + # Let all configuration non multi-layered project here. # If those are moving to a multi-layer layout, this needs to be # done in chroot hooks. diff --git a/live-build/auto/config b/live-build/auto/config index 6ed05a42..58c0367b 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -1096,6 +1096,17 @@ rm -f /etc/fstab EOF fi +if [ $PROJECT = ubuntu-base ]; then + cat > config/hooks/100-preserve-ua-tools-prefs.chroot < config/hooks/100-ubuntukylin.chroot < Date: Thu, 12 Dec 2019 12:57:05 +1300 Subject: [PATCH 2/5] fix in case of no preferences --- live-build/auto/config | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/live-build/auto/config b/live-build/auto/config index 58c0367b..a4e90059 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -1103,7 +1103,9 @@ if [ $PROJECT = ubuntu-base ]; then # live-build "helpfully" removes /etc/apt/preferences.d/* so we put a # copy somewhere it won't touch it. -cp -a /etc/apt/preferences.d /etc/apt/preferences.d.save +if [ -n "$(ls -A /etc/apt/preferences.d)" ]; then + cp -a /etc/apt/preferences.d /etc/apt/preferences.d.save +fi EOF fi From fb31b64a7c46f613453c7cbce41ac5fb7d5f8c4f Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Thu, 12 Dec 2019 12:58:37 +1300 Subject: [PATCH 3/5] preserve apt preferences for all projects --- live-build/auto/config | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/live-build/auto/config b/live-build/auto/config index a4e90059..cb995a21 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -1096,8 +1096,7 @@ rm -f /etc/fstab EOF fi -if [ $PROJECT = ubuntu-base ]; then - cat > config/hooks/100-preserve-ua-tools-prefs.chroot < config/hooks/100-preserve-apt-prefs.chroot < config/hooks/100-ubuntukylin.chroot < Date: Fri, 13 Dec 2019 09:01:30 +1300 Subject: [PATCH 4/5] ubuntu-cpc hooks are Different --- live-build/auto/config | 4 +++- .../hooks.d/chroot/100-preserve-apt-prefs.chroot | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100755 live-build/ubuntu-cpc/hooks.d/chroot/100-preserve-apt-prefs.chroot diff --git a/live-build/auto/config b/live-build/auto/config index cb995a21..0b50f0ff 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -1096,7 +1096,8 @@ rm -f /etc/fstab EOF fi -cat > config/hooks/100-preserve-apt-prefs.chroot < config/hooks/100-preserve-apt-prefs.chroot <<\EOF #! /bin/sh -ex # live-build "helpfully" removes /etc/apt/preferences.d/* so we put a @@ -1106,6 +1107,7 @@ if [ -n "$(ls -A /etc/apt/preferences.d)" ]; then cp -a /etc/apt/preferences.d /etc/apt/preferences.d.save fi EOF +fi if [ $PROJECT = ubuntukylin ]; then cat > config/hooks/100-ubuntukylin.chroot < Date: Sat, 14 Dec 2019 20:59:21 +1300 Subject: [PATCH 5/5] bump version number --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index e68f9f16..98dd08a3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -livecd-rootfs (2.634) UNRELEASED; urgency=medium +livecd-rootfs (2.635) UNRELEASED; urgency=medium * Preserve apt preferences created by any package we install (i.e. ubuntu-advantage-tools) against live-build's attempt to delete them.