App-GhostWork
view release on metacpan or search on metacpan
Config 0
ExtUtils::MakeMaker 5.4302
Fcntl 1.03
File::Basename 2.6
File::Copy 2.02
File::Path 1.0401
FindBin 1.42
IOas::CP932 0.06
IOas::CP932IBM 0.06
IOas::CP932NEC 0.06
IOas::CP932X 0.06
IOas::SJIS2004 0.06
Jacode4e::RoundTrip 2.13.81.8
UTF8::R2 0.05
strict 1.01
));
my %requires = (qw(
perl 5.005_03
));
my %provides = ();
for my $file (grep /\.(pl|pm|t|bat)\z/i, @file) {
if (open FILE, $file) {
while (<FILE>) {
chomp;
if (/^use\s+([0-9]+(\.[0-9]*)?)/) {
$requires{'perl'} = $1;
}
elsif (/^use\s+([A-Za-z][^;\s]*).*;/) {
$requires{$1} = ($requires_version{$1} || '0');
}
elsif (/^package\s+([A-Za-z][^;\s]*).*;/) {
$provides{$1} = $file;
}
}
close(FILE);
}
}
delete @requires{keys %provides};
if ($package eq 'Char') {
delete @requires{qw(
Ebig5hkscs
Ebig5plus
Egb18030
Egbk
Ehp15
Einformixv6als
Ekps9566
Euhc
)};
delete @provides{qw(
Esjis
Sjis
)};
}
# 12345678
my $requires_as_makefile_pl = join "\n", map {qq{ '$_' => '$requires{$_}',}} sort keys %requires;
# write Makefile.PL
open(FH_MAKEFILEPL,'>Makefile.PL') || die "Can't open file: Makefile.PL.\n";
binmode FH_MAKEFILEPL;
printf FH_MAKEFILEPL (<<'END', $package, $version, $abstract, $requires_as_makefile_pl, $author);
use strict;
BEGIN { $INC{'warnings.pm'} = '' if $] < 5.006 }; use warnings; local $^W=1;
use ExtUtils::MakeMaker;
WriteMakefile(
'NAME' => q{%s},
'VERSION' => q{%s},
'ABSTRACT' => q{%s},
'PREREQ_PM' => {
%s
},
'AUTHOR' => q{%s},
);
__END__
END
close(FH_MAKEFILEPL);
check_usascii('Makefile.PL');
# write META.yml
#
# CPANTS Kwalitee shows us following message, but never believe it.
# It's a trap. #'
#
# Kwalitee Indicator: meta_yml_conforms_to_known_spec core
# META.yml does not conform to any recognised META.yml Spec.
# How to fix
# Take a look at the META.yml Spec at https://metacpan.org/pod/CPAN::Meta::History::Meta_1_4
# (for version 1.4) or https://metacpan.org/pod/CPAN::Meta::Spec (for version 2),
# and change your META.yml accordingly.
#
# How to escape from trap
#
# meta-spec:
# version: 1.4
# url: http://module-build.sourceforge.net/META-spec-v1.4.html
# 12 1234
my $provides_as_yml = join "\n", map {" $_:\n file: $provides{$_}"} sort keys %provides;
my $requires_as_yml = join "\n", map {" $_: $requires{$_}"} sort keys %requires;
# 12
open(FH_METAYML,'>META.yml') || die "Can't open file: META.yml.\n";
binmode FH_METAYML;
printf FH_METAYML (<<'END', $name_as_dist_on_url, $version, $abstract, $author, $requires_as_yml, $name_as_dist_on_url);
--- #YAML:1.0
meta-spec:
version: 1.4
url: http://module-build.sourceforge.net/META-spec-v1.4.html
name: %s
version: %s
abstract: %s
author:
- %s
license: perl
generated_by: pmake.bat
requires:
%s
build_requires:
Test: 1.122
resources:
license: http://dev.perl.org/licenses/
repository: https://github.com/ina-cpan/%s
END
close(FH_METAYML);
check_usascii('META.yml');
# write META.json
#
# CPANTS Kwalitee shows us following message, but never believe it.
# It's a trap. #'
#
# Kwalitee Indicator: meta_json_conforms_to_known_spec
# META.json does not conform to any recognised META Spec.
# How to fix
# Take a look at the META.json Spec at https://metacpan.org/pod/CPAN::Meta::History::Meta_1_4
# (for version 1.4) or https://metacpan.org/pod/CPAN::Meta::Spec (for version 2),
# and change your META.json accordingly.
#
# How to escape from trap
#
# "meta-spec" : {
# "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
# "version" : 2
# },
# 1234567890123456
my $requires_as_json = join ",\n", map {qq{ "$_" : "$requires{$_}"}} sort keys %requires;
my $provides_as_json = join ",\n", map {qq{ "$_" : {\n "file" : "$provides{$_}"\n }}} sort keys %provides;
# 12345678 123456789012 12345678
open(FH_METAJSON,'>META.json') || die "Can't open file: META.json.\n";
binmode FH_METAJSON;
printf FH_METAJSON (<<'END', $name_as_dist_on_url, $version, $abstract, $author, $name_as_dist_on_url, $requires_as_json, $requires_as_json, $requires_as_json);
{
"name" : "%s",
"version" : "%s",
"abstract" : "%s",
"author" : [
"%s"
],
"dynamic_config" : 1,
"generated_by" : "pmake.bat",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : 2
},
"release_status" : "stable",
"resources" : {
"license" : [
"http://dev.perl.org/licenses/"
],
"repository" : {
"url" : "https://github.com/ina-cpan/%s"
}
},
"prereqs" : {
"build" : {
"requires" : {
%s
}
},
"configure" : {
"requires" : {
%s
}
},
"runtime" : {
"requires" : {
%s
}
}
}
}
END
close(FH_METAJSON);
check_usascii('META.json');
# write LICENSE
open(FH_LICENSE,'>LICENSE') || die "Can't open file: LICENSE\n";
binmode FH_LICENSE;
print FH_LICENSE <<'LICENSING';
Terms of Perl itself
a) the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any
later version, or
b) the "Artistic License"
----------------------------------------------------------------------------
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
b) use the modified Package only within your corporation or
organization.
c) rename any non-standard executables so the names do not
conflict with standard executables, which must also be provided,
and provide a separate manual page for each non-standard
executable that clearly documents how it differs from the Standard
Version.
d) make other distribution arrangements with the Copyright Holder.
4. You may distribute the programs of this Package in object code or executable
form, provided that you do at least ONE of the following:
a) distribute a Standard Version of the executables and library
files, together with instructions (in the manual page or equivalent)
on where to get the Standard Version.
b) accompany the distribution with the machine-readable source of
the Package with your modifications.
c) accompany any non-standard executables with their
corresponding Standard Version executables, giving the
non-standard executables non-standard names, and clearly
documenting the differences in manual pages (or equivalent),
together with instructions on where to get the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
5. You may charge a reasonable copying fee for any distribution of this Package.
You may charge any fee you choose for support of this Package. You may not
charge a fee for this Package itself. However, you may distribute this Package in
aggregate with other (possibly commercial) programs as part of a larger
(possibly commercial) software distribution provided that you do not advertise
this Package as a product of your own.
6. The scripts and library files supplied as input to or produced as output from
the programs of this Package do not automatically fall under the copyright of this
Package, but belong to whomever generated them, and may be sold
commercially, and may be aggregated with this Package.
7. C or perl subroutines supplied by you and linked into this Package shall not
be considered part of this Package.
8. The name of the Copyright Holder may not be used to endorse or promote
products derived from this software without specific prior written permission.
9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
PURPOSE.
The End
LICENSING
close FH_LICENSE;
check_usascii('LICENSE');
# write CONTRIBUTING
open(FH_CONTRIBUTING,'>CONTRIBUTING') || die "Can't open file: CONTRIBUTING\n";
binmode FH_CONTRIBUTING;
print FH_CONTRIBUTING <<'TO_CONTRIBUTE';
# Contributing to this project
Before you go crazy with huge changes, send some small e-mail to check
that we want to change the tools in that way. E-mail that have one logical
change are better.
Good e-mail, patches, improvements, new features - are a fantastic help.
They should remain focused in scope and avoid containing unrelated commits.
**Please ask first** before embarking on any significant e-mail (e.g.
implementing features, refactoring code, porting to a different language),
otherwise you risk spending a lot of time working on something that the
project's developers might not want to merge into the project.
Please adhere to the coding conventions used throughout a project
(indentation, accurate comments, etc.) and any other requirements (such
as test coverage).
**IMPORTANT**: By submitting a patch, you agree to allow the project owner
to license your work under the same license as that used by the project.
TO_CONTRIBUTE
close FH_CONTRIBUTING;
check_usascii('CONTRIBUTING');
# 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
# of ISBN 0-596-00027-8 Programming Perl Third Edition.
# local $ENV{'PATH'} = '.';
local @ENV{qw(IFS CDPATH ENV BASH_ENV)};
# untar test
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) {
system(qq{pmake.bat ptar.bat});
system(qq{ptar.bat xzvf $tardir.tar.gz});
}
else {
system(qq{./pmake.bat ptar});
system(qq{./ptar xzvf $tardir.tar.gz});
}
}
# make ptar
elsif ($target =~ /^ptar(?:\.bat)?$/) {
my $ptar = <<'PTAR_END';
######################################################################
#
# ptar - tar of Perl Poor Tools
#
# Copyright (c) 2008, 2009, 2010, 2011, 2018, 2019, 2020, 2021 INABA Hitoshi <ina@cpan.org> in a CPAN
######################################################################
use strict;
BEGIN { $INC{'warnings.pm'} = '' if $] < 5.006 }; use warnings; local $^W=1;
if (scalar(@ARGV) == 0) {
die <<END;
usage: ptar xzvf file1.tar.gz file2.tar.gz ...
** This ptar supports xzvf option only. **
e(x)tract
(z)ip-file
(v)erbose
(f)ile
END
}
if ($ARGV[0] eq 'xzvf') {
() = shift @ARGV;
}
for my $gzfile (grep m/\.tar\.gz$/xmsi, @ARGV) {
if ($^O =~ /(?:solaris|linux)/i) {
system(qq{gzip -cd $gzfile | tar -xvf -});
}
else {
eval q{
use Compress::Zlib;
use Archive::Tar;
};
my $gz = gzopen($gzfile, 'rb');
(my $tarfile = $gzfile) =~ s/\.gz$//xmsi;
open(FH_TAR, ">$tarfile") || die "Can't open file: $tarfile\n";
binmode FH_TAR;
while ($gz->gzreadline(my $line)) {
print FH_TAR $line;
}
$gz->gzclose;
close FH_TAR;
my $tar = Archive::Tar->new($tarfile,1);
for my $file ($tar->list_files){
if (-e $file) {
print STDERR "skip $file is already exists.\n";
}
else {
print STDERR "x $file\n";
$tar->extract($file);
}
}
unlink $tarfile;
}
}
__END__
PTAR_END
# make ptar.bat
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) {
open(FH_TARBAT, '>ptar.bat') || die "Can't open file: ptar.bat\n";
print FH_TARBAT <<'END';
@rem = '--*-Perl-*--
@echo off
if "%OS%" == "Windows_NT" goto WinNT
perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
goto endofperl
:WinNT
perl -x -S "%0" %*
if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
if %errorlevel% == 9009 echo You do not have Perl in your PATH.
goto endofperl
@rem ';
#!perl
#line 14
undef @rem;
END
print FH_TARBAT $ptar;
print FH_TARBAT ":endofperl\n";
close FH_TARBAT;
}
# make ptar
else {
open(FH_TARBAT, '>ptar') || die "Can't open file: ptar\n";
print FH_TARBAT '#!', &which($^X), "\n";
print FH_TARBAT $ptar;
close FH_TARBAT;
chmod 0755, 'ptar';
}
}
# unzip and untar *.tar.gz
elsif ($target =~ /^xzvf$/) {
for my $gzfile (grep m/\.tar\.gz$/xmsi, @ARGV) {
if ($^O =~ /(?:solaris|linux)/i) {
system(qq{gzip -cd $gzfile | tar -xvf -});
}
else {
eval q{
use Compress::Zlib;
use Archive::Tar;
};
my $gz = gzopen($gzfile, 'rb');
(my $tarfile = $gzfile) =~ s/\.gz$//xmsi;
open(FH_TAR, ">$tarfile") || die "Can't open file: $tarfile\n";
binmode FH_TAR;
while ($gz->gzreadline(my $line)) {
print FH_TAR $line;
}
$gz->gzclose;
close FH_TAR;
my $tar = Archive::Tar->new($tarfile,1);
for my $file ($tar->list_files){
if (-e $file) {
print STDERR "skip $file is already exists.\n";
}
else {
print STDERR "x $file\n";
$tar->extract($file);
}
}
unlink $tarfile;
}
}
last;
}
# make pwget
elsif ($target =~ /^pwget(?:\.bat)?$/) {
my $pwget = <<'PWGET_END';
######################################################################
#
# pwget - wget of Perl Poor Tools
#
# Copyright (c) 2011, 2018, 2019, 2020, 2021 INABA Hitoshi <ina@cpan.org> in a CPAN
######################################################################
use Socket;
unless (@ARGV) {
die <<END;
usage: pwget http://www.foo.com/bar/baz.tar.gz
END
}
my $url = $ARGV[0];
my $forward = 3;
while ($forward-- > 0) {
my($hostname) = $url =~ m#http://([^/]+)/#;
my $port = ($hostname =~ s/:([0-9]+)//) ? $1 : 80;
socket(SOCKET,PF_INET,SOCK_STREAM,getprotobyname('tcp')) || die "Can't open TCP/IP socket.\n";
connect(SOCKET,sockaddr_in($port,inet_aton($hostname))) || die "Can't connect to $hostname:$port.\n";
select SOCKET;
$| = 1;
select STDOUT;
my $request = <<END;
GET $url HTTP/1.0
Accept: */*
User-Agent: $0
END
$request =~ s/\n/\r\n/g;
print SOCKET $request;
my($head,$body) = split(/\r\n\r\n/,join('',<SOCKET>),2);
close SOCKET;
if ($head =~ m#^Location: (\S+)#ms) {
$url = $1;
print STDERR "Location: $url\n";
next;
}
my($file) = $ARGV[0] =~ m#([^/]+)$#;
open(FILE,">$file") || die "Can't open file: $file\n";
binmode FILE;
print FILE $body;
close FILE;
if ($head =~ m#Content-Length: ([0-9]+)#ms) {
if (-s $file == $1) {
print STDERR "ok - $file\n";
}
else {
print STDERR "not ok - $file\n";
unlink $file;
}
}
last;
}
__END__
PWGET_END
# make pwget.bat
if ($^O =~ /\A (?: MSWin32 | NetWare | symbian | dos ) \z/oxms) {
open(FH_WGETBAT, '>pwget.bat') || die "Can't open file: pwget.bat\n";
print FH_WGETBAT <<'END';
@rem = '--*-Perl-*--
@echo off
if "%OS%" == "Windows_NT" goto WinNT
perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
goto endofperl
:WinNT
perl -x -S "%0" %*
if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
if %errorlevel% == 9009 echo You do not have Perl in your PATH.
goto endofperl
@rem ';
#!perl
#line 14
undef @rem;
END
print FH_WGETBAT $pwget;
print FH_WGETBAT ":endofperl\n";
close FH_WGETBAT;
}
# make pwget
else {
open(FH_WGETBAT, '>pwget') || die "Can't open file: pwget\n";
print FH_WGETBAT '#!', &which($^X), "\n";
print FH_WGETBAT $pwget;
close FH_WGETBAT;
chmod 0755, 'pwget';
}
}
else {
warn "unknown target: $target.\n";
}
}
sub which {
if ($_[0] =~ m#\A / #oxms) {
return $_[0];
}
else {
( run in 0.736 second using v1.01-cache-2.11-cpan-39bf76dae61 )