| 1 | package App::CpanDak; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 3 | ▶ | use mro; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 3 | ▶ | use App::CpanDak::Specials; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 3 | ▶ | use App::cpanminus::fatscript (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 3 | our @ISA=('App::cpanminus::script'); ## no critic(ProhibitExplicitISA) | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 3 | our $VERSION = '0.1.0'; # VERSION | |||||||||||||||||||
| 11 | # ABSTRACT: cpanm, with some sort of distroprefs | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 3 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 15 | 3 | my ($class) = @_; | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 3 | my $self = $class->next::method(); | |||||||||||||||||||
| 18 | 3 | $self->{dak_specials} = App::CpanDak::Specials->new(); | |||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 3 | return $self; | |||||||||||||||||||
| 21 | } | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | # These are for tracking which distribution we're building: the data | ||||||||||||||||||||
| 24 | # structure is set inside `install_module` as a lexical, and passed to | ||||||||||||||||||||
| 25 | # *some* methods, but we need it in all methods. | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | # `resolve_name` is the method that creates that data structure, so we | ||||||||||||||||||||
| 28 | # capture its result | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | # `install_module` is indirectly recursive, so we need to keep a stack | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 0 | ▶ | sub install_module { | ||||||||||||||||||
|
Subroutine
install_module: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 33 | 0 | my $self = shift; | |||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 0 | push @{$self->{dak_dist}}, undef; | |||||||||||||||||||
| 36 | 0 | my $ret = $self->next::method(@_); | |||||||||||||||||||
| 37 | 0 | pop @{$self->{dak_dist}}; | |||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 0 | return $ret; | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 0 | ▶ | sub resolve_name { | ||||||||||||||||||
|
Subroutine
resolve_name: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 43 | 0 | my $self = shift; | |||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 0 | my $ret = $self->next::method(@_); | |||||||||||||||||||
| 46 | 0 | ▶ | $self->{dak_dist}[-1] //= $ret; | ||||||||||||||||||
|
Condition0%0/3
$self->{"dak_dist"}[-1] //= $ret
MC/DC0%0/2
$self->{"dak_dist"}[-1] //= $ret
$self->{"dak_dist"}[-1]
$ret
Truth table0%0/3
A //= B
A= $self->{"dak_dist"}[-1]B= $ret
| |||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 0 | return $ret; | |||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 2 | ▶ | sub dak_dist { | ||||||||||||||||||
|
Subroutine
dak_dist: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 52 | 2 | return shift->{dak_dist}[-1]; | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | # cpanm has a bug here: it localises the mirrors badly, it puts | ||||||||||||||||||||
| 56 | # backpan first *and leaves it there*; see | ||||||||||||||||||||
| 57 | # https://github.com/miyagawa/cpanminus/issues/689 | ||||||||||||||||||||
| 58 | 0 | ▶ | sub search_cpanmetadb_history { | ||||||||||||||||||
|
Subroutine
search_cpanmetadb_history: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 59 | 0 | my ($self, $module, $version) = @_; | |||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 0 | my @mirrors = @{$self->{mirrors}}; | |||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | 0 | my $result = $self->next::method($module, $version); | |||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 0 | $self->{mirrors} = \@mirrors; | |||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 0 | return $result; | |||||||||||||||||||
| 68 | } | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | # here we actually do the things | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 0 | ▶ | sub _match_module { | ||||||||||||||||||
|
Subroutine
_match_module: not called CC=4 SCAR=30.0
| |||||||||||||||||||||
| 73 | 0 | my ($self, $module, $version_spec) = @_; | |||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 0 | ▶ | return $version_spec unless ref($version_spec); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 76 | 0 | ▶ | if (my $module_version = $version_spec->{$module}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 77 | 0 | return $module_version; | |||||||||||||||||||
| 78 | } | ||||||||||||||||||||
| 79 | 0 | ▶ | if (my $star_version = $version_spec->{'*'}) { ## no critic(ProhibitNoisyQuotes) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 80 | 0 | return $star_version; | |||||||||||||||||||
| 81 | } | ||||||||||||||||||||
| 82 | 0 | return undef; | |||||||||||||||||||
| 83 | } | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | 0 | ▶ | sub search_module { | ||||||||||||||||||
|
Subroutine
search_module: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||
| 86 | 0 | my ($self, $module, $version) = @_; | |||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | 0 | ▶ | my $found = $self->next::method($module, $version) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 89 | or return; | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | 0 | ▶ | my $version_spec = $self->{dak_specials}->option_for($found, 'add_version_spec') | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 92 | or return $found; | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | 0 | ▶ | my $add_module_version = $self->_match_module($module, $version_spec) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 95 | or return $found; | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | 0 | my $specials_file = $self->{dak_specials}->match_for($found,'.options.yml'); | |||||||||||||||||||
| 98 | 0 | my $msg = "for $module"; | |||||||||||||||||||
| 99 | 0 | ▶ | $msg .= ", $version was requested" if $version; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 100 | 0 | $msg .= ", $specials_file added $add_module_version, we found $found->{module_version}"; | |||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | 0 | ▶ | my $combined_version = $version | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 103 | ? "$version, $add_module_version" | ||||||||||||||||||||
| 104 | : $add_module_version; | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | 0 | my $found_already; | |||||||||||||||||||
| 107 | 0 | my $satisfy_worked = eval { | |||||||||||||||||||
| 108 | $found_already = $self->satisfy_version( | ||||||||||||||||||||
| 109 | $module, $found->{module_version}, | ||||||||||||||||||||
| 110 | 0 | $combined_version, | |||||||||||||||||||
| 111 | ); | ||||||||||||||||||||
| 112 | 0 | 1; | |||||||||||||||||||
| 113 | }; | ||||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | 0 | ▶ | if (!$satisfy_worked) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 116 | 0 | my $error = $@; | |||||||||||||||||||
| 117 | 0 | $self->diag("$msg, checking the combined version failed\n"); | |||||||||||||||||||
| 118 | 0 | die $error; ## no critic(RequireCarping) | |||||||||||||||||||
| 119 | } | ||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | 0 | ▶ | if ($found_already) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 122 | 0 | $self->diag("$msg, no need to search again\n"); | |||||||||||||||||||
| 123 | 0 | return $found; | |||||||||||||||||||
| 124 | } | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | 0 | $self->diag("$msg, searching again\n"); | |||||||||||||||||||
| 127 | 0 | return $self->next::method($module, $combined_version); | |||||||||||||||||||
| 128 | } | ||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | 1 | ▶ | sub fetch_module { | ||||||||||||||||||
|
Subroutine
fetch_module: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||
| 131 | 1 | my $self = shift; | |||||||||||||||||||
| 132 | 1 | my ($dist, $dir) = $self->next::method(@_); | |||||||||||||||||||
| 133 | |||||||||||||||||||||
| 134 | 1 | ▶ | return unless $dir; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 135 | |||||||||||||||||||||
| 136 | # note that this patching happens *after* `unpack` has verified | ||||||||||||||||||||
| 137 | # the checksum of the distribution tarball, so patches will not | ||||||||||||||||||||
| 138 | # break that verification | ||||||||||||||||||||
| 139 | 1 | $self->{dak_specials}->apply_patch_to($dist, "$self->{base}/$dir"); | |||||||||||||||||||
| 140 | |||||||||||||||||||||
| 141 | 0 | return $dist, $dir; | |||||||||||||||||||
| 142 | } | ||||||||||||||||||||
| 143 | |||||||||||||||||||||
| 144 | 1 | ▶ | sub configure { | ||||||||||||||||||
|
Subroutine
configure: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 145 | 1 | my $self = shift; | |||||||||||||||||||
| 146 | 1 | my $env = $self->{dak_specials}->env_for($self->dak_dist, 'configure'); | |||||||||||||||||||
| 147 | |||||||||||||||||||||
| 148 | 1 | local @ENV{keys %{$env}} = values %{$env}; | |||||||||||||||||||
| 149 | 1 | delete local @ENV{grep { !defined $env->{$_} } keys %{$env}}; | |||||||||||||||||||
| 150 | |||||||||||||||||||||
| 151 | 1 | return $self->next::method(@_); | |||||||||||||||||||
| 152 | } | ||||||||||||||||||||
| 153 | |||||||||||||||||||||
| 154 | 0 | ▶ | sub build { | ||||||||||||||||||
|
Subroutine
build: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 155 | 0 | my $self = shift; | |||||||||||||||||||
| 156 | 0 | my $env = $self->{dak_specials}->env_for($self->dak_dist, 'build'); | |||||||||||||||||||
| 157 | |||||||||||||||||||||
| 158 | 0 | local @ENV{keys %{$env}} = values %{$env}; | |||||||||||||||||||
| 159 | 0 | delete local @ENV{grep { !defined $env->{$_} } keys %{$env}}; | |||||||||||||||||||
| 160 | |||||||||||||||||||||
| 161 | 0 | return $self->next::method(@_); | |||||||||||||||||||
| 162 | } | ||||||||||||||||||||
| 163 | |||||||||||||||||||||
| 164 | 0 | ▶ | sub test { | ||||||||||||||||||
|
Subroutine
test: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 165 | 0 | my $self = shift; | |||||||||||||||||||
| 166 | 0 | ▶ | return 1 if $self->{dak_specials}->option_for($self->dak_dist, 'notest'); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 167 | |||||||||||||||||||||
| 168 | 0 | my $env = $self->{dak_specials}->env_for($self->dak_dist, 'test'); | |||||||||||||||||||
| 169 | |||||||||||||||||||||
| 170 | 0 | local @ENV{keys %{$env}} = values %{$env}; | |||||||||||||||||||
| 171 | 0 | delete local @ENV{grep { !defined $env->{$_} } keys %{$env}}; | |||||||||||||||||||
| 172 | |||||||||||||||||||||
| 173 | 0 | return $self->next::method(@_); | |||||||||||||||||||
| 174 | } | ||||||||||||||||||||
| 175 | |||||||||||||||||||||
| 176 | 0 | ▶ | sub install { | ||||||||||||||||||
|
Subroutine
install: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 177 | 0 | my $self = shift; | |||||||||||||||||||
| 178 | 0 | my $env = $self->{dak_specials}->env_for($self->dak_dist, 'install'); | |||||||||||||||||||
| 179 | |||||||||||||||||||||
| 180 | 0 | local @ENV{keys %{$env}} = values %{$env}; | |||||||||||||||||||
| 181 | 0 | delete local @ENV{grep { !defined $env->{$_} } keys %{$env}}; | |||||||||||||||||||
| 182 | |||||||||||||||||||||
| 183 | 0 | return $self->next::method(@_); | |||||||||||||||||||
| 184 | } | ||||||||||||||||||||
| 185 | |||||||||||||||||||||
| 186 | 3 | 1; | |||||||||||||||||||
| 187 | |||||||||||||||||||||
| 188 | __END__ | ||||||||||||||||||||