[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[RFC] dpkg-buildpackage: Convert from Shell to Perl



This will make it easier to add more features in the
future and easier to give a consistent user experience
(e.g. regarding l10n and output formatting).

Currently this should just be a 1:1 conversion without
any huge changes.

Signed-off-by: Frank Lichtenheld <djpig@debian.org>
---
 ChangeLog                    |    5 +
 scripts/Makefile.am          |    2 +-
 scripts/dpkg-buildpackage.pl |  423 ++++++++++++++++++++++++++++++++++++++++++
 scripts/dpkg-buildpackage.sh |  297 -----------------------------
 4 files changed, 429 insertions(+), 298 deletions(-)
 create mode 100644 scripts/dpkg-buildpackage.pl
 delete mode 100755 scripts/dpkg-buildpackage.sh

(Since this is all in a single commit for now, I'm not yet publishing it
in a public git repo but only send this patch instead)

I would like to get some comments about the usefulness of this move.
It seems to work at least for all common usages but requires some
testing and polishing still.

As can seen from the diffstat above, the overall code size increases,
but AFAICT this is mostly due to formatting and due to the fact that
I refrained from using `command` style calls in favor for the
open '-|' command. Also since I have no "set -e" in Perl the error
checking tends to get a little more verbose. Speed is not really
an argument either way, the build itself will always take way more
time, by some orders of magnitude.

I really think this would make it easier in the long run to add features
like #440636 (e.g. compatibility with DEB_BUILD_OPTIONS=parallel=n) and
#4655 (i.e. more sanity checks before starting with the build). It also
would it make easier to profit from advances in the move to real Perl
modules. Also it enables l10n without much (programming) effort.

What do you think?

diff --git a/ChangeLog b/ChangeLog
index 043aec3..a2affb4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,11 @@
 
 	* scripts/Dpkg.pm: Make the regex for determining
 	$progname more robust.
+	
+	* scripts/dpkg-buildpackage.sh: Move to...
+	* scripts/dpkg-buildpackage.pl: Convert from
+	Shell to Perl.
+	* scripts/Makefile.am: Adapt to move.
 
 2007-09-18  Guillem Jover  <guillem@debian.org>
 
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 454db54..ed194dc 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -31,7 +31,7 @@ EXTRA_DIST = \
 	README.alternatives \
 	822-date.pl \
 	dpkg-architecture.pl \
-	dpkg-buildpackage.sh \
+	dpkg-buildpackage.pl \
 	dpkg-checkbuilddeps.pl \
 	dpkg-distaddfile.pl \
 	dpkg-genchanges.pl \
diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl
new file mode 100644
index 0000000..52374ea
--- /dev/null
+++ b/scripts/dpkg-buildpackage.pl
@@ -0,0 +1,423 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Cwd;
+use File::Basename;
+
+use Dpkg;
+use Dpkg::Gettext;
+
+push (@INC, $dpkglibdir);
+require 'controllib.pl';
+
+textdomain("dpkg-dev");
+
+sub showversion {
+    printf _g("Debian %s version %s.\n"), $progname, $version;
+
+    print _g("
+Copyright (C) 1996 Ian Jackson.
+Copyright (C) 2000 Wichert Akkerman
+Copyright (C) 2007 Frank Lichtenheld");
+
+    print _g("
+This is free software; see the GNU General Public Licence version 2 or
+later for copying conditions. There is NO warranty.
+");
+}
+
+sub usage {
+	printf _g("
+Usage: %s [<options> ...]
+
+Options:
+  -r<gain-root-command>
+                 command to gain root privileges (default is fakeroot if it
+                 exists).
+  -p<sign-command>
+  -d             do not check build dependencies and conflicts.
+  -D             check build dependencies and conflicts.
+  -k<keyid>      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.
+  -uc            unsigned changes.
+  -a<arch>       Debian architecture we build for (implies -d).
+  -b             binary-only, do not build source. } also passed to
+  -B             binary-only, no arch-indep files. } dpkg-genchanges
+  -S             source only, no binary files.     }
+  -t<system>     set GNU system type.           } passed to dpkg-architecture
+  -v<version>    changes since version <version>.      }
+  -m<maint>      maintainer for package is <maint>.    }
+  -e<maint>      maintainer for release is <maint>.    } only passed
+  -C<descfile>   changes are described in <descfile>.  } to dpkg-genchangs
+  -si (default)  src includes orig for rev. 0 or 1.    }
+  -sa            uploaded src always includes orig.    }
+  -sd            uploaded src is diff and .dsc only.   }
+  -sn            force Debian native source format.      } only passed
+  -s[sAkurKUR]   see dpkg-source for explanation.        } to dpkg-source
+  -nc            do not clean source tree (implies -b).
+  -tc            clean source tree when finished.
+  -ap            add pause before starting signature process.
+  -W             turn certain errors into warnings.       } passed to
+  -E             when -W is turned on, -E turned it off.  } dpkg-source
+  -i[<regex>]    ignore diffs of files matching regex.    } only passed
+  -I<filename>   filter out files when building tarballs. } to dpkg-source
+  --admindir=<directory>
+                 change the administrative directory.
+  -h, --help     show this help message.
+      --version  show the version.
+"), $progname;
+}
+
+sub testcommand {
+    my ($cmd) = @_;
+
+    return -x "/usr/bin/$cmd";
+}
+
+my $rootcommand = '';
+if (testcommand('fakeroot')) {
+    $rootcommand = 'fakeroot';
+}
+
+my $signcommand = '';
+if ( ( ($ENV{GNUPGHOME} && -e $ENV{GNUPGHOME})
+       || ($ENV{HOME} && -e "$ENV{HOME}/.gnupg") )
+     && testcommand('gpg')) {
+	 $signcommand = 'gpg';
+} elsif (testcommand('pgp')) {
+	$signcommand = 'pgp'
+}
+
+my ($admindir, $signkey, $forcesigninterface, $usepause, $noclean,
+    $warnable_errors, $sourcestyle, $cleansource,
+    $binaryonly, $sourceonly, $since, $maint,
+    $changedby, $desc);
+my (@checkbuilddep_args, @passopts, @tarignore);
+my $checkbuilddep = 1;
+my $signsource = 1;
+my $signchanges = 1;
+my $diffignore = '';
+my $binarytarget = 'binary';
+my $targetarch = my $targetgnusystem = '';
+
+while (@ARGV) {
+    $_ = shift @ARGV;
+
+    if (/^(--help|-h)$/) {
+	usage;
+	exit 0;
+    } elsif (/^--version$/) {
+	showversion;
+	exit 0;
+    } elsif (/^--admindir=(.*)$/) {
+	$admindir = $1;
+    } elsif (/^-r(.*)$/) {
+	$rootcommand = $1;
+    } elsif (/^-p(.*)$/) {
+	$signcommand = $1;
+    } elsif (/^-k(.*)$/) {
+	$signkey = $1;
+    } elsif (/^-([dD])$/) {
+	$checkbuilddep = ($1 eq 'D');
+    } elsif (/^-s(gpg|pgp)$/) {
+	$forcesigninterface = $1;
+    } elsif (/^-us$/) {
+	$signsource = 0;
+    } elsif (/^-uc$/) {
+	$signchanges = 0;
+    } elsif (/^-ap$/) {
+	$usepause = 1;
+    } elsif (/^-a(.*)$/) {
+	$targetarch = $1;
+	$checkbuilddep = 0;
+    } elsif (/^-s[iad]$/) {
+	$sourcestyle = $_;
+    } elsif (/^-s[nsAkurKUR]$/) {
+	push @passopts, $_; # passed to dpkg-source
+    } elsif (/^-i.*$/) {
+	$diffignore = $_;
+    } elsif (/^-I.*$/) {
+	push @tarignore, $_;
+    } elsif (/^-tc$/) {
+	$cleansource = 1;
+    } elsif (/^-t(.*)$/) {
+	$targetgnusystem = $1; # Order DOES matter!
+    } elsif (/^-nc$/) {
+	$noclean = 1;
+	if ($sourceonly) {
+	    usageerr(sprintf(_g("cannot combine %s and %s"), '-nc', '-S'));
+	}
+	unless ($binaryonly) {
+	    $binaryonly = '-b';
+	}
+    } elsif (/^-b$/) {
+	$binaryonly = '-b';
+	@checkbuilddep_args = ();
+	$binarytarget = 'binary';
+	if ($sourceonly) {
+	    usageerr(sprintf(_g("cannot combine %s and %s"), '-b', '-S'));
+	}
+    } elsif (/^-B$/) {
+	$binaryonly = '-B';
+	@checkbuilddep_args = ('-B');
+	$binarytarget = 'binary-arch';
+	if ($sourceonly) {
+	    usageerr(sprintf(_g("cannot combine %s and %s"), '-B', '-S'));
+	}
+    } elsif (/^-S$/) {
+	$sourceonly = '-S';
+	$checkbuilddep = 0;
+	if ($binaryonly) {
+	    usageerr(sprintf(_g("cannot combine %s and %s"), $binaryonly, '-S'));
+	}
+    } elsif (/^-v(.*)$/) {
+	$since = $1;
+    } elsif (/^-m(.*)$/) {
+	$maint = $1;
+    } elsif (/^-e(.*)$/) {
+	$changedby = $1;
+    } elsif (/^-C(.*)$/) {
+	$desc = $1;
+    } elsif (/^-W$/) {
+	$warnable_errors = 1;
+	push @passopts, '-W';
+    } elsif (/^-E$/) {
+	$warnable_errors = 0;
+	push @passopts, '-E';
+    } else {
+	usageerr(sprintf(_g("unknown option or argument %s"), $_));
+    }
+}
+
+unless ($signcommand) {
+    $signsource = 0;
+    $signchanges = 0;
+}
+
+my $signinterface;
+if ($forcesigninterface) {
+    $signinterface = $forcesigninterface;
+} else {
+    $signinterface = $signcommand;
+}
+
+if ($signcommand && ($signinterface !~ /^(gpg|pgp)$/)) {
+    warning(_g("unknown sign command, assuming pgp style interface"));
+}
+
+my $cwd = cwd();
+my $dir = basename($cwd);
+
+my %changes;
+open CHANGELOG, '-|', 'dpkg-parsechangelog' or syserr('dpkg-parsechangelog');
+# until we have a better parsecdata function this
+# should suffice
+while ($_ = <CHANGELOG>) {
+    chomp;
+    /^(\S+):\s*(.*)$/ && do {
+	$changes{lc $1} = $2;
+    };
+}
+close CHANGELOG or syserr('dpkg-parsechangelog');
+
+sub mustsetvar {
+    my ($var, $text) = @_;
+
+    error(sprintf(_g("unable to determine %s", $text)))
+	unless defined($var);
+
+    print "$progname: $text $var\n";
+    return $var;
+}
+
+my $pkg = mustsetvar($changes{source}, _g('source package'));
+my $version = mustsetvar($changes{version}, _g('source version'));
+
+my $maintainer;
+if ($changedby) {
+    $maintainer = $changedby;
+} elsif ($maint) {
+    $maintainer = $maint;
+} else {
+    $maintainer = mustsetvar($changes{maintainer}, _g('source changed by'));
+}
+
+open my $arch_env, '-|', 'dpkg-architecture', "-a$targetarch",
+    "-t$targetgnusystem", '-s', '-f' or syserr('dpkg-architecture');
+while ($_ = <$arch_env>) {
+    chomp;
+    my @cmds = split /\s*;\s*/;
+    foreach (@cmds) {
+	/^\s*(\w+)=([\w-]*)\s*$/ && do {
+	    $ENV{$1} = $2;
+	};
+    }
+}
+close $arch_env or syserr('dpkg-architecture');
+
+my $arch;
+unless ($sourceonly) {
+    $arch = mustsetvar($ENV{'DEB_HOST_ARCH'}, _g('host architecture'));
+} else {
+    $arch = 'source';
+}
+
+(my $sversion = $version) =~ s/^\d+://;
+
+my $pv = "${pkg}_$sversion";
+my $pva = "${pkg}_${sversion}_$arch";
+
+sub signfile {
+    my ($file) = @_;
+    print STDERR " signfile $file\n";
+    my $qfile = quotemeta($file);
+
+    if ($signinterface eq 'gpg') {
+	system("(cat ../$qfile ; echo '') | ".
+	       "$signcommand --local-user ".quotemeta($signkey||$maintainer).
+	       " --clearsign --armor --textmode  > ../$qfile.asc");
+    } else {
+	system("$signcommand -u ".quotemeta($signkey||$maintainer).
+	       " +clearsig=on -fast <../$qfile >../$qfile.asc");
+    }
+    my $status = $?;
+    unless ($status) {
+	system('mv', '--', "../$file.asc", "../$file")
+	    and syserr('mv');
+    } else {
+	system('/bin/rm', '-f', "../$file.asc")
+	    and syserr('rm -f');
+    }
+    print "\n";
+    return $status
+}
+
+
+sub withecho {
+    print STDERR " @_\n";
+    system(@_)
+	and syserr("@_");
+}
+
+if ($checkbuilddep) {
+    if ($admindir) {
+	push @checkbuilddep_args, "--admindir=$admindir";
+    }
+
+    if (system('dpkg-checkbuilddeps', @checkbuilddep_args)) {
+	printf(STDERR _g("%s: Build dependencies/conflicts unsatisfied; aborting.\n"),
+	       $progname);
+	printf(STDERR _g("%s: (Use -d flag to override.)"), $progname);
+	exit 3;
+    }
+}
+
+unless ($noclean) {
+    withecho($rootcommand, 'debian/rules', 'clean');
+}
+unless ($binaryonly) {
+    chdir('..') or failure('chdir ..');
+    my @opts = @passopts;
+    if ($diffignore) { push @opts, $diffignore }
+    push @opts, @tarignore;
+    withecho('dpkg-source', @opts, '-b', $dir);
+    chdir($dir) or failure("chdir $dir");
+}
+unless ($sourceonly) {
+    withecho('debian/rules', 'build');
+    withecho($rootcommand, 'debian/rules', $binarytarget);
+}
+if ($usepause &&
+    ($signchanges || ( !$binaryonly && $signsource )) ) {
+    print _g("Press the return key to start signing process\n");
+    getc();
+}
+
+my $signerrors;
+unless ($binaryonly) {
+    if ($signsource && signfile("$pv.dsc")) {
+	$signerrors = "(WARNING: Failed to sign .dsc and .changes file)";
+	$signchanges = 0;
+    }
+}
+
+my @change_opts;
+
+if ($binaryonly) { push @change_opts, $binaryonly }
+if ($sourceonly) { push @change_opts, $sourceonly }
+if ($sourcestyle) { push @change_opts, $sourcestyle }
+
+if ($maint) { push @change_opts, "-m$maint" }
+if ($changedby) { push @change_opts, "-e$changedby" }
+if ($since) { push @change_opts, "-v$since" }
+if ($desc) { push @change_opts, "-C$desc" }
+
+my $chg = "../$pva.changes";
+print STDERR " dpkg-genchanges @change_opts >$chg\n";
+open CHANGES, '-|', 'dpkg-genchanges', @change_opts
+    or syserr('dpkg-genchanges');
+
+open OUT, '>', $chg or syserr(_g('write changes file'));
+
+my $infiles = my $files = '';
+while ($_ = <CHANGES>) {
+    print OUT $_ or syserr(_g('write changes file'));
+    chomp;
+
+    if (/^Files:/i) {
+	$infiles = 1;
+    } elsif ($infiles && /^\s+(.*)$/) {
+	$files .= " $1 ";
+    } elsif ($infiles && /^\S/) {
+	$infiles = 0;
+    }
+}
+
+close CHANGES or syserr(_g('dpkg-genchanges'));
+close OUT or syserr(_g('write changes file'));
+
+sub fileomitted {
+    my ($regex) = @_;
+
+    return $files !~ /$regex/;
+}
+
+my $srcmsg;
+if (fileomitted '\.deb') {
+    # source only upload
+    if (fileomitted '\.diff\.gz') {
+	$srcmsg = _g('source only upload: Debian-native package');
+    } elsif (fileomitted '\.orig\.tar\.gz') {
+	$srcmsg = _g('source only, diff-only upload (original source NOT included)');
+    } else {
+	$srcmsg = _g('source only upload (original source is included)');
+    }
+} else {
+    $srcmsg = _g('full upload (original source is included)');
+    if (fileomitted '\.dsc') {
+	$srcmsg = _g('binary only upload (no source included)');
+    } elsif (fileomitted '\.diff\.gz') {
+	$srcmsg = _g('full upload; Debian-native package (full source is included)');
+    } elsif (fileomitted '\.orig\.tar\.gz') {
+	$srcmsg = _g('binary and diff upload (original source NOT included)');
+    } else {
+	$srcmsg = _g('full upload (original source is included)');
+    }
+}
+
+if ($signchanges && signfile("$pva.changes")) {
+    $signerrors = _g("(WARNING: Failed to sign .changes file)");
+}
+
+if ($cleansource) {
+    withecho($rootcommand, 'debian/rules', 'clean');
+}
+
+print "$progname: $srcmsg\n";
+if ($signerrors) {
+    failure($signerrors);
+}
diff --git a/scripts/dpkg-buildpackage.sh b/scripts/dpkg-buildpackage.sh
deleted file mode 100755
index 931de3f..0000000
--- a/scripts/dpkg-buildpackage.sh
+++ /dev/null
@@ -1,297 +0,0 @@
-#!/bin/sh
-
-set -e
-
-version="1.10.10"; # This line modified by Makefile
-
-progname="$(basename "$0")"
-
-showversion () {
-	echo "Debian $progname version $version."
-
-	echo "
-Copyright (C) 1996 Ian Jackson.
-Copyright (C) 2000 Wichert Akkerman
-This is free software; see the GNU General Public Licence version 2 or
-later for copying conditions. There is NO warranty."
-}
-
-usage () {
-	cat <<END
-Usage: $progname [<options> ...]
-
-Options:
-  -r<gain-root-command>
-                 command to gain root privileges (default is fakeroot if it
-                 exists).
-  -p<sign-command>
-  -d             do not check build dependencies and conflicts.
-  -D             check build dependencies and conflicts.
-  -k<keyid>      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.
-  -uc            unsigned changes.
-  -a<arch>       Debian architecture we build for (implies -d).
-  -b             binary-only, do not build source. } also passed to
-  -B             binary-only, no arch-indep files. } dpkg-genchanges
-  -S             source only, no binary files.     }
-  -t<system>     set GNU system type.           } passed to dpkg-architecture
-  -v<version>    changes since version <version>.      }
-  -m<maint>      maintainer for package is <maint>.    }
-  -e<maint>      maintainer for release is <maint>.    } only passed
-  -C<descfile>   changes are described in <descfile>.  } to dpkg-genchanges
-  -si (default)  src includes orig for rev. 0 or 1.    }
-  -sa            uploaded src always includes orig.    }
-  -sd            uploaded src is diff and .dsc only.   }
-  -sn            force Debian native source format.      } only passed
-  -s[sAkurKUR]   see dpkg-source for explanation.        } to dpkg-source
-  -nc            do not clean source tree (implies -b).
-  -tc            clean source tree when finished.
-  -ap            add pause before starting signature process.
-  -W             turn certain errors into warnings.       } passed to
-  -E             when -W is turned on, -E turned it off.  } dpkg-source
-  -i[<regex>]    ignore diffs of files matching regex.    } only passed
-  -I<filename>   filter out files when building tarballs. } to dpkg-source
-  --admindir=<directory>
-                 change the administrative directory.
-  -h, --help     show this help message.
-      --version  show the version.
-END
-}
-
-rootcommand=''
-if command -v fakeroot >/dev/null 2>&1; then
-	rootcommand=fakeroot
-fi
-
-signcommand=""
-if [ -e "$GNUPGHOME" ] || [ -e "$HOME/.gnupg" ] && \
-		command -v gpg > /dev/null 2>&1; then
-	signcommand=gpg
-elif command -v pgp > /dev/null 2>&1 ; then
-	signcommand=pgp
-fi
-
-signsource='withecho signfile'
-signchanges='withecho signfile'
-cleansource=false
-checkbuilddep=true
-checkbuilddep_args=''
-binarytarget=binary
-sourcestyle=''
-changesversion=''
-since=''
-maint=''
-desc=''
-noclean=false
-usepause=false
-warnable_error=0
-passopts=''
-admindir=''
-
-while [ $# != 0 ]
-do
-	value="$(echo x"$1" | sed -e 's/x--.*=//;s/^x-.//')"
-	case "$1" in
-	-h|--help)
-		usage; exit 0 ;;
-	--version)
-		showversion; exit 0 ;;
-	--admindir=*)
-		admindir="$value" ;;
-	-r*)	rootcommand="$value" ;;
-	-p*)	signcommand="$value" ;;
-	-k*)	signkey="$value" ;;
-	-d)	checkbuilddep=false ;;
-	-D)	checkbuilddep=true ;;
-	-sgpg)  forcesigninterface=gpg ;;
-	-spgp)  forcesigninterface=pgp ;;
-	-us)	signsource=: ;;
-	-uc)	signchanges=: ;;
-	-ap)	usepause="true";;
-	-a*)    targetarch="$value"; checkbuilddep=false ;;
-	-si)	sourcestyle=-si ;;
-	-sa)	sourcestyle=-sa ;;
-	-sd)	sourcestyle=-sd ;;
-	-s[nsAkurKUR])    passopts="$passopts $1";; # passed to dpkg-source
-        -i*)    diffignore=$1;;
-	-I*)	tarignore="$tarignore $1";;
-	-tc)	cleansource=true ;;
-	-t*)    targetgnusystem="$value" ;;          # Order DOES matter!
-	-nc)	noclean=true; if [ -z "$binaryonly" ]; then binaryonly=-b; fi ;;
-	-b)	binaryonly=-b;
-		checkbuilddep_args='';
-		binarytarget=binary;
-		[ "$sourceonly" ] && \
-			{ echo >&2 "$progname: cannot combine $1 and -S" ; exit 2 ; } ;;
-	-B)	binaryonly=-B; checkbuilddep_args=-B; binarytarget=binary-arch; [ "$sourceonly" ] && \
-			{ echo >&2 "$progname: cannot combine $1 and -S" ; exit 2 ; } ;;
-	-S)	sourceonly=-S; checkbuilddep=false; [ "$binaryonly" ] && \
-			{ echo >&2 "$progname: cannot combine $binaryonly and $1" ; exit 2 ; } ;;
-	-v*)	since="$value" ;;
-	-m*)	maint="$value" ;;
-	-e*)	changedby="$value" ;;
-	-C*)	desc="$value" ;;
-	-W)	warnable_error=1; passopts="$passopts -W";;
-	-E)	warnable_error=0; passopts="$passopts -E";;
-	*)	echo >&2 "$progname: unknown option or argument $1"
-		usage; exit 2 ;;
-	esac
-	shift
-done
-
-if [ -z "$signcommand"  ] ; then
-	signsource=:
-	signchanges=:
-fi
-
-if test -n "$forcesigninterface" ; then
-  signinterface=$forcesigninterface
-else
-  signinterface=$signcommand
-fi
-if [ -n "$signcommand" ] && [ "$signinterface" != "gpg" ] && [ "$signinterface" != "pgp" ] ; then
-    echo >&2 "$progname: unknown sign command, assuming pgp style interface"
-fi
-
-mustsetvar () {
-	if [ "x$2" = x ]; then
-		echo >&2 "$progname: unable to determine $3" ; \
-		exit 1
-	else
-		echo "$progname: $3 $2" ; \
-		eval "$1=\"\$2\""
-	fi
-}
-
-curd="`pwd`"
-dirn="$(basename "$curd")"
-mustsetvar package "`dpkg-parsechangelog | sed -n 's/^Source: //p'`" "source package is"
-mustsetvar changesversion "`dpkg-parsechangelog | sed -n 's/^Version: //p'`" "source version is"
-if [ -n "$changedby" ]; then maintainer="$changedby";
-elif [ -n "$maint" ]; then maintainer="$maint";
-else mustsetvar maintainer "`dpkg-parsechangelog | sed -n 's/^Maintainer: //p'`" "source changed by"; fi
-eval `dpkg-architecture -a${targetarch} -t${targetgnusystem} -s -f`
-
-if [ x$sourceonly = x ]; then
-	mustsetvar arch "`dpkg-architecture -a${targetarch} -t${targetgnusystem} -qDEB_HOST_ARCH`" "host architecture"
-else
-	arch=source
-fi
-mustsetvar sversion "$(echo "$changesversion" | perl -pe 's/^\d+://')" "source version without epoch"
-pv="${package}_${sversion}"
-pva="${package}_${sversion}_${arch}"
-
-signfile () {
-	if test "$signinterface" = "gpg" ; then
-		(cat "../$1" ; echo "") | \
-		$signcommand --local-user "${signkey:-$maintainer}" --clearsign --armor \
-			--textmode  > "../$1.asc" 
-	else
-		$signcommand -u "${signkey:-$maintainer}" +clearsig=on -fast <"../$1" \
-			>"../$1.asc"
-	fi
-	status=$?
-	if [ $status -eq 0 ]; then
-		mv -- "../$1.asc" "../$1"
-	else
-		/bin/rm -f "../$1.asc"
-	fi
-	echo
-	return $status
-}
-
-withecho () {
-        echo " $@" >&2
-	"$@"
-}
-
-if [ "$checkbuilddep" = "true" ]; then
-	if [ -n "$admindir" ]; then
-		checkbuilddep_args="$checkbuilddep_args --admindir=$admindir"
-	fi
-
-	if ! dpkg-checkbuilddeps $checkbuilddep_args; then
-		echo >&2 "$progname: Build dependencies/conflicts unsatisfied; aborting."
-		echo >&2 "$progname: (Use -d flag to override.)"
-		exit 3
-	fi
-fi
-
-set -- $binaryonly $sourceonly $sourcestyle
-if [ -n "$maint"	]; then set -- "$@" "-m$maint"		; fi
-if [ -n "$changedby"	]; then set -- "$@" "-e$changedby"	; fi
-if [ -n "$since"	]; then set -- "$@" "-v$since"		; fi
-if [ -n "$desc"		]; then set -- "$@" "-C$desc"		; fi
-
-if [ x$noclean != xtrue ]; then
-	withecho $rootcommand 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
-fi
-if [ "$usepause" = "true" ] && \
-   ( [ "$signchanges" != ":" ] || ( [ -z "$binaryonly" ] && [ "$signsource" != ":" ] ) ) ; then
-    echo Press the return key to start signing process
-    read dummy_stuff
-fi
-
-signerrors=
-if [ x$binaryonly = x ]; then
-	if ! $signsource "$pv.dsc"; then
-		signerrors="(WARNING: Failed to sign .dsc and .changes file)"
-		signchanges=:
-	fi
-fi
-chg=../"$pva.changes"
-withecho dpkg-genchanges "$@" >"$chg"
-
-fileomitted () {
-	set +e
-	test -z "`sed -n '/^Files:/,/^[^ ]/ s/'$1'$//p' <$chg`"
-	fir=$?
-	set -e
-	return $fir
-}	
-
-
-if fileomitted '\.deb'; then
-	# source only upload
-	if fileomitted '\.diff\.gz'; then
-		srcmsg='source only upload: Debian-native package'
-	elif fileomitted '\.orig\.tar\.gz'; then
-		srcmsg='source only, diff-only upload (original source NOT included)'
-	else
-		srcmsg='source only upload (original source is included)'
-	fi
-else
-	srcmsg='full upload (original source is included)'
-	if fileomitted '\.dsc'; then
-		srcmsg='binary only upload (no source included)'
-	elif fileomitted '\.diff\.gz'; then
-		srcmsg='full upload; Debian-native package (full source is included)'
-	elif fileomitted '\.orig\.tar\.gz'; then
-		srcmsg='binary and diff upload (original source NOT included)'
-	else
-		srcmsg='full upload (original source is included)'
-	fi
-fi
-
-if ! $signchanges "$pva.changes"; then
-	signerrors="(WARNING: Failed to sign .changes file)"
-fi
-
-if $cleansource; then
-	withecho $rootcommand debian/rules clean
-fi
-
-echo "dpkg-buildpackage: $srcmsg"
-if [ -n "$signerrors" ]; then
-	echo >&2 $signerrors
-	exit 1
-fi
-- 
1.5.2.5

-- 
Frank Lichtenheld <djpig@debian.org>
www: http://www.djpig.de/



Reply to: