[Aptitude-devel] why does not aptitude purge rather than just remove packages.

Daniel Hartwig mandyke at gmail.com
Wed Feb 22 09:06:04 UTC 2012


2012/2/22 shirish शिरीष <shirishag75 at gmail.com>:
> Hi all,
> This is more of a user question but don't know where else to ask hence
> asking here.
> This is when we do $sudo aptitude safe- upgrade (obviously after
> updating the index)
> Usually what happens is you get a bunch of updates and sometimes it
> tells of a library or a package which needs to removed (as its
> outdated).  Why isn't it purged (rather than just removed from the
> system)

Purging packages is a dangerous operation.  This is why it is not done
by default.

For everyday activity there is no practical difference between a
purged package and one which is only removed -- a few files and such
remain on the system but you will not notice.

> The question came to me as I was trawling through the wiki and came
> across http://dsa.debian.org/howto/upgrade-to-squeeze/ .
> I saw this interesting bit of code/commands :-
> dpkg --get-selections | awk '$2=="deinstall" {print $1}' &&
> echo "really purge these [y/N]?" && read ans && [ "$ans" = "y" ] &&
> dpkg --purge `dpkg --get-selections | awk '$2=="deinstall" {print
> $1}'` && echo "These are not at install:" && dpkg --get-selections |
> awk '$2!="install" {print $1}'
> Now I just ran the first bit of commands and it produced a nice listing :-
> dpkg --get-selections | awk '$2=="deinstall" {print $1}'

You can use aptitude to get a similar list:

$ aptitude search ?config-files

> Now I have few questions about this :-
> a. Is this warning still valid ? 'THIS OPTION CAN CAUSE DATA LOSS! DO


When a package is *removed* it leaves any configuration and log files
still on the system.  These files may contain data that is useful to
the user and could be used again if the package was reinstalled --
such as customizations to a configuration file.

If a package is *purged*, those conf. and log files are also removed,
which is the data loss referred to in the warning.

> b. If I do want to add this option where and how do I add it ? From
> looking at the manpage and others, it seems I have to create a file in
> /etc/apt/ and call it apt.conf .
> Do I just say in that file Aptitude::Delete-Unused=True with some
> comment on the top or what ?

To purge items, both Aptitude::Delete-Unused and Aptitude::Purge-Unused
need to be true.  Delete-Unused is true by default, so you only need
to set Purge-Unused.

You can specify this option on the command line or in the apt.conf file.

Note that the format differs between them.  See the apt.conf man page
for the file format.

-- apt.conf:
Aptitude::Purge-Unused "true";

-- cmdline:
$ sudo aptitude -oAptitude::Purge-Unused=true safe-upgrade

See apt.conf man page for details on the file format.

Keep in mind that this is one of the most dangerous options you can
give to aptitude, which is saying a lot.

> I did have a look at /usr/share/aptitude/aptitude-defaults and
> ~/.aptitude/config is empty.

You do not want to change *any* files in /usr/share.

~/.aptitude/config is not the best place to set configuration, as
the curses interface has a habit of mangling it when you change
preferences (a long-running saga :-/)

So the best place to set these options is in /etc/apt/apt.conf


More information about the Aptitude-devel mailing list