| 1 | # Copyrights 1998,2005-2022 by [Mark Overmeer]. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # For other contributors see ChangeLog. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # See the manual pages for details on the licensing terms. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # Pod stripped from pm file by OODoc 2.03. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # This code is part of distribution CPAN::Site. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | package CPAN::Site::Index; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | $VERSION = '1.17'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use base 'Exporter'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | our @EXPORT_OK = qw/cpan_index cpan_mirror/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | our $VERSION; # required in test-env | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use Log::Report 'cpan-site', syntax => 'SHORT'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | use version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | ▶ | use File::Find qw/find/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use File::Copy qw/copy/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | use File::Basename qw/basename dirname/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | use HTTP::Date qw/time2str/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | use File::Spec::Functions qw/catfile catdir splitdir/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | ▶ | use LWP::UserAgent (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | ▶ | use Archive::Tar (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | ▶ | use Archive::Zip qw(:ERROR_CODES :CONSTANTS); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | ▶ | use CPAN::Checksums qw(updatedir); # horrible function name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | ▶ | use IO::Zlib (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | my $tar_gz = qr/ \.tar\.gz$ | \.tar\.Z$ | \.tgz$/xi; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | my $zip = qr/ \.zip$ /xi; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | my $cpan_update = 0.04; # days between reload of full CPAN index | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | my $ua; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | sub safe_copy($$); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | sub cpan_index($@); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | sub register($$$); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | sub package_inventory($$;$); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | sub package_on_usual_location($); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | sub inspect_archive; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | sub inspect_tar_archive($$); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | sub inspect_zip_archive($$); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | sub collect_package_details($$$); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | sub update_global_cpan($$); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | sub load_file($$); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | sub merge_global_cpan($$$); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | sub create_details($$$$$); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | sub calculate_checksums($$); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | sub read_details($); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | sub remove_expired_details($$$); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | sub mkdirhier(@); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | sub cpan_mirror($$$@); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | sub safe_copy($$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | ▶ | { my ($from, $to) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
safe_copy: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | trace "copy $from to $to"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 2 | ▶ | copy $from, $to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | or fault __x"cannot copy {from} to {to}", from => $from, to => $to; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | sub cpan_index($@) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 1 | ▶ | { my ($mycpan, $globalcpan, %opts) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cpan_index: called CC=12 SCAR=27.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | my $lazy = $opts{lazy}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | my $fallback = $opts{fallback}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | ▶ | my $undefs = exists $opts{undefs} ? $opts{undefs} : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | ▶ | unless($ua) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | { $ua = LWP::UserAgent->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | ▶ | $ua->env_proxy if $opts{env_proxy}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | ▶ | -d $mycpan | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | or error __x"archive top '{dir}' is not a directory" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | , dir => $mycpan; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | my $program = basename $0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | ▶ | $VERSION ||= 'undef'; # test env at home | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$CPAN::Site::Index::VERSION ||= "undef"
MC/DC0%0/1
$CPAN::Site::Index::VERSION ||= "undef"
$CPAN::Site::Index::VERSION
Truth table50%1/2
A
A= $CPAN::Site::Index::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | trace "$program version $VERSION"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | my $global = catdir $mycpan, 'global'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | my $mods = catdir $mycpan, 'modules'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | my $authors = catdir $mycpan, 'authors'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | mkdirhier $global, $mods, $authors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | my $globdetails = update_global_cpan $mycpan, $globalcpan; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # Create mailrc and modlist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 1 | safe_copy catfile($global, '01mailrc.txt.gz') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | , catfile($authors, '01mailrc.txt.gz'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | safe_copy catfile($global, '03modlist.data.gz') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | , catfile($mods, '03modlist.data.gz'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | # Create packages details | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | my $details = catfile $mods, '02packages.details.txt.gz'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | my $newlist = catfile $mods, '02packages.details.tmp.gz'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | my $newer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 1 | my $reuse_dists = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | ▶ | if($lazy && -f $details) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$lazy and -f $details
MC/DC0%0/2
$lazy and -f $details
$lazy
-f $details
Truth table33%1/3
A and B
A= $lazyB= -f $details
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | { $reuse_dists = read_details $details; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $newer = -M $details; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | remove_expired_details $mycpan, $reuse_dists, $newer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | my ($mypkgs, $distdirs) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | = package_inventory $mycpan, $reuse_dists, $newer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | ▶ | merge_global_cpan $mycpan, $mypkgs, $globdetails | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | if $fallback; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | create_details $details, $newlist, $mypkgs, $lazy, $undefs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | ▶ | if(-f $details) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | { trace "backup old details file to $details.bak"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | safe_copy $details, "$details.bak"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 1 | ▶ | if(-f $newlist) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | { trace "promoting $newlist to current"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | ▶ | rename $newlist, $details | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | or error __x"cannot rename '{from}' in '{to}'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | , from => $newlist, to => $details; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 1 | calculate_checksums $distdirs, catdir($mycpan, 'authors', 'id'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # Package Inventory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | # global variables for testing purposes (sorry) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 2 | our ($topdir, $findpkgs, %finddirs, $olddists, $index_age); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | sub register($$$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 31 | ▶ | { my ($package, $this_version, $dist) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register: called CC=7 SCAR=25.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | # warn "register $package, " . (defined $this_version ? $this_version : 'undef'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 31 | ▶ | if(ref $this_version) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | { eval { $this_version = version->parse($this_version) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if($@) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | { alert __x"error when creating version object for {pkg}: {err}" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | , pkg => $package, err => $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 31 | ▶ | my $registered_version = exists $findpkgs->{$package} ? $findpkgs->{$package}[0] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 31 | ▶ | $this_version =~ s/^v// if $this_version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 31 | ▶ | return if defined $registered_version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $registered_version and $registered_version > $this_version
MC/DC0%0/2
defined $registered_version and $registered_version > $this_version
defined $registered_version
$registered_version > $this_version
Truth table33%1/3
A and B
A= defined $registered_versionB= $registered_version > $this_version
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | && $registered_version > $this_version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 31 | $findpkgs->{$package} = [ $this_version, $dist ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | sub package_inventory($$;$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | ▶ | { (my $mycpan, $olddists, $index_age) = @_; #!!! see "my" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
package_inventory: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | $topdir = catdir $mycpan, 'authors', 'id'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | mkdirhier $topdir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | $findpkgs = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 1 | trace "creating inventory from $topdir"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 1 | find {wanted => \&inspect_archive, no_chdir => 1}, $topdir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 1 | ($findpkgs, \%finddirs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | sub package_on_usual_location($) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 23 | ▶ | { my $file = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
package_on_usual_location: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 23 | my ($top, $subdir, @rest) = splitdir $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 23 | ▶ | defined $subdir or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | !@rest # path is at top-level of distro | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 23 | ▶ | || $subdir eq 'lib'; # inside lib | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | sub inspect_archive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 8 | ▶ | { my $fn = $File::Find::name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inspect_archive: called CC=10 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 8 | ▶ | return unless -f $fn && ($fn =~ $tar_gz || $fn =~ $zip); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
-f $fn and $fn =~ /$tar_gz/xi || $fn =~ /$zip/
$fn =~ /$tar_gz/xi or $fn =~ /$zip/
MC/DC33%1/3
-f $fn and $fn =~ /$tar_gz/xi || $fn =~ /$zip/
-f $fn
$fn =~ /$tar_gz/xi
$fn =~ /$zip/
Truth table50%2/4
A and B or C
A= -f $fnB= $fn =~ /$tar_gz/xiC= $fn =~ /$zip/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 4 | (my $dist = $fn) =~ s!^\Q$topdir\E[\\/]!!; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 4 | ▶ | if(defined $index_age && -M $fn > $index_age) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $CPAN::Site::Index::index_age and -M $fn > $CPAN::Site::Index::index_age
MC/DC0%0/2
defined $CPAN::Site::Index::index_age and -M $fn > $CPAN::Site::Index::index_age
defined $CPAN::Site::Index::index_age
-M $fn > $CPAN::Site::Index::index_age
Truth table33%1/3
A and B
A= defined $CPAN::Site::Index::index_ageB= -M $fn > $CPAN::Site::Index::index_age
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | unless(exists $olddists->{$dist}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | { trace "not the latest: $dist"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | trace "latest older than index: $dist"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | foreach (@{$olddists->{$dist}}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | { my ($pkg, $version) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | register $pkg, $version, $dist; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 4 | trace "inspecting archive $fn"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 4 | $finddirs{$File::Find::dir}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 4 | ▶ | return inspect_tar_archive $dist, $fn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | if $fn =~ $tar_gz; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | return inspect_zip_archive $dist, $fn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | if $fn =~ $zip; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | sub inspect_tar_archive($$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 4 | ▶ | { my ($dist, $fn) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inspect_tar_archive: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 4 | my $arch = Archive::Tar->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 4 | ▶ | $arch->read($fn, 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | or error __x"no files in tar archive '{fn}': {err}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | , fn => $fn, err => $arch->error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 4 | foreach my $file ($arch->get_files) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 64 | { my $fn = $file->full_path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 64 | ▶ | $file->is_file && $fn =~ m/\.pm$/i && package_on_usual_location $fn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$file->is_file and $fn =~ /\.pm$/i and &package_on_usual_location($fn)
$file->is_file and $fn =~ /\.pm$/i
MC/DC100%3/3
$file->is_file and $fn =~ /\.pm$/i and &package_on_usual_location($fn)
$file->is_file
$fn =~ /\.pm$/i
&package_on_usual_location($fn)
Truth table100%4/4
A and B and C
A= $file->is_fileB= $fn =~ /\.pm$/iC= &package_on_usual_location($fn)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 21 | collect_package_details $fn, $dist, $file->get_content_by_ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | sub inspect_zip_archive($$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | { my ($dist, $fn) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inspect_zip_archive: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | my $arch = Archive::Zip->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | $arch->read($fn)==AZ_OK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | or error __x"no files in zip archive '{fn}': {err}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | , fn => $fn, err => $arch->error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | foreach my $member ($arch->membersMatching( qr/\.pm$/i )) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | { my $fn = $member->fileName; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | $member->isTextFile && package_on_usual_location $fn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$member->isTextFile and &package_on_usual_location($fn)
MC/DC0%0/2
$member->isTextFile and &package_on_usual_location($fn)
$member->isTextFile
&package_on_usual_location($fn)
Truth table0%0/3
A and B
A= $member->isTextFileB= &package_on_usual_location($fn)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | my ($contents, $status) = $member->contents; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | $status==AZ_OK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | or error "error in zip file {fn}: {err}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | , fn => $fn, err => $status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | collect_package_details $fn, $dist, \$contents; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | sub collect_package_details($$$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 21 | ▶ | { my ($fn, $dist) = (shift, shift); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
collect_package_details: called CC=21 SCAR=31.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 21 | my @lines = split /\r?\n/, ${shift()}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 21 | my $in_pod = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 21 | my $package; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 21 | local $VERSION = undef; # may get destroyed by eval | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 21 | ▶ | while(@lines) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 4650 | { local $_ = shift @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 4650 | ▶ | last if m/^__(?:END|DATA)__$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 4650 | ▶ | $in_pod = ($1 ne 'cut') if m/^=(\w+)/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 4650 | ▶ | next if $in_pod || m/^\s*#/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$in_pod or /^\s*#/
MC/DC100%2/2
$in_pod or /^\s*#/
$in_pod
/^\s*#/
Truth table100%3/3
A or B
A= $in_podB= /^\s*#/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 3409 | ▶ | $_ .= shift @lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
@lines and /package|use|VERSION/ and not /[;{]/
@lines and /package|use|VERSION/
MC/DC100%3/3
@lines and /package|use|VERSION/ and not /[;{]/
@lines
/package|use|VERSION/
not /[;{]/
Truth table100%4/4
A and B and not(C)
A= @linesB= /package|use|VERSION/C= not /[;{]/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | while @lines && m/package|use|VERSION/ && !m/[;{]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 3409 | ▶ | if( m/^\s* package \s* ((?:\w+\:\:)*\w+) (?:\s+ (\S*))? \s* [;{]/x ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 31 | { my ($thispkg, $v) = ($1, $2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 31 | my $thisversion; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 31 | ▶ | if($v) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | { $thisversion = eval {qv($v)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | alert __x"illegal version for {pkg}, found '{version}': {err}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | , pkg => $thispkg, version => $v, err => $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | # second package in file? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 31 | ▶ | register $package, $VERSION, $dist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | if defined $package; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 31 | ($package, $VERSION) = ($thispkg, $thisversion); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 31 | trace "pkg $package from $fn"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 3409 | ▶ | if( m/^\s* \$ ${package}::VERSION \s* = \s* ["']?(\w+?)["']? \s* ;/x ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | { $VERSION = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 3409 | ▶ | if( !$VERSION && m/^ (?:use\s+version\s*;\s*)? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $CPAN::Site::Index::VERSION and /^ (?:use\s+version\s*;\s*)?
(?:our)? \s* \$ ((?: \w+\:\:)*) VERSION \s* \= (.*)/x
MC/DC100%2/2
not $CPAN::Site::Index::VERSION and /^ (?:use\s+version\s*;\s*)?
(?:our)? \s* \$ ((?: \w+\:\:)*) VERSION \s* \= (.*)/x
not $CPAN::Site::Index::VERSION
/^ (?:use\s+version\s*;\s*)?
(?:our)? \s* \$ ((?: \w+\:\:)*) VERSION \s* \= (.*)/x
Truth table100%3/3
not(A) and B
A= not $CPAN::Site::Index::VERSIONB= /^ (?:use\s+version\s*;\s*)?
(?:our)? \s* \$ ((?: \w+\:\:)*) VERSION \s* \= (.*)/x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | (?:our)? \s* \$ ((?: \w+\:\:)*) VERSION \s* \= (.*)/x ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 10 | ▶ | { defined $2 or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 10 | my ($ns, $vers) = ($1, $2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | # some versions of CPAN.pm do contain lines like "$VERSION =~ ..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # which also need to be processed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 10 | eval "\$VERSION =$vers"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 10 | ▶ | if(defined $VERSION) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 10 | ▶ | { ($package = $ns) =~ s/\:\:$// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | if length $ns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 10 | trace "pkg $package version $VERSION"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 21 | ▶ | $VERSION = $VERSION->numify if ref $VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 21 | ▶ | register $package, $VERSION, $dist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | if defined $package; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | sub update_global_cpan($$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 1 | ▶ | { my ($mycpan, $globalcpan) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_global_cpan: called CC=5 SCAR=17.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 1 | my $global = catdir $mycpan, 'global'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | my ($mailrc, $globdetails, $modlist) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 1 | map { catfile $global, $_ } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | qw/01mailrc.txt.gz 02packages.details.txt.gz 03modlist.data.gz/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 1 | ▶ | return $globdetails | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
-f $globdetails and -f $globdetails and -f $modlist and -M $globdetails < $cpan_update
-f $globdetails and -f $globdetails and -f $modlist
-f $globdetails and -f $globdetails
MC/DC0%0/4
-f $globdetails and -f $globdetails and -f $modlist and -M $globdetails < $cpan_update
-f $globdetails
-f $globdetails
-f $modlist
-M $globdetails < $cpan_update
Truth table20%1/5
A and B and C and D
A= -f $globdetailsB= -f $globdetailsC= -f $modlistD= -M $globdetails < $cpan_update
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | if -f $globdetails && -f $globdetails && -f $modlist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | && -M $globdetails < $cpan_update; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 1 | info "(re)loading global CPAN files"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 1 | mkdirhier $global; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 1 | load_file "$globalcpan/authors/01mailrc.txt.gz", $mailrc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 1 | load_file "$globalcpan/modules/02packages.details.txt.gz", $globdetails; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 1 | load_file "$globalcpan/modules/03modlist.data.gz", $modlist; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 1 | $globdetails; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | sub load_file($$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 3 | ▶ | { my ($from, $to) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_file: called CC=2 SCAR=8.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 3 | my $response = $ua->get($from, ':content_file' => $to); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 3 | ▶ | return if $response->is_success; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | unlink $to; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | error __x"failed to get {uri} for {to}: {err}" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | , uri => $from, to => $to, err => $response->status_line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | sub merge_global_cpan($$$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | { my ($mycpan, $pkgs, $globdetails) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge_global_cpan: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | trace "merge packages with CPAN core list in $globdetails"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | my $cpan_pkgs = read_details $globdetails; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | while(my ($cpandist, $cpanpkgs) = each %$cpan_pkgs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | { foreach (@$cpanpkgs) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | { my ($pkg, $version) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | next if exists $pkgs->{$pkg}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | $pkgs->{$pkg} = [$version, $cpandist]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | sub create_details($$$$$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 2 | ▶ | { my ($details, $filename, $pkgs, $lazy, $undefs) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_details: called CC=8 SCAR=20.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 2 | trace "creating package details in $filename"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 2 | ▶ | my $fh = IO::Zlib->new($filename, 'wb') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | or fault __x"generating gzipped {fn}", fn => $filename; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 2 | my $lines = keys %$pkgs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 2 | my $date = time2str time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 2 | ▶ | my $how = $lazy ? "lazy" : "full"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 2 | info "produced list of $lines packages $how"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 2 | my $program = basename $0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 2 | my $module = __PACKAGE__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 2 | $fh->print (<<__HEADER); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | File: 02packages.details.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | URL: file://$details | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | Description: Packages listed in CPAN and local repository | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | Columns: package name, version, path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | Intended-For: private CPAN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | Line-Count: $lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | Written-By: $program with $module $CPAN::Site::Index::VERSION ($how) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | Last-Updated: $date | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | __HEADER | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 2 | foreach my $pkg (sort { lc($a) cmp lc($b) } keys %$pkgs) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 32 | { my ($version, $path) = @{$pkgs->{$pkg}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 32 | ▶ | $version = 'undef' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $version or $version eq ""
MC/DC50%1/2
not defined $version or $version eq ""
not defined $version
$version eq ""
Truth table66%2/3
not(A) or B
A= not defined $versionB= $version eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | if !defined $version || $version eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | next | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 32 | ▶ | if $version eq 'undef' && !$undefs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$version eq "undef" and not $undefs
MC/DC0%0/2
$version eq "undef" and not $undefs
$version eq "undef"
not $undefs
Truth table66%2/3
A and not(B)
A= $version eq "undef"B= not $undefs
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 32 | $path =~ s,\\,/,g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 32 | $fh->printf("%-30s\t%s\t%s\n", $pkg, $version, $path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | sub calculate_checksums($$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 1 | ▶ | { my $dirs = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
calculate_checksums: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 1 | my $root = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 1 | trace "updating checksums"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 1 | foreach my $dir (keys %$dirs) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 1 | { trace "summing $dir"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 1 | ▶ | updatedir($dir, $root) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | or warning 'failed calculating checksums in {dir}', dir => $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | sub read_details($) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | { my $fn = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_details: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | -f $fn or return {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | trace "collecting all details from $fn"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | my $fh = IO::Zlib->new($fn, 'rb') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | or fault __x"cannot read from {fn}", fn => $fn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | my $line; # skip header, search first blank | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | do { $line = $fh->getline } until $line =~ m/^\s*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | my $time_last_update = (stat $fn)[9]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | my %dists; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | while(my $line = $fh->getline) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | { chomp $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | my ($pkg, $version, $dist) = split ' ', $line, 3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | unless($dist) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | { warning "$fn error line=\n $line"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | push @{$dists{$dist}}, [$pkg, $version]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | \%dists; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | sub remove_expired_details($$$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | { my ($mycpan, $dists, $newer) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_expired_details: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | trace "extracting only existing local distributions"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | my $authors = catdir $mycpan, 'authors', 'id'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | foreach my $dist (keys %$dists) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | { my $fn = catfile $authors, $dist; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | if(! -f $fn) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | { # removed local or a global dist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | delete $dists->{$dist}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | elsif(-M $fn < $newer) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | { trace "dist $dist file updated, reindexing"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | delete $dists->{$dist}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | sub mkdirhier(@) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 5 | ▶ | { foreach my $dir (@_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mkdirhier: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 7 | ▶ | { next if -d $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 2 | mkdirhier dirname $dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 2 | ▶ | mkdir $dir, 0755 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | or fault __x"cannot create directory {dir}", dir => $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 2 | trace "created $dir"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | sub cpan_mirror($$$@) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | { my ($mycpan, $globalcpan, $mods, %opts) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cpan_mirror: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | @$mods or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | my %need = map { ($_ => 1) } @$mods; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | my $auth = catdir $mycpan, 'authors', 'id'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | unless($ua) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | { $ua = LWP::UserAgent->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | $ua->env_proxy if $opts{env_proxy}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | my $globdetails | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | = update_global_cpan $mycpan, $globalcpan; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | my $fh = IO::Zlib->new($globdetails, 'rb') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | or fault __x"cannot read from {fn}", fn => $globdetails; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | while(my $line = $fh->getline) # skip header, search first blank | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | { last if $line =~ m/^\s*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | $ua ||= LWP::UserAgent->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ua ||= "LWP::UserAgent"->new
MC/DC0%0/2
$ua ||= "LWP::UserAgent"->new
$ua
"LWP::UserAgent"->new
Truth table0%0/3
A ||= B
A= $uaB= "LWP::UserAgent"->new
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | while(my $line = $fh->getline) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | { my ($pkg, $version, $dist) = split ' ', $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | ▶ | delete $need{$pkg} or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | my $to = catfile $auth, split m#/#, $dist; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | if(-f $to) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | { trace __x"package {pkg} present in distribution {dist}" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | , pkg => $pkg, dist => $dist; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | my $source = "$globalcpan/authors/id/$dist"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | mkdirhier dirname $to; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | my $response = $ua->get($source, ':content_file' => $to); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | unless($response->is_success) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | { unlink $to; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | error __x"failed to get {uri} for {to}: {err}" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | , uri => $source, to => $to, err => $response->status_line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | info __x"got {pkg} in {dist}", pkg => $pkg, dist => $dist; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | warning __x"package {pkg} does not exist", pkg => $_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | for sort keys %need; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||