]> git.donarmstrong.com Git - debhelper.git/commitdiff
r308: * dh_suidregister: Die with understandable error message if asked to
authorjoey <joey>
Tue, 23 Nov 1999 21:56:41 +0000 (21:56 +0000)
committerjoey <joey>
Tue, 23 Nov 1999 21:56:41 +0000 (21:56 +0000)
     act on files that don't exist.
   * dh_installchangelogs: to comply with policy, if it's told to act on a
     html changelog, it installs it as changelog.html.gz and dumps a plain
     text version to changelog.gz. The dumping is done with lynx.
     (Closes: #51099)
   * Dh_Getopt.pm: Modified it so any options specified after -- are added to
     U_PARAMS. This means that instead of passing '-u"something nasty"' to
     dh_gencontrol and the like, you can pass '-- something nasty' without
     fiddling to get the quoting right, etc.

Dh_Getopt.pm
debian/changelog
dh_builddeb.1
dh_gencontrol.1
dh_installchangelogs
dh_installinit.1
dh_shlibdeps.1
dh_suidregister
doc/PROGRAMMING

index 0eec704db6eb9b62bd89c754eec4fcf6c6e7a495..5084d6f0ddaefe21376c9f726e7d9ea1a85307bf 100644 (file)
@@ -50,6 +50,11 @@ sub AddExclude { my($option,$value)=@_;
        push @{$options{EXCLUDE}},$value;
 }
 
+# This collects non-options values.
+sub NonOption {
+       push @{$options{ARGV}}, @_;
+}
+
 # Parse options and return a hash of the values.
 sub parseopts {
        undef %options;
@@ -122,6 +127,8 @@ sub parseopts {
                "number=s" => \$options{number},
                
                "flavor=s" => \$options{flavor},
+               
+               "<>" => \&NonOption,
        );
 
        if (!$ret) {
@@ -168,6 +175,12 @@ sub parseopts {
                error("I have no package to build");
        }
 
+       # Anything left in @ARGV is options that appeared after a --
+       # These options are added to U_PARAMS, while the non-option
+       # values we collected replace them in @ARGV;
+       $options{U_PARAMS}.=join(' ', @ARGV);
+       @ARGV=@{$options{ARGV}} if exists $options{ARGV};
+
        return %options;
 }      
 
index 2de265dd0ed3b638827770232bad7eb8a172e558..d32495e695a66fc7b665e97221eb4241eddab027 100644 (file)
@@ -1,3 +1,18 @@
+debhelper (2.0.74) unstable; urgency=low
+
+  * dh_suidregister: Die with understandable error message if asked to
+    act on files that don't exist.
+  * dh_installchangelogs: to comply with policy, if it's told to act on a
+    html changelog, it installs it as changelog.html.gz and dumps a plain
+    text version to changelog.gz. The dumping is done with lynx. 
+    (Closes: #51099)
+  * Dh_Getopt.pm: Modified it so any options specified after -- are added to
+    U_PARAMS. This means that instead of passing '-u"something nasty"' to
+    dh_gencontrol and the like, you can pass '-- something nasty' without
+    fiddling to get the quoting right, etc.
+
+ -- Joey Hess <joeyh@master.debian.org>  Tue, 23 Nov 1999 11:36:15 -0800
+
 debhelper (2.0.73) unstable; urgency=low
 
   * Actually, debhelper build-depends on perl-5.005.
index 556b5430ea1d80b9c5b59dbd769d742497e7c64d..4e87b7b3503e33532995489f2098a2b75bae1d1e 100644 (file)
@@ -3,7 +3,7 @@
 dh_builddeb \- build debian packages
 .SH SYNOPSIS
 .B dh_builddeb
-.I "[debhelper options] [--destdir=directory] [-uparams]"
+.I "[debhelper options] [--destdir=directory] [-uparams] [-- params]"
 .SH "DESCRIPTION"
 dh_builddeb simply calls
 .BR dpkg (8)
@@ -20,6 +20,8 @@ Use this if you want the generated .deb files to be put in a directory other
 than the default of ".."
 .TP
 .B \-uparams
+.TP
+.B \-\- params
 Pass "params" to 
 .BR dpkg-deb (1)
 when it is used to build the package.
index 84bdb0a21db6df0146f5d61a8f5bceba8156138a..15e90a7c77ab8231989eb696560a03e3223a6bc3 100644 (file)
@@ -3,7 +3,7 @@
 dh_gencontrol \- generate and install control file
 .SH SYNOPSIS
 .B dh_gencontrol
-.I "[debhelper options] [-uparams]"
+.I "[debhelper options] [-uparams] [-- params]"
 .SH "DESCRIPTION"
 dh_gencontrol is a debhelper program that is responsible for generating 
 control files, and installing them into the DEBIAN directory with the proper
@@ -19,6 +19,8 @@ See
 for a list of options common to all debhelper commands.
 .TP
 .B \-uparams, \--dpkg-gencontrol-params=params
+.TP
+.B \-\- params
 Pass "params" to 
 .BR dpkg-gencontrol (1)
 .SH ENVIRONMENT
index 187e134c4cec578e9f76460106c57568dd1bdc4a..5325f7b11e647cb7818b223dcca965f668bd4ca7 100755 (executable)
@@ -43,21 +43,23 @@ foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
                "$TMP/usr/share/doc/$PACKAGE/$changelog_name");
 
        if ($upstream) {
+               my $link_to;
                if ($upstream=~m/\.html?$/i) {
                        # HTML changelog
                        doit("install","-o","root","-g","root","-p","-m644",
                                $upstream,"$TMP/usr/share/doc/$PACKAGE/changelog.html");
-                       doit("ln", "-sf", 'changelog.html',
-                               "$TMP/usr/share/doc/$PACKAGE/changelog");
+                       complex_doit("lynx -dump $upstream > $TMP/usr/share/doc/$PACKAGE/changelog");
+                       $link_to='changelog.html';
                }
                else {
                        doit("install","-o","root","-g","root","-p","-m644",
                                $upstream,"$TMP/usr/share/doc/$PACKAGE/changelog");
+                       $link_to='changelog';                           
                }
                if ($dh{K_FLAG}) {
                        # Install symlink to original name of the upstream changelog file.
                        # Use basename in case original file was in a subdirectory or something.
-                       doit("ln","-sf","changelog","$TMP/usr/share/doc/$PACKAGE/".Dh_Lib::basename($upstream));
+                       doit("ln","-sf",$link_to,"$TMP/usr/share/doc/$PACKAGE/".Dh_Lib::basename($upstream));
                }
        }
 }
index 6a0e4758d40e8f646b27f59931dc2c51d9ea55ae..0b3841263dc02778c908a359ad7bf8eaad94958c 100644 (file)
@@ -3,7 +3,7 @@
 dh_installinit \- install init scripts into package build directories
 .SH SYNOPSIS
 .B dh_installinit
-.I "[debhelper options] [--init-script=scriptname] [-n] [-r] [-d] [-uparams]"
+.I "[debhelper options] [--init-script=scriptname] [-n] [-r] [-d] [-uparams] -- [params]"
 .SH "DESCRIPTION"
 dh_installinit is a debhelper program that is responsible for installing
 init scripts into package build directories. 
@@ -37,6 +37,8 @@ for daemons with names ending in "d". (Note: this takes precedence over
 the --init-script parameter described below.)
 .TP
 .B \-uparams, \--update-rcd-params=params
+.TP
+.B \-\- params
 Pass "params" to 
 .BR update-rc.d (8)
 If not specified, "defaults" will be passed to
index 5e01d0864ac0a289668cc232dd2ce0585648dc10..20427969f9a07d252dfb2f2755b010fbe4e4b93d 100644 (file)
@@ -3,7 +3,7 @@
 dh_shlibdeps \- calculate shared library dependancies
 .SH SYNOPSIS
 .B dh_shlibdeps
-.I "[debhelper options] [-uparams] [-ldirectory]"
+.I "[debhelper options] [-ldirectory] [-uparams] [-- params]"
 .SH "DESCRIPTION"
 dh_shlibdeps is a debhelper program that is responsible for calculating
 shared library dependancies for all executables found in the package build
@@ -20,6 +20,8 @@ See
 for a list of options common to all debhelper commands.
 .TP
 .B \-uparams, \--dpkg-shlibdeps-params=params
+.TP
+.B \-\- params
 Pass "params" to 
 .BR dpkg-shlibdeps (1)
 .TP
index 4ca72a1cf0ab97491720ec8bad1c048cc3fa7936..b7b3152fc1842fa0a9837429031fb1d5c4235047 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,53 +6,71 @@
 # 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/share/debhelper" }
+use Dh_Lib;
+init();
 
-for PACKAGE in $DH_DOPACKAGES; do
-       TMP=`tmpdir $PACKAGE`
-       EXT=`pkgext $PACKAGE`
+foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
+       $TMP=tmpdir($PACKAGE);
+       $suid=pkgfile($PACKAGE,"suid");
 
-       files=""
+       @files=();
+       if ($suid) {
+               @files=filearray($suid);
+       }
 
-       if [ -e debian/${EXT}suid ]; then
-               files=`tr "\n" " " < debian/${EXT}suid`
-       fi
+       if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
+               push @files, @ARGV;
+       }
 
-       if [ "$PACKAGE" = "$MAINPACKAGE" -a "$*" ]; then
-               files="$* $files"
-       fi
-
-       if [ ! "$files" -a ! -e debian/${EXT}suid ]; then
+       if (! @files && ! $suid) {
                # No files specified (and no empty debian/suid file), so
                # guess what files to process.
-               files=`find debian/$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="debian/$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 debian/$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"
-               done
-       fi
-done
+               $tostrip="/";
+       }
+
+       foreach $file (@files) {
+               # Strip leading $tostrip from $file.
+               $file=~s/^$tostrip//;
+
+               if (! -e "$TMP/$file") {
+                       error("\"$TMP/$file\" does not exist.");
+               }
+               
+               # 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");
+               # Now come up with the user and group names for the uid and gid.
+               $user=getpwuid($uid);
+               if (! defined $user) {
+                       warning("$file has odd uid $uid, not in /etc/passwd");
+                       $user=$uid;
+               }
+               $group=getgrgid($gid);
+               if (! defined $group) {
+                       warning("$file has odd gid $gid not in /etc/group");
+                       $group=$gid;
+               }
+               # Note that I have to print mode in ocal, stripping file type.
+               $sedstr=sprintf("s:#FILE#:$file:;s/#PACKAGE#/$PACKAGE/;s/#OWNER#/$user/;s/#GROUP#/$group/;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 98b4cd2951a3abc6728e6cd1c9739c50df4b4b4b..bf73cc57a5cb1ae58ec92b481c0b2c70ce2065b7 100644 (file)
@@ -34,6 +34,8 @@ The autoscript() function (see below) is one easy way to do this.
 dh_installdeb is an exception, it will run after the other commands and
 merge these modifications into the actual postinst scripts.
 
+Debhelper programs should default to doing exactly what policy says to do.
+
 There are always exceptions. Just ask me.
 
 Introducing Dh_Lib.pm: