diff --git a/cpan2rpm/cpan2rpm b/cpan2rpm/cpan2rpm index 28e8b01..1933cab 100755 --- a/cpan2rpm/cpan2rpm +++ b/cpan2rpm/cpan2rpm @@ -1253,14 +1253,11 @@ sub untar($) { system(@cmd) == 0 || die "system @cmd failed: $?"; system("chmod", "-R", "u+w", $dst); - my $cmd = $zip - ? "unzip -l $_ | grep -P -o '\\S+/\$' |tail -1" - : "tar -t${z}vf $_ |head -1" - ; + my $cmd = $zip ? "unzip -l $_" : "tar -t${z}vf $_"; + $cmd .= " | grep -E '(Makefile|Build)\\.PL'"; chomp($_ = qx/$cmd/); - $_ = (split)[5] unless $zip; - $dst .= "/$1" if m|^(\S+)/?|; + $dst .= "/$1" if m!(\S+)/(?:Makefile|Build)\.PL$!; $dst =~ s|/*$||; # path shouldn't end in / or tardir gets wiped $dst =~ s|\./||; # paths in tarballs shouldn't be relative return $dst;