[debhelper-devel] [debhelper] 01/02: dh_compress: Improve path resolution error handling

Niels Thykier nthykier at moszumanska.debian.org
Sat Feb 27 10:12:33 UTC 2016


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

nthykier pushed a commit to branch master
in repository debhelper.

commit ef24f6405d14d1359d4b4e4c2028a28b47035d8b
Author: Niels Thykier <niels at thykier.net>
Date:   Sat Feb 27 10:11:57 2016 +0000

    dh_compress: Improve path resolution error handling
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 debian/changelog |  5 +++++
 dh_compress      | 25 ++++++++++++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index e4b587f..ce4f03e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -29,6 +29,11 @@ debhelper (9.20160116) UNRELEASED; urgency=medium
   * dh_installdeb: Clarify what goes in the "maintscript" config
     files.  Thanks to Julian Andres Klode for the report.
     (Closes: #814761)
+  * dh_compress: Correct and warn if given a path with a package
+    tmp dir prefix (e.g. "debian/<pkg>/path/to/file").
+  * dh_compress: Handle file resolution failures more gracefully.
+    Thanks to Daniel Leidert for reporting this issue.
+    (Closes: #802274)
 
   [ Joachim Breitner ]
   * addsubstvar: Pass -a to grep to handle substvars with unicode content
diff --git a/dh_compress b/dh_compress
index 7dcc36c..cca83cb 100755
--- a/dh_compress
+++ b/dh_compress
@@ -175,7 +175,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	}
 
 	# normalize file names and remove duplicates
-	my @normalized = map abs2rel(abs_path($_)), @f;
+	my @normalized = normalize_paths("${olddir}/${tmp}", $tmp, @f);
 	my %uniq_f; @uniq_f{@normalized} = ();
 	@f = sort keys %uniq_f;
 
@@ -220,6 +220,29 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	} while $changed;
 }
 
+sub normalize_paths {
+	my ($cwd, $tmp, @paths) = @_;
+	my @normalized;
+	my $prefix = qr{\Q${tmp}/};
+
+	for my $path (@paths) {
+		my $abs = abs_path($path);
+		if (not defined($abs)) {
+			my $err = $!;
+			my $alt = $path;
+			if ($alt =~ s/^$prefix//) {
+				$abs = abs_path($alt);
+			}
+			error(qq{Cannot resolve "$path": $err (relative to "${cwd}")})
+				if (not defined($abs));
+			warning(qq{Interpreted "$path" as "$alt"});
+		}
+		error("${abs} does not exist") if not -e $abs;
+		push(@normalized, abs2rel($abs, $cwd));
+	}
+	return @normalized;
+}
+
 =head1 SEE ALSO
 
 L<debhelper(7)>

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