#!/bin/sh set -e is_installed() { local pkg="$1" dpkg-query -s "$pkg" >/dev/null 2>&1 || return 1 local status="$(dpkg-query -W -f '${Status}' $pkg)" test "$status" != "unknown ok not-installed" || return 1 test "$status" != "deinstall ok config-files" || return 1 return 0 } # # Remove obsolete base packages from the reference chroot. # # These packages are part of a minimal chroot in release R, but no # longer exist in release R+1. # Package dependencies will cause removal of the obsolete packages # during a subset of upgrade paths. Since these packages cannot be # reinstalled in release R+1 ensure they are always gone from the # final reference chroot. # # Only while creating the reference chroot. test "$PIUPARTS_PHASE" = "" || exit 0 PURGE= mark_for_purge() { pkg="$1" # skip if the package is not installed is_installed "$pkg" || return 0 case ${PIUPARTS_OBJECTS%%=*} in $pkg) # keep it while testing it ;; *) PURGE="$PURGE $pkg" esac } if [ "$PIUPARTS_DISTRIBUTION" = "wheezy" ] ; then mark_for_purge libdb4.8 # gcc-4.4-base is part of the minimal squeeze chroot # but it no longer exists in wheezy mark_for_purge gcc-4.4-base fi if [ "$PIUPARTS_DISTRIBUTION" = "jessie" ] ; then mark_for_purge libdb5.1 fi if [ "$PIUPARTS_DISTRIBUTION" = "stretch" ] || \ [ "$PIUPARTS_DISTRIBUTION" = "stretch-next" ] ; then mark_for_purge libprocps3 mark_for_purge sysvinit # pulled in during dist-upgrade of the reference chroot with --install-recommends # can cause problems if the tested upgrade path installs a different pinentry-* # because apt may fail to properly switch during removal (seen on e.g. # plasma-desktop, plasma-netbook, kdeutils, print-manager, science-chemistry) mark_for_purge pinentry-curses fi if [ "$PIUPARTS_DISTRIBUTION" = "buster" ] || \ [ "$PIUPARTS_DISTRIBUTION" = "buster-next" ] ; then mark_for_purge libcryptsetup4 mark_for_purge libprocps6 fi if [ -n "$PURGE" ]; then echo "Removing packages from base system:$PURGE" apt-get -y remove --purge $PURGE fi