#895897 how to purge removed packages without breaking your fingers

Package:
apt
Source:
apt
Description:
commandline package manager
Submitter:
Harald Dunkel
Date:
2024-04-30 11:42:03 UTC
Severity:
wishlist
#895897#5
Date:
2018-04-17 11:26:13 UTC
From:
To:
There are some weird constructs floating around about how to
purge removed packages, see

https://askubuntu.com/questions/687295/how-to-purge-previously-only-removed-packages

for example. And

https://www.debian.org/doc/manuals/debian-reference/ch02.en.html

mentions only "aptitude purge '~c'".

This could be improved.

Please reassign, if necessary.


Thanx in advance. Please keep on your good work
Harri

#895897#10
Date:
2024-04-29 23:16:14 UTC
From:
To:
Note that

apt purge ~c

does something, but apt(8) does not mention the support for the ~c
parameter.

On my system, it seems to be attempting to remove all packages that have
the "c" second character status in dpkg -l.  Unfortunately, this
includes packages such as "locales" which I think are normally "ic", so
this command does not seem appropriate for removing "rc" packages as
suggested elsewhere.

The following packages will be REMOVED:
   bsdmainutils* grub-legacy-ec2* isc-dhcp-client*
language-pack-en-base* linux-image-6.5.0-17-generic*
linux-image-6.5.0-25-generic* linux-modules-6.5.0-17-generic*
linux-modules-6.5.0-25-generic* linux-modules-extra-6.5.0-17-generic*
linux-modules-extra-6.5.0-25-generic* locales*
   openvswitch-switch* reportbug* resolvconf* ufw* upower*

#895897#15
Date:
2024-04-30 11:38:39 UTC
From:
To:
It is relatively new and part of the aptitude-pattern backport.
See apt-patterns(7).

As "dpkg -l" documents itself at the top, the first letter is a desired
state, while the second is current status (and the third if present
indicates an error state that is worse than the "normal" error states).

So, 'rc' expresses the desire for the package to be removed and the
current status is "removed, but not purged (conf-files remaining)".

You could set it to 'pc' (to desire a purge) or like you did to 'ic',
which would mean you desire it to be installed (again).


Note that this "desire" is something used by dpkg/dselect and to some
extend aptitude, but most (other) libapt-based tools including apt(-get)
do not really work with it (except in fringe use cases like apt-get
dselect-upgade) and/or internally while talking to dpkg. They prefer to
receive the users desire directly on the command line if you want to
interpret it this way.


So, yes and no, ~c does indeed match 'ic' as well as 'rc', but that is
because it looks at the current state – which is the same for them all,
they only have conf-files remaining.

Specifically, as you seem to think otherwise: "locales" in state 'ic' is
not installed and behaves exactly like in state 'rc' – as in, they don't
have a behaviour at all. If you want it to be installed, just install it
and it will have the state 'ii'. Or purge it and it will be 'un'.


Best regards

David Kalnischkies