@@ -9,7 +9,7 @@ $fatpacked{"Algorithm/C3.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AL
9
9
ALGORITHM_C3
10
10
11
11
$fatpacked{"App/cpm.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'APP_CPM';
12
- package App::cpm;use strict;use warnings;our$VERSION='0.997022 ';our ($GIT_DESCRIBE,$GIT_URL);1;
12
+ package App::cpm;use strict;use warnings;our$VERSION='0.997023 ';our ($GIT_DESCRIBE,$GIT_URL);1;
13
13
APP_CPM
14
14
15
15
$fatpacked{"App/cpm/CLI.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'APP_CPM_CLI';
@@ -57,7 +57,7 @@ $fatpacked{"App/cpm/Resolver.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<
57
57
APP_CPM_RESOLVER
58
58
59
59
$fatpacked{"App/cpm/Resolver/02Packages.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'APP_CPM_RESOLVER_02PACKAGES';
60
- package App::cpm::Resolver::02Packages;use strict;use warnings;use App::cpm::DistNotation;use App::cpm::HTTP;use App::cpm::version;use CPAN::02Packages::Search;use Cwd ();use File::Basename ();use File::Copy ();use File::Path ();use File::Spec;use File::Which ();use IPC::Run3 ();use Proc::ForkSafe;sub new {my ($class,%option)=@_;my$cache_dir_base=$option{cache}or die "cache option is required\n";my$mirror=$option{mirror}or die "mirror option is required\n";$mirror =~ s{/*$}{/};my$path=$option{path}|| "${mirror}modules/02packages.details.txt.gz";my$cache_dir=$class->_cache_dir($mirror,$cache_dir_base);my$local_path=$class->_fetch($path=>$cache_dir);my$index=Proc::ForkSafe->wrap(sub {CPAN::02Packages::Search->new(file=>$local_path)});bless {mirror=>$mirror,local_path=>$local_path,index=>$index },$class}sub _cache_dir {my ($class,$mirror,$base)=@_;if ($mirror !~ m{^https?://}){$mirror =~ s{^file://}{};$mirror=Cwd::abs_path($mirror);$mirror =~ s{^/}{}}$mirror =~ s{/$}{};$mirror =~ s/[^\w\.\-]+/%/g;my$dir="$base/$mirror";File::Path::mkpath([$dir],0,0777);return$dir}sub _fetch {my ($class,$path,$cache_dir)=@_;my$dest=File::Spec->catfile($cache_dir,File::Basename::basename($path));if ($path =~ m{^https?://}){my$res=App::cpm::HTTP->create->mirror($path=>$dest);die "$res->{status} $res->{reason}, $path\n" if!$res->{success}}else {$path =~ s{^file://}{};die "$path: No such file.\n" if!-f $path;if (!-f $dest or (stat$dest)[9]<= (stat$path)[9]){File::Copy::copy($path,$dest)or die "Copy $path $dest: $!\n";my$mtime=(stat$path)[9];utime$mtime,$mtime,$dest}}return$dest if$dest !~ /\.gz$/;my$plain=$dest;$plain =~ s/\.gz$//;if (!-f $plain or (stat$plain)[9]<= (stat$dest)[9]){my$gzip=File::Which::which('gzip');die "Need gzip command to decompress $dest\n" if!$gzip;my@cmd=($gzip,"-dc",$dest);IPC::Run3::run3 \@cmd,undef,$plain,\my$err;if ($?!=0){chomp$err;$err ||= "exit status $?";die "@cmd: $err\n"}}return$plain}sub resolve {my ($self,$task)=@_;my$res=$self->{index}->call(search=>$task->{package});if (!$res){return {error=>"not found, @{[$self->{local_path}]}" }}if (my$version_range=$task->{version_range}){my$version=$res->{version}|| 0;if (!App::cpm::version->parse($version)->satisfy($version_range)){return {error=>"found version $version, but it does not satisfy $version_range, @{[$self->{local_path}]}" }}}my$dist=App::cpm::DistNotation->new_from_dist($res->{path});return +{source=>"cpan",distfile=>$dist->distfile,uri=>$dist->cpan_uri($self->{mirror}),version=>$res->{version}|| 0,package=>$task->{package},}}1;
60
+ package App::cpm::Resolver::02Packages;use strict;use warnings;use App::cpm::DistNotation;use App::cpm::HTTP;use App::cpm::Util;use App::cpm::version;use CPAN::02Packages::Search;use Cwd ();use File::Basename ();use File::Copy ();use File::Path ();use File::Spec;use File::Temp ();use Proc::ForkSafe;sub new {my ($class,%option)=@_;my$cache_dir_base=$option{cache}or die "cache option is required\n";my$mirror=$option{mirror}or die "mirror option is required\n";$mirror =~ s{/*$}{/};my$path=$option{path}|| "${mirror}modules/02packages.details.txt.gz";if ($path =~ m{^https?://}){my$cache_dir=$class->_cache_dir($mirror,$cache_dir_base);$path=$class->_fetch($path=>$cache_dir)}else {$path =~ s{^file://}{};-f $path or die "$path: No such file or directory\n"}my$text_file=$path =~ /\.gz$/ ? $class->_gunzip($path): App::cpm::Util::maybe_abs($path);my$index=Proc::ForkSafe->wrap(sub {CPAN::02Packages::Search->new(file=>$text_file)});bless {mirror=>$mirror,path=>$path,index=>$index },$class}sub _cache_dir {my ($class,$mirror,$base)=@_;if ($mirror !~ m{^https?://}){$mirror =~ s{^file://}{};$mirror=Cwd::abs_path($mirror);$mirror =~ s{^/}{}}$mirror =~ s{/$}{};$mirror =~ s/[^\w\.\-]+/%/g;my$dir="$base/$mirror";File::Path::mkpath([$dir],0,0777);return$dir}sub _fetch {my ($class,$path,$cache_dir)=@_;my$dest=File::Spec->catfile($cache_dir,File::Basename::basename($path));my$res=App::cpm::HTTP->create->mirror($path=>$dest);die "$res->{status} $res->{reason}, $path\n" if!$res->{success};return$dest}sub _gunzip {my ($class,$path)=@_;my ($fh,$dest)=File::Temp::tempfile("perl-cpm-XXXXX",UNLINK=>1,SUFFIX=>".txt",EXLOCK=>0,TMPDIR=>1);App::cpm::Util::gunzip$path,$fh;close$fh;$dest}sub resolve {my ($self,$task)=@_;my$res=$self->{index}->call(search=>$task->{package});if (!$res){return {error=>"not found, @{[$self->{path}]}" }}if (my$version_range=$task->{version_range}){my$version=$res->{version}|| 0;if (!App::cpm::version->parse($version)->satisfy($version_range)){return {error=>"found version $version, but it does not satisfy $version_range, @{[$self->{path}]}" }}}my$dist=App::cpm::DistNotation->new_from_dist($res->{path});return +{source=>"cpan",distfile=>$dist->distfile,uri=>$dist->cpan_uri($self->{mirror}),version=>$res->{version}|| 0,package=>$task->{package},}}1;
61
61
APP_CPM_RESOLVER_02PACKAGES
62
62
63
63
$fatpacked{"App/cpm/Resolver/Cascade.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'APP_CPM_RESOLVER_CASCADE';
@@ -93,7 +93,7 @@ $fatpacked{"App/cpm/Tutorial.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<
93
93
APP_CPM_TUTORIAL
94
94
95
95
$fatpacked{"App/cpm/Util.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'APP_CPM_UTIL';
96
- package App::cpm::Util;use strict;use warnings;use Config;use Cwd ();use Digest::MD5 ();use File::Spec;use Exporter 'import';our@EXPORT_OK=qw(perl_identity maybe_abs WIN32 determine_home);use constant WIN32=>$^O eq 'MSWin32';sub perl_identity {my$digest=Digest::MD5::md5_hex($Config{perlpath}.Config->myconfig);$digest=substr$digest,0,8;join '-',$Config{version},$Config{archname},$digest}sub maybe_abs {my$path=shift;if (File::Spec->file_name_is_absolute($path)){return$path}my$cwd=shift || Cwd::cwd();File::Spec->canonpath(File::Spec->catdir($cwd,$path))}sub determine_home {my$homedir=$ENV{HOME}|| eval {require File::HomeDir;File::HomeDir->my_home}|| join('',@ENV{qw(HOMEDRIVE HOMEPATH)});if (WIN32){require Win32;$homedir=Win32::GetShortPathName($homedir)}File::Spec->catdir($homedir,".perl-cpm")}1;
96
+ package App::cpm::Util;use strict;use warnings;use Config;use Cwd ();use Digest::MD5 ();use File::Spec;use File::Which ();use IPC::Run3 ();use Exporter 'import';our@EXPORT_OK=qw(perl_identity maybe_abs WIN32 determine_home);use constant WIN32=>$^O eq 'MSWin32';sub perl_identity {my$digest=Digest::MD5::md5_hex($Config{perlpath}.Config->myconfig);$digest=substr$digest,0,8;join '-',$Config{version},$Config{archname},$digest}sub maybe_abs {my$path=shift;if (File::Spec->file_name_is_absolute($path)){return$path}my$cwd=shift || Cwd::cwd();File::Spec->canonpath(File::Spec->catdir($cwd,$path))}sub determine_home {my$homedir=$ENV{HOME}|| eval {require File::HomeDir;File::HomeDir->my_home}|| join('',@ENV{qw(HOMEDRIVE HOMEPATH)});if (WIN32){require Win32;$homedir=Win32::GetShortPathName($homedir)}File::Spec->catdir($homedir,".perl-cpm")}my$gzip;sub gunzip {my ($from,$to)=@_;if (!$gzip){$gzip=File::Which::which('gzip');die "need gzip command to decompress $from\n" if!$gzip}my@cmd=($gzip,"-dc",$from);IPC::Run3::run3(\@cmd,undef,$to,\my$err);return if $?==0;chomp$err;$err ||= "exit status $?";die "@cmd: $err\n"}1;
97
97
APP_CPM_UTIL
98
98
99
99
$fatpacked{"App/cpm/Worker.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'APP_CPM_WORKER';
0 commit comments