chiark / gitweb /
Update copyright years
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 9384f64e87faba171d6c761de8e6963d34773d01..c1a01840d367e77c65c6e8d0b8f0bba8aae49154 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
@@ -4756,29 +4756,6 @@ sub cmd_push {
     dopush();
 }
 
-our $sourcechanges;
-
-sub cmd_push_source {
-    prep_push();
-    fail "dgit push-source: --include-dirty/--ignore-dirty does not make".
-      "sense with push-source!" if $includedirty;
-    build_maybe_quilt_fixup();
-    if ($changesfile) {
-        my $changes = parsecontrol("$buildproductsdir/$changesfile",
-                                   "source changes file");
-        unless (test_source_only_changes($changes)) {
-            fail "user-specified changes file is not source-only";
-        }
-    } else {
-        # Building a source package is very fast, so just do it
-       build_source();
-       die "er, patches are applied dirtily but shouldn't be.."
-           if $patches_applied_dirtily;
-       $changesfile = $sourcechanges;
-    }
-    dopush();
-}
-
 #---------- remote commands' implementation ----------
 
 sub pre_remote_push_build_host {
@@ -5068,6 +5045,7 @@ sub i_want_signed_dsc_changes {
 #---------- building etc. ----------
 
 our $version;
+our $sourcechanges;
 our $dscfn;
 
 #----- `3.0 (quilt)' handling -----
@@ -6415,22 +6393,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
@@ -6478,9 +6440,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;
 }
 
@@ -6492,6 +6468,27 @@ sub cmd_build_source {
     printdone "source built, results in $dscfn and $sourcechanges";
 }
 
+sub cmd_push_source {
+    prep_push();
+    fail "dgit push-source: --include-dirty/--ignore-dirty does not make".
+      "sense with push-source!" if $includedirty;
+    build_maybe_quilt_fixup();
+    if ($changesfile) {
+        my $changes = parsecontrol("$buildproductsdir/$changesfile",
+                                   "source changes file");
+        unless (test_source_only_changes($changes)) {
+            fail "user-specified changes file is not source-only";
+        }
+    } else {
+        # Building a source package is very fast, so just do it
+       build_source();
+       die "er, patches are applied dirtily but shouldn't be.."
+           if $patches_applied_dirtily;
+       $changesfile = $sourcechanges;
+    }
+    dopush();
+}
+
 sub cmd_sbuild {
     build_prep(WANTSRC_SOURCE); # not BUILDER because sbuild uses the .dsc
     build_source();