Bug#355654: dpkg-buildpackage to be able to override /usr/bin/make -f in debian/rules

2008-01-29 Thread Frank Lichtenheld
On Tue, Jan 29, 2008 at 08:58:25AM +0100, Raphael Hertzog wrote:
> On Sun, 20 Jan 2008, Frank Lichtenheld wrote:
> > Hrm, the whole split(/\s+/) is somewhat ugly (and BTW not documented for the
> > -R option). Please do not commit before the upcoming upload, to give
> > us a chance to think that over.
> 
> I updated my patch to document better the option parsing (patch attached).
> I'll push the change if nobody has any better idea.

Fine by me. Haven't had any better ideas during the last week.

Gruesse,
-- 
Frank Lichtenheld <[EMAIL PROTECTED]>
www: http://www.djpig.de/




-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Bug#355654: dpkg-buildpackage to be able to override /usr/bin/make -f in debian/rules

2008-01-29 Thread Raphael Hertzog
On Sun, 20 Jan 2008, Frank Lichtenheld wrote:
> Hrm, the whole split(/\s+/) is somewhat ugly (and BTW not documented for the
> -R option). Please do not commit before the upcoming upload, to give
> us a chance to think that over.

I updated my patch to document better the option parsing (patch attached).
I'll push the change if nobody has any better idea.

Cheers,
-- 
Raphaël Hertzog

Le best-seller français mis à jour pour Debian Etch :
http://www.ouaza.com/livre/admin-debian/
commit 9eb64576efe803d8ca93ee11d19dc47b5fb24f87
Author: Raphael Hertzog <[EMAIL PROTECTED]>
Date:   Sat Jan 19 21:53:18 2008 +0100

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.

diff --git a/man/dpkg-buildpackage.1 b/man/dpkg-buildpackage.1
index 2a84119..f12cb07 100644
--- a/man/dpkg-buildpackage.1
+++ b/man/dpkg-buildpackage.1
@@ -117,24 +117,32 @@ command it executes with
 if one has been specified. Otherwise, if none has been specified,
 \fBfakeroot\fP will be used by default, if the command is present.
 .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
 and will get as arguments the name of the real command to run and the
 arguments it should take.
 .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
 might typically be
 .BR fakeroot ", " sudo ", " super " or " really .
 .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
 instead of passing arguments individually to the command to be run.
 .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
 When
 .B dpkg\-buildpackage
diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl
index ebb9247..7498d4f 100755
--- a/scripts/dpkg-buildpackage.pl
+++ b/scripts/dpkg-buildpackage.pl
@@ -38,6 +38,7 @@ Usage: %s [ ...]
 Options:
   -r
  command to gain root privileges (default is fakeroot).
+  -R  rules file to execute (default is debian/rules).
   -p
   -d do not check build dependencies and conflicts.
   -D check build dependencies and conflicts.
@@ -78,7 +79,8 @@ Options:
 "), $progname;
 }
 
-my $rootcommand = '';
+my @debian_rules = ("debian/rules");
+my @rootcommand = ();
 my $signcommand = '';
 if ( ( ($ENV{GNUPGHOME} && -e $ENV{GNUPGHOME})
|| ($ENV{HOME} && -e "$ENV{HOME}/.gnupg") )
@@ -114,7 +116,7 @@ while (@ARGV) {
 } elsif (/^-j(\d*)$/) {
$parallel = $1 || '-1';
 } elsif (/^-r(.*)$/) {
-   $rootcommand = $1;
+   @rootcommand = split /\s+/, $1;
 } elsif (/^-p(.*)$/) {
$signcommand = $1;
 } elsif (/^-k(.*)$/) {
@@ -195,23 +197,25 @@ while (@ARGV) {
 } elsif (/^-E$/) {
$warnable_error = 0;
push @passopts, '-E';
+} elsif (/^-R(.*)$/) {
+   @debian_rules = split /\s+/, $1;
 } else {
usageerr(_g("unknown option or argument %s"), $_);
 }
 }
 
 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 {
-$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" .
 "package, specify a command with the -r option, " .
 "or run this as root"));
} 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) {
-withecho($rootcommand, 'debian/rules', 'clean');
+withecho(@rootcommand, @debian_rules, 'clean');
 }
 unless ($binaryonly) {
 chdir('..')

Bug#355654: dpkg-buildpackage to be able to override /usr/bin/make -f in debian/rules

2008-01-20 Thread Raphael Hertzog
On Sun, 20 Jan 2008, Frank Lichtenheld wrote:
> > We have the -j command now, so it's much less useful. Still I have created
> > another patch that implements what I explained above: it offers a -R
> > option to replace "debian/rules" by whatever you want.
> > 
> > (the other patches were meant for the old shell version of
> > dpkg-buildpackage anyway)
> > 
> > Frank, any comments or is it safe to commit?
> 
> Hrm, the whole split(/\s+/) is somewhat ugly 

It's not very nice but works in 99% of the use case that I can imagine.
The alternative is to accept those options multiple times:
-R/usr/local/bin/make -R-f -Rdebian/rules

I didn't find that to be nicer.

> (and BTW not documented for the -R option). 

It's indirectly documented by the fact that one can use a value like the
example given ("/usr/local/bin/make -f debian/rules") which contains
spaces. If you have something more specific in mind, please feel free to
suggest it.

> Please do not commit before the upcoming upload, to give
> us a chance to think that over.

Sure, I didn't plan to commit before anyway. I don't want to introduce
bugs at the last minute. :)

Cheers,
-- 
Raphaël Hertzog

Le best-seller français mis à jour pour Debian Etch :
http://www.ouaza.com/livre/admin-debian/





Bug#355654: dpkg-buildpackage to be able to override /usr/bin/make -f in debian/rules

2008-01-19 Thread Frank Lichtenheld
On Sat, Jan 19, 2008 at 10:00:37PM +0100, Raphael Hertzog wrote:
> On Tue, 07 Mar 2006, Davor Ocelic wrote:
> > A simple patch to allow this behavior is attached. It adds the -M
> > option which should be used like say:
> > 
> >   dpkg-buildpackage -M'/usr/local/bin/make -f'
> 
> I didn't like this intermediary command. What you really wanted to do is
> not use "debian/rules" as build command but a custom command that is
> "/usr/local/bin/make -f debian/rules".

That is indeed better than the original proposal, IMHO.

> On Sun, 26 Aug 2007, Robert Millan wrote:
> > I'm attaching an updated version of Davor's patch (against 1.14.5).
> > Note that this allows to do very useful things such as:
> >   dpkg-buildpackage -B -rfakeroot -M"make -j `getconf _NPROCESSORS_ONLN` -f"
> 
> We have the -j command now, so it's much less useful. Still I have created
> another patch that implements what I explained above: it offers a -R
> option to replace "debian/rules" by whatever you want.
> 
> (the other patches were meant for the old shell version of
> dpkg-buildpackage anyway)
> 
> Frank, any comments or is it safe to commit?

Hrm, the whole split(/\s+/) is somewhat ugly (and BTW not documented for the
-R option). Please do not commit before the upcoming upload, to give
us a chance to think that over.

Gruesse,
-- 
Frank Lichtenheld <[EMAIL PROTECTED]>
www: http://www.djpig.de/




-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Bug#355654: dpkg-buildpackage to be able to override /usr/bin/make -f in debian/rules

2008-01-19 Thread Raphael Hertzog
Hi,

On Tue, 07 Mar 2006, Davor Ocelic wrote:
> A simple patch to allow this behavior is attached. It adds the -M
> option which should be used like say:
> 
>   dpkg-buildpackage -M'/usr/local/bin/make -f'

I didn't like this intermediary command. What you really wanted to do is
not use "debian/rules" as build command but a custom command that is
"/usr/local/bin/make -f debian/rules".

On Sun, 26 Aug 2007, Robert Millan wrote:
> I'm attaching an updated version of Davor's patch (against 1.14.5).
> Note that this allows to do very useful things such as:
>   dpkg-buildpackage -B -rfakeroot -M"make -j `getconf _NPROCESSORS_ONLN` -f"

We have the -j command now, so it's much less useful. Still I have created
another patch that implements what I explained above: it offers a -R
option to replace "debian/rules" by whatever you want.

(the other patches were meant for the old shell version of
dpkg-buildpackage anyway)

Frank, any comments or is it safe to commit?

Cheers,
-- 
Raphaël Hertzog

Le best-seller français mis à jour pour Debian Etch :
http://www.ouaza.com/livre/admin-debian/
>From 1b77732a7ab316ca7d71f8db62b5079aa5915adc Mon Sep 17 00:00:00 2001
From: Raphael Hertzog <[EMAIL PROTECTED]>
Date: Sat, 19 Jan 2008 21:53:18 +0100
Subject: [PATCH] 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.
---
 man/dpkg-buildpackage.1  |   20 +---
 scripts/dpkg-buildpackage.pl |   26 +++---
 2 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/man/dpkg-buildpackage.1 b/man/dpkg-buildpackage.1
index 2a84119..e0a16b7 100644
--- a/man/dpkg-buildpackage.1
+++ b/man/dpkg-buildpackage.1
@@ -117,24 +117,30 @@ command it executes with
 if one has been specified. Otherwise, if none has been specified,
 \fBfakeroot\fP will be used by default, if the command is present.
 .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
 and will get as arguments the name of the real command to run and the
 arguments it should take.
 .I gain-root-command
-should not contain spaces or any other shell metacharacters.
-.\" what happens, if it contains spaces? (hs)
+can include parameters but no shell metacharacters.
 .I gain-root-command
 might typically be
 .BR fakeroot ", " sudo ", " super " or " really .
 .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
 instead of passing arguments individually to the command to be run.
 .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 executable as rules file to build the package.
+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
 When
 .B dpkg\-buildpackage
diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl
index a841e3d..2c8911f 100755
--- a/scripts/dpkg-buildpackage.pl
+++ b/scripts/dpkg-buildpackage.pl
@@ -38,6 +38,7 @@ Usage: %s [ ...]
 Options:
   -r
  command to gain root privileges (default is fakeroot).
+  -R  rules file to execute (default is debian/rules).
   -p
   -d do not check build dependencies and conflicts.
   -D check build dependencies and conflicts.
@@ -86,7 +87,8 @@ sub testcommand {
 return $fullcmd && -x $fullcmd;
 }
 
-my $rootcommand = '';
+my @debian_rules = ("debian/rules");
+my @rootcommand = ();
 my $signcommand = '';
 if ( ( ($ENV{GNUPGHOME} && -e $ENV{GNUPGHOME})
|| ($ENV{HOME} && -e "$ENV{HOME}/.gnupg") )
@@ -122,7 +124,7 @@ while (@ARGV) {
 } elsif (/^-j(\d*)$/) {
 	$parallel = $1 || '-1';
 } elsif (/^-r(.*)$/) {
-	$rootcommand = $1;
+	@rootcommand = split /\s+/, $1;
 } elsif (/^-p(.*)$/) {
 	$signcommand = $1;
 } elsif (/^-k(.*)$/) {
@@ -203,23 +205,25 @@ while (@ARGV) {
 } elsif (/^-E$/) {
 	$warnable_error = 0;
 	push @passopts, '-E';
+} elsif (/^-R(.*)$/) {
+	@debian_rules = split /\s+/, $1;
 } else {
 	usageerr(_g("unknown option or argument %s"), $_);
 }
 }
 
 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 {
-$rootcommand ||= 'fakeroot';
+push @rootcommand, "fakeroot" unless @rootcommand;
 
-if (!testcommand($rootcommand)) {
-	if ($rootcommand eq

Bug#355654: dpkg-buildpackage to be able to override /usr/bin/make -f in debian/rules

2006-03-06 Thread Davor Ocelic
Package: dpkg
Version: 1.13.13
Severity: wishlist
Tags: patch


dpkg-buildpackage should be able to overwrite the hardcoded
make path (#!/usr/bin/make -f) in debian/rules file.

A simple patch to allow this behavior is attached. It adds the -M
option which should be used like say:

  dpkg-buildpackage -M'/usr/local/bin/make -f'

Rgds,
-doc


--- ./bin/dpkg-buildpackage Tue Feb 21 19:09:23 CET 2006
+++ patch/bin/dpkg-buildpackage Mon Mar 06 02:39:45 CET 2006
@@ -16,9 +16,10 @@
 Usage: dpkg-buildpackage [options]
 Options: -r
  -p
--ddo not check build dependencies and conflicts
--Dcheck build dependencies and conflicts
--k the key to use for signing
+ -M
+ -ddo not check build dependencies and conflicts
+ -Dcheck build dependencies and conflicts
+ -k the key to use for signing
  -sgpg the sign-command is called like GPG
  -spgp the sign-command is called like PGP 
  -us   unsigned source
@@ -47,6 +48,7 @@
 }
 
 rootcommand=''
+makecommand=''
 signcommand=""
 if ( [ -e $GNUPGHOME/secring.gpg ] || [ -e $HOME/.gnupg/secring.gpg ] ) && \
command -v gpg > /dev/null 2>&1; then
@@ -78,6 +80,7 @@
-h) usageversion; exit 0 ;;
-r*)rootcommand="$value" ;;
-p*)signcommand="$value" ;;
+   -M*)makecommand="$value" ;;
-k*)signkey="$value" ;;
-d) checkbuilddep=false ;;
-D) checkbuilddep=true ;;
@@ -190,14 +193,14 @@
 if [ -n "$desc"]; then set -- "$@" "-C$desc"   ; fi
 
 if [ x$noclean != xtrue ]; then
-   withecho $rootcommand debian/rules clean
+   withecho $rootcommand $makecommand debian/rules clean
 fi
 if [ x$binaryonly = x ]; then
cd ..; withecho dpkg-source $passopts $diffignore $tarignore -b 
"$dirn"; cd "$dirn"
 fi
 if [ x$sourceonly = x ]; then
-   withecho debian/rules build 
-   withecho $rootcommand debian/rules $binarytarget
+   withecho $makecommand debian/rules build 
+   withecho $rootcommand $makecommand debian/rules $binarytarget
 fi
 if [ "$usepause" = "true" ] && \
( [ "$signchanges" != ":" ] || ( [ -z "$binaryonly" ] && [ "$signsource" != 
":" ] ) ) ; then
@@ -245,7 +248,7 @@
 $signchanges "$pva.changes"
 
 if $cleansource; then
-   withecho $rootcommand debian/rules clean
+   withecho $rootcommand $makecommand debian/rules clean
 fi
 
 echo "dpkg-buildpackage: $srcmsg"



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]