[debhelper-devel] [debhelper] 01/01: dh_install: Disable bulk install optimization on clashes

Niels Thykier nthykier at moszumanska.debian.org
Thu Jul 13 18:16:48 UTC 2017


This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository debhelper.

commit 50366a3095e65431e4460835b1c40416557945ac
Author: Niels Thykier <niels at thykier.net>
Date:   Thu Jul 13 18:12:01 2017 +0000

    dh_install: Disable bulk install optimization on clashes
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 debian/changelog |  3 +++
 dh_install       | 42 +++++++++++++++++++++++++++---------------
 2 files changed, 30 insertions(+), 15 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 766ca42..d250925 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -25,6 +25,9 @@ debhelper (10.6.4) UNRELEASED; urgency=medium
     native file copying that caused dh_installdocs to no longer replace
     dangling symlinks with real files.  Thanks to Stéphane Glondu
     for the report.  (Closes: #868204)
+  * dh_install: Silently disable bulk optimization when two source paths
+    have the same destination.  Thanks to Gianfranco Costamagna for
+    reporting the regression.  (Closes: #868169)
 
  -- Niels Thykier <niels at thykier.net>  Sun, 09 Jul 2017 12:30:20 +0000
 
diff --git a/dh_install b/dh_install
index 60ac42c..b5a3248 100755
--- a/dh_install
+++ b/dh_install
@@ -232,32 +232,44 @@ foreach my $package (getpackages()) {
 		next if $skip_install or $missing_files;
 
 		if (not $exclude) {
+			my @unoptimized;
 			for my $src (@filelist) {
 				my $d = $dest // compute_dest($src);
 				my $basename = basename($src);
 				if (exists($dest2sources{$d}{$basename})) {
-					my $replaced = $dest2sources{$d}{$basename};
-					# warn if the sources differ, but permit
-					# duplicates of the same source (as that is
-					# well-defined).
-					warning("$src overwrites $replaced (both installed as: $d/$basename)")
-						if $src ne $replaced;
-					# Historical behaviour is to use the last
-					# specified version where there was duplicates (as
-					# cp was called once per file in order).  Keep
-					# that for compatibility.
+					# If there is a clash, silently undo the optimizations.
+					# See #866405 and #868169.
+					my $replaced = delete($dest2sources{$d}{$basename});
+					# Associate the $replaced the destination
+					# directory.  We cannot be sure that compute_dest will
+					# get it right nor can we blindly set $dest.
+					#
+					# It is technically unnecessary for $src, but we
+					# might as well do it to possibly save a
+					# compute_dest call.
+					push(@unoptimized, [$replaced, $d], [$src, $d]);
+					next;
 				}
 				$dest2sources{$d}{$basename} = $src;
 			}
-			next;
+			next if not @unoptimized;
+			@filelist = @unoptimized;
 		}
 
 		foreach my $src (@filelist) {
 
-			my $target_dest = $dest;
-			if (! defined $target_dest) {
-				# Guess at destination directory.
-				$target_dest = compute_dest($src);
+			my $target_dest;
+
+			if (ref($src)) {
+				# On a failed optimization, we will have the
+				# destination directory.
+				($src, $target_dest) = @{$src};
+			} else {
+				$target_dest = $dest;
+				if (! defined $target_dest) {
+					# Guess at destination directory.
+					$target_dest = compute_dest($src);
+				}
 			}
 
 			# Make sure the destination directory exists.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git




More information about the debhelper-devel mailing list