From: joey Date: Tue, 17 Aug 1999 05:03:50 +0000 (+0000) Subject: r139: Initial Import X-Git-Tag: debian_version_0_1~100 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=86dad95164449b89ef4d97df2750c3e8b94cf47f;p=debhelper.git r139: Initial Import --- diff --git a/debian/changelog b/debian/changelog index 2c4e79a..32baae8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,16 @@ +debhelper (1.2.5) unstable; urgency=low + + * The perl conversion is complete. + . + * dh_compress: perlized (yay, perl has readlink, no more ls -l | awk + garbage!) + * dh_lib, dh_getopt.pl: deleted, nothing uses them anymore. + * debian/rules: don't install above 2 files. + * doc/PROGRAMMING: removed all documentation of the old shell library + interface. + + -- Joey Hess Fri, 13 Nov 1998 15:36:57 -0800 + debhelper (1.2.4) unstable; urgency=low * dh_debstd, dh_movefiles: perlized. diff --git a/debian/rules b/debian/rules index bb790cd..4827597 100755 --- a/debian/rules +++ b/debian/rules @@ -1,7 +1,7 @@ #!/usr/bin/make -f # Note that I have to refer to debhelper programs with ./, to make sure # I run the most current ones. That's also why there is a symlink to the -# current dh_lib and the current dh_getopt.pl in this debian/ directory. +# current Dh_lib.pm and the current Dh_getopt.pm 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. @@ -34,7 +34,7 @@ binary-indep: build echo -e "package Dh_Version;\n\$$version='$(VERSION)';" > debian/tmp/usr/lib/debhelper/Dh_Version.pm find . -perm +111 -maxdepth 1 -type f -not -name "*.pl" \ -exec install -p {} debian/tmp/usr/bin \; - cp -a dh_lib dh_getopt.pl *.pm debian/tmp/usr/lib/debhelper + cp -a *.pm debian/tmp/usr/lib/debhelper cp -a autoscripts debian/tmp/usr/lib/debhelper ./dh_installdocs doc/TODO doc/README doc/PROGRAMMING doc/from-debstd diff --git a/dh_compress b/dh_compress index 76f7614..0cc79c7 100755 --- a/dh_compress +++ b/dh_compress @@ -1,82 +1,74 @@ -#!/bin/sh -e +#!/usr/bin/perl -w # # Compresses files and makes sure that symlinks pointing to the # compressed files get fixed. -PATH=debian:$PATH:/usr/lib/debhelper -. dh_lib +use Cwd; +BEGIN { push @INC, "debian", "/usr/lib/debhelper" } +use Dh_Lib; +init(); -# Returns a list of all the files that we want to compress, -# (ignoring any files we were asked to exclude on the command -# line). Assumes we are already in the temp directory. -filelist () { - # First of all, deal with any files specified right on the command line. - if [ \( "$PACKAGE" = "$DH_FIRSTPACKAGE" -o "$DH_PARAMS_ALL" \) \ - -a "$*" ]; then - # Convert to having each file on its own line - # so grep will work. - echo "$*" | tr " " "\n" - fi - - if [ "$compress" ]; then - # The config file is a sh script that outputs the files to be compressed - # (typically using find). - sh $olddir/$compress 2>/dev/null || true - else - # By default fall back on what the policy manual says to compress. - find usr/info usr/man usr/X11*/man -type f ! -name "*.gz" 2>/dev/null || true - find usr/doc -type f \( -size +4k -or -name "changelog*" \) \ - ! -name "*.htm*" ! -name "*.gif" ! -name "*.gz" \ - ! -name "copyright" 2>/dev/null || true - fi -} - -# Returns a list of all the files we want to compress, -# after taking command line exclusions into account. -# Call only if DH_EXCLUDE_GREP is non-empty. -filelist_excluded () { - # Use grep -F so we don't have to worry about regexp's. - (filelist "$*" | grep -v -F \ - "`echo "$DH_EXCLUDE_GREP" | tr "|" "\n"`") || true -} - -for PACKAGE in $DH_DOPACKAGES; do - TMP=`tmpdir $PACKAGE` - compress=`pkgfile $PACKAGE compress` +foreach $PACKAGE (@{$dh{DOPACKAGES}}) { + $TMP=tmpdir($PACKAGE); + $compress=pkgfile($PACKAGE,"compress"); # Run the file name gathering commands from within the directory # structure that will be effected. - olddir=`pwd` - # Can't use doit here, that breaks --no-act mode. - verbose_echo "cd $TMP" - cd "$TMP" + $olddir=getcwd(); + chdir($TMP) || error("Can't cd to $TMP: $!"); + + # Figure out what files to compress. + @files=(); + # First of all, deal with any files specified right on the command line. + if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) { + push @files,#ARGV; + } + if ($compress) { + # The config file is a sh script that outputs the files to be compressed + # (typically using find). + push @files, split(/\n/,`sh $olddir/$compress 2>/dev/null`); + } + else { + # By default, fall back to what the policy manual says to compress. + push @files, split(/\n/,` + find usr/info usr/man usr/X11*/man -type f ! -name "*.gz" 2>/dev/null || true; + find usr/doc -type f \\( -size +4k -or -name "changelog*" \\) \\ + ! -name "*.htm*" ! -name "*.gif" ! -name "*.gz" \\ + ! -name "copyright" 2>/dev/null || true + `); + } - # Get the list of files to compress. - if [ "$DH_EXCLUDE_GREP" ]; then - files=`filelist_excluded $*` - else - files=`filelist $*` - fi + # Exclude files from compression. + if (@files && defined($dh{EXCLUDE}) && $dh{EXCLUDE}) { + @new=(); + foreach (@files) { + $ok=1; + foreach $x (@{$dh{EXCLUDE}}) { + if (/\Q$x\E/) { + $ok=''; + last; + } + } + push @new,$_ if $ok; + } + @files=@new; + } - if [ "$files" ]; then - # This is just a cosmetic fix. - files=`echo $files | tr "\n" " "` - - doit "gzip -f9 $files" || true - fi + if (@files) { + doit("gzip","-9f",@files); + } - # Change back to old pwd. - verbose_echo "cd $olddir" - cd "$olddir" + chdir($olddir); # Fix up symlinks that were pointing to the uncompressed files. - for file in `find $TMP -type l`; do - DIRECTORY=`expr $file : "\(.*\)/[^/]*"` - NAME=`expr $file : ".*/\([^/]*\)"` - LINKVAL=`ls -l $DIRECTORY/$NAME | awk '{ print $11;}'` - if [ ! -e $DIRECTORY/$LINKVAL -a -f $DIRECTORY/$LINKVAL.gz ]; then - doit "rm $DIRECTORY/$NAME" - doit "ln -s $LINKVAL.gz $DIRECTORY/$NAME.gz" - fi - done -done + open (FIND,"find $TMP -type l |"); + while () { + chomp; + ($directory)=m:(.*)/:; + $linkval=readlink($_); + if (! -e "$directory/$linkval" && -e "$directory/$linkval.gz") { + doit("rm","-f",$_); + doit("ln","-sf","$linkval.gz","$_.gz"); + } + } +} diff --git a/dh_debstd b/dh_debstd index e9e7b3c..2a557ec 100755 --- a/dh_debstd +++ b/dh_debstd @@ -10,7 +10,7 @@ # This has been gutted and extensively rewritten to function as a debhelper # command by Joey Hess. And then completly rewritten in perl. -# Pre-parse command line before we load dh_lib, becuase we use a +# Pre-parse command line before we load Dh_lib, becuase we use a # different style of arguments. @argv=(); foreach (@ARGV) { diff --git a/doc/PROGRAMMING b/doc/PROGRAMMING index 67d25d0..da21ea9 100644 --- a/doc/PROGRAMMING +++ b/doc/PROGRAMMING @@ -36,27 +36,20 @@ merge these modifications into the actual postinst scripts. There are always exceptions. Just ask me. -Introducing dh_lib and Dh_Lib.pm: --------------------------------- +Introducing Dh_Lib.pm: +--------------------- -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. +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.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. -Typically, you invoke dh_lib like this if your debhelper program is a shell -script: +(There used to be a version of Dh_lib.pm that was a library of functions for +shell scripts. If you want to write a debhelper command that is a shell +script, I can dig up that old library for you. Only the perl one is +supported now, though.) -PATH=debian:$PATH:/usr/lib/debhelper -. dh_lib - -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: +Use Dh_lib.pm like this: BEGIN { push @INC, "debian", "/usr/lib/debhelper" } use Dh_Lib; @@ -65,25 +58,19 @@ 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. +The init() function in the perl version. This causes Dh_lib to +parse the command line and do some other initialization tasks. 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/Dh_Lib.pm handles -argument processing. - -As soon as dh_lib loads, it processes any arguments that have been passed to -your program. On the other hand, you need to call init() in Dh_Lib.pm before -it will parse arguments. +-a, and -p. To help you make this work right, Dh_Lib.pm handles argument +processing. Just call init(). 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. +results; programs can use them later. These variables are elements of the +%dh hash. switch variable description -v VERBOSE should the program verbosely output what it is @@ -99,10 +86,7 @@ switch variable description package's postinst, postrm, etc scripts. -X EXCLUDE exclude a something from processing (you decide what this means for your program) - (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 (only available to dh_lib) + (This is an array) 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 @@ -117,7 +101,7 @@ switch variable description package is being acted on) -u U_PARAMS will be set to a string, that is typically parameters your program passes on to some - other program. (In Dh_Lib.pm, this is an array) + other program. (This is an array) -m M_PARAMS will be set to a string, you decide what it means to your program -V V_FLAG will be set to a string, you decide what it @@ -141,38 +125,32 @@ If you need a new command line option, just ask me, and I will add it. Global variables: ---------------- -If using dh_lib, the following variables are also set as soon as you load -the library: +The following keys are also set in the %dh hash when you call init(): MAINPACKAGE the name of the first binary package listed in debian/control -DH_FIRSTPACKAGE the first package we were instructed to act on. This package +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/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. +Dh_Lib.pm also contains a number of functions you may find useful. doit() - 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 + Pass this function an array 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() 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. + to this (ie, commands involving piping redirection), however, you + have to worry about things like escaping shell metacharacters. +verbose_print() + 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 exit. @@ -191,20 +169,20 @@ pkgfile() debian/ directory, so there can be one config file per binary package. The convention is that the files are named debian/package.filename, and debian/filename is also allowable for - the MAINPACKAGE. If the file does not exist, nothing is returned. + the $dh{MAINPACKAGE}. If the file does not exist, nothing is returned. pkgext() Pass this command the name of a binary package, and it will return the name to prefix to files in debian/ for this package. For the - MAINPACKAGE, it returns nothing (there is no prefix), for the other + $dh{MAINPACKAGE}, it returns nothing (there is no prefix), for the other packages, it returns "package.". isnative() Pass this command the name of a package, it returns 1 if the package is a native debian package. - As a side effect, VERSION is set to the version number of the + As a side effect, $dh{VERSION} is set to the version number of the package. autoscript() Pass parameters: - - package to be affected (Dh_Lib.pm only) + - binary package to be affected - script to add to - filename of snippet - sed commands to run on the snippet. Ie, s/#PACKAGE#/$PACKAGE/ diff --git a/doc/README b/doc/README index 93b1687..d851966 100644 --- a/doc/README +++ b/doc/README @@ -1,7 +1,7 @@ Debhelper is a collection of programs that can be used in debian/rules files to automate common tasks related to building debian binary packages. For further documentation, see the man pages for dh_* commands. For an overview -of debhelper, see the debhelper man page. +of debhelper, see the debhelper(1) man page. To help you get started, I've included examples of debian/rules files that use debhelper commands extensively. See /usr/doc/debhelper/examples/ . diff --git a/doc/TODO b/doc/TODO index ac5c212..9a10335 100644 --- a/doc/TODO +++ b/doc/TODO @@ -60,8 +60,3 @@ Depricated: on doing this after slink is released or one year after they were depricated, whichever comes first. Be sure to grep whole debian archive for alls to them before removing them, though! - -Long term goals: - -* Convert selected debhelper commands to be perl programs, for speed, ease - of maintainence, and 8-bit cleanness.