Tue, 05 Feb 2008

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.

[, , , ] | # Read Comments (5) |

Related Products

Comments

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.
Posted by fatal at Tue Feb 5 11:19:28 2008
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 ?
Posted by Tweek at Tue Feb 5 11:47:45 2008
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.
Posted by AJ at Tue Feb 5 12:08:43 2008
IIRC if you, as the admin, delete a conffile file, the Debian system assumes you know what your doing. So it assumes you don't want it reinstalled.
Posted by Kevin Mark at Tue Feb 5 21:27:44 2008
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).
Posted by MVF at Wed Feb 6 17:58:16 2008

Name:


E-mail:


URL:


Comment:


Please enter "fudge" to prove you are a human