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

Re: howto create debian package with conf files

On Sat, Oct 25, 2008 at 11:21:19PM +0200, lucas kenter wrote:
> I would like to create a debian package for a simple project that I've
> created. The project contains only scripts, so there is no makefile or
> anything like that. For the script to work I would like to prompt for some
> simple questions like "what url should be used", "what organisation does
> this computer belong to".
> I've created a postinst script that asks these questions and writes them in
> a configuration file. (and this configuration file is listed in conffiles)
> Now the problem that I have is that when I reinstall this package, or
> upgrade it, all the questions are asked again.
> After some research I'm still not able to find a simple example or howto to
> do this right.
> - Is it necessary to use debconf to accomplish this?

I'm not sure if Policy mandates using Debconf, but since this sounds like
it's a local-only package, you don't need to follow policy anyway.  I'd
certainly *recommend* using debconf, though, as it provides both a
standardised interface for the asking and answering of questions, a way to
avoid re-asking questions, and also an easy means of automating the
answering of the questions with preseeding, should you wish to do so in
the future.

> - I thought that the postinst script was called with an argument
> install/upgrade/configure and so I could ask my question only when it was
> and install or configure, but this doesnt work. apperantly upgrading a
> package also uses argument configure...

The postinst is called with the configure argument to say "please configure
the package that has just been installed", whether or not that installation
is a new one or an upgrade.  What might be of use to you is the fact that
the second argument to the postinst call is the previous version that was
fully configured.  So you could do something like this in your postinst:

if [ "$1" = "configure" -a "$2" = "" ]; then
	# Ask your questions

Because the only time that the second argument will be empty is on the
initial install -- after that, $2 will always contain the previously
configured version.

> I've tried to look at packages like postfix, to see how they do it, but
> those are to difficult for my simple scripting skills :-(

I don't know if the 'hello' package has any debconf in it, but it's usually
considered the canonical "how to get started" package.  Otherwise, I can't
think of any specific packages that are good examples of the debconf art,
but I know that MTAs in general are far too complex to make good examples
for new packagers.

- Matt

Reply to: