| 1 | 4 | ▶ | use 5.006; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | package Gentoo::Util::VirtualDepend; | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 4 | our $VERSION = '0.003021'; | |||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | # ABSTRACT: Hard-coded replacements for perl-core/ dependencies and dependencies with odd names in Gentoo | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 4 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 4 | ▶ | use Moo qw( has ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 4 | ▶ | use Path::Tiny qw( path ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | 4 | ▶ | use File::ShareDir qw( dist_file ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | # Note: this should be the version default max_perl is in | ||||||||||||||||||||
| 18 | 4 | ▶ | use Module::CoreList 5.20151213; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | # Note: This should be the latest visible version in portage at time of release | ||||||||||||||||||||
| 30 | 1 | ▶ | has max_perl => ( is => 'ro', lazy => 1, default => sub { '5.22.1' } ); | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | # Note: This should be the lowest visible version 12 months prior to the time of release | ||||||||||||||||||||
| 42 | 1 | ▶ | has min_perl => ( is => 'ro', lazy => 1, default => sub { '5.18.2' } ); | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 4 | my %MOD2GENTOO; | |||||||||||||||||||
| 45 | my $MOD2GENTOO_LOADED; | ||||||||||||||||||||
| 46 | 4 | my $MOD2GENTOO_FILE = 'module-to-gentoo.csv'; | |||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 4 | my %DIST2GENTOO; | |||||||||||||||||||
| 49 | my $DIST2GENTOO_LOADED; | ||||||||||||||||||||
| 50 | 4 | my $DIST2GENTOO_FILE = 'dist-to-gentoo.csv'; | |||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 4 | my %GENTOO2DIST; | |||||||||||||||||||
| 53 | my %GENTOO2MOD; | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 4 | my $DIST = q[Gentoo-Util-VirtualDepend]; | |||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | sub _load_mod2gentoo { | ||||||||||||||||||||
| 58 | 3 | ▶ | return if $MOD2GENTOO_LOADED; | ||||||||||||||||||
|
Subroutine
_load_mod2gentoo: called CC=4 SCAR=13.9
Branch: 1 branch
| |||||||||||||||||||||
| 59 | 3 | my $fh = path( dist_file( $DIST, $MOD2GENTOO_FILE ) )->openr_raw; | |||||||||||||||||||
| 60 | 3 | ▶ | while ( my $line = <$fh> ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 61 | 6930 | chomp $line; | |||||||||||||||||||
| 62 | 6930 | my ( $module, $map ) = split /,/, $line; ## no critic (RegularExpressions) | |||||||||||||||||||
| 63 | 6930 | $MOD2GENTOO{$module} = $map; | |||||||||||||||||||
| 64 | 6930 | ▶ | $GENTOO2MOD{$map} = [] unless exists $GENTOO2MOD{$map}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 65 | 6930 | push @{ $GENTOO2MOD{$map} }, $module; | |||||||||||||||||||
| 66 | } | ||||||||||||||||||||
| 67 | 3 | return $MOD2GENTOO_LOADED = 1; | |||||||||||||||||||
| 68 | } | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | sub _load_dist2gentoo { | ||||||||||||||||||||
| 71 | 1 | ▶ | return if $DIST2GENTOO_LOADED; | ||||||||||||||||||
|
Subroutine
_load_dist2gentoo: called CC=4 SCAR=13.9
Branch: 1 branch
| |||||||||||||||||||||
| 72 | 1 | my $fh = path( dist_file( $DIST, $DIST2GENTOO_FILE ) )->openr_raw; | |||||||||||||||||||
| 73 | 1 | ▶ | while ( my $line = <$fh> ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 74 | 121 | chomp $line; | |||||||||||||||||||
| 75 | 121 | my ( $module, $map ) = split /,/, $line; ## no critic (RegularExpressions) | |||||||||||||||||||
| 76 | 121 | $DIST2GENTOO{$module} = $map; | |||||||||||||||||||
| 77 | 121 | ▶ | $GENTOO2DIST{$map} = [] unless exists $GENTOO2DIST{$map}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 78 | 121 | push @{ $GENTOO2DIST{$map} }, $module; | |||||||||||||||||||
| 79 | } | ||||||||||||||||||||
| 80 | 1 | return $DIST2GENTOO_LOADED = 1; | |||||||||||||||||||
| 81 | } | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | sub has_module_override { | ||||||||||||||||||||
| 84 | 189 | ▶ | my ( undef, $module ) = @_; | ||||||||||||||||||
|
Subroutine
has_module_override: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 85 | 189 | ▶ | _load_mod2gentoo unless $MOD2GENTOO_LOADED; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 86 | 189 | return exists $MOD2GENTOO{$module}; | |||||||||||||||||||
| 87 | } | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | sub get_module_override { | ||||||||||||||||||||
| 90 | 30 | ▶ | my ( undef, $module ) = @_; | ||||||||||||||||||
|
Subroutine
get_module_override: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||
| 91 | 30 | ▶ | _load_mod2gentoo unless $MOD2GENTOO_LOADED; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 92 | 30 | return $MOD2GENTOO{$module}; | |||||||||||||||||||
| 93 | } | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | sub has_dist_override { | ||||||||||||||||||||
| 96 | 2 | ▶ | my ( undef, $dist ) = @_; | ||||||||||||||||||
|
Subroutine
has_dist_override: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 97 | 2 | ▶ | _load_dist2gentoo unless $DIST2GENTOO_LOADED; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 98 | 2 | return exists $DIST2GENTOO{$dist}; | |||||||||||||||||||
| 99 | } | ||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | sub get_dist_override { | ||||||||||||||||||||
| 102 | 1 | ▶ | my ( undef, $dist ) = @_; | ||||||||||||||||||
|
Subroutine
get_dist_override: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||
| 103 | 1 | ▶ | _load_mod2gentoo unless $DIST2GENTOO_LOADED; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 104 | 1 | return $DIST2GENTOO{$dist}; | |||||||||||||||||||
| 105 | } | ||||||||||||||||||||
| 106 | |||||||||||||||||||||
| 107 | sub has_gentoo_package { | ||||||||||||||||||||
| 108 | 0 | ▶ | my ( undef, $package ) = @_; | ||||||||||||||||||
|
Subroutine
has_gentoo_package: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 109 | 0 | ▶ | _load_dist2gentoo unless $DIST2GENTOO_LOADED; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 110 | 0 | return exists $GENTOO2DIST{$package}; | |||||||||||||||||||
| 111 | } | ||||||||||||||||||||
| 112 | |||||||||||||||||||||
| 113 | sub get_dists_in_gentoo_package { | ||||||||||||||||||||
| 114 | 0 | ▶ | my ( undef, $package ) = @_; | ||||||||||||||||||
|
Subroutine
get_dists_in_gentoo_package: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 115 | 0 | ▶ | _load_dist2gentoo unless $DIST2GENTOO_LOADED; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 116 | 0 | ▶ | return @{ $GENTOO2DIST{$package} || [] }; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 117 | } | ||||||||||||||||||||
| 118 | |||||||||||||||||||||
| 119 | sub get_modules_in_gentoo_package { | ||||||||||||||||||||
| 120 | 0 | ▶ | my ( undef, $package ) = @_; | ||||||||||||||||||
|
Subroutine
get_modules_in_gentoo_package: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 121 | 0 | ▶ | _load_mod2gentoo unless $MOD2GENTOO_LOADED; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 122 | 0 | ▶ | return @{ $GENTOO2MOD{$package} || [] }; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 123 | } | ||||||||||||||||||||
| 124 | |||||||||||||||||||||
| 125 | sub get_known_gentoo_packages { | ||||||||||||||||||||
| 126 | 0 | ▶ | _load_dist2gentoo unless $DIST2GENTOO_LOADED; | ||||||||||||||||||
|
Subroutine
get_known_gentoo_packages: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||
| 127 | 0 | return keys %GENTOO2DIST; | |||||||||||||||||||
| 128 | } | ||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | sub get_known_dists { | ||||||||||||||||||||
| 131 | 0 | ▶ | _load_dist2gentoo unless $DIST2GENTOO_LOADED; | ||||||||||||||||||
|
Subroutine
get_known_dists: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||
| 132 | 0 | return keys %DIST2GENTOO; | |||||||||||||||||||
| 133 | } | ||||||||||||||||||||
| 134 | |||||||||||||||||||||
| 135 | sub get_known_modules { | ||||||||||||||||||||
| 136 | 0 | ▶ | _load_mod2gentoo unless $MOD2GENTOO_LOADED; | ||||||||||||||||||
|
Subroutine
get_known_modules: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||
| 137 | 0 | return keys %MOD2GENTOO; | |||||||||||||||||||
| 138 | } | ||||||||||||||||||||
| 139 | |||||||||||||||||||||
| 140 | sub module_is_perl { | ||||||||||||||||||||
| 141 | 83 | ▶ | my ( $self, $opts, $module, $mod_version ) = @_; | ||||||||||||||||||
|
Subroutine
module_is_perl: called CC=13 SCAR=25.7
Pod
documented
| |||||||||||||||||||||
| 142 | 83 | ▶ | if ( not ref $opts ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 143 | 75 | ( $opts, $module, $mod_version ) = ( {}, $opts, $module ); | |||||||||||||||||||
| 144 | } | ||||||||||||||||||||
| 145 | |||||||||||||||||||||
| 146 | # If the module has a virtual, don't even consider | ||||||||||||||||||||
| 147 | # CPAN/perl decisions | ||||||||||||||||||||
| 148 | |||||||||||||||||||||
| 149 | 83 | ▶ | return if $self->has_module_override($module); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 150 | 83 | require version; | |||||||||||||||||||
| 151 | |||||||||||||||||||||
| 152 | 83 | ▶ | $opts->{min_perl} ||= $self->min_perl; | ||||||||||||||||||
|
Condition66%2/3
$opts->{"min_perl"} ||= $self->min_perl
MC/DC0%0/2
$opts->{"min_perl"} ||= $self->min_perl
$opts->{"min_perl"}
$self->min_perl
Truth table66%2/3
A ||= B
A= $opts->{"min_perl"}B= $self->min_perl
| |||||||||||||||||||||
| 153 | 83 | my $min_perl = version->parse( $opts->{min_perl} ); | |||||||||||||||||||
| 154 | 83 | ▶ | $opts->{max_perl} ||= $self->max_perl; | ||||||||||||||||||
|
Condition66%2/3
$opts->{"max_perl"} ||= $self->max_perl
MC/DC0%0/2
$opts->{"max_perl"} ||= $self->max_perl
$opts->{"max_perl"}
$self->max_perl
Truth table66%2/3
A ||= B
A= $opts->{"max_perl"}B= $self->max_perl
| |||||||||||||||||||||
| 155 | 83 | my $max_perl = version->parse( $opts->{max_perl} ); | |||||||||||||||||||
| 156 | |||||||||||||||||||||
| 157 | 83 | my $seen; | |||||||||||||||||||
| 158 | ## no critic (Variables::ProhibitPackageVars) | ||||||||||||||||||||
| 159 | 83 | for my $version ( keys %Module::CoreList::version ) { | |||||||||||||||||||
| 160 | 4471 | my $perlver = version->parse($version); | |||||||||||||||||||
| 161 | ## no critic (ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions) | ||||||||||||||||||||
| 162 | 4471 | ▶ | next unless $perlver >= $min_perl; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 163 | 3150 | ▶ | next unless $perlver <= $max_perl; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 164 | |||||||||||||||||||||
| 165 | # If any version in the range returns "deprecated", then we should | ||||||||||||||||||||
| 166 | # default to CPAN | ||||||||||||||||||||
| 167 | 240 | ▶ | return if $Module::CoreList::deprecated{$version}{$module}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 168 | |||||||||||||||||||||
| 169 | # If any version in the range does not exist, then we should default to CPAN | ||||||||||||||||||||
| 170 | # | ||||||||||||||||||||
| 171 | 237 | ▶ | return if not exists $Module::CoreList::version{$version}{$module}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 172 | |||||||||||||||||||||
| 173 | 165 | ▶ | if ( not defined $mod_version ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 174 | 68 | $seen = 1; | |||||||||||||||||||
| 175 | 68 | next; | |||||||||||||||||||
| 176 | } | ||||||||||||||||||||
| 177 | |||||||||||||||||||||
| 178 | # If any version in the range is undef, and a specific version is requested, | ||||||||||||||||||||
| 179 | # Default to CPAN, because it means a virtual is not provisioned. | ||||||||||||||||||||
| 180 | 97 | ▶ | return if not defined $Module::CoreList::version{$version}{$module}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 181 | |||||||||||||||||||||
| 182 | 97 | my $this_version = version->parse( $Module::CoreList::version{$version}{$module} ); | |||||||||||||||||||
| 183 | |||||||||||||||||||||
| 184 | # If any version in the range is lower than required, default to CPAN | ||||||||||||||||||||
| 185 | # because it means a virtual is not provisioned, and a breakage will occur | ||||||||||||||||||||
| 186 | # on one of the versions. | ||||||||||||||||||||
| 187 | 97 | ▶ | return if $this_version < version->parse($mod_version); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 188 | |||||||||||||||||||||
| 189 | 96 | $seen = 1; | |||||||||||||||||||
| 190 | } | ||||||||||||||||||||
| 191 | 7 | return $seen; | |||||||||||||||||||
| 192 | } | ||||||||||||||||||||
| 193 | |||||||||||||||||||||
| 194 | 4 | ▶ | no Moo; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 195 | |||||||||||||||||||||
| 196 | 4 | 1; | |||||||||||||||||||
| 197 | |||||||||||||||||||||
| 198 | __END__ | ||||||||||||||||||||