Add ignorepkgs option

Add option for list of packages for divingbell-apt to completely ignore

Change-Id: I79f7ff7887c110d88f052705e2c62f12a6974a30
This commit is contained in:
Mosher, Jaymes (jm616v) 2024-10-08 15:15:21 -06:00
parent cd6a301976
commit c46c253729
2 changed files with 27 additions and 4 deletions

View File

@ -15,4 +15,4 @@
apiVersion: v1
description: divingbell
name: divingbell
version: 0.1.4
version: 0.1.5

View File

@ -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