There are many ways to show packages installed manually using apt, such as:
apt-mark showmanual
But sometimes that output is too much. For example if the user manually installed package foo:
apt-get install foo
...and foo depended on bar and baz, then apt-mark showmanual would output:
bar
baz
foo
How can we list only the top level manually installed packages (i.e. foo) without their dependencies (i.e. not baz, nor bar)?
The following code seems to work, but GNU parallel calling apt-rdepends a few hundred times is too slow, (three hours with a 4 core CPU):
apt-mark showmanual |
tee /tmp/foo |
parallel "apt-rdepends -f Depends,PreDepends,Suggests,Recommends {} |
tail +2" 2> /dev/null |
tr -s ' ' '\n' |
grep -v '[():]' |
sort -Vu |
grep -wv -f - /tmp/foo