On Tue, 2022-01-04 at 12:34 +0100, Niels Thykier wrote: > (Having seen your enquiry on IRC, I presume this issue was still > relevant)
Hey Niels. Yes, indeed. Still trying to solve this problem.
> I read the "newly unpacked /etc/myfoo/server.conf" as you shipping
> "/etc/myfoo/server.conf" directly inside the package in that path. If
> that is correctly understood, then I think that is the source of your
> woes.
Yes, that is what I was trying to do.
> 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.
Ok, I see that now buried in the last paragraph in DPM s 5.1:
"Note that a package should not modify a dpkg-handled conffile in its
maintainer scripts. Doing this will lead to dpkg giving the user
confusing and possibly dangerous options for conffile update when the
package is upgraded."
> Perhaps have a look at openssh-server (postinst + config + file
> listing) as an example, which does something similar. It does use
> "ucf" for handling the merge on updates, which is a different approach
> than yours for creating/updating the configuration file.
> I can recommend that from a consistency PoV, so your package would
> behave the same as other Debian packages if the user were to change the
> file directly. However, I do not think it would be strictly
> necessary to migrate to ucf in order to fix your immediate issue.
I've taken a look at openssh-server.{config,postinst} and the contents
of the package in what's shipped to /etc (nothing). The way they are
doing it is a bit complicated and I am surprised there isn't an elegant
solution yet with debconf. Although it could be I just don't understand
what they were doing, in which case it's probably even more
complicated.
I also still can't figure out why the .config is run twice during
installation.
Anyways, what I am trying to do now is ship server.conf as
server.conf.template in /usr/share/myserver/ and then have .postinst
attempt the following:
new_config="$(mktemp)"
cp -a /usr/share/myserver/server.conf.template "$new_config"
mkdir -p /etc/myserver/
ucf --three-way --debconf-ok \
"$new_config" /etc/myserver/server.conf
ucfr myserver-server /etc/myserver/server.conf
But it's not really clear to be what needs to be done within .config.
Should the script check for /etc/myserver/server.conf early, and if
it's not available, exit 0?
--
Kip Warner -- Senior Software Engineer
OpenPGP signed/encrypted mail preferred
https://www.thevertigo.com
signature.asc
Description: This is a digitally signed message part

