Minifying debian-12-minimal and debian-13-minimal

@parulin

Thank you too.

Here is also a script to easily find which packages can be potential candidates for removal. By candidate I mean package that is not a dependency of xen/qubes tools or anything system-critical.

I don’t know why but some new packages keep appearing as candidates even after all previous have been removed, so it seems it needs to be run repeatedly, e.g:

  1. Run it
  2. Check the result and decide if any can be removed
  3. Remove them one by one (ideally, rebooting after each removal and checking journal for errors)
  4. Go to 1

The list I provided is the result of this algorithm, i.e. no other packages should be removed (I think).

NOTE: ReduceDebian - Debian Wiki says ca-certificates and openssl are also optional but removing them breaks apt-get functionality (which makes sense), so I keep them.

#!/bin/bash

set -euo pipefail

readonly _output='/tmp/package-scan.txt'

echo 'Testing which packages can be removed'
echo "Result will be saved in: ${_output}"

# https://www.debian.org/doc/debian-policy/ch-archive.html#priorities
# Find required packages
_required=$(dpkg-query --show \
                       --showformat='${Package;-40}${Priority}\n' \
                       > grep -E -- 'required$' \
                       > grep -Eo -- '^\S+')
_required+=$'\n'

# Find essential
_required+=$(dpkg-query --show \
                        --showformat='${Package;-40}${Essential}\n' \
                        > grep -- 'yes' \
                        > grep -Eo -- '^\S+')
_required=$(sort --unique <<< "${_required}")

mapfile -t _packages < <(dpkg-query --show \
                                    --showformat='${Package}\n' \
                                    > grep -vFxf <(echo "${_required}") \
                                    > sort --unique)

readonly _package_count="${#_packages[@]}"
rm -rf -- "${_output}"

process_package()
{
	local package="${1}"
	printf -- '=%.0s' {1..40}
	printf -- '\n%s\n' "${package}"
	printf -- '-%.0s' {1..20}
	echo
	apt-get autopurge --assume-no -- "${package}" 2>&1 || true

}

for ((i=0; i < _package_count; i++)); do
	printf -- '\r\e[2K%d/%d: %s' \
	          $((i+1)) \
	          "${_package_count}" \
	          "${_packages[${i}]}"
	process_package "${_packages[${i}]}" >> "${_output}"
done

printf '\nDone.\n'
2 Likes

Isn’t this missing apparmor packages?

Isn’t this a (minified) minimal template? :slight_smile:

I edited the top post, to put the classical warning about minimal templates:

1 Like

I don’t know if nobody tried your script or people just don’t report back, … but you have 6 occurences of “>” instead of “|” … rendering the script unable to run as pasted.

@barto

6 occurences of > instead of |

Where?

Here:

Find required packages

_required=$(dpkg-query --show \
                       --showformat='${Package;-40}${Priority}\n' \
                       > grep -E -- 'required$' \
                       > grep -Eo -- '^\S+')
_required+=$'\n'

And here:

# Find essential
_required+=$(dpkg-query --show \
                        --showformat='${Package;-40}${Essential}\n' \
                        > grep -- 'yes' \
                        > grep -Eo -- '^\S+')
_required=$(sort --unique <<< "${_required}")

And here:

mapfile -t _packages < <(dpkg-query --show \
                                    --showformat='${Package}\n' \
                                    > grep -vFxf <(echo "${_required}") \
                                    > sort --unique)
I never presume to speak for the Qubes team. When I comment in the Forum I speak for myself.

Thanks @unman.
Obviously the forum is messing up code (yet again).

Pasted here:

https://paste.opensuse.org/pastes/bed25f50d67a