summaryrefslogtreecommitdiff
path: root/dgit
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2022-12-26 17:26:09 +0000
committerIan Jackson <ijackson@chiark.greenend.org.uk>2022-12-26 17:33:01 +0000
commit88d1b67c019e0746c2df59d4e4ec264485cfcb43 (patch)
tree98dfd9a4774d37b2e6c277df48777a745ab6b5f1 /dgit
parentd29b232c577f41113a5c99c54ae185e7794b4168 (diff)
dgit: Scan for duplicated orig tarballs with different names
Closes: #993769 Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Diffstat (limited to 'dgit')
-rwxr-xr-xdgit38
1 files changed, 38 insertions, 0 deletions
diff --git a/dgit b/dgit
index ba70cea..eee53dc 100755
--- a/dgit
+++ b/dgit
@@ -2266,6 +2266,44 @@ sub dotdot_bpd_transfer_origs ($$$) {
my $dotdot = $maindir;
$dotdot =~ s{/[^/]+$}{};
+ my %dupes;
+ my $dupe_scan = sub {
+ my ($dir, $why_token) = @_;
+
+ if (!opendir SD, $dir) {
+ return if $! == ENOENT;
+ fail "opendir $why_token ($dir): $!";
+ }
+ while ($!=0, defined(my $leaf = readdir SD)) {
+ next unless is_orig_file_of_vsn $leaf, $upstreamversion;
+ next if $leaf =~ m{$orig_f_sig_re$};
+ next unless $leaf =~ m{\.tar(?:\.\w+)?$};
+ my $base = "$`.tar";
+ push @{ $dupes{$base}{$leaf} }, [$why_token, $dir];
+ }
+ die "$dir; $!" if $!;
+ };
+ $dupe_scan->($dotdot, "..");
+ $dupe_scan->(bpd_abs(), 'build-products-dir') if $buildproductsdir ne '..';
+
+ my $dupes_found = 0;
+ foreach my $base (sort keys %dupes) {
+ my $leaves = $dupes{$base};
+ next if keys(%$leaves) == 1;
+ $dupes_found = 1;
+ print STDERR f_
+ "%s: multiple representations of similar orig %s:\n",
+ $us, $base;
+ foreach my $leaf (keys %$leaves) {
+ foreach my $found (@{ $leaves->{$leaf} }) {
+ print STDERR f_ " %s: in %s (%s)\n",
+ $leaf, @$found;
+ }
+ }
+ }
+ fail __ "Duplicate/inconsistent orig tarballs. Delete the spurious ones."
+ if $dupes_found;
+
return if $buildproductsdir eq '..';
my $warned;