0
0
mirror of https://github.com/zeux/pugixml.git synced 2024-12-27 13:33:17 +08:00

Release archiving now converts newlines to Unix style in tar archives

git-svn-id: http://pugixml.googlecode.com/svn/trunk@606 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
arseny.kapoulkine 2010-07-19 09:46:30 +00:00
parent 18055b5bfa
commit 86ac39edb0
2 changed files with 64 additions and 10 deletions

View File

@ -148,18 +148,12 @@ RELEASE_FILES =
readme.txt readme.txt
; ;
actions ZipAction actions ArchiveAction
{ {
zip -q -9 $(<) $(>) perl tests/archive.pl $(<) $(>)
} }
actions TgzAction ArchiveAction pugixml-$(VERSION).zip : $(RELEASE_FILES) ;
{ ArchiveAction pugixml-$(VERSION).tar.gz : $(RELEASE_FILES) ;
tar cf $(<:S=) $(>)
gzip -9 $(<:S=)
}
ZipAction pugixml-$(VERSION).zip : $(RELEASE_FILES) ;
TgzAction pugixml-$(VERSION).tar.gz : $(RELEASE_FILES) ;
Depends release : pugixml-$(VERSION).zip pugixml-$(VERSION).tar.gz : $(RELEASE_FILES) ; Depends release : pugixml-$(VERSION).zip pugixml-$(VERSION).tar.gz : $(RELEASE_FILES) ;
NotFile release ; NotFile release ;

60
tests/archive.pl Normal file
View File

@ -0,0 +1,60 @@
#!/usr/bin/perl
use Archive::Tar;
use Archive::Zip;
my $target = shift @ARGV;
my @sources = @ARGV;
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);
if ($zip)
{
my $path = $source;
$arch->addDirectory($path) if $path =~ s/\/[^\/]+$/\// && !defined($arch->memberNamed($path));
my $member = $arch->addString($contents, $source);
$member->desiredCompressionMethod(COMPRESSION_DEFLATED);
$member->desiredCompressionLevel(9);
$member->setLastModFileDateTimeFromUnix($$meta{mtime});
}
else
{
# tgz releases are for Unix people, Unix people like Unix newlines
$contents =~ s/\r//g if (-T $source);
$arch->add_data($source, $contents, $meta);
}
}
$zip ? $arch->overwriteAs($target) : $arch->write($target, 9);
sub readfile_contents
{
my $file = shift;
open FILE, $file or die "Can't open $file: $!";
binmode FILE;
my @contents = <FILE>;
close FILE;
return join('', @contents);
}
sub readfile_meta
{
my $file = shift;
my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat($file);
return {mtime => $mtime};
}