home · contact · privacy
Fixes.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 21 Aug 2025 22:03:36 +0000 (00:03 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 21 Aug 2025 22:03:36 +0000 (00:03 +0200)
trixie/scripts/lib/ensure_packages_of_tags.sh

index 53a1ee303356d3837c14f5de138a5016ede5894c..72d8a15340e7ba8fb74d1c7d9d6c8a4f949f5541 100644 (file)
@@ -2,34 +2,39 @@
 . lib/prefixed_msg.sh
 
 ensure_packages_of_tags() {
-prefixed_msg_init 'ensure_packages_of_tags'
+    prefixed_msg_init 'ensure_packages_of_tags'
 
-_APT_ARG="-q -q -o 'Dpkg::Options::=--force-confnew' install"
-for _TAG in $@; do
-    prefixed_msg_no_nl "For tag '${_TAG}', "
-    if [ "$(echo ${_TAG} | cut -d':' -f1)" = 'keep_if_installed' ]; then
-        _PACKAGE=$(echo ${_TAG} | cut -d':' -f2)
-        printf 'checking if installed … '
-        if dpkg-query -Wf '${Package}\n' | grep '^'"${_PACKAGE}"'$' > /dev/null; then
-            echo 'yup, keeping!'
-            apt_digested ${_APT_ARG} ${_PACKAGE}
+    local APT_ARG="-q -q -o 'Dpkg::Options::=--force-confnew' install"
+    local TAG
+    for TAG in $@; do
+        prefixed_msg_no_nl "For tag '${TAG}', "
+        local TEST
+        TEST=$(echo "${TAG}" | cut -d':' -f1)
+        if [ "${TEST}" = 'keep_if_installed' ]; then
+            local PACKAGE
+            PACKAGE=$(echo "${TAG}" | cut -d':' -f2)
+            printf 'checking if installed … '
+            if dpkg-query -Wf '${Package}\n' | grep '^'"${PACKAGE}"'$' > /dev/null; then
+                echo 'yup, keeping!'
+                apt_digested ${APT_ARG} ${PACKAGE}
+            else
+                echo 'nope, nothing to keep.'
+            fi
+            continue
+        fi
+        local PATH_APTMARK_TAG="../aptmark/${TAG}"
+        if [ ! -f "${PATH_APTMARK_TAG}" ]; then
+            echo 'no file, ignoring.'
+            continue
+        fi
+        local PACKAGES
+        PACKAGES=$(cat "${PATH_APTMARK_TAG}" | sed -E 's/#.*//g' | sed -z 's/\n/ /g' | sed 's/  */ /g' | cut -c 2-)
+        if [ -z "${PACKAGES}" ]; then
+            echo 'nothing to install.'
         else
-            echo 'nope, nothing to keep.'
+            echo "ensuring installation of: ${PACKAGES}"
+            apt_digested ${APT_ARG} ${PACKAGES}
         fi
-        continue
-    fi
-    _PATH_APTMARK_TAG="../aptmark/${_TAG}"
-    if [ ! -f "${_PATH_APTMARK_TAG}" ]; then
-        echo 'no file, ignoring.'
-        continue
-    fi
-    _PACKAGES=$(cat "${_PATH_APTMARK_TAG}" | sed -E 's/#.*//g' | sed -z 's/\n/ /g' | sed 's/  */ /g' | cut -c 2-)
-    if [ -z "${_PACKAGES}" ]; then
-        echo 'nothing to install.'
-    else
-        echo "ensuring installation of: ${_PACKAGES}"
-        apt_digested ${_APT_ARG} ${_PACKAGES}
-    fi
-done
-prefixed_msg_exit
+    done
+    prefixed_msg_exit
 }