| 1 | package Dist::Conformance::Check::SystemPackages 0.006; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: The system packages that a repository declares in metamerge.yml, validated, and resolved for a host | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use 5.040; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use re '/aasx'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Mojo::Base 'Dist::Conformance::Check', -signatures; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Lingua::EN::Inflect(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use List::Util(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Dist::Conformance::Schema(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Dist::Conformance::Snapshot::Directory(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | our $FILE = 'metamerge.yml'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | our $PACKAGES = 'x_system_packages'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | our $SOURCES = 'x_system_sources'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | our $DEPENDENCY = '\A[A-Za-z0-9][A-Za-z0-9_.+:-]*\z'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | our $SOURCE_NAME = '\A[a-z0-9][a-z0-9.-]*\z'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # The name of a packager, as Provisioner::Packager->named takes it. test is not one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | our $PACKAGER = '\A(?!test\z)[a-z][a-z0-9]*\z'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | our %PACKAGE_NAME = ( deb => '\A[a-z0-9][a-z0-9+.-]*[a-z0-9+.]\z' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | our $ANY_PACKAGE_NAME = '\A[A-Za-z0-9](?:[A-Za-z0-9+._-]*[A-Za-z0-9+._])?\z'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # DISTRO or DISTRO/RELEASE, in the characters that os-release allows in ID and VERSION_ID. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | our $HOST = '\A[a-z0-9._-]+(?:/[a-z0-9._-]+)?\z'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | ▶ | my sub list_of ($item) { return { type => 'array', minItems => 1, items => $item } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_of: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # The keywords of a mapping that must have a key other than $key, which refuse it with $message. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 3 | ▶ | my sub more_than ( $key, $message ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
more_than: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 3 | minProperties => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | not => { required => [$key], maxProperties => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 'x-errorMessage' => { minProperties => $message, not => $message }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 2 | ▶ | my sub entry_of ($pattern) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
entry_of: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | my $name = { type => 'string', pattern => $pattern }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | anyOf => [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | type => 'object', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | more_than( source => 'names no package, as name or for a distro' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | additionalProperties => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | properties => { name => $name, source => { type => 'string', pattern => $SOURCE_NAME } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | patternProperties => { '(?!(?:name|source)\z)' . $HOST => { %$name, nullable => 1 } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | our $URL = { type => 'string', pattern => '\Ahttps?://[^/\s]+\S*\z' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | our %SOURCE = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | deb => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | type => 'object', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | required => [qw{name uri suites components key fingerprint}], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | additionalProperties => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | properties => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | name => { type => 'string', pattern => $SOURCE_NAME }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | uri => $URL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | key => $URL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | suites => list_of( { type => 'string', pattern => '\A(?:[^\s{}]|\{codename\})+\z' } ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | components => { type => 'array', items => { type => 'string', pattern => '\A\S+\z' } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | architectures => { type => 'array', items => { type => 'string', pattern => '\A[a-z0-9]+\z' } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | fingerprint => { type => 'string', pattern => '\A[0-9A-Fa-f]{40}\z' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | distros => list_of( { type => 'string', pattern => $HOST } ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | pin => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | type => 'object', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | required => ['priority'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | additionalProperties => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | properties => { priority => { type => 'integer' }, packages => { type => 'string', pattern => '\A\S+\z' } }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | our $SCHEMA = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | type => 'object', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | properties => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | $PACKAGES => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | type => 'object', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | additionalProperties => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | patternProperties => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | $DEPENDENCY => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | type => 'object', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | more_than( test => 'names no packager' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | additionalProperties => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | properties => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | test => { type => 'string', pattern => '\A[^\n]*\S[^\n]*\z' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | map { $_ => entry_of( $PACKAGE_NAME{$_} ) } keys %PACKAGE_NAME, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | patternProperties => { '(?!(?:' . join( q{|}, sort keys %PACKAGE_NAME ) . ')\z)' . $PACKAGER => entry_of($ANY_PACKAGE_NAME) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | $SOURCES => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | type => 'object', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | additionalProperties => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | properties => { map { $_ => list_of( $SOURCE{$_} ) } keys %SOURCE }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # The mapping of metamerge.yml, or an empty one when there is none. Dies when the file does not parse. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | my sub document_of ($snapshot) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
document_of: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | my $text = $snapshot->content($FILE) // return {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$snapshot->content($Dist::Conformance::Check::SystemPackages::FILE) // (return {})
MC/DC0%0/1
$snapshot->content($Dist::Conformance::Check::SystemPackages::FILE) // (return {})
$snapshot->content($Dist::Conformance::Check::SystemPackages::FILE)
Truth table0%0/2
A
A= $snapshot->content($Dist::Conformance::Check::SystemPackages::FILE)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | return Dist::Conformance::Schema::parse_yaml( $text, $FILE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | my sub declaration_of ($document) { return { packages => $document->{$PACKAGES} // {}, sources => $document->{$SOURCES} // {} } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
declaration_of: not called CC=3 SCAR=24.8
Condition0%0/4
$document->{$Dist::Conformance::Check::SystemPackages::PACKAGES} // {}
$document->{$Dist::Conformance::Check::SystemPackages::SOURCES} // {}
MC/DC0%0/1
$document->{$Dist::Conformance::Check::SystemPackages::PACKAGES} // {}
$document->{$Dist::Conformance::Check::SystemPackages::PACKAGES}
MC/DC0%0/1
$document->{$Dist::Conformance::Check::SystemPackages::SOURCES} // {}
$document->{$Dist::Conformance::Check::SystemPackages::SOURCES}
Truth table0%0/2
A
A= $document->{$Dist::Conformance::Check::SystemPackages::PACKAGES}
Truth table0%0/2
A
A= $document->{$Dist::Conformance::Check::SystemPackages::SOURCES}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # The errors of the schema, or else what it cannot say, because it compares one part of the document with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # another: that the sources and the entries that name them agree. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | my sub errors_of ($document) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
errors_of: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my @errors = Dist::Conformance::Schema::errors( $document, $SCHEMA ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | return @errors if @errors; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my ( $packages, $sources ) = @{ declaration_of($document) }{qw{packages sources}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my %named; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | for my $dependency ( sort keys %$packages ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my @packagers = grep { $_ ne 'test' } sort keys %{ $packages->{$dependency} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | for my $packager ( grep { ref $packages->{$dependency}{$_} } @packagers ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my $entry = $packages->{$dependency}{$packager}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | next if !defined $entry->{source}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | $named{$packager}{ $entry->{source} } = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if ( List::Util::none { $_->{name} eq $entry->{source} } @{ $sources->{$packager} // [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
Condition0%0/2
$sources->{$packager} // []
MC/DC0%0/1
$sources->{$packager} // []
$sources->{$packager}
Truth table0%0/2
A
A= $sources->{$packager}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | push @errors, "/$PACKAGES/$dependency/$packager/source: $entry->{source} is not a source in $SOURCES/$packager"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | for my $packager ( sort keys %$sources ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | for my $index ( 0 .. $#{ $sources->{$packager} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | my $source = $sources->{$packager}[$index]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | push @errors, "/$SOURCES/$packager/$index/name: $source->{name} is the name of another source too" if $seen{ $source->{name} }++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | push @errors, "/$SOURCES/$packager/$index: no dependency names $source->{name} as its source" if !$named{$packager}{ $source->{name} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | return @errors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | sub declared ( $, $from ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
declared: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | my $snapshot = builtin::blessed($from) && $from->isa('Dist::Conformance::Snapshot') ? $from : Dist::Conformance::Snapshot::Directory->new( root => $from ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($from) and $from->isa("Dist::Conformance::Snapshot")
MC/DC0%0/2
builtin::blessed($from) and $from->isa("Dist::Conformance::Snapshot")
builtin::blessed($from)
$from->isa("Dist::Conformance::Snapshot")
Truth table0%0/3
A and B
A= builtin::blessed($from)B= $from->isa("Dist::Conformance::Snapshot")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $document = document_of($snapshot); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my @errors = errors_of($document); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | Dist::Conformance::Schema::refuse( $FILE, @errors ) if @errors; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | return declaration_of($document); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | sub resolve ( $, $declared, %host ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve: not called CC=19 SCAR=59.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my ( $packager, $distro, $release, $codename ) = @host{qw{packager distro release codename}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | die "resolve needs a packager\n" if !defined $packager; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | my @keys = ( ( defined $distro && defined $release ? "$distro/$release" : () ), ( defined $distro ? $distro : () ), 'name' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $distro and defined $release
MC/DC0%0/2
defined $distro and defined $release
defined $distro
defined $release
Truth table0%0/3
A and B
A= defined $distroB= defined $release
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my %on_host = map { $_ => 1 } grep { $_ ne 'name' } @keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | my %source = map { $_->{name} => $_ } @{ $declared->{sources}{$packager} // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$declared->{"sources"}{$packager} // []
MC/DC0%0/1
$declared->{"sources"}{$packager} // []
$declared->{"sources"}{$packager}
Truth table0%0/2
A
A= $declared->{"sources"}{$packager}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my ( @needs, @unresolved ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | for my $name ( sort keys %{ $declared->{packages} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my $dependency = $declared->{packages}{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $entry = $dependency->{$packager}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | my %need = ( name => $name, package => $entry, source => undef, test => $dependency->{test} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if ( ref $entry ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | my ($key) = grep { exists $entry->{$_} } @keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | $need{package} = defined $key ? $entry->{$key} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | $need{source} = $entry->{source} if defined $need{package}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | $entry = undef if !defined $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | my $source = defined $need{source} ? $source{ $need{source} } : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if ( !defined $entry || ( $source && $source->{distros} && !List::Util::any( sub { $on_host{$_} }, @{ $source->{distros} } ) ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
Condition0%0/9
not defined $entry or $source and $source->{"distros"} and not &List::Util::any(sub {
$on_host{$_};
}
, @{$$source{"distros"};})
$source and $source->{"distros"} and not &List::Util::any(sub {
$on_host{$_};
}
, @{$$source{"distros"};})
$source and $source->{"distros"}
MC/DC0%0/4
not defined $entry or $source and $source->{"distros"} and not &List::Util::any(sub {
$on_host{$_};
}
, @{$$source{"distros"};})
not defined $entry
$source
$source->{"distros"}
not &List::Util::any(sub {
$on_host{$_};
}
, @{$$source{"distros"};})
Truth table0%0/5
not(A) or B and C and not(D)
A= not defined $entryB= $sourceC= $source->{"distros"}D= not &List::Util::any(sub {
$on_host{$_};
}
, @{$$source{"distros"};})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | push @unresolved, $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | push @needs, \%need; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my @sources; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | for my $name ( List::Util::uniq( grep { defined } map { $_->{source} } @needs ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | my %resolved = %{ $source{$name} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | delete $resolved{distros}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | $resolved{suites} = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my $suite = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | die "The source $name needs the codename of the host, for the suite $suite\n" if index( $suite, '{codename}' ) >= 0 && !defined $codename; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
index($suite, "{codename}") != -1 and not defined $codename
MC/DC0%0/2
index($suite, "{codename}") != -1 and not defined $codename
index($suite, "{codename}") != -1
not defined $codename
Truth table0%0/3
A and not(B)
A= index($suite, "{codename}") != -1B= not defined $codename
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $suite =~ s/\{codename\}/$codename/gr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | } @{ $resolved{suites} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | push @sources, \%resolved; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | needs => \@needs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | packages => [ List::Util::uniq( grep { defined } map { $_->{package} } @needs ) ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | sources => \@sources, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | programs => [ grep { defined } map { $_->{test} } @needs ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | unresolved => \@unresolved, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | sub os_release ($text) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
os_release: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | my %variables; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | for my $line ( split /\n/, $text ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | my ( $name, $value ) = $line =~ m/\A\s*([[:alpha:]_]\w*)=(.*?)\s*\z/ or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my ($double) = $value =~ m/\A"((?:[^"\\]|\\.)*)"\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my ($single) = $value =~ m/\A'([^']*)'\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | $variables{$name} = defined $double ? $double =~ s/\\(.)/$1/gr : $single // $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$single // $value
MC/DC0%0/2
$single // $value
$single
$value
Truth table0%0/3
A // B
A= $singleB= $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | return \%variables; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | sub check ( $, $snapshot ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | return ( 'pass', "there is no $FILE, so it needs no system packages" ) if !$snapshot->contains($FILE); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | my $document = eval { document_of($snapshot) } // return ( 'fail', Dist::Conformance::Schema::first_line($@) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
eval {
do {
document_of $snapshot
}
} // (return "fail", Dist::Conformance::Schema::first_line($@))
MC/DC0%0/1
eval {
do {
document_of $snapshot
}
} // (return "fail", Dist::Conformance::Schema::first_line($@))
eval {
do {
document_of $snapshot
}
}
Truth table0%0/2
A
A= eval {
do {
document_of $snapshot
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | my @errors = errors_of($document); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | return ( 'fail', "$FILE is not valid: " . join '; ', @errors ) if @errors; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | my $declaration = declaration_of($document); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | my $sources = $declaration->{sources}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my @said = ( map { Lingua::EN::Inflect::NO( "$_ source", scalar @{ $sources->{$_} } ) } sort keys %$sources ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | unshift @said, Lingua::EN::Inflect::NO( 'dependency', scalar keys %{ $declaration->{packages} } ) if %{ $declaration->{packages} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | return ( 'pass', "$FILE declares no system packages" ) if !@said; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my $last = pop @said; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | return ( 'pass', "$FILE declares " . ( @said ? join( ', ', @said ) . " and $last" : $last ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||