Debian DEB package replace config files

debian

I created a custom debian package which needs to replace certain configuration files like /etc/ssh/sshd.conf. If these files exist it does not replace them.
What is the best way from a deb package to force overwrite these files (if it's possible without a question).

Thanks

Best Answer

First: Don't do that. Configuration files are expected to belong to only one package. Better use some configuration management.

If you really want to do it anyway, you likely need to use dpkg-divert in the maintainer scripts (preinst, postrm, etc.) to rename the original configuration file. See the maintainer scripts of grml's grml-etc-core package for an example:

Once again: Despite dpkg-divert is used above (for a live CD) to "overwrite" conffiles, it's not expected to work that way either, so expect that it may fail under some obscure conditions.

Related Topic