[debhelper-devel] [debhelper] 02/03: Dh_Lib: Fix use of uninitialized variables in find_hardlinks
Niels Thykier
nthykier at moszumanska.debian.org
Sun Oct 22 21:24:33 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 077502cecdcff4ee38e3909f3d1fa809f5c8134e
Author: Niels Thykier <niels at thykier.net>
Date: Sun Oct 22 21:16:41 2017 +0000
Dh_Lib: Fix use of uninitialized variables in find_hardlinks
Signed-off-by: Niels Thykier <niels at thykier.net>
---
debian/changelog | 8 ++++++++
dh_compress | 2 +-
lib/Debian/Debhelper/Dh_Lib.pm | 2 +-
t/dh_compress.t | 22 ++++++++++++++++++++++
4 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index ebd1518..5de2bcd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+debhelper (10.10.2) UNRELEASED; urgency=medium
+
+ * Dh_Lib: Fix uninitialized warning in find_hardlinks that
+ broke dh_compress's ability to deal with hardlinks. Thanks
+ to Ondřej Surý for finding the bug.
+
+ -- Niels Thykier <niels at thykier.net> Sun, 22 Oct 2017 21:14:46 +0000
+
debhelper (10.10.1) unstable; urgency=medium
* debhelper.pod: Document that all tools by default must be run
diff --git a/dh_compress b/dh_compress
index 2c8061e..b4a891b 100755
--- a/dh_compress
+++ b/dh_compress
@@ -166,7 +166,7 @@ on_pkgs_in_parallel {
}
my $resolved = abs_path($norm_from_dir)
or error("Cannot resolve $norm_from_dir: $!");
- my @normalized = normalize_paths($norm_from_dir, $resolved, $tmp, @{$unique_files});
+ my @normalized = normalize_paths($norm_from_dir, $resolved, $tmp, @f);
my %uniq_f; @uniq_f{@normalized} = ();
@f = sort keys %uniq_f;
diff --git a/lib/Debian/Debhelper/Dh_Lib.pm b/lib/Debian/Debhelper/Dh_Lib.pm
index 7aac27a..97f2eae 100644
--- a/lib/Debian/Debhelper/Dh_Lib.pm
+++ b/lib/Debian/Debhelper/Dh_Lib.pm
@@ -2055,7 +2055,7 @@ sub find_hardlinks {
push(@unique_files, $file);
} else {
# This is a hardlink.
- $hardlinks{$_}=$seen{"$inode.$dev"};
+ $hardlinks{$file}=$seen{"$inode.$dev"};
}
} else {
push(@unique_files, $file);
diff --git a/t/dh_compress.t b/t/dh_compress.t
index 11c3e13..b2055f0 100755
--- a/t/dh_compress.t
+++ b/t/dh_compress.t
@@ -58,6 +58,28 @@ each_compat_subtest {
);
rm_test_dir();
+
+ mk_test_dir();
+
+ is(system('cp', '-la', "${PREFIX}/bar.txt", "${PREFIX}/hardlink.txt"), 0,
+ 'create hardlink');
+
+ ok(run_dh_tool('dh_compress'));
+
+ is_deeply(
+ [map { s{${PREFIX}/}{}; $_ } sort glob "$PREFIX/*"],
+ [qw|bar.txt.gz foo.txt hardlink.txt.gz|],
+ 'the 5k and its hardlink txt docs compressed'
+ );
+
+ # Verify that the hardlink is preserved.
+ my ($dev1, $inode1) = stat("${PREFIX}/bar.txt.gz") // error("stat ${PREFIX}/bar.txt.gz: $!");
+ my ($dev2, $inode2) = stat("${PREFIX}/hardlink.txt.gz") // error("stat ${PREFIX}/hardlink.txt.gz: $!");
+
+ is($dev1, $dev2, 'Still hardlinked');
+ is($inode1, $inode2, 'Still hardlinked');
+
+ rm_test_dir();
};
--
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