]> git.donarmstrong.com Git - debhelper.git/commitdiff
r137: Initial Import
authorjoey <joey>
Tue, 17 Aug 1999 05:03:41 +0000 (05:03 +0000)
committerjoey <joey>
Tue, 17 Aug 1999 05:03:41 +0000 (05:03 +0000)
Dh_Getopt.pm
debian/changelog
dh_debstd
dh_du
dh_fixperms
dh_installdeb
dh_installdebfiles
dh_installinit
dh_movefiles
dh_suidregister
doc/PROGRAMMING

index 1592d5d020fa09d7adee1703d4996b33bd7fbd51..42ad7abf23ac7e0e980f1c74911f6a37568116eb 100644 (file)
@@ -145,6 +145,13 @@ sub parseopts {
        }
        @{$options{DOPACKAGES}}=@package_list;
 
+       # Generate EXCLUDE_FIND.
+       $options{EXCLUDE_FIND}='';
+       foreach (@{$options{EXCLUDE}}) {
+               $options{EXCLUDE_FIND}.="-regex .*".quotemeta($_).".* -or ";
+       }
+       $options{EXCLUDE_FIND}=~s/ -or $//;
+
        # If there are no packages to act on now, it's an error.
        if (! defined $options{DOPACKAGES} || ! @{$options{DOPACKAGES}}) {
                error("I have no package to build");
index 5f3eb36745a0d5ccf9d83c605b649922adec6102..51977f184e83de19b75b791f9c53650aa4d04162 100644 (file)
@@ -1,3 +1,15 @@
+debhelper (1.2.3) unstable; urgency=low
+
+  * dh_fixperms, dh_installdebfiles, dh_installdeb: perlized
+  * dh_suidregister: perlized, with help from Che_Fox (and Tom Christianson,
+    indirectly..).
+  * dh_suidregister: include leading 0 (or 1 for sticky, etc) in file
+    permissions.
+  * Only 3 more to go and it'll be 100% perl.
+  * Made $dh{EXCLUDE_FIND} available to perl scripts.
+
+ -- Joey Hess <joeyh@master.debian.org>  Tue, 10 Nov 1998 15:47:43 -0800
+
 debhelper (1.2.2) unstable; urgency=low
 
   * dh_du, dh_shlibdeps, dh_undocumented: rewrite in perl.
index 6187fd31e45e806192217e10bd2fb26b59c2e235..e9e7b3cae7f6f987e1ff29b59b13599f44cf8319 100755 (executable)
--- a/dh_debstd
+++ b/dh_debstd
@@ -1,4 +1,4 @@
-#!/bin/sh -e
+#!/usr/bin/perl -w
 #
 # Script to be called from debian/rules to setup all the debian specifc
 # required files
 # (but doc files can also be listed in debian/docs)
 #
 # This has been gutted and extensively rewritten to function as a debhelper
-# command by Joey Hess.
+# command by Joey Hess. And then completly rewritten in perl.
 
 # Pre-parse command line before we load dh_lib, becuase we use a
 # different style of arguments.
-for i;do
-  case "$i" in
-  -p) PERMS=1
-    ;;
-  -u) UNDOC=1
-    ;;
-  -s) SUMS=1
-    ;;
-  -m) NOAUTOMAN=1
-    ;;
-  -c) NOCOMPRESS=1
-    ;;
-  *) collect="$collect$i "
-    ;;
-  esac
-done
-set -- $collect
-
-PATH=debian:$PATH:/usr/lib/debhelper
-. dh_lib
+@argv=();
+foreach (@ARGV) {
+       if ($_ eq '-p') {
+               $ds{PERMS}=1;
+       }
+       elsif ($_ eq '-u') {
+               $ds{UNDOC}=1;
+       }
+       elsif ($_ eq '-s') {
+               $ds{SUMS}=1;
+       }
+       elsif ($_ eq '-m') {
+               $ds{NOAUTOMAN}=1;
+       }
+       elsif ($_ eq '-c') {
+               $ds{NOCOMPRESS}=1;
+       }
+       else {
+               push @argv,$_;
+       }
+}
+@ARGV=@argv;
 
-# Tolerate old style debstd invocations
-if [ "$DH_FIRSTPACKAGE" = "$1" ]; then
-       shift
-fi
+BEGIN { push @INC, "debian", "/usr/lib/debhelper" }
+use Dh_Lib;
+init();
 
-# Subroutines
+# Tolerate old style debstd invocations
+if ($ARGV[0] && $dh{FIRSTPACKAGE} eq $ARGV[0]) {
+       shift;
+}
 
 # debinit handles the installation of an init.d script
-# Parameters:
-# $1= name in /etc/init.d
-# $2 = scriptname
-# $3 = package name
-# $4 = extra params for debhelper
-debinit() {
-       PPACKAGE=$3
-       SCRIPT=$1
-
-       INITPARAMS=`grep "^FLAGS=" $2` || true
-       if [ "$INITPARAMS" != "" ]; then
-               INITPARAMS=`expr "$INITPARAMS" : 'FLAGS="\(.*\)"'` || true
-               if [ "$INITPARAMS" ]; then
-                       INITPARAMS="--update-rcd-params='$INITPARAMS'"
-               fi
-       fi
-
-       if grep -q NO_RESTART_ON_UPGRADE $2; then
-               doit "dh_installinit --no-restart-on-upgrade -p$PPACKAGE $INITPARAMS --init-script=$SCRIPT $4"
-         else
-               doit "dh_installinit -p$PPACKAGE $INITPARAMS --init-script=$SCRIPT $4"
-       fi
+sub debinit { my ($script, $filename, $package, @params)=@_;
+       @initparams=();
+       $norestart='';
+       open (IN,$filename) || warn("$filename: $!");
+       while (<IN>) {
+               if (/^FLAGS=(.*)/) {
+                       push @initparams, $1;
+               }
+               if (/NO_RESTART_ON_UPGRADE/) {
+                       $norestart='--no-restart-on-upgrade';
+               }
+       }
+       close IN;
+       $initparams='';
+       if (@initparams) {
+               $initparams="--update-rcd-params='".join(" ",@initparams)."'";
+       }
+
+       doit("dh_installinit",$norestart,"-p$package",$initparams,"--init-script=$script",@params);
 }
 
-# Package specific things
-#
-# The first parameter is the package name
-# The second parameter is the directory name of the temp directory
-# The third parameter is the prefix for all configuration files to be processed
-package()
-{
-       local i
-       local X Y
-       CPACKAGE=$1
-       CTEMP=$2
-
+# Do package specific things for a package.
+sub do_package { my ($package, $tmp, $prefix)=@_;
        # Deal with scripts in etc directories
-       if [ -f $3/rc.boot ]; then
-               warning "file $3/rc.boot was ignored."
-       fi
+       if (-d "$prefix/rc.boot") {
+               warning("file $prefix/rc.boot was ignored.");
+       }
 
        # etc files that could need some tweaking
-       for i in services inittab crontab protocols profile shells rpc shells \
-               syslog.conf conf.modules modules aliases diversions inetd.conf \
-               X11/Xresources X11/config X11/window-managers X11/xinit purge ; do
-               if [ -f $3$i ]; then
-                       warning "file $3$i was ignored."
-               fi
-       done
-
-       if [ -f $3init.d ]; then
-               debinit $1 $3init.d $1 ""
-       fi
+       foreach $f ('services','inittab','crontab','protocols','profile',
+               'shells','rpc','syslog.conf','conf.modules','modules',
+               'aliases','diversions','inetd.conf','X11/Xresources',
+               'X11/config','X11/window-managers','X11/xinit','purge') {
+               if ( -f "$prefix$f") {
+                       warning("file $prefix$f was ignored.");
+               }
+       }
+
+       if (-f "${prefix}init.d") {
+               debinit($package,"${prefix}init.d",$package,"");
+       }
 
        # The case of a daemon without the final d
-       if [ -f $3init ]; then
-               X=`expr $1 : '\(.*\)d$'` || true  
-               if [ "$X" ]; then
-                       debinit $X $3init $1 "--remove-d"
-               fi
-       fi
-
-       if [ -f $3info ]; then
-               warning "debhelper does not yet support info files, so $3info was ignored."
-       fi
-
-       X=`find $2 -type f -perm +111 2>/dev/null | tr "\n" " "`
-       for i in $X; do
-               BINPATH="`expr "$i" : "$2/\(.*\)/.*"`"
-               BINNAME="`expr "$i" : "$2/.*/\(.*\)"`"
-
-               # Check if manpages exist
-               case "$BINPATH" in
-                       DEBIAN|etc/rc.boot|usr/lib/cgi-bin|etc/init.d|etc/cron.*|usr/lib/lib*|usr/lib/*) SECTION=""
-                               ;;
-                       sbin|usr/sbin) SECTION="8"
-                               ;;
-                       usr/X11R6/bin) SECTION="1x"
-                               ;;
-                       bin|usr/bin) SECTION="1"
-                               ;;
-                       usr/games) SECTION="6"
-                               ;;
-                       *)  SECTION=""
-                               ;;
-               esac
-               if [ "$SECTION" ]; then
-                       Y=`find $2/usr/man $2/usr/X11R6/man -name "$BINNAME.*" 2>/dev/null` || true
-                       if [ "$Y" = "" ]; then
-                               if [ "$UNDOC" ]; then
-                                       doit "dh_undocumented -p$CPACKAGE $BINNAME.$SECTION"
-                               fi
-                       fi
-               fi
-       done
+       if (-f "${prefix}init") {
+               $p=$package;
+               if ($p=~s/d$//) {
+                       debinit($p,"${prefix}init",$package,"--remove-d");
+               }
+       }
+
+       if (-f "${prefix}info") {
+               warning("debhelper does not yet support info files, so ${prefix}info was ignored.");
+       }
+
+       # Set up undocumented man page symlinks.
+       if (defined($ds{UNDOC}) && $ds{UNDOC}) {
+               open (FIND,"find $tmp -type f -perm +111 2>/dev/null |") || warning("find: $!");
+               while (<FIND>) {
+                       chomp;
+                       ($binpath, $binname)=m:$tmp/(.*)/(.*):;
+       
+                       # Check if manpages exist
+                       $section='';
+                       if ($binpath eq 'sbin' || $binpath eq 'usr/sbin') {
+                               $section=8;
+                       }
+                       elsif ($binpath eq 'usr/X11R6/bin') {
+                               $section='1x';
+                       }
+                       elsif ($binpath eq 'bin' || $binpath eq 'usr/bin') {
+                               $section=1;
+                       }
+                       elsif ($binpath eq 'usr/games') {
+                               $section=6;
+                       }       
+                       if ($section && `find $tmp/usr/man $tmp/usr/X11R6/man -name "$binname.*" 2>/dev/null` eq '') {
+                               doit("dh_undocumented","-p$package","$binname.$section");
+                       }
+               }
+               close FIND;
+       }
 }
 
-packages() {
-       local i
-       BASE=$1
-       shift
-       for i in $*; do
-               package $i debian/$i "debian/$i."
-               if [ -x debian/$i.prebuild ]; then
-                       warning "file debian/$i.prebuild ignored"
-               fi
-       done
-
-       if [ -f debian/clean ]; then
-               warning "file debian/clean ignored"
-       fi
-       package $BASE debian/tmp "debian/"
+# Special case of changelog
+$changelogfile='';
+if ($ARGV[0] && $ARGV[0]=~m/change|news|history/) {
+       $changelogfile=shift;
 }
 
-# Special case of changelog
-if [ "$1" ]; then
-       if echo "$1" | egrep -qi "change|news|history" ; then
-               changelogfile=$1
-               shift
-       fi
-fi
-
-doit "dh_installdirs" # here just to make the debian/tmp, etc directories.
-doit "dh_installdocs $*"
-doit "dh_installexamples"
-doit "dh_installchangelogs $changelogfile"
-doit "dh_installmenu"
-doit "dh_installcron"
+doit("dh_installdirs"); # here just to make the debian/tmp, etc directories.
+doit("dh_installdocs",@ARGV);
+doit("dh_installexamples");
+if ($changelogfile) {
+       doit("dh_installchangelogs",$changelogfile);
+}
+else {
+       doit("dh_installchangelogs");
+}
+doit("dh_installmenu");
+doit("dh_installcron");
 
 # Manpage scan
-if [ "$NOAUTOMAN" = "" ]; then
-       doit "dh_installmanpages -p$DH_FIRSTPACKAGE"
-fi
+if (! $ds{NOAUTOMAN}) {
+       doit("dh_installmanpages","-p$dh{FIRSTPACKAGE}");
+}
 
-packages $DH_DOPACKAGES
+# Per-package stuff:
+foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
+       if ($PACKAGE eq $dh{FIRSTPACKAGE}) {
+               if (-f "debian/clean") {
+                       warning("file debian/clean ignored.");
+               }
+               do_package($PACKAGE,"debian/tmp","debian/");
+       }
+       else {
+               do_package($PACKAGE,"debian/$PACKAGE","debian/$PACKAGE.");
+               if ( -x "debian/$PACKAGE.prebuild") {
+                       warning("file debian/$PACKAGE.prebuild ignored.");
+               }
+       }
+}
 
-doit "dh_movefiles"
-doit "dh_strip"
+doit("dh_movefiles");
+doit("dh_strip");
 
-if [ ! "$nocompress" ]; then
-       doit "dh_compress"
-fi
+if (! $ds{NOCOMPRESS}) {
+       doit("dh_compress");
+}
 
-doit "dh_fixperms"
-doit "dh_suidregister"
-doit "dh_shlibdeps"
-doit "dh_gencontrol"
-doit "dh_makeshlibs"
+doit("dh_fixperms");
+doit("dh_suidregister");
+doit("dh_shlibdeps");
+doit("dh_gencontrol");
+doit("dh_makeshlibs");
 
 # Check to see if the install scripts have #DEBHELPER# in them, if not,
 # warn.
-for PACKAGE in $DH_DOPACKAGES; do
-       for file in postinst postrm preinst prerm; do
-               f="`pkgfile $PACKAGE $file`"
-               if [ "$f" ]; then
-                       if ! grep -q "#DEBHELPER#" "$f"; then
-                               filelist="$filelist$f "
-
-                       fi
-               fi
-       done
-done
-if [ "$filelist" ]; then
-       warning "The following scripts do not contain \"#DEBHELPER#\" in them,"
-       warning "and so debhelper will not automatically add commands to them:"
-       warning "$filelist"
-fi
-
-doit "dh_installdeb"
-
-if [ "$SUMS" = "" ]; then
-       doit "dh_md5sums"
-fi
+@filelist=();
+foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
+       foreach $file (qw{postinst postrm preinst prerm}) {
+               $f=pkgfile($PACKAGE,$file);
+               if ($f) {
+                       open (IN,$f);
+                       $found=undef;
+                       while (<IN>) {
+                               if (/#DEBHELPER#/) {
+                                       $found=1;
+                                       last;
+                               }
+                       }
+                       if (! $found) {
+                               push @filelist, $f;
+                       }
+               }
+       }
+}
+if (@filelist) {
+       warning("The following scripts do not contain \"#DEBHELPER#\" in them,");
+       warning("and so debhelper will not automatically add commands to them:");
+       warning(join(" ",@filelist));
+}
+
+doit("dh_installdeb");
+
+if (! $ds{SUMS}) {
+       doit("dh_md5sums");
+}
 
 # This causes the main binary package to be built, which
 # real debstd does not do. Shouldn't be a problem though,
 # if that package gets built twice.
-doit "dh_builddeb"
+doit("dh_builddeb");
diff --git a/dh_du b/dh_du
index 78518f8ef06de36909b08bd8159a413335109b09..f81b074d464c62db6de311426f97ae43fe1e3791 100755 (executable)
--- a/dh_du
+++ b/dh_du
@@ -5,4 +5,7 @@
 #
 # No longer - it was decided these files are a bad idea.
 
-print STDERR "dh_du: this program does nothing and is deprecated. Remove it from debian/rules.\n";
+BEGIN { push @INC, "debian", "/usr/lib/debhelper" }
+use Dh_Lib;
+
+warning("this program does nothing and is deprecated. Remove it from debian/rules.");
index 58aa1484e0693de87a520cb9244fb4f7af29b7c2..e7e1ec6aa0cae8b3d2adb7b9e91f2fb0a8cee768 100755 (executable)
@@ -1,50 +1,52 @@
-#!/bin/sh -e
+#!/usr/bin/perl -w
 #
 # Do some general file permission fixups.
 
-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`
+foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
+       $TMP=tmpdir($PACKAGE);
 
        # General permissions fixing.
-       if [ ! "$DH_EXCLUDE_FIND" ]; then
+       if (! defined($dh{EXCLUDE_FIND}) || $dh{EXCLUDE_FIND} eq '') {
                # It's much faster to do it this way, but we can only do
                # this if there is nothing to exclude.
-               if [ -d $TMP ]; then
-                       doit "chown -R root.root $TMP"
-                       doit "chmod -R go=rX $TMP"
-                       doit "chmod -R u+rw $TMP"
-               fi
-
-               FIND_OPTIONS=""
-       else
+               if (-d $TMP) {
+                       doit("chown","-R","root.root",$TMP);
+                       doit("chmod","-R","go=rX",$TMP);
+                       doit("chmod","-R","u+rw",$TMP);
+               }
+
+               $find_options="";
+       }
+       else {
                # Do it the hard way.
-               complex_doit "find $TMP ! \( $DH_EXCLUDE_FIND \) -print0 \
-                       2>/dev/null | xargs -0r chown root.root"
-               complex_doit "find $TMP ! \($DH_EXCLUDE_FIND \) -print0 \
-                       2>/dev/null | xargs -0r chmod go=rX"
-               complex_doit "find $TMP ! \( $DH_EXCLUDE_FIND \) -print0 \
-                       2>/dev/null | xargs -0r chmod u+rw"
+               complex_doit("find $TMP ! \\( $dh{EXCLUDE_FIND} \\) -print0 \
+                       2>/dev/null | xargs -0r chown root.root");
+               complex_doit("find $TMP ! \\( $dh{EXCLUDE_FIND} \\) -print0 \
+                       2>/dev/null | xargs -0r chmod go=rX");
+               complex_doit("find $TMP ! \\( $dh{EXCLUDE_FIND} \\) -print0 \
+                       2>/dev/null | xargs -0r chmod u+rw");
 
-               FIND_OPTIONS="! \( $DH_EXCLUDE_FIND \)"
-       fi
+               $find_options="! \\( $dh{EXCLUDE_FIND} \\)";
+       }
 
        # Fix up premissions in usr/doc, setting everything to not exectable
        # by default, but leave examples directories alone.
-       complex_doit "find $TMP/usr/doc -type f $FIND_OPTIONS ! -regex .\*/examples/.\* -print0 \
-               2>/dev/null | xargs -0r chmod 644"
-       complex_doit "find $TMP/usr/doc -type d $FIND_OPTIONS -print0 \
-               2>/dev/null | xargs -0r chmod 755"
+       complex_doit("find $TMP/usr/doc -type f $find_options ! -regex .\*/examples/.\* -print0",
+               "2>/dev/null | xargs -0r chmod 644");
+       complex_doit("find $TMP/usr/doc -type d $find_options -print0",
+               "2>/dev/null | xargs -0r chmod 755");
 
        # Executable man pages are a bad thing..
-       complex_doit "find $TMP/usr/man/ $TMP/usr/X11*/man/ -type f \
-               $FIND_OPTIONS -print0 2>/dev/null | xargs -0r chmod 644"
+       complex_doit("find $TMP/usr/man/ $TMP/usr/X11*/man/ -type f",
+               "$find_options -print0 2>/dev/null | xargs -0r chmod 644");
 
        # ..and so are executable shared and static libraries 
        # (and .la files from libtool)
-       complex_doit "find $TMP -perm -5 -type f \
-               \( -name '*.so*' -or -name '*.la' -or -name '*.a' \) $FIND_OPTIONS -print0 \
-               2>/dev/null | xargs -0r chmod a-X"
-done
+       complex_doit("find $TMP -perm -5 -type f",
+               "\\( -name '*.so*' -or -name '*.la' -or -name '*.a' \\) $find_options -print0",
+               "2>/dev/null | xargs -0r chmod a-X");
+}
index dd1a23fb541f578e73b4aff5b864e437444e7555..f5f3055a821e5cfcbde428bb199f481a3433ec2a 100755 (executable)
@@ -1,51 +1,55 @@
-#!/bin/sh -e
+#!/usr/bin/perl -w
 #
 # Install files from debian/ into the package's DEBIAN directory.
 
-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`
-       EXT=`pkgext $PACKAGE`
+foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
+       $TMP=tmpdir($PACKAGE);
+       $EXT=pkgext($PACKAGE);
 
-       if [ ! -d $TMP/DEBIAN ]; then
-               doit "install -o root -g root -d $TMP/DEBIAN"
-       fi
+       if (! -d "$TMP/DEBIAN") {
+               doit("install","-o","root","-g","root","-d","$TMP/DEBIAN");
+       }
 
        # Install debian install scripts.
        # If any .debhelper files exist, add them into the scripts.
-       for file in postinst preinst prerm postrm; do
-               f=`pkgfile $PACKAGE $file`
-               if [ "$f" ]; then
-                       if [ -f debian/$EXT$file.debhelper ]; then
+       foreach $file (qw{postinst preinst prerm postrm}) {
+               $f=pkgfile($PACKAGE,$file);
+               if ($f) {
+                       if (-f "debian/$EXT$file.debhelper") {
                                # Add this into the script, where it has
                                # #DEBHELPER#
-                               complex_doit "perl -pe 's~#DEBHELPER#~qx{cat debian/$EXT$file.debhelper}~eg' < $f > $TMP/DEBIAN/$file"
-                       else
+                               # TODO: do internally, no perl fork?
+                               complex_doit("perl -pe 's~#DEBHELPER#~qx{cat debian/$EXT$file.debhelper}~eg' < $f > $TMP/DEBIAN/$file");
+                       }
+                       else {
                                # Just get rid of any #DEBHELPER# in the 
                                # script.
-                               complex_doit "sed s/#DEBHELPER#// < $f > $TMP/DEBIAN/$file"
-                       fi
-                       doit "chown root.root $TMP/DEBIAN/$file"
-                       doit "chmod 755 $TMP/DEBIAN/$file"
-               else
+                               complex_doit("sed s/#DEBHELPER#// < $f > $TMP/DEBIAN/$file");
+                       }
+                       doit("chown","root.root","$TMP/DEBIAN/$file");
+                       doit("chmod",755,"$TMP/DEBIAN/$file");
+               }
+               else {
                        # Auto-generate script header and add .debhelper
                        # content to it.
-                       if [ -f debian/$EXT$file.debhelper ]; then
-                               complex_doit "echo '#!/bin/sh -e' > $TMP/DEBIAN/$file"
-                               complex_doit "cat debian/$EXT$file.debhelper >> $TMP/DEBIAN/$file"
-                               doit "chown root.root $TMP/DEBIAN/$file"
-                               doit "chmod 755 $TMP/DEBIAN/$file"
-                       fi
-               fi
-       done
+                       if (-f "debian/$EXT$file.debhelper") {
+                               complex_doit("echo '#!/bin/sh -e' > $TMP/DEBIAN/$file");
+                               complex_doit("cat debian/$EXT$file.debhelper >> $TMP/DEBIAN/$file");
+                               doit("chown","root.root","$TMP/DEBIAN/$file");
+                               doit("chmod",755,"$TMP/DEBIAN/$file");
+                       }
+               }
+       }
 
        # Install non-executable files
-       for file in shlibs conffiles; do
-               f=`pkgfile $PACKAGE $file`
-               if [ "$f" ]; then
-                       doit "install -o root -g root -m 644 -p $f $TMP/DEBIAN/$file"
-               fi                                               
-       done
-done
+       foreach $file (qw{shlibs conffiles}) {
+               $f=pkgfile($PACKAGE,$file);
+               if ($f) {
+                       doit("install","-o","root","-g","root","-m",644,"-p",$f,"$TMP/DEBIAN/$file");
+               }
+       }
+}
index d999c91b2d57f6ede0d7c16112f2dda7f0563f47..cd4562eab3a146087164c8e88e6a71b7effc4c13 100755 (executable)
@@ -1,12 +1,15 @@
-#!/bin/sh -e
+#!/usr/bin/perl -w
 #
 # This program is deprecated, but left in the package for backwards
 # compatability. It simply calls the 3 programs that replaced it.
 
-PATH=debian:$PATH:/usr/lib/debhelper
+BEGIN { push @INC, "debian", "/usr/lib/debhelper" }
+use Dh_Lib;
 
-echo "dh_installdebfiles: use of this program is deprecated, see man page." >&2
+$ENV{PATH}="debian:$ENV{PATH}:/usr/lib/debhelper";
 
-dh_installdeb $*
-dh_shlibdeps $*
-dh_gencontrol $*
+warning("use of this program is deprecated, see man page.");
+
+doit("dh_installdeb",@ARGV);
+doit("dh_shlibdeps",@ARGV);
+doit("dh_gencontrol",@ARGV);
index d455de4a19f8a08b54205b79fcdb0e5ddeaad64d..d1de18075b4e3c39731e5257b027cd91e4249042 100755 (executable)
@@ -42,7 +42,10 @@ foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
                # This is set by the -u "foo" command line switch, it's
                # the parameters to pass to update-rc.d. If not set,
                # we have to say "defaults".
-               my $params=join(' ',@{$dh{U_PARAMS}});
+               my $params='';
+               if (defined($dh{U_PARAMS})) {
+                       $params=join(' ',@{$dh{U_PARAMS}});
+               }       
                if ($params eq '') {
                        $params="defaults";
                }
index 712ed887708fc6183c067a196c4785826e8a725e..5967ff543cbc24be202e49be80eb02f3417c90a3 100755 (executable)
@@ -1,70 +1,70 @@
-#!/bin/sh -e
+#!/usr/bin/perl -w
 #
 # Move files out of debian/tmp, into subpackages.
 
-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`
-       files=`pkgfile $PACKAGE files`
+$ret=0;
 
-       if [ ! -d "debian/tmp" ]; then
-               error "debian/tmp does not exist"
-       fi
+foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
+       $TMP=tmpdir($PACKAGE);
+       $files=pkgfile($PACKAGE,"files");
 
-       tomove=""
+       if (! -d "debian/tmp") {
+               error("debian/tmp does not exist.");
+       }
+
+       @tomove=();
 
         # debian/files has a different purpose, so ignore it.
-       if [ "$files" -a "$files" != "debian/files" ]; then
-               tomove=`cat $files`
-       fi
+       if ( $files && $files != "debian/files" ) {
+               @tomove=filearray($files);
+       }
        
-       if [ \( "$PACKAGE" = "$DH_FIRSTPACKAGE" -o "$DH_PARAMS_ALL" \) \
-            -a "$*" ]; then
-               tomove="$* $tomove"
-       fi
-
-       if [ "$tomove" -a "$TMP" = "debian/tmp" ]; then
-               error "I was asked to move files from debian/tmp to debian/tmp."
-       fi
+       if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
+               push @tomove, @ARGV;
+       }
 
-       if [ "$tomove" ]; then
-               if [ ! -d "$TMP" ]; then
-                       doit "install -d $TMP"
-               fi
+       if (@tomove && $TMP eq "debian/tmp") {
+               error("I was asked to move files from debian/tmp to debian/tmp.");
+       }
 
+       if (@tomove) {
+               if (! -d $TMP) {
+                       doit("install","-d",$TMP);
+               }
+               # Now we need to expand wildcards in @tomove.
+               @filelist=();
+               foreach (@tomove) {
+                       push @filelist, glob("debian/tmp/$_");
+               }
+               
                # Order the files. First all real files, then symlinks. 
                # Putting symlinks last is a nice thing to do for library 
                # packages and doesn't affect much of anything else.
-               #
-               # (The echo is in here to expand wildcards. Note that 'ls'
-               # won't work properly.)
-               # The file list is used, so even very weird filenames can be
-               # moved.
-               doit "rm -f movelist"
-               for i in `(cd debian/tmp; echo $tomove)`; do
-                       if [ ! -e "debian/tmp/$i" -a ! -L "debian/tmp/$i" ]; then
-                               fail=1
-                       fi
-                       complex_doit "(cd debian/tmp ; find $i ! -type d -and ! -type l -print || true) >> movelist"
-               done
-               for i in `(cd debian/tmp; echo $tomove)`; do
-                       if [ ! -e "debian/tmp/$i" -a ! -L "debian/tmp/$i" ]; then
-                               fail=1
-                       fi
-                       complex_doit "(cd debian/tmp ; find $i ! -type d -and -type l -print || true) >> movelist"
-               done
-               complex_doit "(cd debian/tmp;tar --create --remove-files --files-from=../../movelist --file -) | (cd $TMP;tar xpf -)"
-               doit "rm -f movelist"
-       fi
-done
+               doit("rm","-f","movelist");
+               foreach (@filelist) {
+                       $ret=1 if (! -e $_ && ! -l $_);
+                       s:^debian/tmp/*::;
+                       complex_doit("(cd debian/tmp ; find $_ ! -type d -and ! -type l -print || true) >> movelist");
+               }
+               foreach (@filelist) {
+                       $ret=1 if (! -e $_ && ! -l $_);
+                       s:^debian/tmp/*::;
+                       complex_doit("(cd debian/tmp ; find $_ ! -type d -and -type l -print || true) >> movelist");
+               }
+               complex_doit("(cd debian/tmp;tar --create --remove-files --files-from=../../movelist --file -) | (cd $TMP;tar xpf -)");
+               doit("rm","-f","movelist");
+       }
+}
 
-# If fail is set, we wern't actually able to find some 
+# If $ret is set, we wern't actually able to find some 
 # files that were specified to be moved, and we should
-# exit with the code in fail. This program puts off 
+# exit with the code in $ret. This program puts off 
 # exiting with an error until all files have been tried
 # to be moved, because this makes it easier for some 
 # packages that arn't always sure exactly which files need
 # to be moved.
-exit $fail
+exit $ret;
index f6d02bc18500571bf5f2cf7383dac0c66a41899f..86188cd46751679196150c04456ec11e1741affb 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh -e
+#!/usr/bin/perl -w
 #
 # If no parameters are given, and no debian/suid files exists, scan for 
 # suid/sgid files and suidregister them. 
@@ -6,58 +6,56 @@
 # If there are parameters, or there is a debian/suid, register the files
 # listed there.
 
-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`
-       suid=`pkgfile $PACKAGE suid`
+foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
+       $TMP=tmpdir($PACKAGE);
+       $suid=pkgfile($PACKAGE,"suid");
 
-       files=""
+       @files=();
+       if ($suid) {
+               @files=filearray($suid);
+       }
 
-       if [ "$suid" ]; then
-               files=`tr "\n" " " < $suid`
-       fi
+       if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
+               push @files, @ARGV;
+       }
 
-       if [ \( "$PACKAGE" = "$DH_FIRSTPACKAGE" -o "$DH_PARAMS_ALL" \) \
-            -a "$*" ]; then
-               files="$* $files"
-       fi
-
-       if [ ! "$files" -a ! "$suid" ]; then
+       if (! @files && ! $suid) {
                # No files specified (and no empty debian/suid file), so
                # guess what files to process.
-               files=`find $TMP -type f -perm +6000`
+               @files=split(/\n/,`find $TMP -type f -perm +6000`);
 
                # We will strip the debian working directory off of the
                # filenames.
-               tostrip="$TMP/"
-       else
+               $tostrip="$TMP/";
+       }
+       else {
                # We will strip leading /'s, so the user can feed this
                # program either absolute filenames, or relative filenames,
                # and it will do the right thing either way.
-               tostrip="/"
-       fi
-
-       if [ "$files" ]; then
-               for file in $files; do
-                       # Strip leading $tostrip from $file. If not there,
-                       # leave $file untouched.
-                       if [ `expr "$file" : "$tostrip\\(.*\\)"` ]; then
-                               file=`expr "$file" : "$tostrip\\(.*\\)"`
-                       fi
-                       
-                       # Create the sed string that will be used to 
-                       # fill in the blanks in the autoscript files.
-                       # Fill with the owner, group, and perms of the file.
-                       sedstr=`find $TMP/$file -printf "s:#FILE#:$file:;s/#PACKAGE#/$PACKAGE/;s/#OWNER#/%u/;s/#GROUP#/%g/;s/#PERMS#/%m/"`
-                       
-                       autoscript "postinst" "postinst-suid" "$sedstr"
-                       autoscript "postrm" "postrm-suid" "$sedstr"
-                       
-                       if [ -e "$TMP/$file" ]; then
-                               doit "chmod a-s $TMP/$file"
-                       fi
-               done
-       fi
-done
+               $tostrip="/";
+       }
+
+       foreach $file (@files) {
+               # Strip leading $tostrip from $file.
+               $file=~s/^$tostrip//;
+
+               # Create the sed string that will be used to 
+               # fill in the blanks in the autoscript files.
+               # Fill with the owner, group, and perms of the file.
+               (undef,undef,$mode,undef,$uid,$gid,undef) = stat("$TMP/$file");
+               # Note that I have to print mode in ocal, stripping file type.
+               $sedstr=sprintf("s:#FILE#:$file:;s/#PACKAGE#/$PACKAGE/;s/#OWNER#/$uid/;s/#GROUP#/$gid/;s/#PERMS#/%#o/",
+                               $mode & 07777);
+
+               autoscript($PACKAGE,"postinst","postinst-suid",$sedstr);
+               autoscript($PACKAGE,"postrm","postrm-suid","$sedstr");
+               
+               if ( -e "$TMP/$file") {
+                       doit("chmod","a-s","$TMP/$file");
+               }
+       }
+}
index 1addc3b81fe45e64be57c9ee69ef0141fed7ca13..67d25d005508b55315a1aeaa44d3a43a0b10598c 100644 (file)
@@ -106,7 +106,7 @@ switch              variable        description
                 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) (only available to dh_lib)
+                               that, of course)
 -x             INCLUDE_CONFFILES
                                include conffiles. It's -x for obscure
                                historical reasons.