Subject: | Portable downloads |
Date: | Mon, 6 Mar 2017 17:31:02 +0300 |
To: | bug-Perl-Dist-Strawberry [...] rt.cpan.org |
From: | Yuri <yurifrus [...] gmail.com> |
The portable.perl file apparently has lost its attributes and
modification time during recent mass-patching of archival portable
distributions (5.18.4.1 and older):
https://github.com/StrawberryPerl/strawberryperl.com/commit/4e2815abe3c48d22620faa7689a0ee4e5601e953
strawberry-perl-5.18.4.1-32bit-portable-old.zip
Filename: portable.perl
Modified: Tue Dec 3 12:47:58 2013
Attributes: 100444 UNIX
Size: 2661
CRC32: 311B87E6
strawberry-perl-5.18.4.1-32bit-portable.zip
Filename: portable.perl
Modified: Mon Jan 23 19:40:12 2017
Attributes: 000666 MSDOS
Size: 2638
CRC32: D95D9CF5
Could I suggest more accurate way of updating those portable zip files
preserving all original attributes as well as modification time of
resulting archive?
perl.exe -lMArchive::Zip
-e"Archive::Zip::setErrorHandler(\&CORE::die);for(@ARGV){my($z,$t)=(Archive::Zip->new,(stat)[9]);$z->read($_);my$m=$z->memberNamed('portable.perl')||next;$m->contents($m->contents=~s/^(.+)\r?\n(?=\1$)//mr);$m->desiredCompressionLevel(9);print;$z->overwrite;utime(($t)x2,$z->fileName)||die$!}"
The same code expanded with printf:
#!perl -l
use Archive::Zip;
Archive::Zip::setErrorHandler(\&CORE::die);
for (@ARGV) {
my ($z, $t) = (Archive::Zip->new, (stat)[9]);
$z->read($_);
my $m = $z->memberNamed('portable.perl') || next;
$m->contents($m->contents =~ s/^(.+)\r?\n(?=\1$)//mr);
$m->desiredCompressionLevel(9);
print;
$z->overwrite;
printf "Filename:\t%s\nModified:\t%s\nAttributes:\t%06o
%s\nSize:\t\t%d\nCRC32:\t\t%08X\n", $m->fileName, scalar localtime
$m->lastModTime, $m->unixFileAttributes, (split /,/,
'MSDOS,,,UNIX')[$m->fileAttributeFormat], $m->uncompressedSize,
$m->crc32;
utime(($t)x2, $z->fileName) || die $!;
}
Yuri