Restore previously installed APT packages

pull/101/head
Michele Locati 2020-01-23 14:50:55 +01:00
parent ef2941603c
commit 8b5078f47f
No known key found for this signature in database
GPG Key ID: 98B7CE2E7234E28B
1 changed files with 17 additions and 1 deletions

View File

@ -199,6 +199,7 @@ sortModulesToInstall() {
# Set: # Set:
# PACKAGES_PERSISTENT # PACKAGES_PERSISTENT
# PACKAGES_VOLATILE # PACKAGES_VOLATILE
# PACKAGES_PREVIOUS
buildRequiredPackageLists() { buildRequiredPackageLists() {
buildRequiredPackageLists_persistent='' buildRequiredPackageLists_persistent=''
buildRequiredPackageLists_volatile='' buildRequiredPackageLists_volatile=''
@ -634,6 +635,7 @@ buildRequiredPackageLists() {
done done
PACKAGES_PERSISTENT='' PACKAGES_PERSISTENT=''
PACKAGES_VOLATILE='' PACKAGES_VOLATILE=''
PACKAGES_PREVIOUS=''
if test -z "$buildRequiredPackageLists_persistent$buildRequiredPackageLists_volatile"; then if test -z "$buildRequiredPackageLists_persistent$buildRequiredPackageLists_volatile"; then
return return
fi fi
@ -643,7 +645,6 @@ buildRequiredPackageLists() {
;; ;;
debian) debian)
DEBIAN_FRONTEND=noninteractive apt-get update -q DEBIAN_FRONTEND=noninteractive apt-get update -q
DEBIAN_FRONTEND=noninteractive apt-get autoremove --purge -y -q
;; ;;
esac esac
if test -n "$buildRequiredPackageLists_persistent"; then if test -n "$buildRequiredPackageLists_persistent"; then
@ -665,6 +666,13 @@ buildRequiredPackageLists() {
done done
PACKAGES_VOLATILE="${PACKAGES_VOLATILE# }" PACKAGES_VOLATILE="${PACKAGES_VOLATILE# }"
fi fi
if test -n "$PACKAGES_PERSISTENT$PACKAGES_VOLATILE"; then
case "$buildRequiredPackageLists_distro" in
debian)
PACKAGES_PREVIOUS="$(dpkg --get-selections | grep -E '\sinstall$' | awk '{ print $1 }')"
;;
esac
fi
} }
# Get the full list of APT/APK packages that will be installed, given the required packages # Get the full list of APT/APK packages that will be installed, given the required packages
@ -1290,6 +1298,14 @@ cleanup() {
;; ;;
esac esac
fi fi
if test -n "$PACKAGES_PREVIOUS"; then
case "$cleanup_distro" in
debian)
printf '### RESTORING PREVIOUSLY INSTALLED PACKAGES ###\n'
DEBIAN_FRONTEND=noninteractive apt-get install -qqy $PACKAGES_PREVIOUS
;;
esac
fi
case "$cleanup_distro" in case "$cleanup_distro" in
alpine) alpine)
rm -rf /var/cache/apk/* rm -rf /var/cache/apk/*