Hello I try to set up a working debconf system for a package [1], I am working on. My problem is about the binary tango-common package.
The debconf consist on one question about a host and a port where a service is running. so I ask a question about this TANGO_HOST=host:port now I want to initialise this TANGO_HOST with a default value during the first install (the configure file /etc/tangorc was not yet created). here is the code use for this purpose in the tango-common.config 1 #!/bin/sh 2 CONFIGFILE=/etc/tangorc 3 set -e 4 . /usr/share/debconf/confmodule 5 6 # Load config file, if it exists. 7 if [ -e $CONFIGFILE ]; then 8 . $CONFIGFILE || true 9 10 # Store values from config file into 11 # debconf db. 12 db_set tango-common/tango-host "$TANGO_HOST" 13 else 14 db_set tango-common/tango-host $(hostname -f)":10000" 15 fi 18 # what is the name of the tango host 19 db_input high tango-common/tango-host || true 20 db_go || true So it seems to work, during the installation the right hosname with the 10000 port is proposed as default value. now the user change this default value and set the 10001 port. If I put a db_get tango-common/tango-host at the end of this script it gives the string typed buy the user host:10001 now my problem is when I generate the configure file from this db entry in the postinst script. Here the code : 1 #!/bin/sh 2 CONFIGFILE=/etc/tangorc 3 set -e 4 . /usr/share/debconf/confmodule 5 6 # Generate config file, if it doesn't exist. 7 # An alternative is to copy in a template 8 # file from elsewhere. 9 if [ ! -e $CONFIGFILE ]; then 10 echo "# Config file for my package" > $CONFIGFILE 11 echo "TANGO_HOST=" >> $CONFIGFILE 12 fi 13 14 # Substitute in the values from the debconf db. 15 # There are obvious optimizations possible here. 16 # The cp before the sed ensures we do not mess up 17 # the config file's ownership and permissions. 18 db_get tango-common/tango-host 19 TANGO_HOST=$RET 20 cp -a -f $CONFIGFILE $CONFIGFILE.tmp 21 22 # If the admin deleted or commented some variables but then set 23 # them via debconf, (re-)add them to the conffile. 24 test -z "$TANGO_HOST" || grep -Eq '^ *TANGO_HOST=' $CONFIGFILE || \ 25 echo "TANGO_HOST=" >> $CONFIGFILE 26 27 sed -e "s/^ *TANGO_HOST=.*/TANGO_HOST=$TANGO_HOST/" \ 28 < $CONFIGFILE > $CONFIGFILE.tmp 29 mv -f $CONFIGFILE.tmp $CONFIGFILE 30 31 #DEBHELPER# at the end of this script the right configure file should be created, but in fact the created file contain the default value `hostname -f`:10000 instead of host:10001 as enter by the user. more strange, If I reconfigure the tango-common package, the the entered value generate the right config file. so it seems that there is a problem only during the very first configuration. I do not understand what is the problem. So I would like some fresh eyes, to help me understand this problem thanks for your attention Frederic other related question what should I do to register properly the /etc/tangorc file as a configuration file with ucf. I am not sure I did the thing correctly in the package. [1] http://git.debian.org/?p=debian-science/packages/tango.git;a=summary -- GPG public key 1024D/A59B1171 2009-08-11 fingerprint = 1688 A3D6 F0BD E4DF 2E6B 06AA B6A9 BA6A A59B 1171 uid Picca Frédéric-Emmanuel <pi...@synchrotron-soleil.fr>
signature.asc
Description: PGP signature