Remove 'autoremove' from strict mode apt purge

This patchset makes two changes for strict mode only:

1) Removes the --autoremove flag from the apt-get purge
   command line
2) Causes the install stage to call apt-get install on
   all packages regardless of whether they're already
   installed. This will have the effect of marking all
   requested packages as manually installed if they
   were previously auto-installed.

Change-Id: Ic1a39205c941973af9d82685180d28457ea2011f
This commit is contained in:
Crank, Daniel 2020-01-25 11:49:27 -06:00
parent 44525162a5
commit 3cc1620319
1 changed files with 11 additions and 1 deletions

View File

@ -115,6 +115,13 @@ dpkg --configure -a
# Perform package installs
set +x
{{- if .Values.conf.apt.strict }}
{{- range $all_apt_packages }}
{{- $pkg_name := .name }}
INSTALLED_THIS_TIME="$INSTALLED_THIS_TIME {{$pkg_name}} {{- if .version }}={{ .version }}{{ end }}"
REQUESTED_PACKAGES="$REQUESTED_PACKAGES {{$pkg_name}}"
{{- end }}
{{- else }}
{{- range $all_apt_packages }}
{{- $pkg_name := .name }}
if [[ "${CURRENT_PACKAGES[{{ .name | squote }}]+isset}" != "isset"{{- if .version }} || "${CURRENT_PACKAGES[{{ .name | squote }}]}" != {{ .version }}{{- end }} ]]; then
@ -122,6 +129,7 @@ if [[ "${CURRENT_PACKAGES[{{ .name | squote }}]+isset}" != "isset"{{- if .versio
fi
REQUESTED_PACKAGES="$REQUESTED_PACKAGES {{$pkg_name}}"
{{- end }}
{{- end }}
set -x
# Run this in case some package installation was interrupted
DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold {{- if .Values.conf.apt.allow_downgrade }} "--allow-downgrades" {{ end }}{{- if .repo }} -t {{ .repo }}{{ end }} $INSTALLED_THIS_TIME
@ -144,7 +152,9 @@ fi
################################################
{{- if .Values.conf.apt.strict }}
APT_PURGE="apt-get purge -y --autoremove --allow-remove-essential"
# For strict mode, we do not want to use --autoremove, to avoid
# letting apt remove packages outside divingbell's control
APT_PURGE="apt-get purge -y --allow-remove-essential"
{{- else }}
APT_PURGE="apt-get purge -y --autoremove"
{{- end }}