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

debconf in preinst and postinst?



Hi,
I am trying to convert moon-buggy to use debconf. Following the tutorial it
was fairly easy to close #89118, ie use debconf in the preinst.
I also want to close #94969, which is not that hard, but I seem to be unable
to use debconf to display a message in the postinst as well, the files get
moved without displaying anything.
I am still a little confused at what the config script does, how do I use
it when I want to use debconf in several maintainer scripts, ie preinst and
postinst? Add all db_ calls there? Does order matter? Is it a collection of
"subroutines" for the different texts and questions?
Or do I need seperate config scripts for each script now?

Also I am confused by this section in the tutorial:

The Config Script

 Note: 
 These questions are asked by a separate config script, not by the postinst,
 so the package can be configured before it is installed, or reconfigured
 after it is installed. 
 Do not make your postinst use debconf to ask questions.
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

But then it says:
 Our config script already handles most of this. After debconf, the postinst
 becomes:

 #!/bin/sh -e

 # Source debconf library.
 . /usr/share/debconf/confmodule
 db_get foo/like_debian
 ^^^^^^^^^^^^^^^^^^^^^^
So it is asking a question in the postinst? I don't want to ask a question
in the postinst (I ask it in the preinst), in postinst I just want to
display a message when an old score file is present and is removed. How do I
do that?

My files look like this now:

moon-buggy-esd.config:
----------------------
# Source debconf library.
. /usr/share/debconf/confmodule

# Sound hardware installed?
db_input medium moon-buggy-esd/sound_hardware || true
db_go

# Check their answer.
db_get moon-buggy-esd/sound_hardware
if [ "$RET" = "false" ]; then
        # Do not install this package..
        db_input high moon-buggy-esd/no_sound_hardware || true
        db_go
fi
  
# Old scorefile
db_get moon-buggy-esd/old_score_file || true
db_go


moon-buggy-esd.preinst:
-----------------------
#! /bin/sh -e

export DEBCONF_DEBUG=developer

case "$1" in
    install|upgrade)
# Source debconf library.
        . /usr/share/debconf/confmodule

        db_get moon-buggy-esd/sound_hardware
        if [ "$RET" = "false" ]; then
            exit 1;
        fi
    ;;

    abort-upgrade)
    ;;

    *)
        echo "preinst called with unknown argument \$1'" >&2
        exit 0
    ;;

esac

#DEBHELPER#

exit 0


moon-buggy-esd.postinst:
------------------------
#! /bin/sh -e

export DEBCONF_DEBUG=developer

# Source debconf library.
    . /usr/share/debconf/confmodule

if [ "$1" = configure ]
then
# (Re)move old scorefile and directory if it exists
  if [ -e /var/lib/games/moon-buggy/mbscore ]
  then 
    db_get moon-buggy-esd/old_score_file
    mv files around...
  fi
fi

#DEBHELPER#

Files are moved, but I am never shown the note about the old score file.
Somewhere I must be doing a very stupid mistake?

And another, not so urgent question.  Can templates be shared between
different packages? When I install moon-buggy and later replace it by
moon-buggy-esd, the moon-buggy templates are still there (unless I purge it,
but then I loose the scores as well).  Some of the templates are identical
in moon-bugy-esd (old score file). Is there a way to "reuse" them? I can not
have both packages installed at the same time, so I never know it "the other"
templates are already there. Maybe the templates should be purged, when "the
other" package is installed to save some space?

Thanks,
Christian



Reply to: