From 60f59661194029a6bba28ebf39d0bf5193789bc5 Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Fri, 7 Aug 2015 14:04:58 -0400 Subject: fix file lists and abspaths for dh_compress w/test Fix dh_compress to accept file names on the command line that it would otherwise compress anyway, by removing duplicates. Also allow dh_compress to accept absolute paths, by stripping the leading slashes. Add tests for the desired behavior in t/dh_compress.t . Fix an undefined warning in dh_compress that is sometimes triggered. Add a . -> lib symlink so that prove -vwlr t works. Signed-off-by: Niels Thykier --- dh_compress | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'dh_compress') diff --git a/dh_compress b/dh_compress index 1b33ac9a..a587454a 100755 --- a/dh_compress +++ b/dh_compress @@ -8,7 +8,8 @@ dh_compress - compress files and fix symlinks in package build directories use strict; use warnings; -use Cwd; +use Cwd qw(getcwd abs_path); +use File::Spec::Functions qw(abs2rel); use Debian::Debhelper::Dh_Lib; =head1 SYNOPSIS @@ -92,7 +93,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) { my @files; # First of all, deal with any files specified right on the command line. if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) { - push @files, @ARGV; + push @files, map { s{^/+}{}; $_ } @ARGV; } if ($compress) { # The compress file is a sh script that outputs the files to be compressed @@ -155,7 +156,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) { my %seen; foreach (@files) { my ($dev, $inode, undef, $nlink)=stat($_); - if ($nlink > 1) { + if (defined $nlink && $nlink > 1) { if (! $seen{"$inode.$dev"}) { $seen{"$inode.$dev"}=$_; push @f, $_; @@ -170,6 +171,12 @@ foreach my $package (@{$dh{DOPACKAGES}}) { } } + # normalize file names and remove duplicates + my @normalized = map abs2rel(abs_path($_)), @f; + my %uniq_f; @uniq_f{@normalized} = (); + @f = sort keys %uniq_f; + + # do it if (@f) { # Make executables not be anymore. xargs(\@f,"chmod","a-x"); -- cgit v1.2.3