7

How does 'it' (ie. purge) know where the dependencies and configuration files are located?

How does purge find out that a particular piece of software created a certain file?

Is there some sort of configuration file that records the creation of all files by programs, so that purge can access the records and match up the files to the program during removal?

  • 2
    I'm not completely sure, but I do know that DEBs tend to just have files inside under paths that match paths on the computer. It's probable purge looks inside the DEB and deletes all matching files on the computer. If the DEB doesn't have the config files by default, purge won't find them. I have had times where using purge doesn't actually remove all configs – TheWanderer Dec 2 '15 at 13:00
  • 3
    AFAIK it doesn't remove files created by a particular piece of software, just the ones installed by the package (which are listed in /var/lib/dpkg/info/package.conffiles) – steeldriver Dec 2 '15 at 13:08
2

Yes, there are such files. In particular, *.list, *.postrm , and *.conffiles, which are all stored in /var/lib/dpkg/info directory.

The .postrm files are post-remove scripts, that run after a package is removed. Those scripts are responsibility of the package maintainers, and each script is tailored to the specific package. If you examine /var/lib/dpkg/info/usb-modeswitch-data.postrm for example , you will see something like this:

#!/bin/sh
set -e
# Automatically added by dh_installdeb
dpkg-maintscript-helper rm_conffile "/etc/usb_modeswitch.d/230d:0001" 20101222-3 -- "$@"
# End automatically added section

There's also *.list and *.conffiles files, which are basically lists. gnome-terminal.list, for example, will list all files and directories created when gnome-terminal was installed. The *.list files are very useful for determining what installed what. *.conffiles list all the config files for a package. For instance, while xterm.list gives all the files , `xterm.conffiles* gives only conffiles. In other words, the contents of conffile will also be present in list file.

$ cat /var/lib/dpkg/info/xterm.conffiles                                       
/etc/X11/app-defaults/XTerm
/etc/X11/app-defaults/KOI8RXTerm-color
/etc/X11/app-defaults/XTerm-color
/etc/X11/app-defaults/UXTerm-color
/etc/X11/app-defaults/UXTerm
/etc/X11/app-defaults/KOI8RXTerm

I don't quite know how *.conffiles work. My assumption is that the post-removal scripts take priority, and apt-get just uses those *.conffiles to double check that files listed there were removed.

As @A.B. properly reminded me, there are also *.prerm files, some of which do remove the .conf files, but not necessarily, for instance the one for xpdf app was removing the files in /etc/xpdf/includes directory

  • You forgot the prerm-files =) – A.B. Dec 3 '15 at 18:59
  • 1
    @A.B. thank you for the reminder, #included<update.h> :) – Sergiy Kolodyazhnyy Dec 3 '15 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.