8

We use Ubuntu at work and I will need to make the same configuration changes to many systems so I am packaging these. One of the configuration changes I need to make is setting lightdm to autologin. For me to package this change it seems I will need to clobber the existing /etc/lightdm/lightdm.conf and replace it with the my customized lightdm.conf. This seems like a bad idea.

How can I do this in a way that is won't cause breakage and is inline with how the rest of the community is working?

9

This is often done by creating a package that uses dpkg-divert in its maintainer scripts to move the old config file aside:

  • In your preinst, divert the file away.

    dpkg-divert --add --package $your_package_name --rename \
        --divert /path/to/file.disabled \
        /path/to/file
    
  • In your postrm, divert the file back.

    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.

| improve this answer | |
  • From the examples on the linked page it looks like the --divert option should be provided in both the preinst and postrm files. – nmgeek Feb 22 '18 at 18:03
  • There seems to be newer documentation in wiki.debian.org/ConfigPackages, which recommends installing the file to /etc/site/ and using symlinks rather than installing directly into /etc/. It also recommends using postinst rather than preinst and prerm rather than postrm. – Ulf Adams Apr 3 '19 at 20:51

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.