diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2018-07-26 13:08:25 +0100 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2018-07-26 13:10:02 +0100 |
commit | 7646c04136bd156af29671bd1081378f6a398aff (patch) | |
tree | 50456141b6716d108af44317a7b7d0a57405eb10 | |
parent | 0fba7acedc2d9e29109451001e53c15a6d81a5d3 (diff) |
dgit: Abolish move_dsc_to_bpd
This subroutine only has one caller. It also contains a bit of
duplication both within itself and compared to its caller - the calls
to mv and its error handling - which is annoying to remove as it is.
Instead, put its code into build_source, and break out a private
subroutine $mv for the rename.
No functional change other than to messages.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
-rwxr-xr-x | dgit | 36 |
1 files changed, 17 insertions, 19 deletions
@@ -6393,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 @@ -6456,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; } |