From 4a4c8d6bbb96f4cc05382018e453f76594734f97 Mon Sep 17 00:00:00 2001 From: joey Date: Tue, 17 Aug 1999 05:03:12 +0000 Subject: [PATCH] r135: Initial Import --- debian/changelog | 6 +++ dh_installinit | 107 +++++++++++++++++++++++---------------------- dh_installmanpages | 2 +- dh_strip | 105 +++++++++++++++++++++++++++----------------- 4 files changed, 128 insertions(+), 92 deletions(-) diff --git a/debian/changelog b/debian/changelog index 94c582c..26d6963 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +debhelper (1.2.1) unstable; urgency=low + + * dh_strip, dh_installinit: rewrite in perl. + + -- Joey Hess 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 diff --git a/dh_installinit b/dh_installinit index 21526e2..d455de4 100755 --- a/dh_installinit +++ b/dh_installinit @@ -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/"); + } + } + } +} diff --git a/dh_installmanpages b/dh_installmanpages index dbb73cf..1647d0a 100755 --- a/dh_installmanpages +++ b/dh_installmanpages @@ -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(); diff --git a/dh_strip b/dh_strip index 28e950a..ad5d40a 100755 --- 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",$_); + } +} -- 2.39.5