From 9c04a4164f49b0c8c0007008ed5e0aaa2ac294fe Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Tue, 19 Aug 2025 20:22:59 +0200 Subject: [PATCH] Fix. --- trixie/scripts/lib/ensure_packages_of_tags.sh | 36 ++++++++++++++++- trixie/scripts/minimize_installation.sh | 40 ++++++++++++++++++- 2 files changed, 74 insertions(+), 2 deletions(-) mode change 120000 => 100644 trixie/scripts/lib/ensure_packages_of_tags.sh mode change 120000 => 100755 trixie/scripts/minimize_installation.sh diff --git a/trixie/scripts/lib/ensure_packages_of_tags.sh b/trixie/scripts/lib/ensure_packages_of_tags.sh deleted file mode 120000 index ca07505..0000000 --- a/trixie/scripts/lib/ensure_packages_of_tags.sh +++ /dev/null @@ -1 +0,0 @@ -../../../bookworm/scripts/lib/ensure_packages_of_tags.sh \ No newline at end of file diff --git a/trixie/scripts/lib/ensure_packages_of_tags.sh b/trixie/scripts/lib/ensure_packages_of_tags.sh new file mode 100644 index 0000000..c4495f6 --- /dev/null +++ b/trixie/scripts/lib/ensure_packages_of_tags.sh @@ -0,0 +1,35 @@ +. lib/apt_digested.sh +. lib/prefixed_msg.sh + +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}" + else + echo 'nope, nothing to keep.' + 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 +} diff --git a/trixie/scripts/minimize_installation.sh b/trixie/scripts/minimize_installation.sh deleted file mode 120000 index a9bd291..0000000 --- a/trixie/scripts/minimize_installation.sh +++ /dev/null @@ -1 +0,0 @@ -../../bookworm/scripts/minimize_installation.sh \ No newline at end of file diff --git a/trixie/scripts/minimize_installation.sh b/trixie/scripts/minimize_installation.sh new file mode 100755 index 0000000..efe4fcd --- /dev/null +++ b/trixie/scripts/minimize_installation.sh @@ -0,0 +1,39 @@ +#!/bin/sh +set -e +cd $(dirname "$0") +. lib/apt_digested.sh +. lib/ensure_packages_of_tags.sh +. lib/prefixed_msg.sh + +prefixed_msg_init +_INSTALL_TAGS="$@" +prefixed_msg "narrow system to what is required explicitly by Debian and by us, as per these INSTALL_TAGS: ${_INSTALL_TAGS}" + +_TOK_REQ='required' +_PATH_LIST_PREFIX=/tmp/list_ +_PATH_LIST_UNSORTED="${_PATH_LIST_PREFIX}unsorted" +_PATH_LIST_WHITE="${_PATH_LIST_PREFIX}white" +_PATH_LIST_ALL_PACKAGES="${_PATH_LIST_PREFIX}all_packages" +_PATH_LIST_BLACK="${_PATH_LIST_PREFIX}black" + +prefixed_msg_no_nl "collect packages deemed '${_TOK_REQ}' by Debian: " +dpkg-query -Wf '${Package} ${Priority}\n' | grep " ${_TOK_REQ}" | cut -d' ' -f1 > "${_PATH_LIST_UNSORTED}" +sort "${_PATH_LIST_UNSORTED}" > "${_PATH_LIST_WHITE}" +echo $(cat "${_PATH_LIST_WHITE}") + +prefixed_msg 'collect installed packages outside this selection …' +dpkg-query -Wf '${Package}\n' > "${_PATH_LIST_UNSORTED}" +sort "${_PATH_LIST_UNSORTED}" > "${_PATH_LIST_ALL_PACKAGES}" +comm -3 "${_PATH_LIST_ALL_PACKAGES}" "${_PATH_LIST_WHITE}" > "${_PATH_LIST_BLACK}" + +prefixed_msg 'apt-mark auto from diff …' +apt-mark auto `cat "${_PATH_LIST_BLACK}"` > /dev/null +rm "${_PATH_LIST_UNSORTED}" "${_PATH_LIST_ALL_PACKAGES}" "${_PATH_LIST_WHITE}" "${_PATH_LIST_BLACK}" + +prefixed_msg 'install or mark as manually installed packages from our own selections …' +ensure_packages_of_tags ${_INSTALL_TAGS} + +prefixed_msg 'run autopurge to get rid of all unwanted packages …' +apt_digested '-q -q autopurge' + +prefixed_msg_exit -- 2.30.2