1

I want to install xubuntu-desktop (a very large metapackage) but leaving out some of the packages on it (around 10). The current way I do this is in two steps: 1) install metapackage, and 2) purge unwanted packages. I wonder whether there is a more efficient and clean method to do this.

I thought apt-get would accept an instruction like install this except these but very surprisingly it seem not.

A potential solution would be to run the command sudo apt-get install xubuntu-desktop, then select No, and copy all the packages listed in the terminal, manually deleting the undesired ones. However this could be even more time consuming than the two-step procedure mentioned earlier, also risking to end up with bad dependencies.

Any ideas on how to make this in one simple command-line instruction?

1 Answers1

1

You could script the task. I'm pretty sure I posted this elsewhere, but can't find it now. First, create a file with the packages you don't want. For example:

$ cat dont-want.txt
memtest86+
wireless-tools
firefox
evince

Then parse the output of apt-cache depends:

apt-cache depends xubuntu-desktop | awk '$1 == "Depends:" {print $2}' | grep -vFf dont-want.txt

This should include the packages on which the metapackage directly depends, without the packages you excluded. Then you can use xargs to install:

apt-cache depends xubuntu-desktop | 
  awk '$1 == "Depends:" {print $2}' | 
  grep -vFf dont-want.txt |
  sudo xargs apt-get install

If the unwanted package is not a direct dependency, you would need to use apt-rdepends instead of apt-cache depends.

You can also use Apt Pinning to enforce the ban: How to forbid a specific package to be installed?

muru
  • 197,895
  • 55
  • 485
  • 740