]> git.donarmstrong.com Git - debhelper.git/commitdiff
r135: Initial Import
authorjoey <joey>
Tue, 17 Aug 1999 05:03:12 +0000 (05:03 +0000)
committerjoey <joey>
Tue, 17 Aug 1999 05:03:12 +0000 (05:03 +0000)
debian/changelog
dh_installinit
dh_installmanpages
dh_strip

index 94c582c06814cd43b7c2d44c966bda09093749b7..26d6963f89bcde3743a5391729a4e4d14d4cb3a1 100644 (file)
@@ -1,3 +1,9 @@
+debhelper (1.2.1) unstable; urgency=low
+
+  * dh_strip, dh_installinit: rewrite in perl.
+
+ -- Joey Hess <joeyh@master.debian.org>  Mon,  9 Nov 1998 20:04:12 -0800
+
 debhelper (1.2.0) unstable; urgency=low
 
   * A new unstable dist means I'm back to converting more of debhelper to
index 21526e2bbd6dab3dbb3309eb7ec94f50d502894b..d455de4a19f8a08b54205b79fcdb0e5ddeaad64d 100755 (executable)
@@ -1,66 +1,69 @@
-#!/bin/sh -e
+#!/usr/bin/perl -w
 #
 # Install debian/init[.d], and set up the postinst and postrm for init
 # scripts.
 
-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`
-       init=`pkgfile $PACKAGE init`
+foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
+       $TMP=tmpdir($PACKAGE);
+       # Debstd used either name, so do we for back-compatability.
+       $init=pkgfile($PACKAGE,"init") || pkgfile($PACKAGE,"init.d");
 
-       # This is for backwards compatability with debstd, which used either
-       # name.
-       if [ ! "$init" ]; then
-               init=`pkgfile $PACKAGE init.d`
-       fi
-
-       if [ "$init" ]; then
-               if [ ! -d $TMP/etc/init.d ]; then
-                       doit "install -d $TMP/etc/init.d"
-               fi
+       if ($init ne '') {
+               if (! -d "$TMP/etc/init.d") {
+                       doit("install","-d","$TMP/etc/init.d");
+               }
 
                # Figure out what filename to install it as.
-               if [ "$DH_D_FLAG" ]; then
-                       # -d on the command line sets DH_D_FLAG. We will 
+               my $script;
+               if ($dh{D_FLAG}) {
+                       # -d on the command line sets D_FLAG. We will 
                        # remove a trailing 'd' from the package name and 
                        # use that as the name.
-                       script=`expr $PACKAGE : '\(.*\)d$'` || true
-                       if [ ! "$script" ]; then
-                               echo `basename $0`" warning: \"$PACKAGE\" has no final -d, but -d was specified."
-                               script=$PACKAGE
-                       fi
-               elif [ "$DH_INIT_SCRIPT" != "" ]; then
-                       script=$DH_INIT_SCRIPT
-               else
-                       script=$PACKAGE
-               fi
-               doit "install -p -m755 $init $TMP/etc/init.d/$script"
+                       $script=$PACKAGE;
+                       if ($script=~m/(.*)d$/) {
+                               $script=$1;
+                       }
+                       else {
+                               warning("\"$PACKAGE\" has no final `d' in its name, but -d was specified.");
+                       }
+               }       
+               elsif ($dh{INIT_SCRIPT}) {
+                       $script=$dh{INIT_SCRIPT};
+               }
+               else {
+                       $script=$PACKAGE;
+               }       
+               doit("install","-p","-m755",$init,"$TMP/etc/init.d/$script");
 
                # This is set by the -u "foo" command line switch, it's
-               # the parameters to pass to update-rc.d. If not set, 
+               # the parameters to pass to update-rc.d. If not set,
                # we have to say "defaults".
-               if [ "$DH_U_PARAMS" = "" ]; then
-                       DH_U_PARAMS="defaults"
-               fi
+               my $params=join(' ',@{$dh{U_PARAMS}});
+               if ($params eq '') {
+                       $params="defaults";
+               }
 
-               # -r on the command line sets DH_R_FLAG. If it's set, there
-               # is no restart on upgrade.
-               if [ ! "$DH_NOSCRIPTS" ]; then
-                       if [ "$DH_R_FLAG" ]; then
-                               autoscript "postinst" "postinst-init-norestart" \
-                                       "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/"
-                               autoscript "postrm" "postrm-init" \
-                                       "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/"
-                       else
-                               autoscript "postinst" "postinst-init" \
-                                       "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/"
-                               autoscript "postrm" "postrm-init" \
-                                       "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/"
-                               autoscript "prerm" "prerm-init" \
-                                       "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/"
-                       fi
-               fi
-       fi
-done
+               if (! $dh{NOSCRIPTS}) {
+                       # -r on the command line sets R_FLAG. If it's set, there
+                       # is no restart on upgrade.
+                       if ($dh{R_FLAG}) {
+                               autoscript($PACKAGE,"postinst","postinst-init-norestart",
+                                       "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
+                               autoscript($PACKAGE,"postrm","postrm-init",
+                                       "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
+                       }
+                       else {
+                               autoscript($PACKAGE,"postinst","postinst-init",
+                                       "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
+                               autoscript($PACKAGE,"postrm","postrm-init",
+                                       "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
+                               autoscript($PACKAGE,"prerm","prerm-init",
+                                       "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/");
+                       }
+               }
+       }
+}
index dbb73cf480230a12fe402cd0fbbb5f8715f9f5d5..1647d0a5f8230ebb307787945bf4deac0687692d 100755 (executable)
@@ -6,8 +6,8 @@
 #
 # This is a little bit (hah!) DWIMish, but still very handy.
 
-BEGIN { push @INC, "debian", "/usr/lib/debhelper" }
 use File::Find;
+BEGIN { push @INC, "debian", "/usr/lib/debhelper" }
 use Dh_Lib;
 init();
 
index 28e950a8f974fdb835bbabda679d638cf3884326..ad5d40a82bc360df7c24fc7fc5b1f5a3ecf9853c 100755 (executable)
--- a/dh_strip
+++ b/dh_strip
@@ -1,44 +1,71 @@
-#!/bin/sh -e
+#!/usr/bin/perl -w
 #
 # Strip files.
 
-PATH=debian:$PATH:/usr/lib/debhelper
-. dh_lib
-
-# This reads in a list of files, and excludes any that match what's in
-# DH_EXCLUDE_GREP.
-filelist_excluded () {
-       if [ "$DH_EXCLUDE_GREP" ]; then
-               # Use grep -F so we don't have to worry about regexp's.
-               grep -v -F "`(cd $TMP; echo "$DH_EXCLUDE_GREP" | tr "|" "\n")`"
-       else
-               # Just pass all files through.
-               cat
-       fi
+use File::Find;
+BEGIN { push @INC, "debian", "/usr/lib/debhelper" }
+use Dh_Lib;
+init();
+
+# Check if a file is an elf binary, shared library, or static library,
+# for use by File::Find. It'll fill the following 3 arrays with anything
+# it finds:
+my (@shared_libs, @executables, @static_libs);
+sub testfile {
+       return if -l $_ or -d $_; # Skip directories and symlinks always.
+
+       # See if we were asked to exclude this file.
+       # Note that we have to test on the full filename, including directory.
+       $fn="$File::Find::dir/$_";
+       foreach $f (@{$dh{EXCLUDE}}) {
+               return if ($fn=~m/\Q$f\E/);
+       }
+
+       # Does its filename look like a shared library?
+       if (m/.*\.so.*?/) {
+               # Ok, do the expensive test.
+               my $type=`file $_`;
+               if ($type=~m/.*ELF.*shared.*/) {
+                       push @shared_libs, $fn;
+                       return;
+               }
+       }
+       
+       # Is it executable? -x isn't good enough, so we need to use stat.
+       (undef,undef,$mode,undef)=stat(_);
+       if ($mode & 0111) {
+               # Ok, expensive test.
+               my $type=`file $_`;
+               if ($type=~m/.*ELF.*executable.*/) {
+                       push @executables, $fn;
+                       return;
+               }
+       }
+       
+       # Is it a static library, and not a debug library?
+       if (m/lib.*\.a/ && ! m/.*_g\.a/) {
+               push @static_libs, $fn;
+               return;
+       }
 }
 
-for PACKAGE in $DH_DOPACKAGES; do
-       TMP=`tmpdir $PACKAGE`
-
-       # Handle executables and shared libraries.
-       for file in `(cd $TMP; find -type f \( -perm +111 -or -name "*.so*" \) 2>/dev/null) | filelist_excluded` ; do
-               case "`file $TMP/$file`" in
-                       *ELF*shared*)
-                               # Note that all calls to strip on shared libs
-                               # *must* inclde the --strip-unneeded.
-                               doit "strip --remove-section=.comment --remove-section=.note --strip-unneeded $TMP/$file"
-                       ;;
-                       *ELF*executable*)
-                               doit "strip --remove-section=.comment --remove-section=.note $TMP/$file"
-                       ;;
-               esac
-       done
-
-       # Handle static libraries.
-       for file in `(cd $TMP; find -type f -name "lib*.a" 2>/dev/null) | filelist_excluded` ; do
-               # Don't strip debug libraries.
-               if ! expr "$file" : ".*_g\.a" >/dev/null ; then
-                       doit "strip --strip-debug $TMP/$file"
-               fi
-       done
-done
+foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
+       $TMP=tmpdir($PACKAGE);
+
+       @shared_libs=@executables=@static_libs=();
+       find(\&testfile,$TMP);
+
+       foreach (@shared_libs) {
+               # Note that all calls to strip on shared libs
+               # *must* inclde the --strip-unneeded.
+               doit("strip","--remove-section=.comment","--remove-section=.note","--strip-unneeded",$_);
+       }
+       
+       foreach (@executables) {
+               doit("strip","--remove-section=.comment","--remove-section=.note",$_);
+       }
+
+       foreach (@static_libs) {
+               doit("strip","--strip-debug",$_);
+       }
+}