summaryrefslogtreecommitdiff
path: root/dh_compress
diff options
context:
space:
mode:
authorNiels Thykier <niels@thykier.net>2016-02-27 10:11:57 +0000
committerNiels Thykier <niels@thykier.net>2016-02-27 10:11:57 +0000
commitef24f6405d14d1359d4b4e4c2028a28b47035d8b (patch)
treec13a5f8536287b68b191903104cfa087bef6bf24 /dh_compress
parent333738c6b8ca1fcf8436184eca7533ae09b4ef20 (diff)
downloaddebhelper-ef24f6405d14d1359d4b4e4c2028a28b47035d8b.tar.gz
dh_compress: Improve path resolution error handling
Signed-off-by: Niels Thykier <niels@thykier.net>
Diffstat (limited to 'dh_compress')
-rwxr-xr-xdh_compress25
1 files changed, 24 insertions, 1 deletions
diff --git a/dh_compress b/dh_compress
index 7dcc36c4..cca83cb2 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)>