Weblog entry #4 for fsateler
dpkg --list | grep '^rc\b' | awk '{ print $2 }'\
| xargs sudo dpkg -P
The explanation: dpkg --list lists all the installed packages. Then we pipe it through grep to select only the lines that start with 'rc' (I guess for Remaining Configuration or somthing like that). Then awk will print the second word of each line (the package name), and finally xargs receives all those packages and passes them as the comand line to dpkg.
Comments on this Entry
[ Send Message | View emeitner's Scratchpad | View Weblogs ]
I think the config line you are looking for is:
Apt::Get::Purge;
See the apt-get man page where it discusses the --purge option.
[ Parent | Reply to this comment ]
Debian values user data.
More specifically it is useful to uninstall and reinstall without losing configuration information.
Note some applications may lose serious user data on a purge, check the options for Postgres installs for one
Now if you'd asked why it doesn't clean up /etc/init.d and friends when removing a package I'd have said you might have a point, although without the files the start-up scripts don't do much, but it does seem untidy.
[ Parent | Reply to this comment ]
--------
Felipe Sateler
[ Parent | Reply to this comment ]
I very rarely reinstall software because it is misconfigured, although later this week I have to figure out where CPAN perl lives, and downgrade one of our boxes from "CPAN" to "sarge" versions of key Perl code - hohum. Blimin mod_perl 1.999.21 to 1.999.22 upgrade.... Steve was right about packaging perl, but making packages of it all that is needed will take a long time, even with the tools available.
As discussed, you can make "apt" always purge.
Just don't expect smooth upgrades of operational systems. If a simple upgrade works, all is fine, if it fails and you need to then purge, and reinstall, all is fine, if you start by purging the customisation and then reinstall, and it doesn't work.... back to backups you go.
Whoever put "diff" for config files in the dpkg tools earns my undying thanks.
[ Parent | Reply to this comment ]
# aptitude purge ~c
[ Parent | Reply to this comment ]
deborphan --find-config | xargs dpkg --purge
[ Parent | Reply to this comment ]
dpkg --purge `dpkg --get-selections | grep deinstall`
or
apt-get remove --purge package
or
in case of postfix exim change
apt-get install --purge postfix ( removes + purges exim and installs postfix )
or
dpkg --purge package remove the configuration files.
Greetz,
Louis
[ Parent | Reply to this comment ]