miniblog.

← Back to all posts
2
That doesn't have the nice declarative properties though. It doesn't guarantee the version installed (running it next week could give a different version), and removing an item from the list doesn't uninstall it.

2 Comments

Version guarantees is pointless for most people, unless you're a dev/tester, in which case you'd be using a dedicated container/sandboxed environment anyways. And how many people remove packages frequently that it's a big requirement? And if it is, it's simple enough to amend the script to do so:
manual_packages=$(apt list --manual-installed=true 2>/dev/null | grep -v "Listing..." | awk -F'/' '{print $1}') for pkg in $manual_packages; do if ! printf '%s\n' "${packages[@]}" | grep -q "^${pkg}$"; then echo "Removing package: $pkg" sudo apt remove -y "$pkg" fi done