From: Christian Heller Date: Mon, 12 Aug 2024 16:31:58 +0000 (+0200) Subject: Add some missing stuff. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/%7B%7Bprefix%7D%7D/edit?a=commitdiff_plain;h=ca94a7ce5793013b2b132ceec7d9aaef1b48950b;p=config Add some missing stuff. --- diff --git a/testing/setup_scripts/misc.sh b/testing/setup_scripts/misc.sh index 64a8916..f6d2367 100644 --- a/testing/setup_scripts/misc.sh +++ b/testing/setup_scripts/misc.sh @@ -14,7 +14,7 @@ expect_n_args() { explainer="$2" shift 2 if [ "$#" -lt "${min_args}" ]; then - echo "Need at least ${1} arguments … ${explainer}" + echo "Need at least ${min_args} arguments … ${explainer}" false fi } diff --git a/testing/setup_scripts/purge_nonrequireds.sh b/testing/setup_scripts/purge_nonrequireds.sh new file mode 100755 index 0000000..48065fc --- /dev/null +++ b/testing/setup_scripts/purge_nonrequireds.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# This script removes all Debian packages that are not of Priority +# "required" or not depended on by packages of priority "required" +# or not listed in the argument-selected files of apt-mark/. +set -e +. ./misc.sh + +# FIXME packages listed twice in the aptmark_dir get blacklisted? + +dpkg-query -Wf '${Package} ${Priority}\n' | grep ' required' | sed 's/ required//' > /tmp/list_white_unsorted +for target in "$@"; do + path="${aptmark_dir}/${target}" + cat "${path}" | while read line; do + if [ ! $(echo "${line}" | cut -c1) = "#" ]; then + echo "${line}" >> /tmp/list_white_unsorted + fi + done +done +sort /tmp/list_white_unsorted > /tmp/list_white +dpkg-query -Wf '${Package}\n' > /tmp/list_all_packages +sort /tmp/list_all_packages > /tmp/foo +mv /tmp/foo /tmp/list_all_packages +comm -3 /tmp/list_all_packages /tmp/list_white > /tmp/list_black +apt-mark auto `cat /tmp/list_black` +DEBIAN_FRONTEND=noninteractive apt-get -y --purge autoremove +rm /tmp/list_all_packages /tmp/list_white_unsorted /tmp/list_white /tmp/list_black + +# Somehow, auto-mounts get undone by all of this, so re-mount /etc/fstab. +# TODO: Find out why. +mount -a