From c46c253729e4fc79ce22991eeefd0fab863f7c8f Mon Sep 17 00:00:00 2001 From: "Mosher, Jaymes (jm616v)" Date: Tue, 8 Oct 2024 15:15:21 -0600 Subject: [PATCH] Add ignorepkgs option Add option for list of packages for divingbell-apt to completely ignore Change-Id: I79f7ff7887c110d88f052705e2c62f12a6974a30 --- divingbell/Chart.yaml | 2 +- divingbell/templates/bin/_apt.sh.tpl | 29 +++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/divingbell/Chart.yaml b/divingbell/Chart.yaml index af2cdbe..f59beaf 100644 --- a/divingbell/Chart.yaml +++ b/divingbell/Chart.yaml @@ -15,4 +15,4 @@ apiVersion: v1 description: divingbell name: divingbell -version: 0.1.4 +version: 0.1.5 diff --git a/divingbell/templates/bin/_apt.sh.tpl b/divingbell/templates/bin/_apt.sh.tpl index 174ebda..a54ce0e 100644 --- a/divingbell/templates/bin/_apt.sh.tpl +++ b/divingbell/templates/bin/_apt.sh.tpl @@ -126,6 +126,17 @@ DEBIAN_FRONTEND=noninteractive apt-get update {{- $all_apt_packages = .Values.conf.apt.packages }} {{- end -}} +{{/* Filter out packages in "ignorepkgs" */}} +{{- if hasKey .Values.conf.apt "ignorepkgs" }} +{{- $new_apt_packages := list }} +{{- range $k, $v := $all_apt_packages }} +{{- if not (has $v.name $.Values.conf.apt.ignorepkgs) }} +{{- $new_apt_packages = $v | append $new_apt_packages }} +{{- end }} +{{- end }} +{{- $all_apt_packages = $new_apt_packages }} +{{- end }} + # Set all debconf selections up front {{- range $all_apt_packages }} {{- $pkg_name := .name }} @@ -192,6 +203,18 @@ APT_PURGE="apt-get purge -y --autoremove" touch ${persist_path}/packages {{- end }} +{{ $whitelist_pkgs := list }} +{{- if hasKey .Values.conf.apt "whitelistpkgs" }} +{{- range .Values.conf.apt.whitelistpkgs }} +{{- $whitelist_pkgs = . | append $whitelist_pkgs }} +{{- end }} +{{- end }} +{{- if hasKey .Values.conf.apt "ignorepkgs" }} +{{- range .Values.conf.apt.ignorepkgs }} +{{- $whitelist_pkgs = . | append $whitelist_pkgs }} +{{- end }} +{{- end }} + echo $INSTALLED_THIS_TIME | sed 's/ /\n/g' | sed '/^[[:space:]]*$/d' | sort > ${persist_path}/packages.new echo $REQUESTED_PACKAGES | sed 's/ /\n/g' | sed '/^[[:space:]]*$/d' | sort > ${persist_path}/packages.requested if [ -f ${persist_path}/packages ]; then @@ -220,12 +243,12 @@ if [ -f ${persist_path}/packages ]; then wait_for_dpkg_availability dpkg --configure -a --force-confold,confdef - {{- if hasKey .Values.conf.apt "whitelistpkgs" }} - WHITELIST=({{ include "helm-toolkit.utils.joinListWithSpace" .Values.conf.apt.whitelistpkgs }}) + {{- if $whitelist_pkgs }} + WHITELIST=({{ include "helm-toolkit.utils.joinListWithSpace" $whitelist_pkgs }}) {{- end }} PURGE_LIST="" while read -r pkg; do - {{- if hasKey .Values.conf.apt "whitelistpkgs" }} + {{- if $whitelist_pkgs }} found=false for item in "${WHITELIST[@]}"; do if [[ "${item}" == "${pkg}" ]]; then