On Tue, 2022-01-04 at 12:34 +0100, Niels Thykier wrote: > As I recall, when you manage a file via debconf, you should *not* ship > it directly in the package. You can ship a template in a different > location (e.g., /usr/share/myfoo/server.conf.template) and then use > that combined with the debconf answers to generate the initial > /etc/myfoo/server.conf.
Hey Niels, Thanks a lot for your help. Maintainer scripts are often difficult to debug because the execution environment is fairly sophisticated with many moving pieces. I gave it another go this evening and it appears to work. But before I get into how I (hopefully) solved my problem, I should mention that the DPM and the debconf manual need to be reconciled on the issue of using debconf to try and manage config files that ship with the package. In DPM § 5.1, it says don't do this in the last paragraph: https://www.debian.org/doc/debian-policy/ap-pkg-conffiles.html#automatic-handling-of-configuration-files-by-dpkg In the debconf manual, it implies that it can be properly done (even if most of the ways people try are not): https://manpages.debian.org/jessie/debconf-doc/debconf-devel.7.en.html#Config_file_handling Anyways, what I did for myfoo-server.config was have it seed debconf from the /usr/share/myfoo/server.conf.template if /etc/myfoo/server.conf isn't available. The first time the script is run neither file will be available during an installation because nothing has been unpacked yet, so it exits quietly. During it's second run just before postinst, if the template exists and the user's configuration does not, it will seed debconf from the template: https://pastebin.com/hyWyH5id In my postinst I studied more carefully again the openssh- server.postinst logic and it seems to make more sense now. Although, admittedly, it is still a bit of a pain that this pattern doesn't have an automated solution yet. This is what I came up with: https://pastebin.com/xW1andmW In my postrm, if the user requested a purge, I call ucf(1) with --purge on the /etc/myfoo/server.conf before rm(1)'ing it: https://pastebin.com/3SjBAJRL Does this look sane now? -- Kip Warner -- Senior Software Engineer OpenPGP signed/encrypted mail preferred https://www.thevertigo.com
signature.asc
Description: This is a digitally signed message part