diff -Nru live-build-3.0~a57/debian/changelog live-build-3.0~a57/debian/changelog --- live-build-3.0~a57/debian/changelog 2023-08-29 06:48:09.000000000 +0000 +++ live-build-3.0~a57/debian/changelog 2023-09-12 03:59:17.000000000 +0000 @@ -1,9 +1,25 @@ -live-build (3.0~a57-1ubuntu47~ppa2) mantic; urgency=medium +live-build (3.0~a57-1ubuntu49~ppa1) mantic; 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 + + -- Phil Roche Tue, 12 Sep 2023 15:59:17 +1200 + +live-build (3.0~a57-1ubuntu48) mantic; urgency=medium + + * d/patches/umount-sys-properly.patch: fix do_umount to actually unmount the + passed mountpoint :/. + + -- Michael Hudson-Doyle Wed, 30 Aug 2023 08:59:13 +1200 + +live-build (3.0~a57-1ubuntu47) mantic; urgency=medium * d/patches/umount-sys-properly.patch: Unmount any submounts of /sys that have appeared since it was mounted. - -- Michael Hudson-Doyle Tue, 29 Aug 2023 18:48:09 +1200 + -- Michael Hudson-Doyle Tue, 29 Aug 2023 20:40:51 +1200 live-build (3.0~a57-1ubuntu46) mantic; urgency=medium 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 1970-01-01 00:00:00.000000000 +0000 +++ live-build-3.0~a57/debian/patches/lp-2033308-backup-and-restore-packaged-preferences.patch 2023-09-12 03:58:53.000000000 +0000 @@ -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 2023-08-29 06:42:27.000000000 +0000 +++ live-build-3.0~a57/debian/patches/series 2023-09-12 03:58:53.000000000 +0000 @@ -46,3 +46,4 @@ ubuntu-apt-preferences.d-removal ubuntu-silence-fdisk-noise.patch umount-sys-properly.patch +lp-2033308-backup-and-restore-packaged-preferences.patch diff -Nru live-build-3.0~a57/debian/patches/umount-sys-properly.patch live-build-3.0~a57/debian/patches/umount-sys-properly.patch --- live-build-3.0~a57/debian/patches/umount-sys-properly.patch 2023-08-29 06:46:21.000000000 +0000 +++ live-build-3.0~a57/debian/patches/umount-sys-properly.patch 2023-08-29 20:51:54.000000000 +0000 @@ -1,27 +1,26 @@ --- a/scripts/build/lb_chroot_sysfs +++ b/scripts/build/lb_chroot_sysfs -@@ -30,6 +30,20 @@ +@@ -30,6 +30,19 @@ # Requiring stage file Require_stagefile .build/config .build/bootstrap +do_umount () { + mountpoint=$(realpath "$1") + -+ # ensure we have exactly one trailing slash, and escape all slashes for awk -+ mountpoint_match=$(echo "$mountpoint" | sed -e's,/$,,; s,/,\\/,g;')'\/' ++ # ensure we have no trailing slashes, and escape all slashes for awk ++ mountpoint_match=$(echo "$mountpoint" | sed -e's,/$,,; s,/,\\/,g;') + # sort -r ensures that deeper mountpoints are unmounted first + for submount in $(awk