From 9a0e08c9ff1d9b3a53e8399290afcee426f76f7c Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 25 Oct 2016 15:05:44 +0100 Subject: 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 --- dgit | 93 +++++++++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 59 insertions(+), 34 deletions(-) diff --git a/dgit b/dgit index 62feb30..356b48c 100755 --- a/dgit +++ b/dgit @@ -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 < $a =~ m/_source\.changes$/) - or $a cmp $b - } @changesfiles; - fail <