Bug#476817: aptitude: misses some automatic packages when deciding what to remove
On Sat, Apr 19, 2008 at 01:20:23PM +0200, Yann Dirson <firstname.lastname@example.org> was heard to say:
> My unstable chroot still has an obsolete libdb2 installed, although it
> is marked automatic and has no revdeps. It even does not break
> anything when I select it explicitely for purge.
The problem is that libdb2 is a required package, and apt refuses to
consider required packages to be garbage. From depcache.cc:1406,
// skip required packages
if (!p.CurrentVer().end() &&
(p.CurrentVer()->Priority == pkgCache::State::Required))
I'm undecided as to whether this is the "right thing to do". On the
one hand, while aptitude wouldn't remove unused Essential packages, it
never had logic to screen out "required" packages. AFAIK, packages that
use a "required" but not Essential package have to declare the dependency.
The really important-looking packages on my system that are Priority: required
and that don't have incoming deps are also Essential.
On the other hand, Policy makes it clear that required packages
shouldn't be removed:
Packages which are necessary for the proper
functioning of the system (usually, this means that
dpkg functionality depends on these packages).
Removing a required package may cause your system to
become totally broken and you may not even be able to
use dpkg to put things back, so only do so if you
know what you are doing. Systems with only the
required packages are probably unusable, but they do
have enough functionality to allow the sysadmin to
boot and install more software.
However, historically I don't think that priorities have been
interpreted that strictly; if a package really and truly should never be
removed even if nothing depends on it, it gets the Essential: yes tag.
(of course, obsolete essential packages will never be autoremoved, but
that's even less common than obsolete required packages)
I also have the sense from reading the list of packages in "required"
that this is a broader category than you'd think from the above
description. Is gcc-4.2-base really required even if nothing depends on
daniel@alpaca:~$ dpkg -L gcc-4.2-base
What about libattr1, which is used by no critical system binary as far
as I can see? Same goes for libcap2.
I don't know if there was a reason behind this change to apt's behavior.
The commit log only says
- never mark required packages as garbage
which sounds like it just "seemed like a good idea".
I don't think this rule is necessary, if nothing else because aptitude
ran without it for six years without a single bug report tied to
removing a required package. Furthermore, it causes user confusion (as
you can see in this bug report) due to the fact that many
not-actually-required packages are binned into the "required" priority.
Removing the stanza that skips required packages causes libdb2 to be
removed on the state snapshot Yann sent me, and the only package it
removes on my system is libdevmapper0.2.