X-Git-Url: https://git.grml.org/?p=grml-live.git;a=blobdiff_plain;f=etc%2Fgrml%2Ffai%2Fconfig%2Fscripts%2FDEBORPHAN%2F98-clean-chroot;h=42ed9c24a028e350ccc72ac575bf927061dd5fa5;hp=a5515f0638684dfff8670bacd37cc50fa9ba6abb;hb=HEAD;hpb=f3b335ea5c94d5cf24ec6b9184106b298849f311 diff --git a/etc/grml/fai/config/scripts/DEBORPHAN/98-clean-chroot b/etc/grml/fai/config/scripts/DEBORPHAN/98-clean-chroot index a5515f0..dce15d4 100755 --- a/etc/grml/fai/config/scripts/DEBORPHAN/98-clean-chroot +++ b/etc/grml/fai/config/scripts/DEBORPHAN/98-clean-chroot @@ -10,12 +10,28 @@ set -u set -e # remove all packages not necessary anymore: +echo "Executing apt-get -y --purge autoremove" $ROOTCMD apt-get -y --purge autoremove -# remove packages until deborphan does not find anymore: -while [ "$($ROOTCMD deborphan)" != "" ] ; do - $ROOTCMD apt-get -y --purge remove $(deborphan) -done +# make sure we don't have any removed but not-yet-purged packages left, +# otherwise GRMLBASE/03-get-sources might try to download unavailable +# packages and will fail doing so +PURGE_PACKAGES=$($ROOTCMD dpkg --list | awk '/^rc/ {print $2}') + +if [ -n "$PURGE_PACKAGES" ] ; then + echo "Getting rid of packages which have been removed but not yet purged: $PURGE_PACKAGES" + $ROOTCMD dpkg --purge $PURGE_PACKAGES +fi + +# note: deborphan is no longer available as of Debian/trixie, +# see https://github.com/grml/grml-live/issues/144 +if [ -x "$target"/usr/bin/deborphan ] ; then + # remove packages until deborphan does not find anymore: + while [ "$($ROOTCMD deborphan)" != "" ] ; do + echo "Executing deborphan" + $ROOTCMD apt-get -y --purge remove $($ROOTCMD deborphan) + done +fi ## END OF FILE ################################################################# # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2