| 1 | package App::DuckPAN::Perl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | our $AUTHORITY = 'cpan:DDG'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Perl related functionality for duckpan | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | $App::DuckPAN::Perl::VERSION = '1021'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | with 'App::DuckPAN::HasApp'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Config::INI; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Dist::Zilla::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Path::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Config::INI::Reader; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Config::INI::Writer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use List::MoreUtils qw/ uniq /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use List::Util qw/ first /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use File::Temp qw/ :POSIX /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use Parse::CPAN::Packages::Fast; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use Class::Load ':all'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | sub get_local_version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_local_version: called CC=6 SCAR=22.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | my ($self, $module) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | require Module::Data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | my $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # ensure $module is installed by trying to load (require) it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | ▶ | eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | my $m = Module::Data->new($module); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | $m->require; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | $v = $m->version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # $module (e.g. DuckPAN, DDG) has loaded, but no $VERSION exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # This means we're not working with code that was built by DZIL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # Example: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # > ./bin/duckpan -I/lib/ -I../duckduckgo/lib server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | ▶ | unless (defined $v) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if ($module eq 'App::DuckPAN' || $module eq 'DDG'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$module eq "App::DuckPAN" or $module eq "DDG"
MC/DC0%0/2
$module eq "App::DuckPAN" or $module eq "DDG"
$module eq "App::DuckPAN"
$module eq "DDG"
Truth table0%0/3
A or B
A= $module eq "App::DuckPAN"B= $module eq "DDG"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # When executing code in-place, $VERSION will not be defined. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # Only the installed package will have a defined version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # thanks to Dist::Zilla::Plugin::PkgVersion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | return $self->app->dev_version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 2 | ▶ | return version->parse($v) unless ref $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | return $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | sub cpanminus_install_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cpanminus_install_error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | shift->app->emit_and_exit(1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | "Failure on installation of modules!", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | "There are several possible explanations and fixes for this error:", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | "1. The download from CPAN was unsuccessful - Please restart this installer.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | "2. Some other error occured - Please read the `build.log` mentioned in the errors and see if you can fix the problem yourself.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | "If you are unable to solve the problem, please let us know by making a GitHub Issue in the DuckPAN Repo:", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | "https://github.com/duckduckgo/p5-app-duckpan/issues", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | "Make sure to attach the `build.log` file if it exists. Otherwise, copy/paste the output you see." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub duckpan_install { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
duckpan_install: not called CC=28 SCAR=67.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my ($self, @modules) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my $mirror = $self->app->duckpan; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my ($reinstall, $latest); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my $reinstall_latest = $modules[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | if($reinstall_latest eq 'reinstall') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # We sent in a signal to force reinstallation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $reinstall = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | shift @modules; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | elsif($reinstall_latest eq 'latest') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | $latest = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | shift @modules; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my $packages = $self->app->duckpan_packages; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my @to_install; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | for (@modules) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my $module = $packages->package($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | $self->app->emit_and_exit(1, "Can't find package " . $_ . " on " . $self->app->duckpan) unless $module; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my $package = $module->package; # Probably $_, but maybe they'll normalize or something someday. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # see if we have an env variable for this module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my $sp = $package; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $sp =~ s/\:\:/_/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # special case: check for a pinned verison number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $pinned_version = $ENV{$sp}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my $installed_version = $self->get_local_version($package); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my $latest_version = version->parse($module->version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my $duckpan_module_url = $self->app->duckpan . 'authors/id/' . $module->distribution->pathname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # Remind user about having pinned env variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | $self->app->emit_info("$package: $installed_version installed, $pinned_version pinned, $latest_version latest") if $pinned_version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # Could be moved up but want dev to see the version installed and available first | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | if($installed_version == $self->app->dev_version){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | $self->app->emit_notice("Skipping installation of $package. Development version detected!"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my ($install_it, $message); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | if($reinstall || $latest || !$installed_version) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition0%0/6
$reinstall or $latest or not $installed_version
$reinstall or $latest
MC/DC0%0/3
$reinstall or $latest or not $installed_version
$reinstall
$latest
not $installed_version
Truth table0%0/4
A or B or not(C)
A= $reinstallB= $latestC= not $installed_version
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # Prefer versions in the following order when (re)installing: installed, pinned, latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # Latest ignores the installed version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my $version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | $version = $installed_version unless $latest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | $version ||= $pinned_version || $latest_version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$version ||= $pinned_version || $latest_version
$pinned_version || $latest_version
MC/DC0%0/3
$version ||= $pinned_version || $latest_version
$version
$pinned_version
$latest_version
Truth table0%0/4
A ||= B || C
A= $versionB= $pinned_versionC= $latest_version
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | # update the url if not the latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | if($version != $latest_version){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | unless($duckpan_module_url = $self->find_previous_url($module, $version)){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $self->app->emit_and_exit(1, "Failed to find version $version of $package"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | $message = $reinstall ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | "Reinstalling $package, version ($version)" : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | "You don't have $package installed. Installing version ($version)"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $install_it = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | elsif($pinned_version) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | if($pinned_version != $installed_version) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # We continue here, even if the version is larger than latest released, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # on the premise that there might exist unreleased development versions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | if($pinned_version == $latest_version || ($duckpan_module_url = $self->find_previous_url($module, $pinned_version))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pinned_version == $latest_version or $duckpan_module_url = $self->find_previous_url($module, $pinned_version)
MC/DC0%0/2
$pinned_version == $latest_version or $duckpan_module_url = $self->find_previous_url($module, $pinned_version)
$pinned_version == $latest_version
$duckpan_module_url = $self->find_previous_url($module, $pinned_version)
Truth table0%0/3
A or B
A= $pinned_version == $latest_versionB= $duckpan_module_url = $self->find_previous_url($module, $pinned_version)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $install_it = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $message = "Could not locate version $pinned_version of '$package'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $self->app->emit_and_exit(1, $message); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | $message = ($pinned_version == $latest_version) ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | "You already have the latest version of '$package' installed!" : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | "A newer version of '$package' exists. Please update your version pin to match the newest version: $latest_version"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $install_it = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | elsif($installed_version == $latest_version) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $message = "You already have latest version ($installed_version) of $package"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | elsif($installed_version > $latest_version) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $message = "You have a newer version ($installed_version) of $package than duckpan.org ($latest_version)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $message = "You have an older version ($installed_version) of $package than duckpan.org. Installing latest version ($latest_version)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $install_it = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $self->app->emit_notice($message); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | push @to_install, $duckpan_module_url if ($install_it && !(first { $_ eq $duckpan_module_url } @to_install)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
Condition0%0/3
$install_it and not &first(sub {
$_ eq $duckpan_module_url;
}
, @to_install)
MC/DC0%0/2
$install_it and not &first(sub {
$_ eq $duckpan_module_url;
}
, @to_install)
$install_it
not &first(sub {
$_ eq $duckpan_module_url;
}
, @to_install)
Truth table0%0/3
A and not(B)
A= $install_itB= not &first(sub {
$_ eq $duckpan_module_url;
}
, @to_install)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | if(@to_install){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | unshift @to_install, '--reinstall' if $reinstall; # cpanm will do the actual forcing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | if(system "cpanm @to_install"){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | my $err = "cpanm failed (err $?) to (re)install the following modules:\n\n\t" . | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | join("\n\t", @to_install); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $self->app->emit_and_exit(1, $err); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 2 | my @POTENTIAL_AUTHORS = qw| | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | ALOHAAS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | ANDREY_P | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | BRAD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | BRIANHALL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | BRIANS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | CAINE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | CRAZEDPSYC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | DDGC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | DUENDEX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | DYLANLL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | GETTY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | ISADDG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | JAG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | JBARRETT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | JDORW | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | KABLAMO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | MGA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | MOOLLAZA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | RSSSSL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | SDOUGBROWN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | TOMMYTOMMYTOMMY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | YEGG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | ZT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # We need to derive URLs because duckpan.org doesn't understand module@0.147 syntax | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | sub find_previous_url { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_previous_url: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my ($self, $module, $desired_version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | # Shaky premise #1: the author of our previous version is a current author. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my @cpanids = uniq($self->authors_of_latest_dists, @POTENTIAL_AUTHORS); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | # Shaky premise #2: the directory structure is always like this. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my @cpan_dirs = map { join('/', substr($_, 0, 1), substr($_, 0, 2), $_) } @cpanids; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # Shaky premise #3: things never change distributions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my $dist = $module->distribution; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my $filename = $dist->filename; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | # CPAN::DistnameInfo parses the filename incorrectly because PAUSE ids can only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | # contain [-A-Z0-9] whereas duckpan allows other characters like _ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $filename =~ s|^[A-Z]/[A-Z]{2}/.*?/||; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # Shaky premise #4: the distribution version will match package version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $version = $dist->version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # Shaky premise #5: the version for which they are asking is well-formed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $filename =~ s/$version/$desired_version/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | my @urls = map { $self->app->duckpan . 'authors/id/' . $_ . '/' . $filename } @cpan_dirs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $self->app->emit_debug("Checking up to " . scalar @urls . " distributions for pinned version..."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | # Shaky premise #6: our network works well enough to make this a definitive test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my $ua = LWP::UserAgent->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | agent => 'DPPF/0.001a', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | requests_redirectable => []); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | return first { $ua->head($_)->is_success } @urls; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | sub authors_of_latest_dists { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
authors_of_latest_dists: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | my @dists = $self->app->duckpan_packages->distributions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # CPAN::DistnameInfo can parse the cpanid incorrectly because PAUSE ids can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # only contain [-A-Z0-9] whereas duckpan allows other characters like _. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # When this happens cpanid is undefined. Thats why we grep for defined. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | return grep { defined $_ } map { $_->cpanid } @dists; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||