diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2016-10-25 15:05:44 +0100 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2016-10-25 15:05:46 +0100 |
commit | 9a0e08c9ff1d9b3a53e8399290afcee426f76f7c (patch) | |
tree | 7770be35a6cb22d505a490c2315728e5a11e67dd | |
parent | 4e73f0c77e0a5c679a39c5e78f67adbb217d5922 (diff) |
build changes handling: Introduce postbuild_mergechanges
Affects only the `sbuild' subcommand.
Mostly code motion.
Other changes include:
* Provide in_parent, and use it.
* "sbuild" changed to "build" in the msg_if_onlyone failure message
* Unapply patches before merging changelogs
* Reorganise so that it is possible to use this code when there
is only one output changes file.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
-rwxr-xr-x | dgit | 93 |
1 files changed, 59 insertions, 34 deletions
@@ -4891,6 +4891,53 @@ sub massage_dbp_args ($;$) { return $r; } +sub in_parent (&) { + my ($fn) = @_; + my $wasdir = must_getcwd(); + changedir ".."; + $fn->(); + changedir $wasdir; +} + +sub postbuild_mergechanges ($) { # must run with CWD=.. (eg in in_parent) + my ($msg_if_onlyone) = @_; + # If there is only one .changes file, fail with $msg_if_onlyone, + # or if that is undef, be a no-op. + # Returns the changes file to report to the user. + my $pat = changespat $version; + my @changesfiles = glob $pat; + @changesfiles = sort { + ($b =~ m/_source\.changes$/ <=> $a =~ m/_source\.changes$/) + or $a cmp $b + } @changesfiles; + my $result; + if (@changesfiles==1) { + fail <<END.$msg_if_onlyone if defined $msg_if_onlyone; +only one changes file from build (@changesfiles) +END + $result = $changesfiles[0]; + } elsif (@changesfiles==2) { + my $binchanges = parsecontrol($changesfiles[1], "binary changes file"); + foreach my $l (split /\n/, getfield $binchanges, 'Files') { + fail "$l found in binaries changes file $binchanges" + if $l =~ m/\.dsc$/; + } + runcmd_ordryrun_local @mergechanges, @changesfiles; + my $multichanges = changespat $version,'multi'; + if (act_local()) { + stat_exists $multichanges or fail "$multichanges: $!"; + foreach my $cf (glob $pat) { + next if $cf eq $multichanges; + rename "$cf", "$cf.inmulti" or fail "$cf\{,.inmulti}: $!"; + } + } + $result = $multichanges; + } else { + fail "wrong number of different changes files (@changesfiles)"; + } + printdone "build successful, results in $result\n" or die $!; +} + sub cmd_build { my @dbp = (@dpkgbuildpackage, qw(-us -uc), changesopts_initial(), @ARGV); my $wantsrc = massage_dbp_args \@dbp; @@ -5024,43 +5071,21 @@ Suggest you delete @unwanted. END if @unwanted; } - my $wasdir = must_getcwd(); - changedir ".."; - if (act_local()) { - stat_exists $dscfn or fail "$dscfn (in parent directory): $!"; - stat_exists $sourcechanges - or fail "$sourcechanges (in parent directory): $!"; - } - runcmd_ordryrun_local @sbuild, qw(-d), $isuite, @ARGV, $dscfn; - my @changesfiles = glob $pat; - @changesfiles = sort { - ($b =~ m/_source\.changes$/ <=> $a =~ m/_source\.changes$/) - or $a cmp $b - } @changesfiles; - fail <<END if @changesfiles==1; -only one changes file from sbuild (@changesfiles) + in_parent { + if (act_local()) { + stat_exists $dscfn or fail "$dscfn (in parent directory): $!"; + stat_exists $sourcechanges + or fail "$sourcechanges (in parent directory): $!"; + } + runcmd_ordryrun_local @sbuild, qw(-d), $isuite, @ARGV, $dscfn; + }; + maybe_unapply_patches_again(); + in_parent { + postbuild_mergechanges(<<END); perhaps you need to pass -A ? (sbuild's default is to build only arch-specific binaries; dgit 1.4 used to override that.) END - fail "wrong number of different changes files (@changesfiles)" - unless @changesfiles==2; - my $binchanges = parsecontrol($changesfiles[1], "binary changes file"); - foreach my $l (split /\n/, getfield $binchanges, 'Files') { - fail "$l found in binaries changes file $binchanges" - if $l =~ m/\.dsc$/; - } - runcmd_ordryrun_local @mergechanges, @changesfiles; - my $multichanges = changespat $version,'multi'; - if (act_local()) { - stat_exists $multichanges or fail "$multichanges: $!"; - foreach my $cf (glob $pat) { - next if $cf eq $multichanges; - rename "$cf", "$cf.inmulti" or fail "$cf\{,.inmulti}: $!"; - } - } - changedir $wasdir; - maybe_unapply_patches_again(); - printdone "build successful, results in $multichanges\n" or die $!; + }; } sub cmd_quilt_fixup { |