Переглянути джерело

dpkg-buildpackage: add a new -R option and allow parameters in -r

* scripts/dpkg-buildpackage.pl: Add a new -R option to be able to replace
"debian/rules" by something else. The replacement command can contain
parameters (and thus spaces). Fix -r option to also accept parameters.
* man/dpkg-buildpackage.1: Document the new option and the changed
behaviour of -r.
Raphael Hertzog 18 роки тому
батько
коміт
c2acc4de8e
4 змінених файлів з 40 додано та 18 видалено
  1. 8 0
      ChangeLog
  2. 2 0
      debian/changelog
  3. 15 7
      man/dpkg-buildpackage.1
  4. 15 11
      scripts/dpkg-buildpackage.pl

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2008-01-29  Raphael Hertzog  <hertzog@debian.org>
+
+	* scripts/dpkg-buildpackage.pl: Add a new -R option to be able to replace
+	"debian/rules" by something else. The replacement command can contain
+	parameters (and thus spaces). Fix -r option to also accept parameters.
+	* man/dpkg-buildpackage.1: Document the new option and the changed
+	behaviour of -r.
+
 2008-01-28  Guillem Jover  <guillem@debian.org>
 2008-01-28  Guillem Jover  <guillem@debian.org>
 
 
 	* getopt: Rename to ...
 	* getopt: Rename to ...

+ 2 - 0
debian/changelog

@@ -16,6 +16,8 @@ dpkg (1.14.17) UNRELEASED; urgency=low
     build-depends/conflicts. Closes: #114774
     build-depends/conflicts. Closes: #114774
   * Include list of libraries in dpkg-gensymbols' warning about new/lost
   * Include list of libraries in dpkg-gensymbols' warning about new/lost
     libraries.
     libraries.
+  * Add -R option to dpkg-buildpackage so that one can replace the usual
+    "debian/rules" by something else. Closes: #355654
 
 
   [ Updated manpages translations ]
   [ Updated manpages translations ]
   * German (Helge Kreutzmann).
   * German (Helge Kreutzmann).

+ 15 - 7
man/dpkg-buildpackage.1

@@ -117,24 +117,32 @@ command it executes with
 if one has been specified. Otherwise, if none has been specified,
 if one has been specified. Otherwise, if none has been specified,
 \fBfakeroot\fP will be used by default, if the command is present.
 \fBfakeroot\fP will be used by default, if the command is present.
 .I gain-root-command
 .I gain-root-command
-should be the name of a program on the
+should start with the name of a program on the
 .B PATH
 .B PATH
 and will get as arguments the name of the real command to run and the
 and will get as arguments the name of the real command to run and the
 arguments it should take.
 arguments it should take.
 .I gain-root-command
 .I gain-root-command
-should not contain spaces or any other shell metacharacters.
-.\" what happens, if it contains spaces? (hs)
+can include parameters (they must be space-separated) but no shell
+metacharacters.
 .I gain-root-command
 .I gain-root-command
 might typically be
 might typically be
 .BR fakeroot ", " sudo ", " super " or " really .
 .BR fakeroot ", " sudo ", " super " or " really .
 .B su
 .B su
-is not suitable, since it requires a
-.B \-c
-option to run a command and even then it can only invoke the user's
-shell with
+is not suitable, since it can only invoke the user's shell with
 .B \-c
 .B \-c
 instead of passing arguments individually to the command to be run.
 instead of passing arguments individually to the command to be run.
 .TP
 .TP
+.BI \-R rules-file
+Building a Debian package usually involves invoking
+.B debian/rules
+as a command with several standard parameters. With this option it's
+possible to use another program invocation to build the package (it can
+include space separated parameters).
+Alternatively it can be used to execute the standard rules file with
+another make program (for example by using
+.B /usr/local/bin/make -f debian/rules
+as \fIrules-file\fR).
+.TP
 .BI \-p sign-command
 .BI \-p sign-command
 When
 When
 .B dpkg\-buildpackage
 .B dpkg\-buildpackage

+ 15 - 11
scripts/dpkg-buildpackage.pl

@@ -38,6 +38,7 @@ Usage: %s [<options> ...]
 Options:
 Options:
   -r<gain-root-command>
   -r<gain-root-command>
                  command to gain root privileges (default is fakeroot).
                  command to gain root privileges (default is fakeroot).
+  -R<rules>      rules file to execute (default is debian/rules).
   -p<sign-command>
   -p<sign-command>
   -d             do not check build dependencies and conflicts.
   -d             do not check build dependencies and conflicts.
   -D             check build dependencies and conflicts.
   -D             check build dependencies and conflicts.
@@ -78,7 +79,8 @@ Options:
 "), $progname;
 "), $progname;
 }
 }
 
 
-my $rootcommand = '';
+my @debian_rules = ("debian/rules");
+my @rootcommand = ();
 my $signcommand = '';
 my $signcommand = '';
 if ( ( ($ENV{GNUPGHOME} && -e $ENV{GNUPGHOME})
 if ( ( ($ENV{GNUPGHOME} && -e $ENV{GNUPGHOME})
        || ($ENV{HOME} && -e "$ENV{HOME}/.gnupg") )
        || ($ENV{HOME} && -e "$ENV{HOME}/.gnupg") )
@@ -114,7 +116,7 @@ while (@ARGV) {
     } elsif (/^-j(\d*)$/) {
     } elsif (/^-j(\d*)$/) {
 	$parallel = $1 || '-1';
 	$parallel = $1 || '-1';
     } elsif (/^-r(.*)$/) {
     } elsif (/^-r(.*)$/) {
-	$rootcommand = $1;
+	@rootcommand = split /\s+/, $1;
     } elsif (/^-p(.*)$/) {
     } elsif (/^-p(.*)$/) {
 	$signcommand = $1;
 	$signcommand = $1;
     } elsif (/^-k(.*)$/) {
     } elsif (/^-k(.*)$/) {
@@ -195,23 +197,25 @@ while (@ARGV) {
     } elsif (/^-E$/) {
     } elsif (/^-E$/) {
 	$warnable_error = 0;
 	$warnable_error = 0;
 	push @passopts, '-E';
 	push @passopts, '-E';
+    } elsif (/^-R(.*)$/) {
+	@debian_rules = split /\s+/, $1;
     } else {
     } else {
 	usageerr(_g("unknown option or argument %s"), $_);
 	usageerr(_g("unknown option or argument %s"), $_);
     }
     }
 }
 }
 
 
 if ($< == 0) {
 if ($< == 0) {
-    warning(_g("using a gain-root-command while being root")) if ($rootcommand);
+    warning(_g("using a gain-root-command while being root")) if (@rootcommand);
 } else {
 } else {
-    $rootcommand ||= 'fakeroot';
+    push @rootcommand, "fakeroot" unless @rootcommand;
 
 
-    if (!testcommand($rootcommand)) {
-	if ($rootcommand eq 'fakeroot') {
+    if (!testcommand($rootcommand[0])) {
+	if ($rootcommand[0] eq 'fakeroot') {
 	    error(_g("fakeroot not found, either install the fakeroot\n" .
 	    error(_g("fakeroot not found, either install the fakeroot\n" .
 	             "package, specify a command with the -r option, " .
 	             "package, specify a command with the -r option, " .
 	             "or run this as root"));
 	             "or run this as root"));
 	} else {
 	} else {
-	    error(_g("gain-root-commmand '%s' not found"), $rootcommand);
+	    error(_g("gain-root-commmand '%s' not found"), $rootcommand[0]);
 	}
 	}
     }
     }
 }
 }
@@ -308,7 +312,7 @@ if ($checkbuilddep) {
 }
 }
 
 
 unless ($noclean) {
 unless ($noclean) {
-    withecho($rootcommand, 'debian/rules', 'clean');
+    withecho(@rootcommand, @debian_rules, 'clean');
 }
 }
 unless ($binaryonly) {
 unless ($binaryonly) {
     chdir('..') or failure('chdir ..');
     chdir('..') or failure('chdir ..');
@@ -319,8 +323,8 @@ unless ($binaryonly) {
     chdir($dir) or failure("chdir $dir");
     chdir($dir) or failure("chdir $dir");
 }
 }
 unless ($sourceonly) {
 unless ($sourceonly) {
-    withecho('debian/rules', 'build');
-    withecho($rootcommand, 'debian/rules', $binarytarget);
+    withecho(@debian_rules, 'build');
+    withecho(@rootcommand, @debian_rules, $binarytarget);
 }
 }
 if ($usepause &&
 if ($usepause &&
     ($signchanges || ( !$binaryonly && $signsource )) ) {
     ($signchanges || ( !$binaryonly && $signsource )) ) {
@@ -400,7 +404,7 @@ if ($signchanges && signfile("$pva.changes")) {
 }
 }
 
 
 if ($cleansource) {
 if ($cleansource) {
-    withecho($rootcommand, 'debian/rules', 'clean');
+    withecho(@rootcommand, @debian_rules, 'clean');
 }
 }
 
 
 print "$progname: $srcmsg\n";
 print "$progname: $srcmsg\n";