]> git.donarmstrong.com Git - debhelper.git/commitdiff
r5: Initial Import
authorjoey <joey>
Tue, 17 Aug 1999 04:21:03 +0000 (04:21 +0000)
committerjoey <joey>
Tue, 17 Aug 1999 04:21:03 +0000 (04:21 +0000)
12 files changed:
README
debian/changelog
debian/control
debian/rules
dh_clean
dh_installdebfiles
dh_installdebfiles.1
dh_installdocs
dh_installexamples
dh_installmenu
dh_installmenu.1
dh_lib

diff --git a/README b/README
index 8fbaebe0bc390b310e3469ab685ba93ffd421013..a13c77265914993674d9cf019e496664d44644d1 100644 (file)
--- a/README
+++ b/README
@@ -6,6 +6,21 @@ To help you get started, I've included an example of a debian/rules file
 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:
 ---------------------------------
 
index 7f1faa301cc0f07a574a084fdc2db14794d490c0..f90410213eae2d60e2f599ea48bdd7b6c179e09d 100644 (file)
@@ -1,3 +1,11 @@
+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
index b934849fa445ba9d3e12dfb63ad52b54ff08a320..35ad8f04f9c19c5811e8427a8c205b977275be3d 100644 (file)
@@ -6,6 +6,7 @@ Standards-Version: 2.1.1.0
 
 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
index 247b48b5d0964e2dd5e3a766d293af69c93b4dc7..c6a4fa955a7796268a53322851c54974c8405b8f 100755 (executable)
@@ -1,6 +1,11 @@
 #!/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
 
@@ -29,10 +34,11 @@ binary-indep: build
                -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
index e7bec968758c7fc5b2425cd5317c56ea8433b3c7..cb20e97380b888e8745a899cf09723e9f2b1b26a 100755 (executable)
--- a/dh_clean
+++ b/dh_clean
@@ -12,7 +12,7 @@ for PACKAGE in $DH_DOPACKAGES; do
        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.
index 872eacbbdb7ea4c8b94664ddc500096a9547b434..a09cd1282c5e2698f6d4ca705ad73090120f390d 100755 (executable)
@@ -14,10 +14,30 @@ for PACKAGE in $DH_DOPACKAGES; do
                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
 
index 1f62084a9700ba205edcde62540bb0ac8fba1bee..3f63986892eda9eeb1fc75336a8972d138e08dd2 100644 (file)
@@ -22,6 +22,16 @@ the DEBIAN directory:
 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
index 336ed6eedf201c18c2dfec7de7362502377798e3..dc216288a412bfead55841dd734399446abe5506 100755 (executable)
@@ -17,7 +17,7 @@ for PACKAGE in $DH_DOPACKAGES; do
        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
index 06e28d619a0b46c256cda83702a15ea480369cf6..f82b0004d1ed1483398f8f303ec974d836c6a361 100755 (executable)
@@ -13,7 +13,7 @@ for PACKAGE in $DH_DOPACKAGES; do
        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
index 775945aaa8d4b35dab3c9ecfd5d71ab6e75aa5fe..1180c60b1db60b6a9a9a07443055483302ed4eda 100755 (executable)
@@ -5,6 +5,8 @@
 # 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
@@ -18,6 +20,13 @@ for PACKAGE in $DH_DOPACKAGES; do
                        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
@@ -25,5 +34,10 @@ for PACKAGE in $DH_DOPACKAGES; do
                        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
index c7fa1bf391232b5e8da9b44a6be064086ff29166..f3eba625225c18671827192e165fec002eb99bf5 100644 (file)
@@ -6,7 +6,12 @@ dh_installmenu \- install debian menu files into package build directories
 .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
@@ -32,6 +37,9 @@ Install menu files into all architecture independent packages.
 .TP
 .B \-ppackage
 Install menu files into the package named "package".
+.TP
+.B \-n
+Do not automatically generate code.
 .SH NOTES
 The
 .B \-a
diff --git a/dh_lib b/dh_lib
index b8562cdfda43976176756b4d2b0ba28084039029..b18c7e5a0deed3fa4b33ea97a7c350414d2b4bd3 100644 (file)
--- a/dh_lib
+++ b/dh_lib
@@ -3,15 +3,17 @@
 # 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
 }
 
@@ -40,10 +42,42 @@ function pkgext() {
        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"
@@ -65,6 +99,10 @@ for i; do
                        shift
                        shift
                        ;;
+               -n)
+                       DH_NOSCRIPTS=1
+                       shift
+                       ;;
                --)
                        shift
                        break