]> git.donarmstrong.com Git - debhelper.git/commitdiff
r110: Initial Import
authorjoey <joey>
Tue, 17 Aug 1999 04:57:23 +0000 (04:57 +0000)
committerjoey <joey>
Tue, 17 Aug 1999 04:57:23 +0000 (04:57 +0000)
13 files changed:
Dh_Lib.pm
debian/changelog
dh_builddeb
dh_du
dh_installchangelogs
dh_installchangelogs.1
dh_installdebfiles
dh_installdebfiles.1
dh_installdirs
dh_installdirs.1
dh_installexamples.1
doc/PROGRAMMING
doc/TODO

index c58d5c083d9ff8e25ddbf396401cf83930ffc393..49e337a9f8df0450708added56e2590084b34f64 100644 (file)
--- a/Dh_Lib.pm
+++ b/Dh_Lib.pm
@@ -72,6 +72,12 @@ sub init {
        $dh{FIRSTPACKAGE}=${$dh{DOPACKAGES}}[0];
 }
 
+# Escapes out shell metacharacters in a word of shell script.
+sub escape_shell { my $word=shift;
+       $word=~s/([\s><&!\[\]\{\}\(\)\$])/\\$1/g;
+       return $word;
+}
+
 # Run a command, and display the command to stdout if verbose mode is on.
 # All commands that modifiy files in $TMP should be ran via this 
 # function.
@@ -79,7 +85,7 @@ sub init {
 # Note that this cannot handle complex commands, especially anything
 # involving redirection. Use complex_doit instead.
 sub doit {
-       verbose_print(join(" ",@_));
+       verbose_print(join(" ",map { escape_shell($_) } @_));
        
        if (! $dh{NO_ACT}) {
                system(@_) == 0
@@ -171,30 +177,30 @@ sub pkgext { my $package=shift;
 # As a side effect, sets $dh{VERSION} to the version of this package.
 {
        # Caches return code so it only needs to run dpkg-parsechangelog once.
-       my $isnative_cache;
+       my %isnative_cache;
        
        sub isnative { my $package=shift;
-               if ($isnative_cache eq undef) {
+               if (! defined $isnative_cache{$package}) {
                        # Make sure we look at the correct changelog.
                        my $isnative_changelog=pkgfile($package,"changelog");
                        if (! $isnative_changelog) {
                                $isnative_changelog="debian/changelog";
                        }
-                       
+
                        # Get the package version.
                        my $version=`dpkg-parsechangelog -l$isnative_changelog`;
-                       ($dh{VERSION})=$version=~s/[^|\n]Version: \(.*\)\n//m;
-       
+                       ($dh{VERSION})=$version=~m/Version: (.*)/m;
+
                        # Is this a native Debian package?
                        if ($dh{VERSION}=~m/.*-/) {
-                               $isnative_cache=1;
+                               $isnative_cache{$package}=0;
                        }
                        else {
-                               $isnative_cache=0;
+                               $isnative_cache{$package}=1;
                        }
                }
        
-               return $isnative_cache;
+               return $isnative_cache{$package};
        }
 }
 
index 22b5587933ff509b9852e10eec7cf3076c707ad8..06f1f332b090bc6f1071d313011eec2ae4367a04 100644 (file)
@@ -1,3 +1,23 @@
+debhelper (1.1.4) unstable; urgency=low
+
+  * dh_movefiles: fixed bug introduced in 1.1.1 where it would fail in some
+    cases if you tried to move a broken symlink.
+  * dh_installdocs: was only operating on the first package.
+  * dh_installexamples: rewritten in perl.
+  * Dh_Lib.pm: all multiple package operations were broken.
+  * Dh_Lib.pm: implemented complex_doit() and autoscript().
+  * Made all perl code work with use strict and -w (well, except
+    dh_getopt.pl, but that's a hack that'll go away one day).
+  * I didn't realize, but rewriting dh_installdocs in perl fixed bug #24686,
+    although this same problem applies to other debhelper programs... like
+    dh_installexamples, which had the same bug fixed when I rewrote it in
+    perl just now.
+  * Dh_Lib.pm: accidentially didn't check DH_VERBOSE if commands were not
+    passed any switches.
+  * Dh_Getopt.pm: --noscripts was broken.
+
+ -- Joey Hess <joeyh@master.debian.org>  Tue, 11 Aug 1998 12:44:04 -0700
+
 debhelper (1.1.3) unstable; urgency=low
 
   * dh_md5sums: -x was broken since version 1.1.1 - fixed.
index 9ddd21dc848b6ae927a0bdf8f7ae92c014652ada..06cc1bebf80af0f3bcbfaf0226ab4ca7a69c18e7 100755 (executable)
@@ -1,11 +1,12 @@
-#!/bin/sh -e
+#!/usr/bin/perl -w
 #
 # Build the .deb package, assuming all the files are set up.
 
-PATH=debian:$PATH:/usr/lib/debhelper
-. dh_lib
+BEGIN { push @INC, "debian", "/usr/lib/debhelper" }
+use Dh_Lib;
+init();
 
-for PACKAGE in $DH_DOPACKAGES; do
-       TMP=`tmpdir $PACKAGE`
-       doit "dpkg --build $TMP .."
-done
+foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
+       $TMP=tmpdir($PACKAGE);
+       doit("dpkg","--build",$TMP,"..");
+}
diff --git a/dh_du b/dh_du
index 73df2a0be30a2c8d3f5eb3718d62ab67bc39781d..9e641a27490cfdb80031ce7dc9a5381bd5d7f311 100755 (executable)
--- a/dh_du
+++ b/dh_du
@@ -5,19 +5,4 @@
 #
 # No longer - it was decided these files are a bad idea.
 
-PATH=debian:$PATH:/usr/lib/debhelper
-. dh_lib
-
-echo "* Note: dh_du does nothing and is deprecated. Remove it from debian/rules." >&2
-
-#for PACKAGE in $DH_DOPACKAGES; do
-#      TMP=`tmpdir $PACKAGE`
-#
-#      if [ ! -d "$TMP/DEBIAN" ]; then
-#              doit "install -d $TMP/DEBIAN"
-#      fi
-#
-#      # Note that the tabs in this next line are important.
-#      complex_doit "du -k $TMP | sed 's:      $TMP/:  :' | grep -v '  DEBIAN$' | grep -v '    $TMP$' >$TMP/DEBIAN/du"
-#      doit "chown root.root $TMP/DEBIAN/du"
-#done
+echo "dh_du: this program does nothing and is deprecated. Remove it from debian/rules." >&2
index 15a42c0948734e14111f24aa0a3e6cd85a133c95..0024fc10799959f1031bb6c399c0cc7866a785b4 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh -e
+#!/usr/bin/perl -w
 #
 # Installs debian/changelog. If another filename is passed to it, installs
 # that file as the upstream changelog.
@@ -7,35 +7,41 @@
 # if so, the debian changelog is just installed as "changelog", and it is an 
 # error to specify an upstream changelog on the command line.
 
-PATH=debian:$PATH:/usr/lib/debhelper
-. dh_lib
+BEGIN { push @INC, "debian", "/usr/lib/debhelper" }
+use Dh_Lib;
+init();
 
-UPSTREAM=$1
+$upstream=shift;
 
-if isnative && [ "$UPSTREAM" ]; then
-       error "Cannot specify an upstream changelog for a native debian package."
-fi
+if (isnative($dh{MAINPACKAGE}) && defined $upstream) {
+       error("Cannot specify an upstream changelog for a native debian package.");
+}
 
-if isnative; then
-       CHANGELOG_NAME=changelog
-else
-       CHANGELOG_NAME=changelog.Debian
-fi
+if (isnative($dh{MAINPACKAGE})) {
+       $changelog_name='changelog';
+}
+else {
+       $changelog_name='changelog.Debian';
+}
 
-for PACKAGE in $DH_DOPACKAGES; do
-       TMP=`tmpdir $PACKAGE`
+foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
+       $TMP=tmpdir($PACKAGE);
+       $changelog=pkgfile($PACKAGE,"changelog");
 
-       changelog=`pkgfile $PACKAGE changelog`
-       if [ ! "$changelog" ]; then
-               changelog=debian/changelog
-       fi
+       if (!$changelog) {
+               $changelog="debian/changelog";
+       }
 
-       if [ ! -d $TMP/usr/doc/$PACKAGE ]; then
-               doit "install -d $TMP/usr/doc/$PACKAGE"
-       fi
-       doit "install -p -m644 $changelog $TMP/usr/doc/$PACKAGE/$CHANGELOG_NAME"
+       if (! -e $changelog) {
+               error("could not find changelog $changelog");
+       }
 
-       if [ "$UPSTREAM" ]; then
-               doit "install -p -m644 $UPSTREAM $TMP/usr/doc/$PACKAGE/changelog"
-       fi
-done
+       if (! -d "$TMP/usr/doc/$PACKAGE") {
+               doit("install","-d","$TMP/usr/doc/$PACKAGE");
+       }
+       doit("install","-p","-m644",$changelog,"$TMP/usr/doc/$PACKAGE/$changelog_name");
+
+       if ($upstream) {
+               doit("install","-p","-m644",$upstream,"$TMP/usr/doc/$PACKAGE/changelog");
+       }
+}
index 708223382bfc78106adcc87e0ec42a30dd8d513a..9a579a659af8fef5f17596d3d824a923245f5482 100644 (file)
@@ -26,7 +26,7 @@ See
 for a list of options common to all debhelper commands.
 .TP
 .B upstream
-Instal this file as the upstream changelog.
+Install this file as the upstream changelog.
 .SH NOTES
 It is an error to specify an upstream changelog file for a debian native
 package.
index 0fba35a5473b22fa70b24b727f49d1dfada7bee1..d999c91b2d57f6ede0d7c16112f2dda7f0563f47 100755 (executable)
@@ -5,7 +5,7 @@
 
 PATH=debian:$PATH:/usr/lib/debhelper
 
-warn "Note: use of this program is deprecated."
+echo "dh_installdebfiles: use of this program is deprecated, see man page." >&2
 
 dh_installdeb $*
 dh_shlibdeps $*
index ae4782d265ea5f4f4b709501ee3a208c1b4cb316..5e41117a7c21f10892bd3c210dbf4a95b8565d27 100644 (file)
@@ -16,7 +16,7 @@ programs, and you may replace any calls to this program by:
   dh_shlibdeps
   dh_gencontrol
 .SH WARNING
-This program will be removed at some time in the furture.
+This program will be removed at some time in the future.
 .SH OPTIONS
 Any options passed to this program will be sent to each of the 3 programs
 listed above.
index 725cdb2cbeb2316fbbb257ff1aee3304761375ce..2d12b76bab3435d1b3069f0bb5273884ab2afed8 100755 (executable)
@@ -1,43 +1,42 @@
-#!/bin/sh -e
+#!/usr/bin/perl -w
 #
-# Reads debian/dirs, creates the directories listed there there
+# Reads debian/dirs, creates the directories listed there
+
+BEGIN { push @INC, "debian", "/usr/lib/debhelper" }
+use Dh_Lib;
+init();
+
+foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
+       $TMP=tmpdir($PACKAGE);
+       $file=pkgfile($PACKAGE,"dirs");
+
+       if (! -e $TMP) {
+               doit("install","-d",$TMP);
+       }
+
+       undef @dirs;
+
+       if ($file) {
+               @dirs=filearray($file)
+       }
+
+       if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
+               push @dirs, @ARGV;
+       }       
+
+       if (@dirs) {
+               # Stick the $TMP onto the front of all the dirs.
+               # This is necessary, for 2 reasons, one to make them 
+               # be in the right directory, but more importantly, it 
+               # protects against the danger of absolute dirs being
+               # specified.
+               @dirs=map {
+                               $_="$TMP/$_";
+                               tr:/:/:s; # just beautification.
+                               $_
+                         } @dirs;
 
-PATH=debian:$PATH:/usr/lib/debhelper
-. dh_lib
-
-for PACKAGE in $DH_DOPACKAGES; do
-       TMP=`tmpdir $PACKAGE`
-       file=`pkgfile $PACKAGE dirs`
-
-       if [ ! -d $TMP ]; then
-               doit "install -d $TMP"
-       fi
-
-       dirs=""
-
-       if [ "$file" ]; then
-               dirs=`tr "\n" " " < $file`
-       fi
-
-       if [ \( "$PACKAGE" = "$DH_FIRSTPACKAGE" -o "$DH_PARAMS_ALL" \) \
-            -a "$*" ]; then
-               dirs="$* $dirs"
-       fi
-
-       if [ "$dirs" ]; then
-               # Check to see if any of the dirs are absolute.
-               for dir in "$dirs" ; do
-                       if expr "$dir" : "/" >/dev/null ; then
-                               error "Absolute directory name \"$dir\" specified."
-                       fi
-               done
                # Create dirs.
-               olddir=`pwd`
-               verbose_echo "cd $TMP"  
-               cd "$TMP"
-               doit "install -d $dirs"
-               verbose_echo "cd $olddir"
-               cd "$olddir"
-       fi
-done
-
+               doit("install","-d",@dirs);
+       }
+}
index 77c992d96b52997f17d4e719758407b2384f1ff7..95be71513b056db59c1368dd17b7d7156751c48a 100644 (file)
@@ -40,6 +40,7 @@ for a list of environment variables that affect all debhelper commands.
 .SH "SEE ALSO"
 .BR debhelper (1)
 .SH BUGS
-Directories with spaces in them will not currently be installed properly.
+It's impossible to specify filenames with spaces or other whitespace in them
+in debian/dirs file. This is more a historical design flaw than a bug.
 .SH AUTHOR
 Joey Hess <joeyh@master.debian.org>
index 776aef79df9b5c0d21153f12e2d6c933a08596ba..91d9988b76b165844c612c73324493270402d4e0 100644 (file)
@@ -40,7 +40,8 @@ for a list of environment variables that affect all debhelper commands.
 .SH "SEE ALSO"
 .BR debhelper (1)
 .SH BUGS
-Filenames with spaces in them will not currently be installed.
+It's impossible to specify filenames with spaces or other whitespace in them
+in debian/examples file. This is more a historical design flaw than a bug.
 .SH "CONFORMS TO"
 Debian policy, version 2.3.0.0
 .SH AUTHOR
index 878c5a2e74ecb837df7e27e3ded1491765398e5f..e514095db7fe4fc387becbf95a817488cd674eea 100644 (file)
@@ -36,15 +36,18 @@ merge these modifications into the actual postinst scripts.
 
 There are always exceptions. Just ask me.
 
-Introducing dh_lib:
-------------------
+Introducing dh_lib and Dh_Lib.pm:
+--------------------------------
 
-All debhelper programs use the dh_lib library (actually it's a shell script)
-to parse their arguments and set some useful variables. It's not mandatory
-that your program use dh_lib, but it will make it a lot easier to keep it in
+dh_lib/Dh_lib.pm is the library used by all debhelper programs to parse
+their arguments and set some useful variables. It's not mandatory that your
+program use dh_lib/Dh_lib.pm, but it will make it a lot easier to keep it in
 sync with the rest of debhelper if it does, so this is highly encouraged.
+There are two versions of this library - dh_lib is a shell library, while
+Dh_Lib.pm is a perl module.
 
-Typically, you invoke dh_lib like this:
+Typically, you invoke dh_lib like this if your debhelper program is a shell
+script:
 
 PATH=debian:$PATH:/usr/lib/debhelper
 . dh_lib
@@ -53,74 +56,93 @@ The path statement is there to make your program look first in debian/ for
 dh_lib (so users can install a modified version there if necessary), then the
 rest of the path, then the canonical location of dh_lib, /usr/lib/debhelper.
 
+If you are writing a perl program instead, use Dh_lib.pm like this:
+
+BEGIN { push @INC, "debian", "/usr/lib/debhelper" }
+use Dh_Lib;
+init();
+
+The BEGIN block is there to make perl look for the module in all the right
+places.
+
+Notice the init() function in the perl version. dh_lib automatically parses
+the command line and does some other initialization tasks. Dh_Lib.pm
+requires you to run init() to accomplish the same task.
+
 Argument processing:
 -------------------
 
 All debhelper programs should respond to certain arguments, such as -v, -i,
--a, and -p. To help you make this work right, dh_lib handles argument
-processing.
+-a, and -p. To help you make this work right, dh_lib/Dh_Lib.pm handles 
+argument processing.
 
 As soon as dh_lib loads, it processes any arguments that have been passed to
-your program. The following variables may be set during this stage; your
-program can use them later:
+your program. On the other hand, you need to call init() in Dh_Lib.pm before
+it will parse arguments.
+
+After argument processing, some global variables are used to hold the
+results; program can use them later. If using dh_lib, prefix DH_ to the name
+of each of these variables to get the name of the environment variable that
+is set. If using Dh_lib.pm, these variables are in the %dh hash.
 
 switch         variable        description
--v             DH_VERBOSE      should the program verbosely output what it is
+-v             VERBOSE         should the program verbosely output what it is
                                doing?
---no-act       DH_NO_ACT       should the program not actually do anything?
--i,-a,-p,-N    DH_DOPACKAGES   a space delimited list of the binary packages
-                               to act on
--i,-p,-N       DH_DOINDEP      a space delimited list of the binary independent
+--no-act       NO_ACT          should the program not actually do anything?
+-i,-a,-p,-N    DOPACKAGES      a space delimited list of the binary packages
+                               to act on (in Dh_Lib.pm, this is an array)
+-i,-p,-N       DOINDEP         a space delimited list of the binary independent
                                packages to act on
--a,-p,-N       DH_DOARCH       a space delimited list of the binary dependent
+-a,-p,-N       DOARCH          a space delimited list of the binary dependent
                                packages to act on
--n             DH_NOSCRIPTS    if set, do not make any modifications to the 
+-n             NOSCRIPTS       if set, do not make any modifications to the 
                                package's postinst, postrm, etc scripts.
--X             DH_EXCLUDE      exclude a something from processing (you
+-X             EXCLUDE         exclude a something from processing (you
                                decide what this means for your program)
-               DH_EXCLUDE_GREP same as DH_EXCLUDE, except all items are
+                               (In Dh_Lib.pm, this is an array)
+               EXCLUDE_GREP    same as DH_EXCLUDE, except all items are
                                separated by '|' characters, instead of spaces,
-                               handy for egrep -v
-                DH_EXCLUDE_FIND same as DH_EXCLUDE, except all items are put
+                               handy for egrep -v (only available to dh_lib)
+                EXCLUDE_FIND   same as DH_EXCLUDE, except all items are put
                                into a string in a way that they will make
                                find find them. (Use ! in front to negate
-                               that, of course)
--x             DH_INCLUDE_CONFFILES
+                               that, of course) (only available to dh_lib)
+-x             INCLUDE_CONFFILES
                                include conffiles. It's -x for obscure
                                historical reasons.
--d             DH_D_FLAG       you decide what this means to your program
--r             DH_R_FLAG       you decide what this means to your program
--k             DH_K_FLAG       you decide what this means to your program
--P             DH_TMPDIR       package build directory (implies only one
+-d             D_FLAG          you decide what this means to your program
+-r             R_FLAG          you decide what this means to your program
+-k             K_FLAG          you decide what this means to your program
+-P             TMPDIR          package build directory (implies only one
                                package is being acted on)
--u             DH_U_PARAMS     will be set to a string, that is typically
+-u             U_PARAMS        will be set to a string, that is typically
                                parameters your program passes on to some
                                other program.
--m             DH_M_PARAMS     will be set to a string, you decide what it
+-m             M_PARAMS        will be set to a string, you decide what it
                                means to your program
--V             DH_V_FLAG       will be set to a string, you decide what it
+-V             V_FLAG          will be set to a string, you decide what it
                                means to your program
--V             DH_V_FLAG_SET   will be 1 if -V was specified, even if no
+-V             V_FLAG_SET      will be 1 if -V was specified, even if no
                                parameters were passed along with the -V
--A             DH_PARAMS_ALL   generally means that additional command line
+-A             PARAMS_ALL      generally means that additional command line
                                parameters passed to the program (other than
                                those processed here), will apply to all 
                                binary packages the program acts on, not just
                                the first
---init-script  DH_INIT_SCRIPT  will be set to a string, which specifies an
+--init-script  INIT_SCRIPT     will be set to a string, which specifies an
                                init script name (probably only
                                dh_installinit will ever use this)
 
 Any additional command line parameters that do not start with "-" will be 
-ignored, and you can access them later just as you normally would ($1, $2,
-etc).
+ignored, and you can access them later just as you normally would.
 
 If you need a new command line option, just ask me, and I will add it.
 
 Global variables:
 ----------------
 
-The following variables are also set, you can use any of them:
+If using dh_lib, the following variables are also set as soon as you load
+the library:
 
 MAINPACKAGE    the name of the first binary package listed in
                debian/control
@@ -128,21 +150,28 @@ DH_FIRSTPACKAGE   the first package we were instructed to act on. This package
                typically gets special treatment, additional arguments
                specified on the command line may effect it.
 
+If using Dh_Lib.pm, these are only set after init(), and they are named
+$dh{MAINPACKAGE} and $dh{FIRSTPACKAGE}, instead.
+
 Functions:
 ---------
 
-Dh_lib also contains a number of functions you may find useful.
+dh_lib/Dh_Lib.pm also contains a number of functions you may find useful.
+Note that the functions calling conventions are slightly different between
+the two versions of the library.
 
 doit()
-       Pass this function a string that is a shell command. It will run the
-       command (unless DH_NO_ACT is set), and if DH_VERBOSE is set, it will
-       also output the command to stdout. You should use this function for
-       almost all commands your program performs that manipulate files in
-       the package build directories.
+       Pass this function a string (dh_lib) or array (Dh_Lib.pm) that is a 
+       shell command. It will run the command (unless DH_NO_ACT is set), and
+       if DH_VERBOSE is set, it will also output the command to stdout. You
+       should use this function for almost all commands your program performs
+       that manipulate files in the package build directories.
 complex_doit()
-       This is the same as doit(), except you can pass more complicated
-       commands to it (ie, commands involving piping redirection)
-verbose_echo()
+       Pass this function a string that is a shell command, it will run it
+       similarly to how doit() does. You can pass more complicated commands 
+       to this (ie, commands involving piping redirection)
+verbose_echo()   (dh_lib)
+verbose_print()  (Dh_Lib.pm)
        Pass this command a string, and it will echo it if DH_VERBOSE is set.
 error()
        Pass this command a string, it will output it to standard error and
@@ -174,18 +203,13 @@ isnative()
        As a side effect, VERSION is set to the version number of the
        package.
 autoscript()
-       Pass 3 parameters:
-        1: script to add to
-        2: filename of snippet
-        3: sed commands to run on the snippet. Ie, s/#PACKAGE#/$PACKAGE/
-           (optional)
+       Pass parameters:
+        - package to be affected (Dh_Lib.pm only)
+        - script to add to
+        - filename of snippet
+        - sed commands to run on the snippet. Ie, s/#PACKAGE#/$PACKAGE/
+          (optional)
        This command automatically adds shell script snippets to a debian
        maintainer script (like the postinst or prerm).
 
-Notes:
------
-
-Dh_lib is still evolving.
-There will probably be a perl version too, in the future.
-
 -- Joey Hess <joeyh@master.debian.org>
index 756eb4bd607c3d58734ae275f1fa7b7e2ac32741..a4e4a10d4bbf7083a3fc80969cfbb231f03619ca 100644 (file)
--- a/doc/TODO
+++ b/doc/TODO
@@ -9,7 +9,6 @@ Bugs:
 
 Wishlist items:
 
-* update PROGRAMMING to cover new perl interface.
 * Make dh_movefiles remove emptied directories after it's moved all the
   files out of them (#17111).
 * info support for debhelper (currently implemented, but I hate how I did it,
@@ -50,7 +49,8 @@ Wishlist items:
   they are stating that they don't do anything later to invalidate the cache,
   without calling ch_cache again. (#23792)
 * Add a switch to dh_installdeb to allow it to do user definied
-  substitutions. (#25235)
+  substitutions. TOH, maybe it's better if peopld just sed
+  postinst.in before debhelper gets it's hands on it... (#25235)
 
 Depricated: