Outsmarting dpkg’s conffile handling

dpkg has a very useful feature where if you delete a conffile (pretty
much everything under /etc and a few other files) it isn’t
replaced when you upgrade the package[0]. This behaviour was
confusing me for a while until I realised what was happening. I was
attempting to reinstall a package to get the default configuration
files back that had been accidentally deleted, but no matter what I
tried, the files didn’t exist after running dpkg. Once I
figured out that dpkg had this behaviour the solution was
simple; use the --force-confmiss command line argument.

root@quux:~# dpkg --force-confmiss -i /tmp/foo_2.0.0-build.14_all.deb
(Reading database ... 33418 files and directories currently installed.)
Preparing to replace foo 2.0.0-build.14 (using .../foo_2.0.0-build.14_all.deb) ...
Unpacking replacement foo ...
Setting up foo (2.0.0-build.14) ...

Configuration file `/etc/foo/foo.xml', does not exist on system.
Installing new config file as you request.
root@quux:~#
[0] If the file didn’t exist in
the previously installed version, it is installed, so you get new
configuration files.

5 thoughts on “Outsmarting dpkg’s conffile handling

  1. Or you could just make sure to purge the package before (re)installing it, that will make the package system forget about all configuration files. Removing a package is not enough for “complete reinstall”. aptitude purge foobar, apt-get remove –purge foobar or dpkg –purge foobar.

  2. dpkg-reconfigure foo wouldn’t do the trick ? It would have given you the default conffile without having to reinstall the whole package, wouldn’t it ?

  3. Hmm, your Arse feed is a bit broken, giving “http://www.davidpashley.com/blog/debian/confmiss.html” as the <link> for this entry, which is a blank page.

  4. Kevin, no system should behave like that, even if you know what you’re doing. you might change your mind. the system should ask if you want the missing config files (y/N).

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.