summaryrefslogtreecommitdiff
path: root/dgit
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2018-07-25 10:02:16 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2018-07-25 10:19:14 +0100
commite23c0f9c068457c33e869f720d30e3c105976dba (patch)
tree1b051beaabd698e0b0fc6a7e8c3f9682b68ef12f /dgit
parentafd222c43e1ad60c19d97cb75cc2e73dd95abb39 (diff)
dgit: actually respect $buildproductsdir in many places
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name> Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Diffstat (limited to 'dgit')
-rwxr-xr-xdgit49
1 files changed, 29 insertions, 20 deletions
diff --git a/dgit b/dgit
index 2ba3aae..1bde327 100755
--- a/dgit
+++ b/dgit
@@ -289,6 +289,11 @@ sub dgit_privdir () {
our $dgit_privdir_made //= ensure_a_playground 'dgit';
}
+sub bpd_abs () {
+ my $r = $buildproductsdir;
+ $r = "$maindir/$r" unless $r =~ m{^/};
+}
+
sub branch_gdr_info ($$) {
my ($symref, $head) = @_;
my ($status, $msg, $current, $ffq_prev, $gdrlast) =
@@ -2113,7 +2118,7 @@ sub generate_commits_from_dsc () {
foreach my $fi (@dfi) {
my $f = $fi->{Filename};
die "$f ?" if $f =~ m#/|^\.|\.dsc$|\.tmp$#;
- my $upper_f = "$maindir/../$f";
+ my $upper_f = (bpd_abs()."/$f");
printdebug "considering reusing $f: ";
@@ -2121,12 +2126,12 @@ sub generate_commits_from_dsc () {
printdebug "linked (using ...,fetch).\n";
} elsif ((printdebug "($!) "),
$! != ENOENT) {
- fail "accessing ../$f,fetch: $!";
+ fail "accessing $buildproductsdir/$f,fetch: $!";
} elsif (link_ltarget $upper_f, $f) {
printdebug "linked.\n";
} elsif ((printdebug "($!) "),
$! != ENOENT) {
- fail "accessing ../$f: $!";
+ fail "accessing $buildproductsdir/$f: $!";
} else {
printdebug "absent.\n";
}
@@ -2141,14 +2146,14 @@ sub generate_commits_from_dsc () {
printdebug "linked.\n";
} elsif ((printdebug "($!) "),
$! != EEXIST) {
- fail "saving ../$f: $!";
+ fail "saving $buildproductsdir/$f: $!";
} elsif (!$refetched) {
printdebug "no need.\n";
} elsif (link $f, "$upper_f,fetch") {
printdebug "linked (using ...,fetch).\n";
} elsif ((printdebug "($!) "),
$! != EEXIST) {
- fail "saving ../$f,fetch: $!";
+ fail "saving $buildproductsdir/$f,fetch: $!";
} else {
printdebug "cannot.\n";
}
@@ -2575,7 +2580,7 @@ sub ensure_we_have_orig () {
foreach my $fi (@dfi) {
my $f = $fi->{Filename};
next unless is_orig_file_in_dsc($f, \@dfi);
- complete_file_from_dsc('..', $fi)
+ complete_file_from_dsc($buildproductsdir, $fi)
or next;
}
}
@@ -5646,8 +5651,9 @@ sub quilt_fixup_linkorigs ($$) {
my ($upstreamversion, $fn) = @_;
# calls $fn->($leafname);
- foreach my $f (<$maindir/../*>) { #/){
- my $b=$f; $b =~ s{.*/}{};
+ opendir QFD, bpd_abs();
+ while ($!=0, defined(my $b = readdir QFD)) {
+ my $f = bpd_abs()."/".$b;
{
local ($debuglevel) = $debuglevel-1;
printdebug "QF linkorigs $b, $f ?\n";
@@ -5657,6 +5663,8 @@ sub quilt_fixup_linkorigs ($$) {
link_ltarget $f, $b or die "$b $!";
$fn->($b);
}
+ die "$buildproductsdir: $!" if $!;
+ closedir QFD;
}
sub quilt_fixup_delete_pc () {
@@ -6223,15 +6231,16 @@ sub massage_dbp_args ($;$) {
return $r;
}
-sub in_parent (&) {
+sub in_bpd (&) {
my ($fn) = @_;
my $wasdir = must_getcwd();
- changedir "..";
+ changedir $buildproductsdir;
$fn->();
changedir $wasdir;
}
-sub postbuild_mergechanges ($) { # must run with CWD=.. (eg in in_parent)
+# this sub must run with CWD=$buildproductsdir (eg in in_bpd)
+sub postbuild_mergechanges ($) {
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.
@@ -6273,7 +6282,7 @@ END
sub midbuild_checkchanges () {
my $pat = changespat $version;
return if $rmchanges;
- my @unwanted = map { s#^\.\./##; $_; } glob "../$pat";
+ my @unwanted = map { s#.*/##; $_; } glob "$bpd_glob/$pat";
@unwanted = grep { $_ ne changespat $version,'source' } @unwanted;
fail <<END
changes files other than source matching $pat already present; building would result in ambiguity about the intended results.
@@ -6290,7 +6299,7 @@ sub midbuild_checkchanges_vanilla ($) {
sub postbuild_mergechanges_vanilla ($) {
my ($wantsrc) = @_;
if ($wantsrc == 1) {
- in_parent {
+ in_bpd {
postbuild_mergechanges(undef);
};
} else {
@@ -6332,7 +6341,7 @@ sub cmd_gbp_build {
# orig is absent.
my $upstreamversion = upstreamversion $version;
my $origfnpat = srcfn $upstreamversion, '.orig.tar.*';
- my $gbp_make_orig = $version =~ m/-/ && !(() = glob "../$origfnpat");
+ my $gbp_make_orig = $version =~ m/-/ && !(() = glob "$bpd_glob/$origfnpat");
if ($gbp_make_orig) {
clean_tree();
@@ -6404,7 +6413,7 @@ sub build_source {
build_prep();
$sourcechanges = changespat $version,'source';
if (act_local()) {
- unlink "../$sourcechanges" or $!==ENOENT
+ unlink "$buildproductsdir/$sourcechanges" or $!==ENOENT
or fail "remove $sourcechanges: $!";
}
$dscfn = dscfn($version);
@@ -6421,7 +6430,7 @@ sub build_source {
($f =~ m/\.debian\.tar(?:\.\w+)$/ &&
$f eq srcfn($version, $&));
printdebug "source copy, found $f - renaming\n";
- rename "$playground/$f", "../$f" or $!==ENOENT
+ rename "$playground/$f", "$buildproductsdir/$f" or $!==ENOENT
or fail "put in place new source file ($f): $!";
}
} else {
@@ -6433,7 +6442,7 @@ sub build_source {
}
runcmd_ordryrun_local qw(sh -ec),
'exec >$1; shift; exec "$@"','x',
- "../$sourcechanges",
+ "$buildproductsdir/$sourcechanges",
@dpkggenchanges, qw(-S), changesopts();
}
@@ -6448,7 +6457,7 @@ sub cmd_build_source {
sub cmd_sbuild {
build_source();
midbuild_checkchanges();
- in_parent {
+ in_bpd {
if (act_local()) {
stat_exists $dscfn or fail "$dscfn (in parent directory): $!";
stat_exists $sourcechanges
@@ -6457,7 +6466,7 @@ sub cmd_sbuild {
runcmd_ordryrun_local @sbuild, qw(-d), $isuite, @ARGV, $dscfn;
};
maybe_unapply_patches_again();
- in_parent {
+ in_bpd {
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.)
@@ -6593,7 +6602,7 @@ END
my @dfi = dsc_files_info();
foreach my $fi (@dfi) {
my $f = $fi->{Filename};
- my $here = "../$f";
+ my $here = "$buildproductsdir/$f";
if (lstat $here) {
next if stat $here;
fail "lstat $here works but stat gives $! !";