I could imagine the patch below, which I started looking at some time ago
but never
got around to coming back to, could form a start at implementing this.
It was just the obvious paths within the script itself, but the various
calls to dpkg-source,
dpkg-genbuildinfo, dpkg-genchanges, that all accept output options, still
need to be
modified to pass this new argument.

diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl
index aacb831..af50b75 100755
--- a/scripts/dpkg-buildpackage.pl
+++ b/scripts/dpkg-buildpackage.pl
@@ -80,6 +80,7 @@ sub usage {
   -d, --no-check-builddeps    do not check build dependencies and
conflicts.
       --ignore-builtin-builddeps
                               do not check builtin build dependencies.
+  -o, --output-dir=<dir>      path to put output files in. (default is ../)
   -P, --build-profiles=<profiles>
                               assume comma-separated build <profiles> as
active.
       --rules-requires-root   assume legacy Rules-Requires-Root field
value.
@@ -182,6 +183,7 @@ my $changedby;
 my $desc;
 my @buildinfo_opts;
 my @changes_opts;
+my $outdir = "..";
 my %target_legacy_root = map { $_ => 1 } qw(
     clean binary binary-arch binary-indep
 );
@@ -301,6 +303,8 @@ while (@ARGV) {
         $postclean = 0;
     } elsif (/^--sanitize-env$/) {
         $sanitize_env = 1;
+    } elsif (/^-o(.*)$/ or /^--output-dir=(.*)$/) {
+        $outdir = $1;
     } elsif (/^-t$/ or /^--host-type$/) {
        $host_type = shift; # Order DOES matter!
     } elsif (/^-t(.*)$/ or /^--host-type=(.*)$/) {
@@ -598,7 +602,7 @@ push @changes_opts, "-e$changedby" if defined
$changedby;
 push @changes_opts, "-v$since" if defined $since;
 push @changes_opts, "-C$desc" if defined $desc;

-my $chg = "../$pva.changes";
+my $chg = "$outdir/$pva.changes";
 my $changes = Dpkg::Control->new(type => CTRL_FILE_CHANGES);

 printcmd("dpkg-genchanges @changes_opts >$chg");
@@ -639,12 +643,12 @@ if ($signsource) {

     # Recompute the checksums as the .dsc has changed now.
     my $buildinfo = Dpkg::Control->new(type => CTRL_FILE_BUILDINFO);
-    $buildinfo->load("../$pva.buildinfo");
+    $buildinfo->load("$outdir/$pva.buildinfo");
     my $checksums = Dpkg::Checksums->new();
     $checksums->add_from_control($buildinfo);
-    $checksums->add_from_file("../$pv.dsc", update => 1, key => "$pv.dsc");
+    $checksums->add_from_file("$outdir/$pv.dsc", update => 1, key =>
"$pv.dsc");
     $checksums->export_to_control($buildinfo);
-    $buildinfo->save("../$pva.buildinfo");
+    $buildinfo->save("$outdir/$pva.buildinfo");
 }
 if ($signbuildinfo && signfile("$pva.buildinfo")) {
     error(g_('failed to sign %s file'), '.buildinfo');
@@ -653,9 +657,9 @@ if ($signsource or $signbuildinfo) {
     # Recompute the checksums as the .dsc and/or .buildinfo have changed.
     my $checksums = Dpkg::Checksums->new();
     $checksums->add_from_control($changes);
-    $checksums->add_from_file("../$pv.dsc", update => 1, key => "$pv.dsc")
+    $checksums->add_from_file("$outdir/$pv.dsc", update => 1, key =>
"$pv.dsc")
         if $signsource;
-    $checksums->add_from_file("../$pva.buildinfo", update => 1, key =>
"$pva.buildinfo");
+    $checksums->add_from_file("$outdir/$pva.buildinfo", update => 1, key
=> "$pva.buildinfo");
     $checksums->export_to_control($changes);
     delete $changes->{'Checksums-Md5'};
     update_files_field($changes, $checksums, "$pv.dsc")
@@ -858,7 +862,7 @@ sub signfile {
     my $signfile = "$signdir/$file";

     # Make sure the file to sign ends with a newline.
-    copy("../$file", $signfile);
+    copy("$outdir/$file", $signfile);
     open my $signfh, '>>', $signfile or syserr(g_('cannot open %s'),
$signfile);
     print { $signfh } "\n";
     close $signfh or syserr(g_('cannot close %s'), $signfile);
@@ -868,8 +872,8 @@ sub signfile {
            '--output', "$signfile.asc", $signfile);
     my $status = $?;
     if ($status == 0) {
-        move("$signfile.asc", "../$file")
-            or syserror(g_('cannot move %s to %s'), "$signfile.asc",
"../$file");
+        move("$signfile.asc", "$outdir/$file")
+            or syserror(g_('cannot move %s to %s'), "$signfile.asc",
"$outdir/$file");
     }

     print "\n";

Reply via email to