| 1 | package Arepa::BuilderFarm; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Cwd; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use File::Temp; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Arepa::Config; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Arepa::PackageDb; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | my ($class, $config_path, %user_opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | my $config = Arepa::Config->new($config_path, %user_opts); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | my $self = bless { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | config_path => $config_path, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | config => $config, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | package_db => Arepa::PackageDb->new($config->get_key('package_db')), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | last_build_log => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 4 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub last_build_log { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
last_build_log: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | return $self->{last_build_log}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 16 | ▶ | sub package_db { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
package_db: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 16 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 16 | return $self->{package_db}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 4 | ▶ | sub get_builder_config { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_builder_config: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 4 | my ($self, $builder) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 4 | return $self->{config}->get_builder_config($builder); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 5 | ▶ | sub builder_type_module { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
builder_type_module: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 5 | my ($self, $type) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 5 | $type =~ s/[^a-z0-9]//goi; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 5 | return "Arepa::Builder::" . ucfirst(lc($type)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 2 | ▶ | sub builder_module { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
builder_module: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 2 | my ($self, $builder_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | my %conf = $self->get_builder_config($builder_name); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 2 | my $module = $self->builder_type_module($conf{type}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | ▶ | eval "use $module;"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 2 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | croak "Couldn't load builder module '$module' for type '$conf{type}': $@"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 2 | return $module; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | ▶ | sub builder { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
builder: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | my ($self, $builder_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | my $module_name = $self->builder_module($builder_name); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 2 | return $module_name->new($self->get_builder_config($builder_name)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub init_builders { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_builders: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | foreach my $builder ($self->{config}->get_builders) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $self->init_builder($builder); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub init_builder { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_builder: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my ($self, $builder) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | my $module = $self->builder_module($builder); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $module->init($builder); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | sub uninit_builders { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uninit_builders: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | foreach my $builder ($self->{config}->get_builders) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $self->uninit_builder($builder); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub uninit_builder { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uninit_builder: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my ($self, $builder) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | my $module = $self->builder_module($builder); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $module->uninit($builder); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | sub compile_package_from_dsc { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compile_package_from_dsc: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my ($self, $builder_name, $dsc_file, %user_opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my %opts = (output_dir => '.', %user_opts); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my $builder = $self->builder_module($builder_name); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | my $r = $builder->compile_package_from_dsc($dsc_file, %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $self->{last_build_log} = $builder->last_build_log; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 7 | ▶ | sub bin_nmu_id { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bin_nmu_id: called CC=6 SCAR=18.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 7 | my ($self, $source_pkg_attrs, $builder) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 7 | my %builder_cfg = $self->{config}->get_builder_config($builder); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 4 | my $r = scalar grep { $_ eq $source_pkg_attrs->{distribution} } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 7 | ▶ | @{$builder_cfg{bin_nmu_for} || []}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$builder_cfg{'bin_nmu_for'} || []
MC/DC100%1/1
$builder_cfg{'bin_nmu_for'} || []
$builder_cfg{'bin_nmu_for'}
Truth table100%2/2
A
A= $builder_cfg{'bin_nmu_for'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 7 | ▶ | if ($r) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # NOTE: This bin_nmu_id thing is explicitly UNSUPPORTED. I'm not sure I | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # want to go down that path, but it _may_ prove useful. So I'm leaving | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # these two lines here while I make my mind. When/if I decide that it's | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # a good idea, I'll add tests and document it. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 4 | ▶ | if (exists $builder_cfg{bin_nmu_id}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | return $builder_cfg{bin_nmu_id}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 4 | my @builders = $self->{config}->get_builders; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 4 | ▶ | for (my $i = 0; $i < scalar @builders; ++$i) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 11 | ▶ | return $i+1 if $builders[$i] eq $builder; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | croak "Can't find builder '$builder'?!\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 3 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 2 | ▶ | sub compile_package_from_queue { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compile_package_from_queue: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 2 | my ($self, $builder_name, $request_id, %user_opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 2 | my %opts = (output_dir => '.', %user_opts); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 2 | my %request = $self->package_db->get_compilation_request_by_id($request_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 2 | $self->package_db->mark_compilation_started($request_id, $builder_name); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 2 | my $builder = $self->builder($builder_name); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 2 | my %source_attrs = $self->package_db->get_source_package_by_id($request{source_package_id}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | $opts{bin_nmu} = $self->bin_nmu_id(\%source_attrs, $builder_name); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | my $r = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | $builder->compile_package_from_repository($source_attrs{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | $source_attrs{full_version}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 2 | %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 2 | $self->{last_build_log} = $builder->last_build_log; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | # Save the build log | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 2 | my $build_log_dir = $self->{config}->get_key('dir:build_logs'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 2 | my $build_log_path = File::Spec->catfile($build_log_dir, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | $request_id); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 2 | ▶ | open F, ">$build_log_path" or croak "Can't write in $build_log_path"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 2 | print F $self->{last_build_log}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 2 | close F; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # Mark the compilation request appropriately | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 2 | ▶ | if ($r) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 2 | $self->package_db->mark_compilation_completed($request_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $self->package_db->mark_compilation_failed($request_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 2 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | ▶ | sub request_package_compilation { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request_package_compilation: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | my ($self, $source_id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | foreach my $target ($self->get_compilation_targets($source_id)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 3 | my ($arch, $dist) = @$target; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 3 | $self->{package_db}->request_compilation($source_id, $arch, $dist); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 4 | ▶ | sub get_compilation_targets { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_compilation_targets: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 4 | my ($self, $source_id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 4 | my %source_attrs = $self->{package_db}->get_source_package_by_id($source_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | my @builders = $self->get_matching_builders($source_attrs{architecture}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 4 | $source_attrs{distribution}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 4 | my %builder_config = $self->{config}->get_builder_config($_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | $source_attrs{architecture} eq 'any' ? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | [$builder_config{architecture}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | $builder_config{distribution}] : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | [$source_attrs {architecture}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 9 | ▶ | $builder_config{distribution}]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } @builders; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 15 | ▶ | sub get_matching_builders { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_matching_builders: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 15 | my ($self, $arch, $distro) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # Get the builder information once | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 56 | my @builder_information = map { { $self->{config}->get_builder_config($_) } } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 15 | $self->{config}->get_builders; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | # Get builders that match *both*: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | return map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | $_->{name} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 25 | } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | # 1) the architecture in 'architecture' (or 'all' if applicable) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | ($arch eq 'any' || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | $arch eq $_->{architecture} || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 38 | ▶ | ($arch eq 'all' && $_->{architecture_all})); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%9/9
$arch eq 'any' || $arch eq $_->{'architecture'} || $arch eq 'all' && $_->{'architecture_all'}
$arch eq "any" or $arch eq $_->{"architecture"}
$arch eq "all" and $_->{"architecture_all"}
MC/DC100%4/4
$arch eq 'any' || $arch eq $_->{'architecture'} || $arch eq 'all' && $_->{'architecture_all'}
$arch eq "any"
$arch eq $_->{"architecture"}
$arch eq "all"
$_->{"architecture_all"}
Truth table100%5/5
A or B || C and D
A= $arch eq "any"B= $arch eq $_->{"architecture"}C= $arch eq "all"D= $_->{"architecture_all"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | # 2) the $distro in *either* 'distribution' or | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | # 'distribution_aliases' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 15 | my @bdistros = ref($_->{distribution_aliases}) eq 'ARRAY' ? | |||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 56 | @{$_->{distribution_aliases}} : | |||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 56 | ▶ | $_->{distribution_aliases}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | my @binnmu_distros = ref($_->{bin_nmu_for}) eq 'ARRAY' ? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 19 | ▶ | @{$_->{bin_nmu_for}} : | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$_->{"bin_nmu_for"} or ()
MC/DC0%0/2
$_->{"bin_nmu_for"} or ()
$_->{"bin_nmu_for"}
()
Truth table33%1/3
A or B
A= $_->{"bin_nmu_for"}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 56 | ▶ | ($_->{bin_nmu_for} || ()); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | $distro eq $_->{distribution} || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 84 | grep({ $distro eq $_ } @bdistros) || | |||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 56 | ▶ | grep({ $distro eq $_ } @binnmu_distros); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$distro eq $_->{'distribution'} || grep({$distro eq $_;} @bdistros) || grep({$distro eq $_;} @binnmu_distros)
$distro eq $_->{"distribution"} or grep {$distro eq $_;} @bdistros
MC/DC100%3/3
$distro eq $_->{'distribution'} || grep({$distro eq $_;} @bdistros) || grep({$distro eq $_;} @binnmu_distros)
$distro eq $_->{"distribution"}
grep {$distro eq $_;} @bdistros
grep({$distro eq $_;} @binnmu_distros)
Truth table100%4/4
A or B || C
A= $distro eq $_->{"distribution"}B= grep {$distro eq $_;} @bdistrosC= grep({$distro eq $_;} @binnmu_distros)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | @builder_information; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | sub register_source_package { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register_source_package: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | my ($self, %source_attrs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | my $pdb = $self->package_db; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | my $source_id = $pdb->get_source_package_id($source_attrs{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | $source_attrs{full_version}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | if (!defined $source_id) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $source_id = $pdb->insert_source_package(%source_attrs); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | return $source_id; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 7 | ▶ | sub canonical_distribution { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
canonical_distribution: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 7 | my ($self, $arch, $distribution) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 7 | my @builders = $self->get_matching_builders($arch, $distribution); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 7 | my $distro; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 7 | foreach my $b (@builders) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 9 | my %builder_cfg = $self->{config}->get_builder_config($b); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 9 | ▶ | if (grep { $_ eq $distribution } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 9 | @{$builder_cfg{distribution_aliases}}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | $builder_cfg{distribution}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | # There should be only one; if there's more than one, that's a | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | # problem | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 7 | ▶ | if ($distro) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 1 | croak "There is more than one builder that " . | |||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | "specifies '$distribution' as alias. " . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | "That's not correct! One of them " . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | "should specify it as bin_nmu_for"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 6 | $distro = $builder_cfg{distribution}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 6 | return $distro; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||