Skip to content

Instantly share code, notes, and snippets.

@sulincix
Last active February 26, 2024 11:20
Show Gist options
  • Save sulincix/0b6a044abc05bc3123a9736169cd0838 to your computer and use it in GitHub Desktop.
Save sulincix/0b6a044abc05bc3123a9736169cd0838 to your computer and use it in GitHub Desktop.
nonfree-cleaner (debian)
#!/usr/bin/bash
dpkg-query -W -f='${Section}\t${Package}\n' | grep ^non-free | sed "s/.*\t//g" | xargs apt purge -y
pkg=""
set -e
export LANG=C
apt-cache policy $(apt list --installed | sed "s/\/.*//g") | while read line ; do
if echo "$line" | grep "^[a-zA-Z0-9-]*:$" >/dev/null ; then
pkg=$(echo $line | sed "s/://g")
elif echo $line | grep "non-free" >/dev/null ; then
echo $pkg
fi
done | uniq | xargs apt purge -y
sed -i "s/non-free-firmware//g;s/non-free//g" /etc/apt/sources.list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment