From: Christian Heller Date: Thu, 21 Aug 2025 22:03:36 +0000 (+0200) Subject: Fixes. X-Git-Url: https://plomlompom.com/repos/blog?a=commitdiff_plain;h=03c43b795476617092bb4cd271611870ac66fd45;p=config Fixes. --- diff --git a/trixie/scripts/lib/ensure_packages_of_tags.sh b/trixie/scripts/lib/ensure_packages_of_tags.sh index 53a1ee3..72d8a15 100644 --- a/trixie/scripts/lib/ensure_packages_of_tags.sh +++ b/trixie/scripts/lib/ensure_packages_of_tags.sh @@ -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 }