From d70309b7e04f4bf07284c109c59612ac331006fa Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Thu, 19 Dec 2019 15:45:17 +1300 Subject: [PATCH] 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 | 13 +++++++++++++ .../hooks.d/chroot/100-preserve-apt-prefs.chroot | 8 ++++++++ 4 files changed, 35 insertions(+) create mode 100755 live-build/ubuntu-cpc/hooks.d/chroot/100-preserve-apt-prefs.chroot diff --git a/debian/changelog b/debian/changelog index 234994c8..0ca4799d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +livecd-rootfs (2.408.57) 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, 19 Dec 2019 15:43:56 +1300 + livecd-rootfs (2.408.56) xenial; urgency=medium * Backport enabling of adding extra snaps to ubuntu-core images via the diff --git a/live-build/auto/build b/live-build/auto/build index 7908cc73..1c562077 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -220,6 +220,12 @@ EOF lb chroot "$@" + 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 + if [ "${SUBPROJECT:-}" = minimized ]; then # and if initramfs-tools was configured before our kernel, # /etc/kernel/postinst.d/initramfs-tools will have created diff --git a/live-build/auto/config b/live-build/auto/config index 721d5dc4..5ef7ae95 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -875,6 +875,19 @@ EOF ;; esac +if [ $PROJECT != ubuntu-cpc ]; then + cat > config/hooks/100-preserve-apt-prefs.chroot <<\EOF +#! /bin/sh -ex + +# live-build "helpfully" removes /etc/apt/preferences.d/* so we put a +# copy somewhere it won't touch it. + +if [ -n "$(ls -A /etc/apt/preferences.d)" ]; then + cp -a /etc/apt/preferences.d /etc/apt/preferences.d.save +fi +EOF +fi + if $BINARY_REMOVE_LINUX; then cat > config/binary_rootfs/excludes << EOF boot/vmlinu?-* diff --git a/live-build/ubuntu-cpc/hooks.d/chroot/100-preserve-apt-prefs.chroot b/live-build/ubuntu-cpc/hooks.d/chroot/100-preserve-apt-prefs.chroot new file mode 100755 index 00000000..ff5afc27 --- /dev/null +++ b/live-build/ubuntu-cpc/hooks.d/chroot/100-preserve-apt-prefs.chroot @@ -0,0 +1,8 @@ +#! /bin/sh -ex + +# live-build "helpfully" removes /etc/apt/preferences.d/* so we put a +# copy somewhere it won't touch it. + +if [ -n "$(ls -A /etc/apt/preferences.d)" ]; then + cp -a /etc/apt/preferences.d /etc/apt/preferences.d.save +fi