[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Wrestling with debconf



Hey list,

I'm having an issue with my myfoo-server maintainer scripts for my
package myfoo-server. In a nutshell, I am trying to get the user's
requested configuration to be handled elegantly.

I've read the debconf specification and debconf-devel(7). I see that my
issue is discussed:
   
   https://manpages.debian.org/jessie/debconf-doc/debconf-devel.7.en.html#HACKS

If the user installs the myfoo-server package they will be prompted by
debconf in myfoo-server.config to select whether to enable zeroconf,
upnp, etc. and various other settings for the server. Those selected
settings, whatever their values, should then be written out during the
subsequent run of myfoo-server.postinst to /etc/myfoo/server.conf.

If myfoo-server.config detects that the user already had an
/etc/myfoo/server.conf, such as when they are re-installing the
package, myfoo-server.conf should read those values in-place from disk
and then seed debconf via my SeedFromUserConfiguration POSIX shell
function before any prompts might be displayed (depends on priority, of
course).

That is what I had intended. I think this behaviour is reasonable.

So I start by installing the myfoo-server package locally, e.g. 

   $ sudo apt install ./myfoo-server(...).deb
   ...
   Preconfiguring packages ...
   ...

I then see debconf prompts, as expected, from within my myfoo-
server.config. I select true to enable upnp and zeroconf (false and
true by default in their templates respectively). 

For the sake of debugging, I checked the myfoo-server/zeroconf debconf
field as you see on myfoo-server.config:192 after it is read back from
debconf and it is indeed whatever value the user had set it to when
prompted (and same for all other settings).

Great. That much works as expected.

But after that session of myfoo-server.config is run, it appears to be
run _again_ after the package is unpacked, but _before_ myfoo-
server.postinst is run:

   ...
   Setting up myfoo-server (...)
   ...

The problem here is this re-running of the myfoo-server.config happens
before the myfoo-server.postinst. This is bad because the latter is
supposed to update the values in /etc/myfoo/server.conf to whatever the
user just entered via debconf prompts.

Because myfoo-server.config's second invocation sees the newly unpacked
/etc/myfoo/server.conf, it unintentionally seeds debconf with the
values contained therein.

The myfoo-server.postinst script is then run, writing out to
/etc/myfoo/server.conf the clobbered debconf values.

What am I doing wrong and what do you recommend? 

These are my myfoo-server.config and myfoo-server.postinst:

   https://pastebin.com/hyWyH5id
   
   https://pastebin.com/xW1andmW

-- 
Kip Warner -- Senior Software Engineer
OpenPGP signed/encrypted mail preferred
https://www.thevertigo.com

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: