Aptitude – remove all packages in X11 category, except for dependencies of a specific package

aptitudepackage-management

I would like to remove most of the packages in the X11 category from my system. However some of those packages are depended on by the 'beaglebone' package. How could I ask aptitude to remove everything in the X11 category, with the exception of the packages depended on by 'beaglebone'?

You can see below that it recommends 'beaglebone' as one of the packages that should be uninstalled at the risk of being broken.

    Aptitude recommended removal. Beaglebone is included.

How can I make sure that this package and its dependencies are retained after the removal?

Best Answer

The short answer is:

aptitude remove '~sX11 ! ~Rbeaglebone'

However in this kind of situation (there are a lot of things that depend on X11!), I recommend using the interactive resolver. To do this add the --schedule-only option to the above and run aptitude again without arguments .You may also have to add -o Aptitude::Auto-Fix-Broken=false to one or both commands (if it is not already in your settings), but I don't think you need it as as far as I can see the automatic resolution only happens when you press g in the interface.

Once you have the ncurses interface running, press e to examine the first solution and look at the additional removals. If you see any you don't want, use the arrow keys to select it and press r to reject the action. Press . to load the next solution, it should now provide a solution that doesn't include any of your rejections. Repeat as necessary and press ! to accept the solution and continue as normal.

Related Question