chiark / gitweb /
dgit: opts_opt_multi_cmd: New @$extra feature
[dgit.git] / dgit
diff --git a/dgit b/dgit
index fcda8d7538b20125a77ed4e55923993d0e138b1e..1a4700ccfdb9af6e6ae544ff17cdd259475e9edb 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -2,8 +2,8 @@
 # dgit
 # Integration between git and Debian-style archives
 #
-# Copyright (C)2013-2017 Ian Jackson
-# Copyright (C)2017 Sean Whitton
+# Copyright (C)2013-2018 Ian Jackson
+# Copyright (C)2017-2018 Sean Whitton
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -275,14 +275,16 @@ sub quiltmode_splitbrain () {
 }
 
 sub opts_opt_multi_cmd {
+    my $extra = shift;
     my @cmd;
     push @cmd, split /\s+/, shift @_;
+    push @cmd, @$extra;
     push @cmd, @_;
     @cmd;
 }
 
 sub gbp_pq {
-    return opts_opt_multi_cmd @gbp_pq;
+    return opts_opt_multi_cmd [], @gbp_pq;
 }
 
 sub dgit_privdir () {
@@ -6351,7 +6353,7 @@ sub cmd_gbp_build {
            $gbp_build[0] = 'gbp buildpackage';
        }
     }
-    my @cmd = opts_opt_multi_cmd @gbp_build;
+    my @cmd = opts_opt_multi_cmd [], @gbp_build;
 
     push @cmd, (qw(-us -uc --git-no-sign-tags),
                "--git-builder=".(shellquote @dbp));
@@ -6393,22 +6395,6 @@ sub cmd_gbp_build {
 }
 sub cmd_git_build { cmd_gbp_build(); } # compatibility with <= 1.0
 
-sub move_dsc_to_bpd ($) {
-    my ($dscfn) = @_;
-    printdebug "moving $dscfn and all referenced files to ".bpd_abs()."\n";
-    $dsc = parsecontrol($dscfn, "source package");
-    foreach my $l (split /\n/, getfield $dsc, 'Files') {
-        $l =~ m/\S+$/ or next;
-        $l =~ s/.* //;
-        printdebug "found $l - renaming\n";
-        rename "$l", bpd_abs()."/$l"
-          or fail "put in place new source file ($l): $!";
-    }
-    printdebug "moving $dscfn to ".bpd_abs()."/$dscfn\n";
-    rename "$dscfn", bpd_abs()."/$dscfn"
-      or fail "put in place new source file ($dscfn): $!";
-}
-
 sub building_source_in_playtree {
     # If $includedirty, we have to build the source package from the
     # working tree, not a playtree, so that uncommitted changes are
@@ -6456,9 +6442,23 @@ sub build_source {
       'exec >../$1; shift; exec "$@"','x', $sourcechanges,
       @dpkggenchanges, qw(-S), changesopts();
     changedir '..';
-    move_dsc_to_bpd($dscfn);
-    rename "$sourcechanges", bpd_abs()."/$sourcechanges"
-       or fail "put in place source changes file ($sourcechanges): $!";
+
+    printdebug "moving $dscfn, $sourcechanges, etc. to ".bpd_abs()."\n";
+    $dsc = parsecontrol($dscfn, "source package");
+
+    my $mv = sub {
+       my ($why, $l) = @_;
+        printdebug " renaming ($why) $l\n";
+        rename "$l", bpd_abs()."/$l"
+           or fail "put in place new built file ($l): $!";
+    };
+    foreach my $l (split /\n/, getfield $dsc, 'Files') {
+        $l =~ m/\S+$/ or next;
+       $mv->('Files', $&);
+    }
+    $mv->('dsc', $dscfn);
+    $mv->('changes', $sourcechanges);
+
     changedir $maindir;
 }