Re: to conffile or not to conffile
Julian Gilbey <J.D.Gilbey@qmw.ac.uk> writes:
> On Tue, Oct 16, 2001 at 10:46:52PM -0600, Matt Armstrong wrote:
>
> Who needs to edit it, the sysadmin or the maintainer scripts?
>
>> - I really do want to make it a conffile, so the user is notified of
>> future options.
>
> There are other ways to do this -- see below.
>
>> - I really do want to ask the user what serial port to use when the
>> thing is installed.
>
> Use debconf to get this info.
>
> Appropriate solution: The first time this package is installed, use
> debconf to get the info, then write a config file to /etc. Maybe add
> a couple of comment lines:
>
> # Please do not modify the next line
> # config_version=0.3
>
> On upgrades, check the "config_version" line, and if you are now
> introducing a later version, either use debconf to get the desired
> newer config settings or just append the default values to the
> existing config file with appropriate comments, taking care to update
> the config_version line and not to affect any of the sysadmin's
> settings.
>
> Remember that if every package told the sysadmin of all the new bells
> and whistles, upgrades would be dreadful; you need only ask them for
> new information really needed via debconf.
Yes I agree with you and Joey that this is probably the best way to
go. In complex packages I think this is hard to get right -- it
seemed like postfix's maintainer scripts screwed me over every time I
upgraded until he added a "don't touch my configuration" option which
I now select every time. So I think if done wrong this approach can
breed user mistrust.
Anyway, I've got two questions:
1) Does Debian have any useful packaging utilities used for simple
programmatic editing of text files? I'm not thinking sed/awk/perl
here, but rather something along the lines of cfengine's
"editfiles" capabilities. It'd be cool to be able to do something
like this (in some made up pseudo language).
config = configfile("/etc/flipit.conf")
if (!config)
dump_default_config(config)
else
if (config.version() < 0.4)
config.append_text(<<EOF)
# The default value for the new 'frob' option is 12
# but it can range from 0 to 100
# frob = 12
EOF
config.set_version(0.4)
end
end
Something like this implemented in Perl, Python, or Ruby might be a
useful maintainer tool. The starting point could be cfengine's
"editfiles" functionality, but additional stuff could be added
(such as a set/set version capability that maintains the "#
config_version=XX" lines.
2) Is there anything wrong with a package's postinst script requiring
Ruby? If not, how would I express the dependency? Were I to
implement the above idea I'd want to do it in that language --
doing OO stuff in Perl makes me want to cry.
--
matt
Reply to: