From f036e0f18c971a1f266393401693f3f35b7a0041 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Thu, 1 May 2025 06:22:41 +0200 Subject: [PATCH] Fix. --- bookworm/aptmark/server_basic | 7 +++++ bookworm/scripts/lib/minimize_installation | 35 ++++++++++++++++++++++ trixie/aptmark/all_old | 1 + trixie/aptmark/server_basic_old | 1 + 4 files changed, 44 insertions(+) create mode 100644 bookworm/aptmark/server_basic create mode 100644 bookworm/scripts/lib/minimize_installation create mode 120000 trixie/aptmark/all_old create mode 120000 trixie/aptmark/server_basic_old diff --git a/bookworm/aptmark/server_basic b/bookworm/aptmark/server_basic new file mode 100644 index 0000000..ade9652 --- /dev/null +++ b/bookworm/aptmark/server_basic @@ -0,0 +1,7 @@ +# so we can log in at all … +openssh-server +# necessary on _some_ vservers +net-tools +quota +# + diff --git a/bookworm/scripts/lib/minimize_installation b/bookworm/scripts/lib/minimize_installation new file mode 100644 index 0000000..26006ca --- /dev/null +++ b/bookworm/scripts/lib/minimize_installation @@ -0,0 +1,35 @@ +. lib/apt_get_edited +. lib/ensure_packages_of_tags + +minimize_installation() { + _INSTALL_TAGS="$@" + + echo '### minimize_installation: narrow system to what's required explicitly by us and Debian' + _PATH_LIST_PREFIX=/tmp/list_ + _TOK_REQ=' required' + + echo "# Collect packages deemed '${_TOK_REQ}' by Debian: " + _PATH_LIST_UNSORTED="${_PATH_LIST_PREFIX}unsorted" + dpkg-query -Wf '${Package} ${Priority}\n' | grep "${_TOK_REQ}" | cut -d' ' -f1 > "${_PATH_LIST_UNSORTED}" + _PATH_LIST_WHITE="${_PATH_LIST_PREFIX}white" + sort "${_PATH_LIST_UNSORTED}" > "${_PATH_LIST_WHITE}" + echo $(cat "${_PATH_LIST_WHITE}) + + echo -n '# Collect installed packages outside this selection: ' + dpkg-query -Wf '${Package}\n' > "${_PATH_LIST_UNSORTED}" + _PATH_LIST_ALL_PACKAGES="${_PATH_LIST_PREFIX}all_packages" + sort "${_PATH_LIST_UNSORTED}" > "${_PATH_LIST_ALL_PACKAGES}" + _PATH_LIST_BLACK="${_PATH_LIST_PREFIX}black" + comm -3 "${_PATH_LIST_ALL_PACKAGES}" "${_PATH_LIST_WHITE}" > "${_PATH_LIST_BLACK}" + echo $(cat "${_PATH_LIST_BLACK}) + + echo '# apt-mark auto packages 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}" + + echo '# install or mark as manually installed packages from our own selections …' + ensure_packages_of_tags ${_INSTALL_TAGS} + + echo '# run autopurge to get rid of all unwanted packages …' + apt_get_edited '-q -q autopurge' +} diff --git a/trixie/aptmark/all_old b/trixie/aptmark/all_old new file mode 120000 index 0000000..1913f5e --- /dev/null +++ b/trixie/aptmark/all_old @@ -0,0 +1 @@ +../../bookworm/aptmark/all \ No newline at end of file diff --git a/trixie/aptmark/server_basic_old b/trixie/aptmark/server_basic_old new file mode 120000 index 0000000..13ab3c2 --- /dev/null +++ b/trixie/aptmark/server_basic_old @@ -0,0 +1 @@ +../../bookworm/aptmark/server_basic \ No newline at end of file -- 2.30.2