From 9c71794454566244b7eaa528ead35b76cca40fc5 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 6 Jan 2019 16:27:35 +0000 Subject: [PATCH] dgit: Provide dotdot_bpd_transfer_origs for using origs from .. No callers yet so no functional change. Signed-off-by: Ian Jackson --- dgit | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/dgit b/dgit index 4b147b2d..21a3f287 100755 --- a/dgit +++ b/dgit @@ -2203,6 +2203,66 @@ sub check_bpd_exists () { $buildproductsdir, $!; } +sub dotdot_bpd_transfer_origs ($$$) { + my ($bpd_abs, $upstreamversion, $wanted) = @_; + # checks is_orig_file_of_vsn and if + # calls $wanted->{$leaf} and expects boolish + my $warned; + + if ($buildproductsdir ne '..') { + my $dotdot = $maindir; + $dotdot =~ s{/[^/]+$}{}; + opendir DD, $dotdot or fail "opendir .. ($dotdot): $!"; + while ($!=0, defined(my $leaf = readdir DD)) { + { + local ($debuglevel) = $debuglevel-1; + printdebug "DD_BPD $leaf ?\n"; + } + next unless is_orig_file_of_vsn $leaf, $upstreamversion; + next unless $wanted->($leaf); + next if lstat "$bpd_abs/$leaf"; + + print STDERR f_ +"%s: found orig(s) in .. missing from build-products-dir, transferring:\n", + $us + unless $warned++; + $! == &ENOENT or fail f_ + "check orig file %s in bpd %s: %s", $leaf, $bpd_abs, $!; + lstat "$dotdot/$leaf" or fail f_ + "check orig file %s in ..: %s", $leaf, $!; + if (-l _) { + stat "$dotdot/$leaf" or fail f_ + "check targe of orig symlink %s in ..: %s", $leaf, $!; + my $ltarget = readlink "$dotdot/$leaf" or + die "readlink $dotdot/$leaf: $!"; + if ($ltarget !~ m{^/}) { + $ltarget = "$dotdot/$ltarget"; + } + symlink $ltarget, "$bpd_abs/$leaf" + or die "$ltarget $bpd_abs $leaf: $!"; + print STDERR f_ + "%s: cloned orig symlink from ..: %s\n", + $us, $leaf; + } elsif (link "$dotdot/$leaf", "$bpd_abs/$leaf") { + print STDERR f_ + "%s: hardlinked orig from ..: %s\n", + $us, $leaf; + } elsif ($! != EXDEV) { + fail f_ "failed to make %s a hardlink to %s: %s", + "$bpd_abs/$leaf", "$dotdot/$leaf", $!; + } else { + symlink "$bpd_abs/$leaf", "$dotdot/$leaf" + or die "$bpd_abs $dotdot $leaf $!"; + print STDERR f_ + "%s: symmlinked orig from .. on other filesystem: %s\n", + $us, $leaf; + } + } + die "$dotdot; $!" if $!; + closedir DD; + } +} + sub generate_commits_from_dsc () { # See big comment in fetch_from_archive, below. # See also README.dsc-import. -- 2.30.2