From fe270ec595dc6bf90df4c79b4da259a41e1ff64d Mon Sep 17 00:00:00 2001 From: Drew Walters Date: Sun, 26 Jan 2020 16:42:03 +0000 Subject: [PATCH] apt: Add whitelist for strict mode This change adds a whitelist of packages that will be ignored when using strict mode. Change-Id: I9138f35a72618100e6094575271f6160336332f4 Signed-off-by: Drew Walters --- divingbell/templates/bin/_apt.sh.tpl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/divingbell/templates/bin/_apt.sh.tpl b/divingbell/templates/bin/_apt.sh.tpl index 5846349..d28863c 100644 --- a/divingbell/templates/bin/_apt.sh.tpl +++ b/divingbell/templates/bin/_apt.sh.tpl @@ -193,9 +193,26 @@ if [ -f ${persist_path}/packages ]; then {{- end }} if [ ! -z "$TO_DELETE" ]; then dpkg --configure -a + + {{- if hasKey .Values.conf.apt "whitelistpkgs" }} + WHITELIST=({{ include "helm-toolkit.utils.joinListWithSpace" .Values.conf.apt.whitelistpkgs }}) + {{- end }} PURGE_LIST="" while read -r pkg; do + {{- if hasKey .Values.conf.apt "whitelistpkgs" }} + found=false + for item in "${WHITELIST[@]}"; do + if [[ "${item}" == "${pkg}" ]]; then + found=true + break + fi + done + if [[ "${found}" == "false" ]]; then + PURGE_LIST="$PURGE_LIST $pkg" + fi + {{- else }} PURGE_LIST="$PURGE_LIST $pkg" + {{- end }} done <<< "$TO_DELETE" DEBIAN_FRONTEND=noninteractive $APT_PURGE $PURGE_LIST fi