Arabic
view release on metacpan or search on metacpan
LICENSING
close FH_LICENSE;
check_usascii('LICENSE');
# make work directory
my $dirname = (dirname($file[0]) eq 'bin') ? 'App' : dirname($file[0]);
$dirname =~ tr#/#-#;
my $basename = basename($file[0], '.pm','.pl','.bat');
my $tardir = "$dirname-$basename-$version";
$tardir =~ s#^lib-##;
rmtree($tardir,0,0);
if ($^O =~ /(?:solaris|linux)/i) {
for my $file (@file) {
if (-e $file) {
mkpath(dirname("$tardir/$file"), 0, 0777);
print STDERR "copy $file $tardir/$file\n";
copy($file, "$tardir/$file");
if ($file =~ m/ (?: Build\.PL | Makefile\.PL ) \z/oxmsi) {
chmod(0664, "$tardir/$file");
}
elsif ($file =~ m/\. (?: pl | bat | exe | com ) \z/oxmsi) {
chmod(0775, "$tardir/$file");
}
elsif ($file =~ m{^bin/}oxmsi) {
chmod(0775, "$tardir/$file");
}
else {
chmod(0664, "$tardir/$file");
}
}
}
system(qq{tar -cvf $tardir.tar $tardir});
system(qq{gzip $tardir.tar});
}
else {
#-----------------------------------------------------------------------------
# https://metacpan.org/search?q=Archive%3A%3ATar%3A%3AConstant
# https://metacpan.org/release/Archive-Tar-Streamed
#-----------------------------------------------------------------------------
eval q{
use Compress::Zlib;
use Archive::Tar;
};
my $BLOCK_SIZE = 512;
my $ZERO_BLOCK = "\0" x $BLOCK_SIZE;
# make *.tar file
open(FH_TAR, ">$tardir.tar") || die "Can't open file: $tardir.tar\n"; #'
binmode FH_TAR;
for my $file (@file) {
if (-e $file) {
mkpath(dirname("$tardir/$file"), 0, 0777);
print STDERR "copy $file $tardir/$file\n";
copy($file, "$tardir/$file");
#-----------------------------------------------------------------------------
# Sunday December 21, 2008 07:38 PM
# Fixing world writable files in tarball before upload to CPAN [ #38127 ]
# http://use.perl.org/~bart/journal/38127 (dead link)
# Fix CPAN uploads for world writable files
# http://perlmonks.org/index.pl?node_id=731935
#-----------------------------------------------------------------------------
# $tar->add_files("$tardir/$file");
#-----------------------------------------------------------------------------
open(FH, $file) || die "Can't open file: $file\n"; #'
binmode FH;
local $/ = undef; # slurp mode
my $data = <FH>;
close FH;
#-----------------------------------------------------------------------------
# Kwalitee Indicator: buildtool_not_executable core
# The build tool (Build.PL/Makefile.PL) is executable. This is bad because
# you should specify which perl you want to use while installing.
#
# How to fix
# Change the permissions of Build.PL/Makefile.PL to not-executable.
#-----------------------------------------------------------------------------
my $tar = Archive::Tar->new;
if ($file =~ m/ (?: Build\.PL | Makefile\.PL ) \z/oxmsi) {
$tar->add_data("$tardir/$file", $data, {'mode' => 0664});
}
elsif ($file =~ m/\. (?: pl | bat | exe | com ) \z/oxmsi) {
$tar->add_data("$tardir/$file", $data, {'mode' => 0775});
}
else {
$tar->add_data("$tardir/$file", $data, {'mode' => 0664});
}
my $format_tar_file = $tar->write;
syswrite FH_TAR, $format_tar_file, length($format_tar_file) - length($ZERO_BLOCK . $ZERO_BLOCK);
undef $tar;
#-----------------------------------------------------------------------------
}
else {
die "file: $file is not exists.\n";
}
}
# syswrite FH_TAR, $ZERO_BLOCK; makes "tar: A lone zero block at %s"
syswrite FH_TAR, ($ZERO_BLOCK . $ZERO_BLOCK);
close FH_TAR;
rmtree($tardir,0,0);
# make *.tar.gz file
my $gz = gzopen("$tardir.tar.gz", 'wb');
open(FH_TAR, "$tardir.tar") || die "Can't open file: $tardir.tar\n";
binmode FH_TAR;
while (sysread(FH_TAR, $_, 1024*1024)) {
$gz->gzwrite($_);
}
close FH_TAR;
$gz->gzclose;
unlink "$tardir.tar";
}
# P.565 Cleaning Up Your Environment
# in Chapter 23: Security
( run in 0.961 second using v1.01-cache-2.11-cpan-b16cb0d3907 )