diff -Nru live-build-3.0~a57/debian/changelog live-build-3.0~a57/debian/changelog --- live-build-3.0~a57/debian/changelog 2020-06-03 20:18:29.000000000 -0400 +++ live-build-3.0~a57/debian/changelog 2023-10-18 12:16:49.000000000 -0400 @@ -1,3 +1,12 @@ +live-build (3.0~a57-1ubuntu38.20.04.3) focal; urgency=medium + + * To avoid removing packaged preferences.d files, in lb_chroot_archives install stage, + only remove apt/preferences.d/* files after we backup any existing preferences.d/ files. + Then during remove stage or lb_chroot_archives restore the backed up packaged + preferences.d files. LP: #2033308 + + -- Catherine Redfield Wed, 18 Oct 2023 12:16:49 -0400 + live-build (3.0~a57-1ubuntu38.20.04.2) focal; urgency=medium * Add riscv64 support to live-build. LP: #1881980 diff -Nru live-build-3.0~a57/debian/patches/lp-2033308-backup-and-restore-packaged-preferences.patch live-build-3.0~a57/debian/patches/lp-2033308-backup-and-restore-packaged-preferences.patch --- live-build-3.0~a57/debian/patches/lp-2033308-backup-and-restore-packaged-preferences.patch 1969-12-31 19:00:00.000000000 -0500 +++ live-build-3.0~a57/debian/patches/lp-2033308-backup-and-restore-packaged-preferences.patch 2023-10-18 12:16:17.000000000 -0400 @@ -0,0 +1,95 @@ +Description: + * To avoid removing packaged preferences.d files, in lb_chroot_archives install stage, + only remove apt/preferences.d/* files after we backup any existing preferences.d/ files. + Then during remove stage or lb_chroot_archives restore the backed up packaged + preferences.d files. LP: #2033308 +Author: Phil Roche +Bug-Ubuntu: https://bugs.launchpad.net/bugs/2033308 + + +Index: live-build-3.0~a57/functions/apt_preferences.sh +=================================================================== +--- /dev/null ++++ live-build-3.0~a57/functions/apt_preferences.sh +@@ -0,0 +1,27 @@ ++#!/bin/sh ++ ++## live-build(7) - System Build Scripts ++## Copyright (C) 2023 Phil Roche ++## ++## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING. ++## This is free software, and you are welcome to redistribute it ++## under certain conditions; see COPYING for details. ++ ++ ++Restore_packaged_apt_preferences () ++{ ++ if [ -d chroot/etc/apt/preferences.d.save ]; then ++ Echo_message "Restoring backed up packaged preferences.d files" ++ mv --verbose chroot/etc/apt/preferences.d.save/* chroot/etc/apt/preferences.d/ ++ rmdir --verbose chroot/etc/apt/preferences.d.save ++ fi ++} ++ ++Backup_packaged_apt_preferences () ++{ ++ if [ -n "$(ls -A chroot/etc/apt/preferences.d)" ]; then ++ Echo_message "Backing up packaged preferences.d/* files ..." ++ cp --archive --verbose chroot/etc/apt/preferences.d chroot/etc/apt/preferences.d.save ++ fi ++} ++ +Index: live-build-3.0~a57/scripts/build/lb_chroot_archives +=================================================================== +--- live-build-3.0~a57.orig/scripts/build/lb_chroot_archives ++++ live-build-3.0~a57/scripts/build/lb_chroot_archives +@@ -189,8 +189,12 @@ EOF + fi + fi + +- # probably too bold, needs refinment (FIXME) +- rm -f chroot/etc/apt/preferences.d/* ++ # Only remove apt/preferences.d/* files after we backup any existing preferences.d/ files ++ # for later restoration ++ Backup_packaged_apt_preferences ++ ++ Echo_message "Clean up /etc/apt/preferences.d/* now that we have persisted the existing files for later restoration ..." ++ rm --verbose --force chroot/etc/apt/preferences.d/* + + # Configure third-party archives + if [ -n "${LB_ARCHIVES}" ] +@@ -625,6 +629,11 @@ EOF + # Removing stage file + rm -f .build/chroot_archives + ++ # Now that we are exiting early from the remove stage, we still need to cleanup /etc/apt/preferences.d and if ++ # there existed a preferences.d.save directory, move the files back ++ # These were backed up in the install stage before any local preferences were added ++ Restore_packaged_apt_preferences ++ + exit 0 + fi + +@@ -755,8 +764,9 @@ EOF + fi + fi + +- # probably too bold, needs refinment (FIXME) +- rm -f chroot/etc/apt/preferences.d/* ++ ++ Echo_message "Clean up /etc/apt/preferences.d/*. Any previous packaged files have been backed up to chroot/etc/apt/preferences.d.save in the install stage for later restoration ..." ++ rm --verbose --force chroot/etc/apt/preferences.d/* + + # Configure third-party archives + if [ -n "${LB_ARCHIVES}" ] +@@ -889,6 +899,10 @@ EOF + apt-key del ${_LB_LOCAL_KEY_EMAIL} + fi + ++ # If there existed a preferences.d.save directory, move the files back ++ # These were backed up before any local preferences were added ++ Restore_packaged_apt_preferences ++ + # Removing stage file + rm -f .build/chroot_archives + ;; diff -Nru live-build-3.0~a57/debian/patches/series live-build-3.0~a57/debian/patches/series --- live-build-3.0~a57/debian/patches/series 2020-06-03 20:18:00.000000000 -0400 +++ live-build-3.0~a57/debian/patches/series 2023-10-18 12:16:17.000000000 -0400 @@ -42,3 +42,4 @@ drop-default-initramfs-compression-override.patch ubuntu-make-genisoimage-more-flexible.patch add-riscv64.patch +lp-2033308-backup-and-restore-packaged-preferences.patch