Jeff Epler wrote:
> Russ Allbery wrote:
> > I use apt dist-upgrade normally and then, periodically, run:
> > dpkg --get-selections | grep deinstall | awk '{ print $1 }' \
> > | xargs dpkg --purge
> >
> > This is obviously somewhat unsafe. It would be neat to have a tool that
> > would do this properly without involving dodgy greps that might match
> > package names and other obvious issues.
>
> Slightly better might be
> dpkg --get-selections | awk '{if ($2 == "deinstall") { print $1 } }'
> though I see there's a way to say this in aptitude to directly say what
> you want.
As long as we are tuning... I prefer grep-status for this. This
returns a list of package names of packages that have been removed but
still have config files behind. Those in the dpkg "rc" state.
grep-status -sPackage -n -FStatus "deinstall ok config-files"
-s print only that field, otherwise print full paragraph
-n no print field name, just value
-F field to search
If that list is reasonable then this. It just feels more precise.
dpkg --purge $(grep-status -sPackage -n -FStatus "deinstall ok config-files")
Don't forget about the "deborphan" and "orphaner" packages either.
Bob
P.S. AWK is design to operate by fields. I am sure I am not the only
one who saw the "if $2" above and thought it should be like this:
awk '$2=="deinstall"{print$1}'
Attachment:
signature.asc
Description: Digital signature