summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/archive.pl10
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/archive.pl b/tests/archive.pl
index 4ede302..0de0945 100644
--- a/tests/archive.pl
+++ b/tests/archive.pl
@@ -6,21 +6,23 @@ use Archive::Zip;
my $target = shift @ARGV;
my @sources = @ARGV;
-my $zip = $target =~ /\.zip$/;
+my $basedir = ($target =~ /^(.*)(\.zip|\.tar.gz|\.tgz)$/) ? "$1/" : '';
+my $zip = $target =~ /\.zip$/;
my $arch = $zip ? Archive::Zip->new : Archive::Tar->new;
for $source (sort {$a cmp $b} @sources)
{
my $contents = &readfile_contents($source);
my $meta = &readfile_meta($source);
+ my $file = $basedir . $source;
if ($zip)
{
- my $path = $source;
+ my $path = $file;
$arch->addDirectory($path) if $path =~ s/\/[^\/]+$/\// && !defined($arch->memberNamed($path));
- my $member = $arch->addString($contents, $source);
+ my $member = $arch->addString($contents, $file);
$member->desiredCompressionMethod(COMPRESSION_DEFLATED);
$member->desiredCompressionLevel(9);
@@ -32,7 +34,7 @@ for $source (sort {$a cmp $b} @sources)
# tgz releases are for Unix people, Unix people like Unix newlines
$contents =~ s/\r//g if (-T $source);
- $arch->add_data($source, $contents, $meta);
+ $arch->add_data($file, $contents, $meta);
}
}