archive.pl now creates a wrapping folder in both .tar.gz and .zip archives

git-svn-id: http://pugixml.googlecode.com/svn/trunk@935 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
arseny.kapoulkine@gmail.com 2012-11-20 05:34:06 +00:00
parent 3af13f1cb8
commit efc634a718

View file

@ -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);
}
}