Commit 23d02adf authored by Chris Lamb's avatar Chris Lamb 👀
Browse files

dh_strip_nondeterminism: Deduplicate hardlinks via stat(2) to avoid issues...

dh_strip_nondeterminism: Deduplicate hardlinks via stat(2) to avoid issues when processing files in parallel. As strip-nondeterminism's handlers are not currently guaranteed to be atomic, one process can temporarily truncate a file which can cause errors in other threads processing the "same" file under a unique pathname. This was causing a FTBFS in packages that deduplicate hardlinks in their build process (eg. src:debian-handbook). (Closes: #922168)
parent 3f4ba2fb
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ things to exclude.

init();

my @nondeterministic_files;
my (@nondeterministic_files, %seen);

sub testfile {
	return if -l $_ or -d $_; # Skip directories and symlinks always.
@@ -57,6 +57,11 @@ sub testfile {
		return if ($fn=~m/\Q$f\E/);
	}

	# Deduplicate hardlinks to avoid issues under parallelism
	my ($dev, $inode, undef, $nlink) = stat($_);
	return if defined $nlink && $nlink > 1 && $seen{"$inode.$dev"};
	$seen{"$inode.$dev"} = 1;

	my $normalizer = File::StripNondeterminism::get_normalizer_for_file($_);
	if ($normalizer) {
		push @nondeterministic_files, [$fn, $normalizer];