diff -Nru live-build-3.0~a57/debian/changelog live-build-3.0~a57/debian/changelog --- live-build-3.0~a57/debian/changelog 2016-06-28 14:48:47.000000000 +0000 +++ live-build-3.0~a57/debian/changelog 2017-03-01 05:21:28.000000000 +0000 @@ -1,3 +1,10 @@ +live-build (3.0~a57-1ubuntu25.2) xenial; urgency=medium + + * debian/patches/ubuntu-debootstrap-demotions.patch: remove packages + after bootstrap that have been demoted. Closes LP: #1668847. + + -- Steve Langasek Tue, 28 Feb 2017 21:21:28 -0800 + live-build (3.0~a57-1ubuntu25.1) xenial; urgency=medium * Avoid recompressing initrd.img symlinks (LP: #1539157). 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 2016-06-28 12:38:19.000000000 +0000 +++ live-build-3.0~a57/debian/patches/series 2017-03-01 05:21:14.000000000 +0000 @@ -32,3 +32,4 @@ upstart-not-in-bootstrap ubuntu-s390x-support.patch ubuntu-initramfs-compression-symlinks.patch +ubuntu-debootstrap-demotions.patch diff -Nru live-build-3.0~a57/debian/patches/ubuntu-debootstrap-demotions.patch live-build-3.0~a57/debian/patches/ubuntu-debootstrap-demotions.patch --- live-build-3.0~a57/debian/patches/ubuntu-debootstrap-demotions.patch 1970-01-01 00:00:00.000000000 +0000 +++ live-build-3.0~a57/debian/patches/ubuntu-debootstrap-demotions.patch 2017-03-01 05:21:14.000000000 +0000 @@ -0,0 +1,72 @@ +Author: Steve Langasek +Description: remove packages after bootstrap that have been demoted + If we are doing a minimal bootstrap, we only want packages that are + Priority: required. Sometimes we may want to downgrade a package from + required post-release; in this case it will still be installed by + debootstrap, but we would want to remove it post-bootstrap. This patch + implements handling of this for any packages which have been downgraded + and removed without removing other installed packages. +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1668847 + +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 +@@ -23,6 +23,45 @@ + + Arguments "${@}" + ++# remove all installed packages that are Prio: required in the release ++# pocket but something else in the latest version ++remove_demoted_packages() { ++ requireds=$( ++ Chroot chroot dpkg -l | awk '/^ii/ { print $2 " " $3 }' \ ++ | while read pkg ver ++ do ++ prio=$(Chroot chroot apt-cache show "$pkg=$ver" \ ++ | awk '/^Priority: / { print $2 }') ++ if [ "$prio" = required ]; then ++ echo "$pkg" ++ fi ++ done ++ ) ++ for pkg in $requireds; do ++ prio=$(Chroot chroot apt-cache show $pkg \ ++ | awk '/^Priority:/ { print $2 }' | sort -u) ++ if [ "$prio" != required ]; then ++ removals="$removals${removals:+ }$pkg" ++ fi ++ done ++ ++ while true; do ++ for pkg in $removals; do ++ count=$(Chroot chroot apt-get -s remove $pkg \ ++ | grep -c ^Remv) ++ if [ "$count" -eq 1 ]; then ++ Chroot chroot apt-get -y remove --purge $pkg ++ else ++ new_removals="$new_removals${new_removals:+ }$pkg" ++ fi ++ done ++ if [ "$new_removals" = "$removals" ]; then ++ break ++ fi ++ removals="$new_removals" ++ done ++} ++ + # Reading configuration files + Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source + Set_defaults +@@ -463,6 +502,11 @@ + >> chroot/root/packages.chroot + fi + ++ if [ "$LB_BOOTSTRAP_FLAVOUR" = minimal ]; then ++ Apt chroot update ++ remove_demoted_packages ++ fi ++ + # Update indices from cache + if [ "${LB_CACHE_INDICES}" = "true" ] && [ -d cache/indices.bootstrap ] + then