I don't know of a one-stop command line solution, although all the tools exist (apt-cache depends --installed
, apt-cache rdepends --installed --recurse
, apt-mark showmanual
, dpigs
, etc.). It would be possible to hack together a command line script that could attempt to find large packages with few manually installed reverse dependencies. Here's the proof of concept I used as a starting point:
dpigs | awk 'NR == 1 {print $2}' | xargs apt-cache rdepends --installed --important --recurse | awk '!/:/ {print $1}' | sort -u
On the other hand, if you want to do complex analysis of the graph in multiple directions (e.g., what set of manually installed packages has the largest on-disk overlapping set of recursive dependencies), it can quickly get out of hand. At that point, you'll probably need to look at something more customizable (awk
or python
?).
Full Disclosure: I have contributed to the project below. If that kind of thing matters to you, please take it into account. If I were aware of a similar project that were already in the Debian repositories, I would probably post that instead.
While I prefer to do everything from the command line, you might find pacgraph (also on github) a useful alternative. It was originally written by Kyle Keen for Arch Linux, but it's now compatible with deb- and rpm- based systems as well. I used to have some sample output from an Ubuntu system, but I can't find it, so here's an example from his web site:
.
It's been a while since I've used it, but I believe there are also flags to highlight a particular package, with different colors for its recursive dependencies and reverse dependencies.
Removing a program just because you don't use it shows a misguided sense of priorities. Disk space is cheap. Gedit takes less than 2MB of disk space. Even at SSD RAID-1 prices, that costs less than ½¢. At the minimum wage in my country, it takes less than 2s to earn that much. It'll take you far more than 2 seconds to do this. The gains from removing the package are negligible — only the network and disk bandwidth when the package is installed.
That being said, here's how you can do it.
The cinnamon-desktop-environment
package depends on the applications that are officially part of the Cinnamon desktop environment. Gedit is one of them.
If you want to remove Gedit but keep the rest of Cinnamon, mark the dependencies of cinnamon-desktop-environment
except gedit
as manually installed, then remove cinnamon-desktop-environment
. You take the responsibility of adding any component that might be added to Cinnamon in the future. You can use aptitude search to list the packages that Cinnamon depends on.
aptitude unmarkauto $(aptitude -F %p search '~i ~Rcinnamon-desktop-environment !^gedit$')
apt-get remove gedit
Alternatively, you could make a fake gedit
package that exists solely to resolve the dependency but doesn't contain the gedit binary. You can use equivs to make such fake packages. Note that some Cinnamon configuration may still believe that Gedit is present and attempt to call the nonexistent binary.
Best Answer
The best solution would be to build your package with the correct dependencies. As a quick hack you can mark the package as manually installed, this will prevent
autoremove
from removing it.