[debhelper-devel] [debhelper] 01/01: install_{file, lib, prog}: Replace dangling symlinks

Niels Thykier nthykier at moszumanska.debian.org
Thu Jul 13 06:04:21 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 8c17ea3afc11295771e49861c860371d7cc79858
Author: Niels Thykier <niels at thykier.net>
Date:   Thu Jul 13 06:03:26 2017 +0000

    install_{file,lib,prog}: Replace dangling symlinks
    
    The "install" command they emulate did as well.
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 Debian/Debhelper/Dh_Lib.pm                         |  6 +++++
 debian/changelog                                   |  4 +++
 .../01-868204-ignore-broken-symlinks.t             | 30 ++++++++++++++++++++++
 3 files changed, 40 insertions(+)

diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 744c9f1..a5664a8 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -377,6 +377,12 @@ sub error_exitcode {
 		verbose_print(sprintf('install -p -m%04o %s', $mode, escape_shell($source, $dest)))
 			if $dh{VERBOSE};
 		return 1 if $dh{NO_ACT};
+		# "install -p -mXXXX foo bar" silently discards broken
+		# symlinks to install the file in place.  File::Copy does not,
+		# so emulate it manually.  (#868204)
+		if ( -l $dest and not -e $dest and not unlink($dest) and $! != ENOENT) {
+			error("unlink $dest failed: $!");
+		}
 		File::Copy::copy($source, $dest) or error("copy($source, $dest): $!");
 		chmod($mode, $dest) or error("chmod($mode, $dest): $!");
 		my (@stat) = stat($source);
diff --git a/debian/changelog b/debian/changelog
index 96de3c5..766ca42 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -21,6 +21,10 @@ debhelper (10.6.4) UNRELEASED; urgency=medium
   * dh_installexamples: Ditto.
   * dh_installinfo: Ditto.
   * dh_installman: Ditto.
+  * Dh_Lib.pm: Fix a regression in handling of dangling symlinks for
+    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)
 
  -- Niels Thykier <niels at thykier.net>  Sun, 09 Jul 2017 12:30:20 +0000
 
diff --git a/t/dh_installdocs/01-868204-ignore-broken-symlinks.t b/t/dh_installdocs/01-868204-ignore-broken-symlinks.t
new file mode 100755
index 0000000..b9801d2
--- /dev/null
+++ b/t/dh_installdocs/01-868204-ignore-broken-symlinks.t
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More;
+
+use File::Basename qw(dirname);
+use lib dirname(dirname(__FILE__));
+use Test::DH;
+use File::Path qw(remove_tree make_path);
+use Debian::Debhelper::Dh_Lib qw(!dirname);
+
+plan(tests => 1);
+
+each_compat_subtest {
+	my ($compat) = @_;
+	# #868204 - dh_installdocs did not replace dangling symlink
+	make_path('debian/debhelper/usr/share/doc/debhelper');
+	make_symlink_raw_target('../to/nowhere/bar',
+							'debian/debhelper/usr/share/doc/debhelper/README.Debian');
+	create_empty_file('debian/README.Debian');
+
+	ok(-l 'debian/debhelper/usr/share/doc/debhelper/README.Debian');
+	ok(!-e 'debian/debhelper/usr/share/doc/debhelper/README.Debian');
+
+	ok(run_dh_tool('dh_installdocs'));
+	ok(!-l 'debian/debhelper/usr/share/doc/debhelper/README.Debian', "#868204 [${compat}]");
+	ok(-f 'debian/debhelper/usr/share/doc/debhelper/README.Debian', "#868204 [${compat}]");
+	remove_tree('debian/debhelper', 'debian/tmp');
+};
+

-- 
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