DebConfigFileOverloading

8th August 2017 at 9:48am
Debian DebianPackaging

Overloaded Config Files in Deb Packages

You may want your package to provide a configuration file for another package. Ordinarily this wouldn't be possible because that configuration file belongs to that other package.

This can be solved by creating a package that uses dpkg-divert in its maintainer scripts to move the old config file aside:

In your debian/preinst script, divert the file away using:

dpkg-divert --add --package $YOUR_PACKAGE_NAME --rename \
    --divert /path/to/file.orig \
    /path/to/file

In your debian/postrm script, revert the file back using:

dpkg-divert --remove --package $YOUR_PACKAGE_NAME --rename \
    /path/to/file

See: http://www.debian.org/doc/debian-policy/ap-pkg-diversions.html.

One solution that helps abstract dpkg-divert is the config-package-dev package created and maintained by MIT's Debathena project. They have a thorough tutorial.