that uses debhelper commands extensivly. See
/usr/doc/debhelper/examples/rules .
+Automatic generation of debian install scripts:
+----------------------------------------------
+
+Some debhelper commands will automatically generate parts of debian install
+scripts. If you want these automatically generated things included in your
+debian install scripts, then you need to add "#DEBHELPER#" to your scripts,
+in the place the code should be added. "#DEBHELPER#" will be replaced by any
+autogenerated code when you run dh_installdebfiles.
+
+All scripts that automatically generate code in this way let it be disabled
+by the -n parameter.
+
+Note that it will be shell code, so you cannot directly use it in a perl
+script.
+
Notes on multiple binary packages:
---------------------------------
+debhelper (0.3) unstable; urgency=low
+
+ * Added support for automatic generation of debian install scripts to
+ dh_installmenu and dh_installdebfiles and dh_clean.
+ * Removed some pointless uses of cat.
+
+ -- Joey Hess <joeyh@master.debian.org> Fri, 26 Sep 1997 21:52:53 -0400
+
debhelper (0.2) unstable; urgency=low
* Moved out of unstable, it still has rough edges and incomplete bits, but
Package: debhelper
Architecture: all
+Depends: perl
Description: helper programs for debian/rules
A collection of programs that can be used in a debian/rules file to
automate common tasks. Programs are included to install various files into
#!/usr/bin/make -f
# Note that I have to refer to debhelper programs witrh ./, to make sure
-# I run the most current ones.
+# I run the most current ones. That's also why there is a symlink to the
+# current dh_lib in this debian/ directory.
+
+# If any automatic script generation is done in building this package,
+# be sure to use the new templates from this package.
+export DH_AUTOSCRIPTDIR=autoscripts
export DH_VERBOSE=1
-exec install -p {} debian/tmp/usr/bin \;
install -d debian/tmp/usr/lib/debhelper
cp dh_lib debian/tmp/usr/lib/debhelper
+ cp -a autoscripts debian/tmp/usr/lib/debhelper
./dh_installdocs TODO README
./dh_installexamples examples/*
-# ./dh_installmenu
+ ./dh_installmenu
./dh_installmanpages
./dh_installchangelogs
./dh_compress
doit "rm -rf debian/$TMP"
doit "rm -f debian/${EXT}substvars"
done
-doit "rm -f debian/files* $*"
+doit "rm -f debian/files* debian/*.debhelper $*"
# Remove other temp files. I don't run this through doit becuase
# I haven't figured out what I have to esacape to put it in quotes.
doit "install -o root -g root -d debian/$TMP/DEBIAN"
fi
- # Install executable files.
+ # Install debian install scripts.
+ # If any .debhelper files exist, add them into the scripts.
for file in postinst preinst prerm postrm; do
if [ -f debian/$EXT$file ]; then
- doit "install -o root -g root -p debian/$EXT$file debian/$TMP/DEBIAN"
+ # Add this into the script, where it has #DEBHELPER#
+ if [ -f debian/$EXT$file.debhelper ]; then
+ verbose_echo "perl -pe \"s~#DEBHELPER#~qx{cat debian/$EXT$file.debhelper}~eg\" < debian/$EXT$file > debian/$TMP/DEBIAN/$EXT$file"
+ perl -pe "s~#DEBHELPER#~qx{cat debian/$EXT$file.debhelper}~eg" < debian/$EXT$file > debian/$TMP/DEBIAN/$EXT$file
+ doit "chown root.root debian/$TMP/DEBIAN/$EXT$file"
+ doit "chmod 755 debian/$TMP/DEBIAN/$EXT$file"
+ else
+ doit "install -o root -g root -p debian/$EXT$file debian/$TMP/DEBIAN/"
+ fi
+ else
+ # Auto-generate script header and add .debhelper
+ # content to it.
+ if [ -f debian/$EXT$file.debhelper ]; then
+ verbose_echo "echo '#!/bin/sh -e' > debian/$TMP/DEBIAN/$EXT$file"
+ echo '#!/bin/sh -e' > debian/$TMP/DEBIAN/$EXT$file
+ verbose_echo "cat debian/$EXT$file.debhelper >> debian/$TMP/DEBIAN/$EXT$file"
+ cat debian/$EXT$file.debhelper >> debian/$TMP/DEBIAN/$EXT$file
+ doit "chown root.root debian/$TMP/DEBIAN/$EXT$file"
+ doit "chmod 755 debian/$TMP/DEBIAN/$EXT$file"
+ fi
fi
done
prefix these filenames with then name of the "package.", for example,
"foo.postinst".)
.P
+The files postinst, preinst, postrm, and prerm are handled specially: If a
+corresponding file named debian/script.debhelper exists, the contents of that
+file are merged into the script as follows: If the script exists, then
+anywhere in it that "#DEBHELPER#" appears, the text of the .debhelper file is
+inserted. If the script does not exist, then a script is generated from the
+.debhelper file. The .debhelper files are created by other debhelper programs,
+such as
+.BR dh_installmenu (1)
+, and are shell scripts.
+.P
In addition, it will generate a DEBIAN/control file, by running
.BR dpkg-shlibdeps (1)
and
docs=""
if [ -e debian/${EXT}docs ]; then
- docs=`cat debian/${EXT}docs | tr "\n" " "`
+ docs=`tr "\n" " " < debian/${EXT}docs`
fi
if [ "$PACKAGE" = "$MAINPACKAGE" -a "$*" ]; then
examples=""
if [ -e debian/${EXT}examples ]; then
- examples=`cat debian/${EXT}examples | tr "\n" " "`
+ examples=`tr "\n" " " < debian/${EXT}examples`
fi
if [ "$PACKAGE" = "$MAINPACKAGE" -a "$*" ]; then
# If debian/menu file exists, save it to debian/$TMP/usr/lib/menu/$PACKAGE
# If debian/menu-method file exists, save it to
# debian/$TMP/etc/menu-methods/$PACKAGE
+#
+# Also, add to postinst and postrm.
PATH=debian:$PATH:/usr/lib/debhelper
source dh_lib
doit "install -d debian/$TMP/usr/lib/menu"
fi
doit "install -p -m644 debian/${EXT}menu debian/$TMP/usr/lib/menu/$PACKAGE"
+
+ # Add the scripts if a menu-method file doesn't exist.
+ # The scripts for menu-method handle everything these do, too.
+ if [ ! -e debian/${EXT}menu-method -a ! "$DH_NOSCRIPTS" ]; then
+ autoscript "postinst" "postinst-menu"
+ autoscript "postrm" "postrm-menu"
+ fi
fi
if [ -e debian/${EXT}menu-method ]; then
doit "install -d debian/$TMP/etc/menu-methods"
fi
doit "install -p debian/${EXT}menu-method debian/$TMP/etc/menu-methods/$PACKAGE"
+
+ if [ ! "$DH_NOSCRIPTS" ]; then
+ autoscript "postinst" "postinst-menu-method" "s/#PACKAGE#/$PACKAGE/"
+ autoscript "postrm" "postrm-menu-method" "s/#PACKAGE#/$PACKAGE/"
+ fi
fi
done
.I "[-v] [-a] [-i] [-ppackage]"
.SH "DESCRIPTION"
dh_installmenu is a debhelper program that is responsible for installing
-fils used by the debian menu package into package build directories.
+fils used by the debian menu package into package build directories.
+.P
+It also automatically generates the postinst and postrm commands needed to
+interface with the debian menu package. See
+.BR dh_installdebfiles (1)
+for an explanation of how this works.
.P
If a file named debian/menu exists, then it is installed into
usr/lib/menu/package in the package build directory. This is a debian menu
.TP
.B \-ppackage
Install menu files into the package named "package".
+.TP
+.B \-n
+Do not automatically generate code.
.SH NOTES
The
.B \-a
# Run a command, and display the command to stdout if verbose mode is on.
# All commands that modifiy files in debian/$TMP should be ran via this
# function.
+# Unfortunatly, this function doesn't work if your command uses redirection,
+# you will have to call verbose_echo by hand then.
function doit() {
- verbose_echo "$1"
- $1
+ verbose_echo "$*"
+ $*
}
# Echo something if the verbose flag is on.
function verbose_echo() {
if [ "$DH_VERBOSE" ]; then
- echo " $1"
+ echo " $*"
fi
}
fi
}
+# Automatically add a shell script snippet to a debian script.
+# Only works if the script has #DEBHELPER# in it.
+#
+# Parameters:
+# 1: script to add to
+# 2: filename of snippet
+# 3: sed commands to run on the snippet. Ie, s/#PACKAGE#/$PACKAGE/
+function autoscript() {
+ autoscript_script=$1
+ autoscript_filename=$2
+ autoscript_sed=$3
+ autoscript_debscript=debian/`pkgext $PACKAGE`$autoscript_script.debhelper
+
+ if [ -e "$DH_AUTOSCRIPTDIR/$autoscript_filename" ]; then
+ autoscript_filename="$DH_AUTOSCRIPTDIR/$autoscript_filename"
+ else
+ if [ -e "/usr/lib/debhelper/autoscripts/$autoscript_filename" ]; then
+ autoscript_filename="/usr/lib/debhelper/autoscripts/$autoscript_filename"
+ else
+ error "/usr/lib/debhelper/autoscripts/$autoscript_filename does not exist"
+ fi
+ fi
+
+ # Running doit doesn't cut it here.
+ verbose_echo echo "# Automatically added by `basename $0` on `822-date`" ">>" $autoscript_debscript
+ echo "# Automatically added by `basename $0` on `822-date`" >> $autoscript_debscript
+ verbose_echo sed "$autoscript_sed" $autoscript_filename ">>" $autoscript_debscript
+ sed "$autoscript_sed" $autoscript_filename >> $autoscript_debscript
+ verbose_echo echo "# End automatically added section" ">>" $autoscript_debscript
+ echo "# End automatically added section" >> $autoscript_debscript
+}
+
# Argument processing and global variable initialization is below.
# Parse command line.
-set -- `getopt viap: $*`
+set -- `getopt vianp: $*`
for i; do
case "$i"
shift
shift
;;
+ -n)
+ DH_NOSCRIPTS=1
+ shift
+ ;;
--)
shift
break