From 4c49acc3a10c4aa95e1be956dde3df7df86aeae4 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 6 Dec 2015 20:58:13 +0000 Subject: [PATCH] Split brain: Run source build in dgit view directory And, after the source build is done, copy the resulting files out into the invocation directory's parent, where people expect to find them. --- dgit | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/dgit b/dgit index 9763bbfd..dd1a647b 100755 --- a/dgit +++ b/dgit @@ -3442,11 +3442,29 @@ sub build_source { runcmd_ordryrun_local @dpkgbuildpackage, qw(-us -uc -S -d), changesopts(); } else { - my $pwd = must_getcwd(); - my $leafdir = basename $pwd; - changedir ".."; - runcmd_ordryrun_local @dpkgsource, qw(-b --), $leafdir; - changedir $pwd; + my @cmd = (@dpkgsource, qw(-b --)); + if ($split_brain) { + changedir $ud; + runcmd_ordryrun_local @cmd, "work"; + my @udfiles = <${package}_*>; + changedir "../../.."; + foreach my $f (@udfiles) { + printdebug "source copy, found $f\n"; + next unless + $f eq $dscfn or + ($f =~ m/\.debian\.tar(?:\.\w+)$/ && + $f eq srcfn($version, $&)); + printdebug "source copy, found $f - renaming\n"; + rename "$ud/$f", "../$f" or $!==ENOENT + or fail "put in place new source file ($f): $!"; + } + } else { + my $pwd = must_getcwd(); + my $leafdir = basename $pwd; + changedir ".."; + runcmd_ordryrun_local @cmd, $leafdir; + changedir $pwd; + } runcmd_ordryrun_local qw(sh -ec), 'exec >$1; shift; exec "$@"','x', "../$sourcechanges", -- 2.30.2