chiark / gitweb /
Provide --build-products-dir option (and corresponding semantics for -C) to specify...
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 19 Jan 2014 00:16:38 +0000 (00:16 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 19 Jan 2014 00:16:38 +0000 (00:16 +0000)
debian/changelog
debian/tests/control
dgit
dgit.1
tests/tests/push-buildproductsdir [new file with mode: 0755]

index aaf0ead..18ab786 100644 (file)
@@ -5,6 +5,8 @@ dgit (0.21~~iwj) unstable; urgency=low
   * Add `Testsuite: autopkgtest' to debian/control.  (This will only have
     the right effect with recent enought dpkg, and will generate a warning
     with earlier versions of dpkg.
+  * Provide --build-products-dir option (and corresponding semantics
+    for -C) to specify where to find the files to upload.  Closes:#731633.
 
  --
 
index 391ac11..48dbda1 100644 (file)
@@ -1,3 +1,3 @@
-Tests: clone-nogit fetch-localgitonly fetch-somegit-notlast push-newpackage push-nextdgit quilt
+Tests: clone-nogit fetch-localgitonly fetch-somegit-notlast push-newpackage push-nextdgit quilt push-buildproductsdir
 Tests-Directory: tests/tests
 Depends: @, devscripts
diff --git a/dgit b/dgit
index 19d6b01..5b99ed1 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -40,6 +40,7 @@ our @ropts;
 our $sign = 1;
 our $dryrun_level = 0;
 our $changesfile;
+our $buildproductsdir = '..';
 our $new_package = 0;
 our $ignoredirty = 0;
 our $noquilt = 0;
@@ -1319,13 +1320,14 @@ sub dopush () {
     my ($clogp, $cversion, $tag, $dscfn) =
        push_parse_changelog("$clogpfn");
 
-    stat "../$dscfn" or
+    my $dscpath = "$buildproductsdir/$dscfn";
+    stat $dscpath or
        fail "looked for .dsc $dscfn, but $!;".
            " maybe you forgot to build";
 
-    responder_send_file('dsc', "../$dscfn");
+    responder_send_file('dsc', $dscpath);
 
-    push_parse_dsc("../$dscfn", $dscfn, $cversion);
+    push_parse_dsc($dscpath, $dscfn, $cversion);
 
     my $format = getfield $dsc, 'Format';
     printdebug "format $format\n";
@@ -1335,7 +1337,8 @@ sub dopush () {
     check_not_dirty();
     changedir $ud;
     progress "checking that $dscfn corresponds to HEAD";
-    runcmd qw(dpkg-source -x --), "../../../../$dscfn";
+    runcmd qw(dpkg-source -x --),
+        $dscpath =~ m#^/# ? $dscpath : "../../../$dscpath";
     my ($tree,$dir) = mktree_in_ud_from_only_subdir();
     changedir '../../../..';
     my @diffcmd = (@git, qw(diff --exit-code), $tree);
@@ -1357,19 +1360,22 @@ sub dopush () {
 #        (uploadbranch());
     my $head = rev_parse('HEAD');
     if (!$changesfile) {
-       my $multi = "../${package}_".(stripepoch $cversion)."_multi.changes";
+       my $multi = "$buildproductsdir/".
+           "${package}_".(stripepoch $cversion)."_multi.changes";
        if (stat "$multi") {
            $changesfile = $multi;
        } else {
            $!==&ENOENT or die "$multi: $!";
            my $pat = "${package}_".(stripepoch $cversion)."_*.changes";
-           my @cs = glob "../$pat";
+           my @cs = glob "$buildproductsdir/$pat";
            fail "failed to find unique changes file".
-               " (looked for $pat in .., or $multi);".
+               " (looked for $pat in $buildproductsdir, or $multi);".
                " perhaps you need to use dgit -C"
                unless @cs==1;
            ($changesfile) = @cs;
        }
+    } else {
+       $changesfile = "$buildproductsdir/$changesfile";
     }
 
     responder_send_file('changes',$changesfile);
@@ -1384,7 +1390,7 @@ sub dopush () {
     } else {
        $tagobjfn =
            push_mktag($head,$clogp,$tag,
-                      "../$dscfn",
+                      $dscpath,
                       $changesfile,$changesfile,
                       $tfn);
     }
@@ -1402,16 +1408,16 @@ sub dopush () {
 
     if (!$we_are_responder) {
        if (act_local()) {
-           rename "../$dscfn.tmp","../$dscfn" or die "$dscfn $!";
+           rename "$dscpath.tmp",$dscpath or die "$dscfn $!";
        } else {
-           progress "[new .dsc left in $dscfn.tmp]";
+           progress "[new .dsc left in $dscpath.tmp]";
        }
     }
 
     if ($we_are_responder) {
        my $dryrunsuffix = act_local() ? "" : ".tmp";
        responder_receive_files('signed-dsc-changes',
-                               "../$dscfn$dryrunsuffix",
+                               "$dscpath$dryrunsuffix",
                                "$changesfile$dryrunsuffix");
     } else {
        sign_changes $changesfile;
@@ -1969,6 +1975,9 @@ sub parseopts () {
            } elsif (m/^--distro=(.*)/s) {
                push @ropts, $_;
                $idistro = $1;
+           } elsif (m/^--build-products-dir=(.*)/s) {
+               push @ropts, $_;
+               $buildproductsdir = $1;
            } elsif (m/^--clean=(dpkg-source|git|none)$/s) {
                push @ropts, $_;
                $cleanmode = $1;
@@ -2017,6 +2026,9 @@ sub parseopts () {
                } elsif (s/^-C(.*)//s) {
                    push @ropts, $&;
                    $changesfile = $1;
+                   if ($changesfile =~ s#^(.*)/##) {
+                       $buildproductsdir = $1;
+                   }
                } elsif (s/^-k(.*)//s) {
                    $keyid=$1;
                } elsif (s/^-wn//s) {
diff --git a/dgit.1 b/dgit.1
index 7e74d5b..b23a3a8 100644 (file)
--- a/dgit.1
+++ b/dgit.1
@@ -359,6 +359,20 @@ Specifies the .changes file which is to be uploaded.  By default
 dgit push looks for single .changes file in the parent directory whose
 filename suggests it is for the right package and version - or,
 if there is a _multi.changes file, dgit uses that.
+
+If the specified
+.I changesfile
+pathname contains slashes, the directory part is also used as
+the value for
+.BR --build-products-dir ;
+otherwise, the changes file is expected in that directory (by
+default, in
+.BR .. ).
+.TP
+.BI --build-products-dir= directory
+Specifies where to find the built files to be uploaded.
+By default, dgit looks in the parent directory
+.BR .. ).
 .TP
 .BI --existing-package= package
 dgit push needs to canonicalise the suite name.  Sometimes, dgit
diff --git a/tests/tests/push-buildproductsdir b/tests/tests/push-buildproductsdir
new file mode 100755 (executable)
index 0000000..987c081
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/bash
+set -e
+. tests/lib
+
+t-archive pari-extra 3-1
+t-git pari-extra 3-1
+
+t-dgit clone $p
+
+cd $p
+t-cloned-fetched-good
+
+v=3-2~dummy1
+t-apply-diff 3-1 $v
+debcommit -a
+
+t-refs-same-start
+t-ref-head
+
+t-dgit --dpkg-buildpackage:-d build
+
+cd ..
+mkdir bpd
+mv $p*_* bpd/
+cd $p
+
+t-dgit --build-products-dir=../bpd push
+
+t-pushed-good dgit/sid
+
+echo ok.