howto create debian package with conf files

2008-10-25 Thread lucas kenter
Hello,

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 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...

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 :-(

Regards,
Luke


Re: howto create debian package with conf files

2008-10-25 Thread Matthew Palmer
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
fi

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


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: howto create debian package with conf files

2008-10-25 Thread lucas kenter
Wow,

Thanks for the quick and helpfull response Matthew and ehm... I suppose this
is what they mean by Debians helpfull community! I'm possitively amazed!
:-D

one more question though,



  So you could do something like this in your postinst:

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

 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.


Would this still allow users to issue a dpkg-reconfigure?

And never heard of the hello package, but I will install it right away :-)

Regards,
Luke


Re: howto create debian package with conf files

2008-10-25 Thread Matthew Palmer
On Sun, Oct 26, 2008 at 12:10:26AM +0200, lucas kenter wrote:
 Wow,
 
 Thanks for the quick and helpfull response Matthew and ehm... I suppose this
 is what they mean by Debians helpfull community! I'm possitively amazed!
 :-D
 
 one more question though,
 
   So you could do something like this in your postinst:
 
  if [ $1 = configure -a $2 =  ]; then
 # Ask your questions
  fi
 
  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.

 Would this still allow users to issue a dpkg-reconfigure?

Now *that* is an interesting question I've never explored.  I'll leave that
one up to you to test.  If you put:

echo $*

at the top of your postinst, though, and then install, upgrade, and
dpkg-reconfigure your package and see what happens...

- Matt


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]