[debhelper-devel] [debhelper] 01/01: dh_install: Bulk install sources
Niels Thykier
nthykier at moszumanska.debian.org
Sat Jul 8 20:40:00 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 ad179c977452703dbb6752964d75f05fe17b24a5
Author: Niels Thykier <niels at thykier.net>
Date: Wed Jul 5 14:27:05 2017 +0000
dh_install: Bulk install sources
Signed-off-by: Niels Thykier <niels at thykier.net>
---
debhelper.pod | 7 -------
debian/changelog | 2 ++
dh_install | 48 ++++++++++++++++++++++++------------------------
3 files changed, 26 insertions(+), 31 deletions(-)
diff --git a/debhelper.pod b/debhelper.pod
index 3d0c453..8e3bfcd 100644
--- a/debhelper.pod
+++ b/debhelper.pod
@@ -697,13 +697,6 @@ to drop support for the B<PERL_USE_UNSAFE_INC> environment variable.
When perl drops support for it, then this variable will be removed
retroactively from existing compat levels as well.
-=item -
-
-B<dh_install> now attempts to optimize installations by bulking files
-together. Generally, this should just silently make things faster.
-However, it can cause issues if multiple patterns expand to the same
-target file.
-
=back
=back
diff --git a/debian/changelog b/debian/changelog
index 5abbf64..0926ade 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,8 @@ debhelper (10.6.3) UNRELEASED; urgency=medium
* Dh_Lib.pm: Embed tool versions into autoscripts so lintian can
extract and display them. Tools that want to rely on this
feature should set "$main::VERSION" to the version of the tool.
+ * dh_install: Rewrite and re-nable optimization so it
+ deterministically and gracefully handles cases like #866405.
-- Niels Thykier <niels at thykier.net> Wed, 05 Jul 2017 15:51:48 +0000
diff --git a/dh_install b/dh_install
index 3cf2418..138498b 100755
--- a/dh_install
+++ b/dh_install
@@ -160,7 +160,7 @@ push(@search_dirs, 'debian/tmp') if not compat(6);
# PROMISE: DH NOOP WITHOUT install
foreach my $package (getpackages()) {
- my @installed;
+ my (@installed, %dest2sources);
# Look at the install files for all packages to handle
# list-missing/fail-missing, but skip really installing for
@@ -200,7 +200,7 @@ foreach my $package (getpackages()) {
foreach my $glob (@$set) {
my @found = glob_expand(\@search_dirs, $glob_error_handler, $glob);
- push(@filelist, @found);
+ push(@filelist, map { tr{/}{/}s; $_ } @found);
}
if (! @filelist && ! $skip_install) {
@@ -217,30 +217,24 @@ foreach my $package (getpackages()) {
next if $skip_install or $missing_files;
if (not $exclude) {
- # Without $exclude and if everything is installed in the same directory, it is trivial
- # to bulk them cp calls via xargs.
- if (not $dest and @filelist > 1) {
- my $same = 1;
- my $common_dest;
- for my $src (@filelist) {
- my $target_dest = compute_dest($src);
- if (not defined($common_dest)) {
- $common_dest = $target_dest;
- } elsif ($common_dest ne $target_dest) {
- $same = 0;
- last;
- }
- }
- $dest = $common_dest if ($same and $common_dest);
- }
- if ($dest and @filelist > 1) {
- if (not compat(10)) {
- # Make sure the destination directory exists.
- install_dir("$tmp/$dest");
- xargs(\@filelist, "cp", '--reflink=auto', "-a", XARGS_INSERT_PARAMS_HERE, "$tmp/$dest/");
- next;
+ 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.
}
+ $dest2sources{$d}{$basename} = $src;
}
+ next;
}
foreach my $src (@filelist) {
@@ -274,6 +268,12 @@ foreach my $package (getpackages()) {
}
}
+ for my $dest (sort(keys(%dest2sources))) {
+ my @srcs = sort(values(%{$dest2sources{$dest}}));
+ # Make sure the destination directory exists.
+ install_dir("$tmp/$dest");
+ xargs(\@srcs, "cp", '--reflink=auto', "-a", XARGS_INSERT_PARAMS_HERE, "$tmp/$dest/");
+ }
log_installed_files($package, @installed);
}
--
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