From: joey Date: Tue, 17 Aug 1999 05:03:41 +0000 (+0000) Subject: r137: Initial Import X-Git-Tag: debian_version_0_1~102 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0eaafbd7e25e0d2fad5869ee65b6080b88c49c80;p=debhelper.git r137: Initial Import --- diff --git a/Dh_Getopt.pm b/Dh_Getopt.pm index 1592d5d..42ad7ab 100644 --- a/Dh_Getopt.pm +++ b/Dh_Getopt.pm @@ -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"); diff --git a/debian/changelog b/debian/changelog index 5f3eb36..51977f1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 Tue, 10 Nov 1998 15:47:43 -0800 + debhelper (1.2.2) unstable; urgency=low * dh_du, dh_shlibdeps, dh_undocumented: rewrite in perl. diff --git a/dh_debstd b/dh_debstd index 6187fd3..e9e7b3c 100755 --- 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 @@ -8,214 +8,212 @@ # (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 () { + 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 () { + 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 () { + 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 78518f8..f81b074 100755 --- 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."); diff --git a/dh_fixperms b/dh_fixperms index 58aa148..e7e1ec6 100755 --- a/dh_fixperms +++ b/dh_fixperms @@ -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"); +} diff --git a/dh_installdeb b/dh_installdeb index dd1a23f..f5f3055 100755 --- a/dh_installdeb +++ b/dh_installdeb @@ -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"); + } + } +} diff --git a/dh_installdebfiles b/dh_installdebfiles index d999c91..cd4562e 100755 --- a/dh_installdebfiles +++ b/dh_installdebfiles @@ -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); diff --git a/dh_installinit b/dh_installinit index d455de4..d1de180 100755 --- a/dh_installinit +++ b/dh_installinit @@ -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"; } diff --git a/dh_movefiles b/dh_movefiles index 712ed88..5967ff5 100755 --- a/dh_movefiles +++ b/dh_movefiles @@ -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; diff --git a/dh_suidregister b/dh_suidregister index f6d02bc..86188cd 100755 --- a/dh_suidregister +++ b/dh_suidregister @@ -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"); + } + } +} diff --git a/doc/PROGRAMMING b/doc/PROGRAMMING index 1addc3b..67d25d0 100644 --- a/doc/PROGRAMMING +++ b/doc/PROGRAMMING @@ -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.