15
4
I have a scenario where I'd like to remove a set of packages that may or may not be installed, and I'd like apt-get to remove those that are and silently ignore those that aren't. Something like:
apt-get remove foo bar baz
which, if foo and bar were installed but baz was not, would remove foo and bar without complaining about baz. Is there a way to do this?
Things I've tried that haven't worked, with cups-dbg as my scapegoat actually-installed package to be removed:
jcp@a-boyd:~$ sudo apt-get remove -y cups-dbg bogus-package
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package bogus-package
jcp@a-boyd:~$ sudo apt-get remove --ignore-missing cups-dbg bogus-package
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package bogus-package
jcp@a-boyd:~$ sudo apt-get remove --fix-broken cups-dbg bogus-package
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package bogus-package
I know I could do this with a shell script and some dpkg --list
magic, but I'd like to avoid any complexity that's not absolutely necessary.
This answer worked for me in the end. Dumb fix for a dumb problem.
Note that there is actually a defect on Launchpad about this so feel free to contribute.