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

Re: Skeleton maintainer scripts

Charles Briscoe-Smith <cpbs@debian.org> writes:

> I seem to remember someone asking what all the cases were that the
> maintainer scripts ({pre,post}{inst,rm}) should handle.  Since I wanted
> to know about this, too, I researched it in the packaging manual and put
> together the following skeleton scripts, which might help.  Let me know if
> they are of any use, and if you have ideas as to how I could improve them!

Charles, these scripts rock out.  They're a little wordy, you might
strip down a little.  More comments below.  Email a new version to
this list and debian-dpkg@lists.debian.org, and I'll lobby to get
these included into the packaging manual.  I think it would be great.
[Please excuse the crossposting to debian-dpkg, I've also forwarded
your original post to that list.]

> #! /bin/sh

Why the space after the shbang?  I don't personally like that.

> # preinst.skeleton
> # Skeleton maintainer script showing all the possible cases.
> # Written by Charles Briscoe-Smith, March 1998.  Public Domain.
> #
> # I've attempted to document all the cases as best I can.  What's more,
> # I even have reason to believe this script works!  It does nothing,
> # but if you replace the lines with a `:' at the left margin with your
> # code, it'll be called at the correct places.

Cut this para.

> # Some general points relevant to preinst scripts (gleaned from the
> # Debian policy manual version, and the packaging manual):

Trim down to one line

> # - Trap all errors
> # - Don't generate any unnecessary output
> # - Do not prompt the user in this script; do prompting in postinst
> # - Vitally important messages to the system administrator (NOT the end
> #   user) should be displayed by the postinst, then wait for return to
> #   be pressed.
> # - Be idempotent: make sure nothing bad will happen if the script is
> #   called twice where it would usually be called once.
> # - Return an exit status of zero if you succeed, non-zero if you fail
> # - Remember stdout may be redirected (e.g. to a pipe) for logging
> #   purposes.
> # Abort if any command returns an error value
> set -e
> # This script is called before this version of this package is installed.
> # When this script is called, the package's files have not been unpacked
> # yet.
> case "$1" in
>   install)
>     # About to install this package.  There are two sub-cases.
> :

Why these colons here against the left column?  The colons aren't
needed here, and I don't like breaking the indent flow.

>     if test "${2+set}" = set; then

Yurk.  Have you tested that in ash?  Wouldn't '"${2}set" = set' be
more general?

No other substantive comments at this time.

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

Reply to: