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

{pre,post}{inst,rm} template



In occasion of a second reading of your templates I have noticed a couple of
potential problems, and I want you to comment that (I think that debian-mentor
is appropriate) and maybe include in your next revision.

I've used revision posted on 8 April.
I copy here only the relevant fragments.


In your templates you use a single case statement with a "default" falling in
an error:


==================
# preinst.skeleton

case "$1" in
  install) : ;;
  upgrade) : ;;
  abort-upgrade) : ;;
  *) echo "$0: didn't understand being called with \`$1'" 1>&2
     exit 1;;
esac

exit 0
==================

This would preclude the possibility that another argument be added to the list
of those passed by dpkg to the scripts. In fact, in that case, an existing
script which follow your structure will suddenly start to fail.

I think that it should not fail, although the warning issued is ok.
It should also not exit, so general statements added out of the case will be
executed.

  *) echo "$0: didn't understand being called with \`$1'" 1>&2
     true ;;

----------------------------------------------------------------------

Several arguments passed to the scripts follow a "two-words" structure which
IMHO would be better handled by a two level case statement. This would permit
to handle "abort-*" as a whole without losing the possibility to have a
greater granularity, but without falling in the "can't add a new argument"
trap that I explained above.

You use:
----------------------------------------------------------------------
case "$1" in
  configure)
  abort-upgrade)
  abort-remove)
  abort-deconfigure)
  *) echo "$0: didn't understand being called with \`$1'" 1>&2
esac
----------------------------------------------------------------------
and:
----------------------------------------------------------------------
case "$1" in
  remove)
  purge)
  disappear)
  upgrade)
  failed-upgrade)
  abort-install)
  abort-upgrade)
  *) echo "$0: didn't understand being called with \`$1'" 1>&2
esac
----------------------------------------------------------------------

I would suggest to use instead:

case "$1" in
  configure)
  abort-*)
	case "$1" in
	  abort-upgrade)
	  abort-remove)
	  abort-deconfigure)
	  *) 
	esac
  *) echo "$0: didn't understand being called with \`$1'" 1>&2
esac

or even:

case "$1" in
  remove*)
  purge*)
  disappear*)
  upgrade*)
  failed-*)
	case "$1" in
	  failed-upgrade)
	  *) 
	esac
  abort-*)
	case "$1" in
	  abort-install)
	  abort-upgrade)
	  *) 
	esac
  *) echo "$0: didn't understand being called with \`$1'" 1>&2
esac



Cheers,
fab
-- 
| fpolacco@icenet.fi    fpolacco@debian.org    fpolacco@pluto.linux.it
| 6F7267F5 fingerprint 57 16 C4 ED C9 86 40 7B 1A 69 A1 66 EC FB D2 5E
> support the open-source initiative! http://www.opensource.org/


--
To UNSUBSCRIBE, email to debian-mentors-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Reply to: