| 1 | package CPAN::FindDependencies; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 34 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 34 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 34 | ▶ | use vars qw(@net_log $VERSION @ISA @EXPORT_OK); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 34 | ▶ | use version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 34 | ▶ | use Archive::Tar; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 34 | ▶ | use Archive::Zip; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 34 | ▶ | use Path::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 34 | ▶ | use File::Temp qw(tempfile); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 34 | ▶ | use File::Type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 34 | ▶ | use HTTP::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 34 | ▶ | use Module::CoreList; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 34 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 34 | ▶ | use CPAN::Meta; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 34 | ▶ | use CPAN::FindDependencies::Dependency; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 34 | ▶ | use CPAN::FindDependencies::MakeMaker qw(getreqs_from_mm); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 34 | ▶ | use Parse::CPAN::Packages; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 34 | ▶ | use URI::file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 34 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 34 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 34 | @EXPORT_OK = qw(finddeps); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 34 | $VERSION = '4.01'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 34 | ▶ | use constant MAXINT => ~0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | CPAN::FindDependencies - find dependencies for modules on the CPAN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | use CPAN::FindDependencies; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | my @dependencies = CPAN::FindDependencies::finddeps("CPAN"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | foreach my $dep (@dependencies) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | print ' ' x $dep->depth(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | print $dep->name().' ('.$dep->distribution().")\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | =head1 INCOMPATIBLE CHANGES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | Up to version 2.49 you used the C<02packages> argument to specify where a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | cached C<02packages.details.txt.gz> could be found. That argument no longer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | exists as of version 3.00, use the C<mirror> argument instead. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | Up to version 2.49, C<maxdepth =E<gt> 0> would incorrectly return the whole | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | tree. From version 3.00 it cuts the tree off at its root so will only return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | the module that you asked about. Not very useful, but correct. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | In version 2.49 you used the C<configreqs> argument to specify that you were | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | interested in configure-time requirements as well as build- and run-time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | requirements. That option no longer exists as of version 3.00, it will always | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | report on configure, build, test, and run-time requirements. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | Up to version 3.13 specifying a bogus directory for C<cachedir> would be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | ignored. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | From version 4.00 onwards you *must* have Net::SSLeay and IO::Socket::SSL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | available. A perl that doesn't have SSL support is broken. We will no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | longer fall back to wget. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | =head1 HOW IT WORKS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | The module uses the CPAN packages index to map modules to distributions and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | vice versa, and then fetches distributions' metadata or Makefile.PL files from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | a CPAN mirror to determine pre-requisites. This means that a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | working interwebnet connection is required. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | There is just one function, which is not exported by default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | although you can make that happen in the usual fashion. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | =head2 finddeps | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | Takes a single compulsory parameter, the name of a module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | (ie Some::Module); and the following optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | named parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | =item nowarnings | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | Warnings about modules where we can't find their META.yml or Makefile.PL, and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | so can't divine their pre-requisites, will be suppressed. Other warnings may | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | still be emitted though, such as those telling you about modules which have | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | dodgy (but still understandable) metadata; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | =item fatalerrors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | Failure to get a module's dependencies will be a fatal error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | instead of merely emitting a warning; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | =item perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | Use this version of perl to figure out what's in core. If not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | specified, it defaults to 5.005. Three part version numbers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | (eg 5.8.8) are supported but discouraged. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | =item cachedir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | A directory to use for caching. It defaults to no caching. Even if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | caching is turned on, this is only for META.yml or Makefile.PL files. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | The cache is never automatically cleared out. It is your responsibility | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | to clear out old data. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | If the directory doesn't exist we will try to create it. If we can't, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | or it exists but isn't readable and writeable, that is a fatal error. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | =item maxdepth | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | Cuts off the dependency tree at the specified depth. Your specified | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | module is at depth 0, your dependencies at depth 1, their dependencies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | at depth 2, and so on. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | If you don't specify any maxdepth at all it will grovel over the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | entire tree. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | =item mirror | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | This can be provided more than once, if for example you want to use | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | a private L<Pinto> repository for your own code while using a public | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | CPAN mirror for open source dependencies. The argument comes in two parts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | separated by a comma - the base URL from which to fetch files, and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | optionally the URL or a file from which to fetch the index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | C<02packages.details.txt.gz> file to use with that mirror. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | mirror https://cpan.mydomain.net,file:///home/me/mycache/02packages.txt.gz | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | If you want to use the default CPAN mirror (https://cpan.metacpan.org/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | but also specify an index location you can use C<DEFAULT> for the mirror URL. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | So for example, to use your own special private mirror, including fetching | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 02packages from it, but also use the default mirror with a cached local | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | copy of its 02packages, specify two mirrors thus: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | mirror => 'https://cpan.mydomain.net', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | mirror => 'DEFAULT,file:///home/me/mycache/02packages.txt.gz' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | The index is cached for three minutes or until your process finishes, whichever is soonest. This is because it is HUMUNGOUS and parsing it takes ages even when it's loaded from a local disk, and I don't want the tests to take forever. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | =item usemakefilepl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | If set to true, then for any module that doesn't have a META.yml, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | try to use its Makefile.PL as well. Note that this involves | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | downloading code from the Internet and running it. This obviously | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | opens you up to all kinds of bad juju, hence why it is disabled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | by default. NB that this fetches Makefile.PL from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | L<https://fastapi.metacpan.org> B<only> so will not work for private mirrors. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | This is a deliberate choice, your own private code ought to be packaged | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | properly with a META file, you should only care about divining dependencies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | from Makefile.PL if you rely on really old stuff on public CPAN mirrors. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | =item recommended | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | Adds recommended modules to the list of dependencies, if set to a true value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | =item suggested | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | Adds suggested modules to the list of dependencies, if set to a true value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | Order of arguments is not important. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | It returns a list of CPAN::FindDependencies::Dependency objects, whose | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | useful methods are: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | =item name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | The module's name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | =item distribution | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | The distribution containing this module; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | =item version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | The minimum required version of his module (if specified in the requirer's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | pre-requisites list); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | =item depth | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | How deep in the dependency tree this module is; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | =item warning | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | If any warning was generated (even if suppressed) for the module, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | it will be recorded here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | Any modules listed as dependencies but which are in the perl core | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | distribution for the version of perl you specified are suppressed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | These objects are returned in a semi-defined order. You can be sure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | that a module will be immediately followed by one of its dependencies, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | then that dependency's dependencies, and so on, followed by the 'root' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | module's next dependency, and so on. You can reconstruct the tree | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | by paying attention to the depth of each object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | The ordering of any particular module's immediate 'children' can be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | assumed to be random - it's actually hash key order. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | =head1 TREE PRUNING | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | The dependency tree is pruned to remove duplicates. This means that even though | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | C<Test::More>, for example, is a dependency of almost everything on the CPAN, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | it will only be listed once. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | =head1 SECURITY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | If you set C<usemakefilepl> to a true value, this module may download code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | from the internet and execute it. You should think carefully before enabling | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | that feature. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | =head1 BUGS/WARNINGS/LIMITATIONS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | You must have web access to L<http://metacpan.org/> and (unless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | you tell it where else to look for the index) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | L<http://www.cpan.org/>, or have all the data cached locally.. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | If any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | metadata or Makefile.PL files are missing, the distribution's dependencies will | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | not be found and a warning will be spat out. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | Startup can be slow, especially if it needs to fetch the index from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | the interweb. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | Dynamic dependencies - for example, dependencies that only apply on some | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | platforms - can't be reliably resolved. They *may* be resolved if you use the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | unsafe Makefile.PL, but even that can't be relied on. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | =head1 FEEDBACK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | I welcome feedback about my code, including constructive criticism | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | and bug reports. The best bug reports include files that I can add | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | to the test suite, which fail with the current code in my git repo and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | will pass once I've fixed the bug | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | Feature requests are far more likely to get implemented if you submit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | a patch yourself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | =head1 SOURCE CODE REPOSITORY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | L<git://github.com/DrHyde/perl-modules-CPAN-FindDependencies.git> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | L<CPAN> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | L<http://deps.cpantesters.org/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | L<http://metacpan.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | =head1 AUTHOR, LICENCE and COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | Copyright 2007 - 2026 David Cantrell E<lt>F<david@cantrell.org.uk>E<gt> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | This software is free-as-in-speech software, and may be used, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | distributed, and modified under the terms of either the GNU | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | General Public Licence version 2 or the Artistic Licence. It's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | up to you which one you use. The full text of the licences can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | be found in the files GPL2.txt and ARTISTIC.txt, respectively. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | =head1 THANKS TO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | Stephan Loyd (for fixing problems with some META.yml files) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | Alexandr Ciornii (for a patch to stop it segfaulting on Windows) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | Brian Phillips (for the code to report on required versions of modules) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | Ian Tegebo (for the code to extract deps from Makefile.PL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | Georg Oechsler (for the code to also list 'recommended' modules) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | Jonathan Stowe (for making it work through HTTP proxies) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | Kenneth Olwing (for support for 'configure_requires') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | =head1 CONSPIRACY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | This module is also free-as-in-mason software. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 34 | my $default_mirror = 'https://cpan.metacpan.org/'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 34 | my @valid_params = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | nowarnings | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | fatalerrors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | cachedir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | maxdepth | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | mirror | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | usemakefilepl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | recommended | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | suggested | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 38 | ▶ | sub finddeps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finddeps: called CC=22 SCAR=31.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 38 | @net_log = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 38 | my $module = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 38 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 38 | my $self = bless({ indices => [], mirrors => [], seen => {} }, __PACKAGE__); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 38 | ▶ | while(@args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 171 | my $option = shift(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # print STDERR "found argument $option. Remaining args [".join(', ', @args)."]\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 171 | ▶ | if($option eq 'mirror') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 37 | my($mirror, $packages) = split(/,/, shift(@args)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 37 | ▶ | $mirror = $default_mirror if($mirror eq 'DEFAULT'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 37 | ▶ | $mirror .= '/' unless($mirror =~ m{/$}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 37 | ▶ | $packages = "${mirror}modules/02packages.details.txt.gz" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | unless($packages); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | ($mirror, $packages) = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 37 | ▶ | $_ =~ /^https?:\/\// ? $_ : ''.URI::file->new_abs($_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } ($mirror, $packages); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 37 | push @{$self->{mirrors}}, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | mirror => $mirror, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | packages => $packages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 1206 | } elsif(grep { $_ eq $option } @valid_params) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 95 | $self->{$option} = shift(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 95 | ▶ | if($option eq 'cachedir' && !(-d $self->{$option} && -r $self->{$option} && -w $self->{$option}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
$option eq "cachedir" and not -d $self->{$option} && -r $self->{$option} && -w $self->{$option}
-d $self->{$option} && -r $self->{$option} && -w $self->{$option}
-d $self->{$option} and -r $self->{$option}
MC/DC50%2/4
$option eq "cachedir" and not -d $self->{$option} && -r $self->{$option} && -w $self->{$option}
$option eq "cachedir"
-d $self->{$option}
-r $self->{$option}
-w $self->{$option}
Truth table60%3/5
A and not(B and C && D)
A= $option eq "cachedir"B= -d $self->{$option}C= -r $self->{$option}D= -w $self->{$option}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | # bad cachedir, try to create | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 3 | eval { path($self->{$option})->mkdir(); }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | die("Bad cachedir: $self->{$option}\n") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 3 | ▶ | unless(-d $self->{$option} && -r $self->{$option} && -w $self->{$option}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
-d $self->{$option} and -r $self->{$option} and -w $self->{$option}
-d $self->{$option} and -r $self->{$option}
MC/DC33%1/3
-d $self->{$option} and -r $self->{$option} and -w $self->{$option}
-d $self->{$option}
-r $self->{$option}
-w $self->{$option}
Truth table50%2/4
A and B and C
A= -d $self->{$option}B= -r $self->{$option}C= -w $self->{$option}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } elsif(!$module) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 38 | $module = $option | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 1 | die("Can't look for dependencies for '$option', already looking for deps for '$module'\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 36 | ▶ | unless(@{$self->{mirrors}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 5 | push @{$self->{mirrors}}, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | mirror => $default_mirror, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | packages => "${default_mirror}modules/02packages.details.txt.gz" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 36 | ▶ | $self->{maxdepth} = MAXINT unless(defined($self->{maxdepth})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 36 | ▶ | $self->{perl} ||= 5.005; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"perl"} ||= "5.005"
MC/DC100%1/1
$self->{"perl"} ||= "5.005"
$self->{"perl"}
Truth table100%2/2
A
A= $self->{"perl"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | die(__PACKAGE__.": $self->{perl} is a broken version number\n") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 36 | ▶ | if($self->{perl} =~ /[^0-9.]/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 36 | ▶ | if($self->{perl} =~ /\..*\./) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 11 | my @parts = split(/\./, $self->{perl}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 11 | $self->{perl} = $parts[0] + $parts[1] / 1000 + $parts[2] / 1000000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 36 | my $first_found = $self->_first_found($module); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 36 | ▶ | return $self->_finddeps( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | module => $module, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | version => ($first_found ? $first_found->version() : 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | # indices are cached for performance, cos even if the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | # file is fetched from disk uncompressing/parsing take ages. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | # the cache lasts three minutes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 34 | our %_parsed_index_cache = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 492 | ▶ | sub _indices { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_indices: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 492 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 492 | ▶ | if(!@{$self->{indices}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 36 | ▶ | local $SIG{__WARN__} = sub {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | $self->{indices} = [map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 41 | my $url = $_->{packages}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 41 | ▶ | if(!(exists($_parsed_index_cache{$url}) && $_parsed_index_cache{$url}->{expiry} > time())) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $CPAN::FindDependencies::_parsed_index_cache{$url} and $CPAN::FindDependencies::_parsed_index_cache{$url}{"expiry"} > time
MC/DC100%2/2
exists $CPAN::FindDependencies::_parsed_index_cache{$url} and $CPAN::FindDependencies::_parsed_index_cache{$url}{"expiry"} > time
exists $CPAN::FindDependencies::_parsed_index_cache{$url}
$CPAN::FindDependencies::_parsed_index_cache{$url}{"expiry"} > time
Truth table100%3/3
A and B
A= exists $CPAN::FindDependencies::_parsed_index_cache{$url}B= $CPAN::FindDependencies::_parsed_index_cache{$url}{"expiry"} > time
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 31 | $_parsed_index_cache{$url}->{expiry} = time() + 180; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 31 | ▶ | $_parsed_index_cache{$url}->{index} = Parse::CPAN::Packages->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->_get($url) || die('CPAN::FindDependencies' . ": Couldn't fetch 02packages index file from $url\n")
MC/DC0%0/1
$self->_get($url) || die('CPAN::FindDependencies' . ": Couldn't fetch 02packages index file from $url\n")
$self->_get($url)
Truth table50%1/2
A
A= $self->_get($url)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | $self->_get($url) || die(__PACKAGE__.": Couldn't fetch 02packages index file from $url\n") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | $_parsed_index_cache{$url}->{index} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 36 | } @{$self->{mirrors}}] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 492 | return @{$self->{indices}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | # look through all the mirrors' 02packages for a module and return a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | # Parse::CPAN::Packages::Package for the first one it finds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 294 | ▶ | sub _first_found { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_first_found: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 294 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 294 | my $module = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 294 | return (map { $_->package($module) } grep { $_->package($module) } $self->_indices())[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 22 | ▶ | sub _yell { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_yell: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 22 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 22 | my $msg = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 22 | $msg = __PACKAGE__.": $msg"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 22 | ▶ | $msg = "$msg\n" unless(substr($msg, -1, 1) eq "\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 22 | ▶ | if(!$self->{nowarnings}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 3 | ▶ | if($self->{fatalerrors} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 1 | die('FATAL: '.$msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 2 | warn('WARNING: '.$msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 232 | ▶ | sub _get { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 232 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 232 | my $url = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 232 | push @net_log, $url; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 232 | ▶ | if($url =~ m{^file://}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 142 | $url =~ s{^file://}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 142 | $url =~ s{^/([A-Z]:)}{$1}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 142 | ▶ | open(my $fh, '<', $url) || return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 32 | return join('', <$fh>); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 90 | my $response = HTTP::Tiny->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | # allow_credentialed_redirects => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | # allow_downgrade => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | agent => __PACKAGE__."/$VERSION", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | )->get($url); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 90 | ▶ | return $response->{content} if($response->{success}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 14 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 1303 | ▶ | sub _incore { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_incore: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 1303 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 1303 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 1303 | my $core = $Module::CoreList::version{$args{perl}}{$args{module}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 1303 | ▶ | $core =~ s/_/00/g if($core); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 1303 | $args{version} =~ s/_/00/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | $args{version} = version->declare($args{version})->numify() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 1303 | ▶ | if($args{version} =~ /^v/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 1303 | ▶ | return ($core && $core >= $args{version}) ? $core : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$core and $core >= $args{"version"}
MC/DC100%2/2
$core and $core >= $args{"version"}
$core
$core >= $args{"version"}
Truth table100%3/3
A and B
A= $coreB= $core >= $args{"version"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 1386 | ▶ | sub _finddeps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_finddeps: called CC=11 SCAR=24.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 1386 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 1386 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 1386 | my( $module, $depth, $version) = @args{qw(module depth version)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 1386 | ▶ | $depth ||= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$depth ||= 0
MC/DC100%1/1
$depth ||= 0
$depth
Truth table100%2/2
A
A= $depth
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | return () if( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | $module eq 'perl' || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | $self->_incore( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | module => $module, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | perl => $self->{perl}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 1386 | ▶ | version => $version) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$module eq "perl" or $self->_incore("module", $module, "perl", $self->{"perl"}, "version", $version)
MC/DC100%2/2
$module eq "perl" or $self->_incore("module", $module, "perl", $self->{"perl"}, "version", $version)
$module eq "perl"
$self->_incore("module", $module, "perl", $self->{"perl"}, "version", $version)
Truth table100%3/3
A or B
A= $module eq "perl"B= $self->_incore("module", $module, "perl", $self->{"perl"}, "version", $version)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 258 | my $dist = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 258 | my $package = $self->_first_found($module); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 258 | ▶ | $package ? $package->distribution() : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 258 | ▶ | return () unless(blessed($dist)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 246 | my $author = $dist->cpanid(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 246 | my $distname = $dist->distvname(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 246 | ▶ | return () if($self->{seen}->{$distname}++); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 203 | my %reqs = $self->_getreqs( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | author => $author, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | distname => $distname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | distfile => $dist->filename(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | CPAN::FindDependencies::Dependency->_new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | depth => $depth, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | distribution => $dist, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | cpanmodule => $module, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | indices => [$self->_indices()], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | version => $version || 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | $reqs{'-warning'} ? (warning => $reqs{'-warning'}) : () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | (!exists($reqs{'-warning'}) && $depth != $self->{maxdepth}) ? (map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | # print "Looking at $_\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 198 | ▶ | $self->_finddeps( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%5/5
$version || 0
not exists $reqs{"-warning"} and $depth != $self->{"maxdepth"}
MC/DC100%1/1
$version || 0
$version
MC/DC100%2/2
not exists $reqs{"-warning"} and $depth != $self->{"maxdepth"}
not exists $reqs{"-warning"}
$depth != $self->{"maxdepth"}
Truth table100%2/2
A
A= $version
Truth table100%3/3
not(A) and B
A= not exists $reqs{"-warning"}B= $depth != $self->{"maxdepth"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | module => $_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | depth => $depth + 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 1350 | version => $reqs{$_} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | } sort keys %reqs) : () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | # caching wrapper around _get | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | # can be asked to fetch a .meta, an archive, or a Makefile.PL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | # so it knows how to figure out what the cache filename is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | # for those, based on the URL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | # can be asked to get whichever first succeeds of multiple options. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | # currently those are always a metadata file or an archive, which | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | # will resolve to the same cache file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 591 | ▶ | sub _get_cached { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_cached: called CC=15 SCAR=27.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 591 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 591 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 591 | my($src, $post_process) = @args{qw(src post_process)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 591 | my $contents; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | # asked to check multiple sources? Return the first which has | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | # content (or what's cached) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 591 | ▶ | if(ref($src)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 255 | foreach my $this_url (@{$src}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 327 | ▶ | last if($contents = $self->_get_cached( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | post_process => $post_process, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | src => $this_url | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 255 | return $contents; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 336 | my $cachefile = $src; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 336 | ▶ | if($cachefile =~ /Makefile.PL/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 9 | $cachefile =~ s{.*/([^/]+)/Makefile.PL$}{$1.MakefilePL}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 327 | $cachefile =~ s{.*/(.*?)\.(meta|zip|tar\.bz2|tar\.gz|tgz)$}{$1.meta}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 336 | ▶ | if($self->{cachedir} && -d $self->{cachedir} && -r $self->{cachedir}."/$cachefile") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$self->{"cachedir"} and -d $self->{"cachedir"} and -r $self->{"cachedir"} . "/$cachefile"
$self->{"cachedir"} and -d $self->{"cachedir"}
MC/DC66%2/3
$self->{"cachedir"} and -d $self->{"cachedir"} and -r $self->{"cachedir"} . "/$cachefile"
$self->{"cachedir"}
-d $self->{"cachedir"}
-r $self->{"cachedir"} . "/$cachefile"
Truth table75%3/4
A and B and C
A= $self->{"cachedir"}B= -d $self->{"cachedir"}C= -r $self->{"cachedir"} . "/$cachefile"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | open(my $cachefh, $self->{cachedir}."/$cachefile") || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 135 | ▶ | $self->_yell('Error reading '.$self->{cachedir}."/$cachefile: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 135 | local $/ = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 135 | $contents = <$cachefh>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 135 | close($cachefh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 201 | $contents = $self->_get($src); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 201 | ▶ | if($contents && $post_process ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$contents and $post_process
MC/DC100%2/2
$contents and $post_process
$contents
$post_process
Truth table100%3/3
A and B
A= $contentsB= $post_process
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 75 | $contents = $post_process->($contents); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 201 | ▶ | if($contents && $self->{cachedir} && -d $self->{cachedir}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$contents and $self->{"cachedir"} and -d $self->{"cachedir"}
$contents and $self->{"cachedir"}
MC/DC66%2/3
$contents and $self->{"cachedir"} and -d $self->{"cachedir"}
$contents
$self->{"cachedir"}
-d $self->{"cachedir"}
Truth table75%3/4
A and B and C
A= $contentsB= $self->{"cachedir"}C= -d $self->{"cachedir"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | open(my $cachefh, '>', $self->{cachedir}."/$cachefile") || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 61 | ▶ | $self->_yell('Error writing '.$self->{cachedir}."/$cachefile: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 61 | print $cachefh $contents; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 61 | close($cachefh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 336 | return $contents; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 203 | ▶ | sub _getreqs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_getreqs: called CC=11 SCAR=24.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 203 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 203 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 203 | my($author, $distname, $distfile) = @args{qw(author distname distfile)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 203 | my $meta_file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 203 | foreach my $source (@{$self->{mirrors}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | $meta_file = $self->_get_cached( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | src => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | $source->{mirror}."authors/id/". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | substr($author, 0, 1).'/'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | substr($author, 0, 2).'/'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | "$author/$distname.meta", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | $source->{mirror}."authors/id/". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | substr($author, 0, 1).'/'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | substr($author, 0, 2).'/'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | "$author/$distfile" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 75 | ▶ | post_process => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | # _get_cached normally just returns a file, but we're | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | # asking it to either fetch a metadata file or if that can't be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | # found fetch an archive from which we want to extract a file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | # and then cache that extracted file's contents. This function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | # takes a blob of data and if it looks like a zip or a tarball | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | # tries to extract a META.json or META.yml and return its content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | # (or the empty string if not found), otherwise if it doesn't | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | # look like an archive, assume that the input was a valid metadata | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | # file after all and just return it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 75 | my $file_data = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 75 | my $meta_file_re = qr/^([^\/]+\/)?META\.(json|yml)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 75 | my $rval = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | # We should be able to avoid writing to disk by something like | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | # this but it doesn't work, for either zip or tar <shrug> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | # # my $tar = Archive::Tar->new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | # # $tar->read([string opened as file]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 75 | my(undef, $tempfile) = tempfile('CPAN-FindDependencies-XXXXXXXX', TMPDIR => 1, OPEN => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 75 | ▶ | open(my $fh, '>', "$tempfile") || die("Can't write $tempfile: $!\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 75 | binmode($fh); # Windows smells of wee | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 75 | print $fh $file_data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 75 | close($fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 75 | ▶ | if(File::Type->mime_type($file_data) eq 'application/zip') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 2 | my $zip = Archive::Zip->new($tempfile); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | ▶ | if(my @members = sort { $a cmp $b } $zip->membersMatching($meta_file_re)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 2 | $rval = $zip->contents($members[0]) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | } elsif(File::Type->mime_type($file_data) =~ m{^application/x-(bzip2|gzip|tar)$}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 18 | ▶ | $rval = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 18 | my $tar = Archive::Tar->new(shift()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | # sort to ensure that we get JSON by preference, META.json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | # often contains more info | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | if(my @members = sort { $a cmp $b } grep { /$meta_file_re/ } $tar->list_files()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 4 | return $tar->get_content($members[0]) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 18 | }->($tempfile); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 55 | } else { $rval = $file_data; } # oh, it must have been a meta file | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 75 | unlink $tempfile; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 75 | return $rval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 255 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 255 | ▶ | last if($meta_file); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 203 | ▶ | if ($meta_file) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 189 | my $meta_data = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 1 | ▶ | local $SIG{__WARN__} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 1 | warn(join("\n", "In $distfile, $_[0]", @_[1 .. $#_])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 189 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 189 | CPAN::Meta->load_string($meta_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 189 | ▶ | if ($@ || !defined($meta_data)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$@ or not defined $meta_data
MC/DC50%1/2
$@ or not defined $meta_data
$@
not defined $meta_data
Truth table66%2/3
A or not(B)
A= $@B= not defined $meta_data
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 7 | $self->_yell("$author/$distname: failed to parse metadata") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 182 | my $reqs = $meta_data->effective_prereqs(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | return %{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 182 | $reqs->merged_requirements( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | [qw(configure build test runtime)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 'requires', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | ($self->{recommended} ? 'recommends' : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 182 | ▶ | ($self->{suggested} ? 'suggests' : ()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | )->as_string_hash() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 14 | $self->_yell("$author/$distname: no metadata"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | # We could have failed to parse the metadata file, but we still want to try the Makefile.PL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 20 | ▶ | if(!$self->{usemakefilepl}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 11 | return ('-warning', 'no metadata'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 9 | my $makefilepl = $self->_get_cached( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | src => "https://fastapi.metacpan.org/source/$author/$distname/Makefile.PL", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 9 | ▶ | if($makefilepl) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 9 | my $result = getreqs_from_mm($makefilepl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 5 | ▶ | if ('HASH' eq ref $result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 4 | return %{ $result }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 1 | $self->_yell("$author/$distname: $result"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 1 | return ('-warning', $result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | $self->_yell("$author/$distname: no metadata nor Makefile.PL"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | return ('-warning', 'no metadata nor Makefile.PL'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 34 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||