Arepa/Builder.pm

filter: Statementstmt 58.9% 56 / 95 Branchbran 25.0% 2 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 20 / 30 Podpod 37.5% 6 / 16 totaltotal 54.5% 84 / 154 CC 6 SCAR 9.8
CC
6
Cov
55%
type
12.0
create
6.0
ui_module
3.5
CRAP 2.7
« Arepa/Web/Keys.pm ↑ Summary Arepa/Config.pm »
1 package Arepa::Builder;
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  
6 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use File::chmod;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use File::Temp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use File::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use File::Find;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 ▶use File::Copy;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 3 ▶use Config::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 3 ▶use YAML::Syck;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 3 ▶use Arepa;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 3 my $ui_module = 'Arepa::UI::Text';
20  
21 1 ▶sub ui_module {
Subroutine ui_module: called CC=3 SCAR=12.6
Pod documented
22 1 my ($self, $module) = @_;
23 1 ▶ if (defined $module) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $module) 1 0 1
24 1 $ui_module = $module;
25 }
26 0 ▶ eval qq(use $ui_module;);
Subroutine BEGIN: called CC=1 SCAR=1.2
27 1 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 1 0 1
28 0 return $ui_module;
29 }
30  
31 0 ▶sub type {
Subroutine type: not called CC=3 SCAR=24.8
Pod undocumented
32 0 my ($self) = @_;
33 0 ▶ my $class = ref($self) || $self;
Condition0%0/3
ref $self || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table0%0/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
34 0 $class =~ s/.+:://;
35 0 ▶ if (!$class) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($class) 0 0 0
36 0 croak "You should use a proper builder class, not ".ref($self);
37 }
38 0 return lc($class);
39 }
40  
41 4 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
42 4 my ($class, %attrs) = @_;
43  
44 4 return bless {
45 %attrs,
46 },
47 $class;
48 }
49  
50 4 ▶sub name { $_[0]->{name} }
Subroutine name: called CC=1 SCAR=0.0
Pod undocumented
51 0 ▶sub last_build_log { $_[0]->{last_build_log} }
Subroutine last_build_log: not called CC=1 SCAR=6.9
Pod documented
52  
53 4 ▶sub config {
Subroutine config: called CC=1 SCAR=0.0
Pod undocumented
54 4 my ($self, $key) = @_;
55 4 return $self->{$key};
56 }
57  
58  
59 # To be implemented by each type
60  
61 0 ▶sub do_init {
Subroutine do_init: not called CC=1 SCAR=6.9
Pod undocumented
62 0 my ($self, $builder) = @_;
63 0 croak "Not implemented";
64 }
65  
66 0 ▶sub init {
Subroutine init: not called CC=1 SCAR=6.9
Pod documented
67 0 my ($self, $builder) = @_;
68 0 $self->do_init($builder);
69 }
70  
71 0 ▶sub do_uninit {
Subroutine do_uninit: not called CC=1 SCAR=6.9
Pod undocumented
72 0 my ($self, $builder) = @_;
73 0 croak "Not implemented";
74 }
75  
76 0 ▶sub uninit {
Subroutine uninit: not called CC=1 SCAR=6.9
Pod undocumented
77 0 my ($self, $builder) = @_;
78 0 $self->do_uninit($builder);
79 }
80  
81 0 ▶sub do_compile_package_from_dsc {
Subroutine do_compile_package_from_dsc: not called CC=1 SCAR=6.9
Pod undocumented
82 0 my ($self, $dsc_file, %user_opts) = @_;
83 0 croak "Not implemented";
84 }
85  
86 2 ▶sub compile_package_from_dsc {
Subroutine compile_package_from_dsc: called CC=1 SCAR=0.0
Pod documented
87 2 my ($self, $dsc_file, %user_opts) = @_;
88 2 $self->do_compile_package_from_dsc($dsc_file, %user_opts);
89 }
90  
91 0 ▶sub do_compile_package_from_repository {
Subroutine do_compile_package_from_repository: not called CC=1 SCAR=6.9
Pod undocumented
92 0 my ($self, $pkg_name, $pkg_version, %user_opts) = @_;
93 0 croak "Not implemented";
94 }
95  
96 2 ▶sub compile_package_from_repository {
Subroutine compile_package_from_repository: called CC=1 SCAR=0.0
Pod documented
97 2 my ($self, $pkg_name, $pkg_version, %user_opts) = @_;
98 2 $self->do_compile_package_from_repository($pkg_name,
99 $pkg_version,
100 %user_opts);
101 }
102  
103 0 ▶sub do_create {
Subroutine do_create: not called CC=1 SCAR=6.9
Pod undocumented
104 0 my ($self, $builder_dir, $mirror, $distribution, %opts) = @_;
105 0 croak "Not implemented";
106 }
107  
108 0 ▶sub create {
Subroutine create: not called CC=2 SCAR=17.9
Pod documented
109 0 my ($self, $builder_dir, $mirror, $distribution, %user_opts) = @_;
110 0 my %opts = (builder_config_dir => '/etc/arepa/builders',
111 arch => `dpkg-architecture -qDEB_BUILD_ARCH`,
112 %user_opts);
113 0 chomp($opts{arch});
114  
115 0 $self->do_create($builder_dir, $mirror, $distribution, %opts);
116  
117 0 $self->ui_module->print_title("Configuration for config.yml");
118  
119 0 my $type = $self->type;
120  
121 0 my $config_string = <<EOD;
122 type: $type
123 architecture: $opts{arch}
124 # Compile "Architecture: all" packages with this builder?
125 architecture_all: 0
126 # This is the distribution the packages compiled by this builder go to. For a
127 # package to be compiled by this builder, it has to have the correct
128 # architecture and this distribution (or an alias or similar, see below) in
129 # its *.changes file.
130 distribution: $distribution
131 # Other names for this distribution (if the distribution name is
132 # mycompany-squeeze, you might want 'squeeze' and 'testing' as aliases)
133 distribution_aliases: []
134 # Recompile packages (binNMU or Binary-only Non-Maintainer Upload; see
135 # http://www.debian.org/doc/developers-reference/pkgs.html#nmu-binnmu)
136 # originally uploaded for other distributions in this builder. This option is
137 # an easy way to get "for free" packages compiled for several distributions.
138 # Typical values for this list would be 'unstable' or 'lenny'
139 bin_nmu_for: []
140 EOD
141  
142 0 my $builder_name = basename($builder_dir);
143 my $path = File::Spec->catfile($opts{builder_config_dir},
144 0 "$builder_name.yml");
145 0 ▶ open F, ">$path" or croak "Can't write builder configuration in $path";
Branch: 1 branch
BranchTrueFalseTotal
open F, ">$path" or croak("Can't write builder configuration in $path") 0 0 0
146 0 print F $config_string;
147 0 close F;
148  
149 0 my $sources_list_path = File::Spec->catfile($builder_dir, "etc", "apt",
150 "sources.list");
151  
152 0 $self->ui_module->print_title("Done");
153 0 print <<EOM
154  
155 Next steps
156 ----------
157 * Tweak the builder configuration in $path
158 * Review $sources_list_path
159 * Add all relevant repository keys to the builder (eg. "apt-key add ...")
160  
161 EOM
162 }
163  
164 3 1;
165  
166 __END__
« Arepa/Web/Keys.pm ↑ Summary Arepa/Config.pm »