| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Ixchel::Actions::xeno_build; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
125081
|
use 5.006; |
|
|
1
|
|
|
|
|
4
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
16
|
|
|
|
1
|
|
|
|
|
37
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
71
|
|
|
6
|
1
|
|
|
1
|
|
1686
|
use File::Slurp; |
|
|
1
|
|
|
|
|
51724
|
|
|
|
1
|
|
|
|
|
105
|
|
|
7
|
1
|
|
|
1
|
|
549
|
use String::ShellQuote; |
|
|
1
|
|
|
|
|
1318
|
|
|
|
1
|
|
|
|
|
80
|
|
|
8
|
1
|
|
|
1
|
|
474
|
use Rex::Commands::Gather; |
|
|
1
|
|
|
|
|
171239
|
|
|
|
1
|
|
|
|
|
7
|
|
|
9
|
1
|
|
|
1
|
|
1574
|
use File::Temp qw/ tempdir /; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
76
|
|
|
10
|
1
|
|
|
1
|
|
20
|
use Rex::Commands::Pkg; |
|
|
1
|
|
|
|
|
16913
|
|
|
|
1
|
|
|
|
|
13
|
|
|
11
|
1
|
|
|
1
|
|
735
|
use LWP::UserAgent (); |
|
|
1
|
|
|
|
|
80420
|
|
|
|
1
|
|
|
|
|
46
|
|
|
12
|
1
|
|
|
1
|
|
20
|
use Ixchel::functions::perl_module_via_pkg; |
|
|
1
|
|
|
|
|
15
|
|
|
|
1
|
|
|
|
|
161
|
|
|
13
|
1
|
|
|
1
|
|
18
|
use Ixchel::functions::install_cpanm; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
96
|
|
|
14
|
1
|
|
|
1
|
|
17
|
use Ixchel::functions::python_module_via_pkg; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
89
|
|
|
15
|
1
|
|
|
1
|
|
17
|
use Ixchel::functions::install_pip; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
109
|
|
|
16
|
1
|
|
|
1
|
|
9
|
use Cwd; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
105
|
|
|
17
|
1
|
|
|
1
|
|
8
|
use base 'Ixchel::Actions::base'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
60
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 NAME |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Ixchel::Actions::xeno_build - Builds and installs stuff based on the supplied hash. |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 VERSION |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Version 0.1.0 |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our $VERSION = '0.1.0'; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 OPTIONS |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 build_hash |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
A build hash containing the options to use for installing and building. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 BUILD HASH |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 BUILD OPTIONS AND VALUES |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head3 options |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
- .options.build_dir :: Build dir to use. If not defined, .config.xeno_options.build_dir |
|
46
|
|
|
|
|
|
|
is used. If that is undef, '/tmp/' is used. |
|
47
|
|
|
|
|
|
|
- Default :: undef |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
. options.tmpdir :: The path for a automatically created tmpdir under .options.build_dir. |
|
50
|
|
|
|
|
|
|
This will be removed one once xeno_build has finished running. This allows for easy cleanup |
|
51
|
|
|
|
|
|
|
when using templating with fetch and exec when using templating. This is created via |
|
52
|
|
|
|
|
|
|
L->newdir. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
- .options.$var :: Additional variable to define. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head3 order |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
An array of the order it should process the steps in. The default is as below. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
fetch |
|
61
|
|
|
|
|
|
|
pkgs |
|
62
|
|
|
|
|
|
|
perl |
|
63
|
|
|
|
|
|
|
python |
|
64
|
|
|
|
|
|
|
exec |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
So lets say you have a .exec in the hash, but .order does not contain 'exec' any place in |
|
67
|
|
|
|
|
|
|
the array, then whatever is in .exec will not be processed. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
If you want to run exec twice with different values, you can create .exec0 and .exec with |
|
70
|
|
|
|
|
|
|
the desired stuff and set the order like below. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
exec0 |
|
73
|
|
|
|
|
|
|
pkgs |
|
74
|
|
|
|
|
|
|
exec |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
First .exec0, then pkgs, and then .exec will be ran. The type is determined via removing |
|
77
|
|
|
|
|
|
|
the end from it via the regexp s/[0-9]*$//. So .perl123 would be ran as perl type. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Unknown types will result in an error. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head3 vars |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This is a hash of variables to pass to the template as var. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head3 templated_vars |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
These are vars that are to be templated. The output is copied to |
|
88
|
|
|
|
|
|
|
the matching name to under vars. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 TYPES |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
- .$type.for :: 'for' may be specified for any of the types. It is a |
|
93
|
|
|
|
|
|
|
array of OS families it is for. |
|
94
|
|
|
|
|
|
|
- Default :: undef |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head3 fetch |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
- .fetch.items.$name.url :: URL to fetch. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
- .fetch.items.$name.dst :: Where to write it to. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
- .fetch.template :: If the url and dst should be treated as a template. |
|
103
|
|
|
|
|
|
|
- Default :: 0 |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
.fetch.items is a hash for the purpose of allowing it to easily be referenced later in exec. If .fetch.items.$name.url or |
|
106
|
|
|
|
|
|
|
.fetch.items.$name.dst is templated, the template output is saved as that variable so it can easily be used in exec. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Variables for template are as below. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
- config :: Ixchel config. |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
- options :: Stuff defined via .options. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
- os :: OS as per L. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head3 pkgs |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
- .pkgs.present :: A hash of arrays. The keys are the OS seen by |
|
119
|
|
|
|
|
|
|
L and values in the array will be ensured to be |
|
120
|
|
|
|
|
|
|
present via L. |
|
121
|
|
|
|
|
|
|
- Default :: undef |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
- .pkgs.latest :: A hash of arrays. The keys are the OS seen by |
|
124
|
|
|
|
|
|
|
L and values in the array will be ensured to be |
|
125
|
|
|
|
|
|
|
latest via L. |
|
126
|
|
|
|
|
|
|
- Default :: undef |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
- .pkgs.absent :: A hash of arrays. The keys are the OS seen by |
|
129
|
|
|
|
|
|
|
L and values in the array will be ensured to be |
|
130
|
|
|
|
|
|
|
absent via L. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
So if you want to install apache24 and exa on FreeBSD and jq on Debian, it would be like below. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
{ |
|
135
|
|
|
|
|
|
|
pkgs => { |
|
136
|
|
|
|
|
|
|
latest => { |
|
137
|
|
|
|
|
|
|
FreeBSD => [ 'apache24', 'exa' ], |
|
138
|
|
|
|
|
|
|
Debian => [ 'jq' ], |
|
139
|
|
|
|
|
|
|
}, |
|
140
|
|
|
|
|
|
|
}, |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head3 perl |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
- .perl.modules :: A array of modules to to install via cpanm. |
|
146
|
|
|
|
|
|
|
- Default :: [] |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
- .perl.reinstall :: A Perl boolean for if it should --reinstall should be passed. |
|
149
|
|
|
|
|
|
|
- Default :: 0 |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
- .perl.notest :: A Perl boolean for if it should --notest should be passed. |
|
152
|
|
|
|
|
|
|
- Default :: 0 |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
- .perl.force :: A Perl boolean for if it should --force should be passed. |
|
155
|
|
|
|
|
|
|
- Default :: 0 |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
- .perl.install :: Ensures that cpanm is installed, which will also ensure that Perl is installed. |
|
158
|
|
|
|
|
|
|
If undef or 0, then cpanm won't be installed and will be assumed to already be present. If |
|
159
|
|
|
|
|
|
|
set to true, it will be installed if anything is specificed in .perl.modules. |
|
160
|
|
|
|
|
|
|
- Default :: 1 |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
- .perl.cpanm_install :: Install cpanm even if .cpanm.modules does not contain any modules. |
|
163
|
|
|
|
|
|
|
- Default :: 0 |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
- .perl.pkgs :: A list of modules to install via packages if possible. |
|
166
|
|
|
|
|
|
|
- Default :: [] |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
- perl.pkgs_always_try :: A Perl boolean for if the array for .cpanm.modules should be appended to |
|
169
|
|
|
|
|
|
|
.cpanm.pkgs. |
|
170
|
|
|
|
|
|
|
- Default :: 1 |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
- perl.pkgs_require :: A list of modules to install via packages. Will fail if any of these fail. |
|
173
|
|
|
|
|
|
|
- Default :: [] |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
For the packages, if you want to make sure the package DB is up to date, you will want to set |
|
176
|
|
|
|
|
|
|
.pkgs.update_package_db_force to "1". |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head3 python |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Install python stuff. |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
- .python.pip_install :: A Perl boolean for if it should install python. By default only installs |
|
183
|
|
|
|
|
|
|
python and pip if .python.pip[0] or .python.pkgs[0] is defined. |
|
184
|
|
|
|
|
|
|
- Default :: 1 |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
- .python.modules :: A array items to install via pip. |
|
187
|
|
|
|
|
|
|
- Default :: [] |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
- .python.pkgs :: A array items to install via packages if possible. |
|
190
|
|
|
|
|
|
|
- Default :: [] |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
- .python.pkgs_require :: A array items that must be install via pkgs. |
|
193
|
|
|
|
|
|
|
- Default :: [] |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
- python.pkgs_always_try :: If pkgs should always be tried first prior to pip. |
|
196
|
|
|
|
|
|
|
- Default :: 1 |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head3 exec |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
- .exec.commands :: A array of hash to use for running commands. |
|
201
|
|
|
|
|
|
|
- Default :: [] |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
- .exec.command :: A command to run. |
|
204
|
|
|
|
|
|
|
- Default :: undef |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
. exec.dir :: Directory to use. If undef, this will use .options.tmpdir . |
|
207
|
|
|
|
|
|
|
- Default :: undef |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
- .exec.exits :: A array of acceptable exit values. May start with >, >=, <, or <= . |
|
210
|
|
|
|
|
|
|
- Default :: [0] |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
- .exec.template :: If the command in question should be treated as a TT template. |
|
213
|
|
|
|
|
|
|
- Default :: [0] |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Either .exec.commands or .exec.command must be used. If .exec.commands is used, each value in |
|
216
|
|
|
|
|
|
|
the array is a hash using the same keys, minus .commands, as .exec. So if .exec.commands[0].exits |
|
217
|
|
|
|
|
|
|
is undef, then .exec.exits is used as the default. |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
If .exec.commands[0] or .exec.command is undef, then nothing will be ran and even if .exec exists. |
|
220
|
|
|
|
|
|
|
Similarly if .command for a hash under .exec.commands, then nothing will be ran for that hash, |
|
221
|
|
|
|
|
|
|
it will be skipped. |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head2 TEMPLATES |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Template is done via L with the base variables being available. |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
- config :: The Ixchel config. |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
- env :: Enviromental variables. |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
- os :: The OS or OS family. |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
- vars :: Variables as set in .vars in the build hash. |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
- templated_vars :: Templates used for crreating some vars under vars. |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
- is_systemd :: If the system looks like it is systemd or not. The value is a boolean |
|
238
|
|
|
|
|
|
|
of 0 or 1. |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
- tmpdir :: The path of the tmpdir. |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
- options :: The contents of .options . |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
- $type_items :: .fetch.items if it exists. $type will be the name of the fetch type entry. |
|
245
|
|
|
|
|
|
|
so 'fetch' will result in 'fetch_items' and 'fetch1' will result in 'fetch1_items'. If |
|
246
|
|
|
|
|
|
|
any of the items were templated, the value here will be the results of the templating. |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
The following functions are available. |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
- shell_quote :: shell_quote from String::ShellQuote |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head1 Determining OS |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
L is used for this. |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
First the module get_operating_system is used. Then the following is ran. |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
if (is_freebsd) { |
|
259
|
|
|
|
|
|
|
$self->{os}='FreeBSD'; |
|
260
|
|
|
|
|
|
|
}elsif (is_debian) { |
|
261
|
|
|
|
|
|
|
$self->{os}='Debian'; |
|
262
|
|
|
|
|
|
|
}elsif (is_redhat) { |
|
263
|
|
|
|
|
|
|
$self->{os}='Redhat'; |
|
264
|
|
|
|
|
|
|
}elsif (is_arch) { |
|
265
|
|
|
|
|
|
|
$self->{os}='Arch'; |
|
266
|
|
|
|
|
|
|
}elsif (is_suse) { |
|
267
|
|
|
|
|
|
|
$self->{os}='Suse'; |
|
268
|
|
|
|
|
|
|
}elsif (is_alt) { |
|
269
|
|
|
|
|
|
|
$self->{os}='Alt'; |
|
270
|
|
|
|
|
|
|
}elsif (is_netbsd) { |
|
271
|
|
|
|
|
|
|
$self->{os}='NetBSD'; |
|
272
|
|
|
|
|
|
|
}elsif (is_openbsd) { |
|
273
|
|
|
|
|
|
|
$self->{os}='OpenBSD'; |
|
274
|
|
|
|
|
|
|
}elsif (is_mageia) { |
|
275
|
|
|
|
|
|
|
$self->{os}='Mageia'; |
|
276
|
|
|
|
|
|
|
}elsif (is_void) { |
|
277
|
|
|
|
|
|
|
$self->{os}='Void'; |
|
278
|
|
|
|
|
|
|
}else{ |
|
279
|
|
|
|
|
|
|
$self->{os}=get_operating_system; |
|
280
|
|
|
|
|
|
|
} |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
Which will set it to that if one of those matches. |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=head1 EXAMPLE |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
Below is a example for installing Sagan on Debian and FreeBSD. |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
--- |
|
289
|
|
|
|
|
|
|
templated_vars: |
|
290
|
|
|
|
|
|
|
github_ref: '[% IF env.sagan_github_ref %][% env.sagan_github_ref %][% ELSE %]main[% END %]' |
|
291
|
|
|
|
|
|
|
fetch: |
|
292
|
|
|
|
|
|
|
items: |
|
293
|
|
|
|
|
|
|
sagan: |
|
294
|
|
|
|
|
|
|
url: '[% IF env.sagan_url %][% env.sagan_url %][% ELSE %]https://api.github.com/repos/quadrantsec/sagan/tarball/[% vars.github_ref %][% END %]' |
|
295
|
|
|
|
|
|
|
dst: 'sagan.tgz' |
|
296
|
|
|
|
|
|
|
template: 1 |
|
297
|
|
|
|
|
|
|
exec: |
|
298
|
|
|
|
|
|
|
commands: |
|
299
|
|
|
|
|
|
|
- command: 'tar -zxvf sagan.tgz' |
|
300
|
|
|
|
|
|
|
- command: 'mv `ls -d *sagan-*` sagan' |
|
301
|
|
|
|
|
|
|
- command: autoreconf -vfi -I m4 |
|
302
|
|
|
|
|
|
|
dir: sagan |
|
303
|
|
|
|
|
|
|
- command: ./configure --enable-bluedot --enable-geoip --enable-redis --enable-esmtp --enable-gzip |
|
304
|
|
|
|
|
|
|
- command: make -j5 |
|
305
|
|
|
|
|
|
|
- command: make install |
|
306
|
|
|
|
|
|
|
- command: make -j5 |
|
307
|
|
|
|
|
|
|
dir: cd tools |
|
308
|
|
|
|
|
|
|
- command: make install |
|
309
|
|
|
|
|
|
|
- command: '[% IF env.sagan_restart %]killall SaganMain[% ELSE %]echo not restarting[% END %]' |
|
310
|
|
|
|
|
|
|
template: 1 |
|
311
|
|
|
|
|
|
|
pkgs: |
|
312
|
|
|
|
|
|
|
present: |
|
313
|
|
|
|
|
|
|
FreeBSD: |
|
314
|
|
|
|
|
|
|
- liblognorm |
|
315
|
|
|
|
|
|
|
- pcre |
|
316
|
|
|
|
|
|
|
- libesmtp |
|
317
|
|
|
|
|
|
|
- hiredis |
|
318
|
|
|
|
|
|
|
- json-c |
|
319
|
|
|
|
|
|
|
- libmaxminddb |
|
320
|
|
|
|
|
|
|
Debian: |
|
321
|
|
|
|
|
|
|
- liblognrom-dev |
|
322
|
|
|
|
|
|
|
- libpcre3-dev |
|
323
|
|
|
|
|
|
|
- build-eesential |
|
324
|
|
|
|
|
|
|
- libesmtp-dev |
|
325
|
|
|
|
|
|
|
- libhiredis-dev |
|
326
|
|
|
|
|
|
|
- libjson-c-dev |
|
327
|
|
|
|
|
|
|
- libmaxminddb-dev |
|
328
|
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
=head1 RESULT HASH REF |
|
330
|
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
.errors :: A array of errors encountered. |
|
332
|
|
|
|
|
|
|
.status :: A string description of what was done and the results. |
|
333
|
|
|
|
|
|
|
.ok :: True if everyting okay. |
|
334
|
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
=cut |
|
336
|
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
sub new_extra{ |
|
338
|
0
|
|
|
0
|
0
|
|
my ( $self ) = @_; |
|
339
|
|
|
|
|
|
|
$self->{template_vars}={ |
|
340
|
0
|
|
|
|
|
|
shell_quote => \&shell_quote, |
|
341
|
|
|
|
|
|
|
env => \%ENV, |
|
342
|
|
|
|
|
|
|
vars => {}, |
|
343
|
|
|
|
|
|
|
templated_vars => {}, |
|
344
|
|
|
|
|
|
|
}; |
|
345
|
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
# having it in two places for the purposes of simplicity |
|
347
|
0
|
|
|
|
|
|
$self->{template_vars}{os} = $self->{os}; |
|
348
|
|
|
|
|
|
|
|
|
349
|
0
|
0
|
|
|
|
|
if (is_freebsd) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
350
|
0
|
|
|
|
|
|
$self->{os} = 'FreeBSD'; |
|
351
|
|
|
|
|
|
|
} elsif (is_debian) { |
|
352
|
0
|
|
|
|
|
|
$self->{os} = 'Debian'; |
|
353
|
|
|
|
|
|
|
} elsif (is_redhat) { |
|
354
|
0
|
|
|
|
|
|
$self->{os} = 'Redhat'; |
|
355
|
|
|
|
|
|
|
} elsif (is_arch) { |
|
356
|
0
|
|
|
|
|
|
$self->{os} = 'Arch'; |
|
357
|
|
|
|
|
|
|
} elsif (is_suse) { |
|
358
|
0
|
|
|
|
|
|
$self->{os} = 'Suse'; |
|
359
|
|
|
|
|
|
|
} elsif (is_alt) { |
|
360
|
0
|
|
|
|
|
|
$self->{os} = 'Alt'; |
|
361
|
|
|
|
|
|
|
} elsif (is_netbsd) { |
|
362
|
0
|
|
|
|
|
|
$self->{os} = 'NetBSD'; |
|
363
|
|
|
|
|
|
|
} elsif (is_openbsd) { |
|
364
|
0
|
|
|
|
|
|
$self->{os} = 'OpenBSD'; |
|
365
|
|
|
|
|
|
|
} elsif (is_mageia) { |
|
366
|
0
|
|
|
|
|
|
$self->{os} = 'Mageia'; |
|
367
|
|
|
|
|
|
|
} elsif (is_void) { |
|
368
|
0
|
|
|
|
|
|
$self->{os} = 'Void'; |
|
369
|
|
|
|
|
|
|
} else { |
|
370
|
0
|
|
|
|
|
|
$self->{os} = get_operating_system; |
|
371
|
|
|
|
|
|
|
} |
|
372
|
|
|
|
|
|
|
|
|
373
|
0
|
|
|
|
|
|
$self->{template_vars}{os} = $self->{os}; |
|
374
|
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
# set is_systemd template var |
|
376
|
0
|
0
|
0
|
|
|
|
if ( $^O eq 'linux' && ( -f '/usr/bin/systemctl' || -f '/bin/systemctl' ) ) { |
|
|
|
|
0
|
|
|
|
|
|
377
|
0
|
|
|
|
|
|
$self->{template_vars}{is_systemd} = 1; |
|
378
|
|
|
|
|
|
|
} else { |
|
379
|
0
|
|
|
|
|
|
$self->{template_vars}{is_systemd} = 0; |
|
380
|
|
|
|
|
|
|
} |
|
381
|
|
|
|
|
|
|
|
|
382
|
0
|
|
|
|
|
|
$self->{template_vars}{config} = $self->{config}; |
|
383
|
|
|
|
|
|
|
} |
|
384
|
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
sub action { |
|
386
|
0
|
|
|
0
|
1
|
|
my $self = $_[0]; |
|
387
|
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
$self->{results} = { |
|
389
|
0
|
|
|
|
|
|
errors => [], |
|
390
|
|
|
|
|
|
|
status_text => '', |
|
391
|
|
|
|
|
|
|
ok => 0, |
|
392
|
|
|
|
|
|
|
}; |
|
393
|
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
# if this is not set, no reason to continue |
|
395
|
0
|
0
|
|
|
|
|
if ( !defined( $self->{opts}{xeno_build} ) ) { |
|
396
|
0
|
|
|
|
|
|
push( @{ $self->{results}{errors} }, '.opts.xeno_build was not set' ); |
|
|
0
|
|
|
|
|
|
|
|
397
|
0
|
|
|
|
|
|
return $self->{results}; |
|
398
|
|
|
|
|
|
|
} |
|
399
|
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
# copy vars under xeno_build if it exists |
|
401
|
0
|
0
|
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{vars} ) ) { |
|
402
|
0
|
|
|
|
|
|
$self->{template_vars}{vars} = $self->{opts}{xeno_build}{vars}; |
|
403
|
|
|
|
|
|
|
} |
|
404
|
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
# process templated_vars |
|
406
|
0
|
0
|
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{templated_vars} ) ) { |
|
407
|
0
|
|
|
|
|
|
my @templated_vars = sort( keys( %{ $self->{opts}{xeno_build}{templated_vars} } ) ); |
|
|
0
|
|
|
|
|
|
|
|
408
|
0
|
|
|
|
|
|
$self->status_add( type => 'templated_vars', status => 'Vars to tempplate: ' . join( ',', @templated_vars ) ); |
|
409
|
0
|
|
|
|
|
|
eval { |
|
410
|
0
|
|
|
|
|
|
foreach my $var (@templated_vars) { |
|
411
|
0
|
|
|
|
|
|
my $output = ''; |
|
412
|
0
|
|
|
|
|
|
my $var_template = $self->{opts}{xeno_build}{templated_vars}{$var}; |
|
413
|
0
|
|
|
|
|
|
$self->status_add( |
|
414
|
|
|
|
|
|
|
type => 'templated_vars', |
|
415
|
|
|
|
|
|
|
status => 'Templated Var "' . $var . '": ' . $var_template |
|
416
|
|
|
|
|
|
|
); |
|
417
|
|
|
|
|
|
|
$self->{t}->process( \$var_template, $self->{template_vars}, \$output ) |
|
418
|
0
|
0
|
|
|
|
|
|| die $self->{t}->error; |
|
419
|
0
|
|
|
|
|
|
$self->{opts}{xeno_build}{vars}{$var} = $output; |
|
420
|
0
|
|
|
|
|
|
$self->status_add( type => 'templated_vars', status => 'Updated Var "' . $var . '": ' . $output ); |
|
421
|
|
|
|
|
|
|
} ## end foreach my $var (@templated_vars) |
|
422
|
|
|
|
|
|
|
}; |
|
423
|
0
|
0
|
|
|
|
|
if ($@) { |
|
424
|
0
|
|
|
|
|
|
$self->status_add( type => 'templated_vars', error => 1, status => 'Vars templating failed... ' . $@ ); |
|
425
|
0
|
|
|
|
|
|
return $self->{results}; |
|
426
|
|
|
|
|
|
|
} |
|
427
|
0
|
|
|
|
|
|
$self->{template_vars}{vars} = $self->{opts}{xeno_build}{vars}; |
|
428
|
|
|
|
|
|
|
} ## end if ( defined( $self->{opts}{xeno_build}{templated_vars...})) |
|
429
|
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
# define the order if not specified |
|
431
|
0
|
0
|
|
|
|
|
if ( !defined( $self->{opts}{xeno_build}{order} ) ) { |
|
432
|
0
|
|
|
|
|
|
$self->{opts}{xeno_build}{order} = [ 'fetch', 'pkgs', 'perl', 'python', 'exec', ]; |
|
433
|
|
|
|
|
|
|
} |
|
434
|
0
|
|
|
|
|
|
$self->status_add( status => 'Order: ' . join( ', ', @{ $self->{opts}{xeno_build}{order} } ) ); |
|
|
0
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
# set default options if needed |
|
437
|
0
|
0
|
|
|
|
|
if ( !defined( $self->{opts}{xeno_build}{options} ) ) { |
|
438
|
0
|
|
|
|
|
|
$self->{opts}{xeno_build}{options} = {}; |
|
439
|
|
|
|
|
|
|
} |
|
440
|
|
|
|
|
|
|
# if the build_dir is not set, set it |
|
441
|
0
|
0
|
|
|
|
|
if ( !defined( $self->{opts}{xeno_build}{options}{build_dir} ) ) { |
|
442
|
|
|
|
|
|
|
# if .xeno_build.build_dir is set in the config, use it |
|
443
|
0
|
0
|
|
|
|
|
if ( defined( $self->{config}{xeno_build}{build_dir} ) ) { |
|
444
|
0
|
|
|
|
|
|
$self->{opts}{xeno_build}{options}{build_dir} = $self->{config}{xeno_build}{build_dir}; |
|
445
|
|
|
|
|
|
|
} else { |
|
446
|
|
|
|
|
|
|
# if that is undef, use /tmp/ |
|
447
|
0
|
|
|
|
|
|
$self->{opts}{xeno_build}{options}{build_dir} = '/tmp/'; |
|
448
|
|
|
|
|
|
|
} |
|
449
|
|
|
|
|
|
|
} |
|
450
|
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
# create the tmpdir under the build dir |
|
452
|
|
|
|
|
|
|
$self->{opts}{xeno_build}{options}{tmpdir} |
|
453
|
0
|
|
|
|
|
|
= File::Temp->newdir( DIR => $self->{opts}{xeno_build}{options}{build_dir} ); |
|
454
|
|
|
|
|
|
|
# now that options are setup, save it as a usable template variable |
|
455
|
0
|
|
|
|
|
|
$self->{template_vars}{options} = $self->{opts}{xeno_build}{options}; |
|
456
|
0
|
|
|
|
|
|
$self->{template_vars}{tmpdir} = $self->{opts}{xeno_build}{options}{tmpdir}; |
|
457
|
0
|
|
|
|
|
|
$self->status_add( status => 'Build Dir, .options.build_dir: ' . $self->{opts}{xeno_build}{options}{build_dir} ); |
|
458
|
0
|
|
|
|
|
|
$self->status_add( status => 'Temp Dir, .options.tmpdir: ' . $self->{opts}{xeno_build}{options}{tmpdir} ); |
|
459
|
|
|
|
|
|
|
|
|
460
|
0
|
|
|
|
|
|
eval { chdir( $self->{opts}{xeno_build}{options}{tmpdir} ); }; |
|
|
0
|
|
|
|
|
|
|
|
461
|
0
|
0
|
|
|
|
|
if ($@) { |
|
462
|
|
|
|
|
|
|
$self->status_add( |
|
463
|
0
|
|
|
|
|
|
status => 'Failed to chdir to "' . $self->{opts}{xeno_build}{options}{tmpdir} . '"', |
|
464
|
|
|
|
|
|
|
error => 1, |
|
465
|
|
|
|
|
|
|
); |
|
466
|
0
|
|
|
|
|
|
return $self->{results}; |
|
467
|
|
|
|
|
|
|
} |
|
468
|
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
# figure out the types we are going to use |
|
470
|
0
|
|
|
|
|
|
my @types; |
|
471
|
0
|
|
|
|
|
|
foreach my $type ( @{ $self->{opts}{xeno_build}{order} } ) { |
|
|
0
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
# make sure it is known |
|
473
|
0
|
0
|
0
|
|
|
|
if ( $type !~ /^fetch[0-9]*$/ |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
474
|
|
|
|
|
|
|
&& $type !~ /^pkgs[0-9]*$/ |
|
475
|
|
|
|
|
|
|
&& $type !~ /^perl[0-9]*$/ |
|
476
|
|
|
|
|
|
|
&& $type !~ /^python[0-9]*$/ |
|
477
|
|
|
|
|
|
|
&& $type !~ /^exec[0-9]*$/ ) |
|
478
|
|
|
|
|
|
|
{ |
|
479
|
0
|
|
|
|
|
|
$self->status_add( status => '"' . $type . '" is not of a known type', error => 1 ); |
|
480
|
0
|
|
|
|
|
|
return $self->{results}; |
|
481
|
|
|
|
|
|
|
} |
|
482
|
|
|
|
|
|
|
# if it exists, add it to the @types array |
|
483
|
0
|
0
|
|
|
|
|
if ( defined $self->{opts}{xeno_build}{$type} ) { |
|
484
|
0
|
|
|
|
|
|
push( @types, $type ); |
|
485
|
|
|
|
|
|
|
} |
|
486
|
|
|
|
|
|
|
} ## end foreach my $type ( @{ $self->{opts}{xeno_build}...}) |
|
487
|
|
|
|
|
|
|
|
|
488
|
0
|
|
|
|
|
|
foreach my $type (@types) { |
|
489
|
0
|
|
|
|
|
|
$self->status_add( status => 'Starting type "' . $type . '"...' ); |
|
490
|
|
|
|
|
|
|
|
|
491
|
0
|
|
|
|
|
|
my $for_this_system = 1; |
|
492
|
|
|
|
|
|
|
|
|
493
|
0
|
0
|
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{$type}{for} ) ) { |
|
494
|
0
|
|
|
|
|
|
$for_this_system = 0; |
|
495
|
0
|
|
|
|
|
|
my @for_oses = @{ $self->{opts}{xeno_build}{$type}{for} }; |
|
|
0
|
|
|
|
|
|
|
|
496
|
0
|
|
|
|
|
|
$self->status_add( type => $type, status => 'For OSes: ' . join( ',', @for_oses ) ); |
|
497
|
0
|
|
|
|
|
|
foreach my $for_os_check (@for_oses) { |
|
498
|
0
|
0
|
|
|
|
|
if ( $for_os_check eq $self->{os} ) { |
|
499
|
0
|
|
|
|
|
|
$self->status_add( type => $type, status => 'For matched' ); |
|
500
|
0
|
|
|
|
|
|
$for_this_system = 1; |
|
501
|
|
|
|
|
|
|
} |
|
502
|
|
|
|
|
|
|
} |
|
503
|
|
|
|
|
|
|
} ## end if ( defined( $self->{opts}{xeno_build}{$type...})) |
|
504
|
|
|
|
|
|
|
|
|
505
|
0
|
0
|
0
|
|
|
|
if ( $type =~ /^fetch[0-9]*$/ && $for_this_system ) { |
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
## |
|
507
|
|
|
|
|
|
|
## |
|
508
|
|
|
|
|
|
|
## |
|
509
|
|
|
|
|
|
|
## start of fetch |
|
510
|
|
|
|
|
|
|
## |
|
511
|
|
|
|
|
|
|
## |
|
512
|
|
|
|
|
|
|
## |
|
513
|
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
# get the names of the items to fetch |
|
515
|
0
|
|
|
|
|
|
my @fetch_names; |
|
516
|
0
|
0
|
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{$type}{items} ) ) { |
|
517
|
0
|
|
|
|
|
|
@fetch_names = keys( %{ $self->{opts}{xeno_build}{$type}{items} } ); |
|
|
0
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
} |
|
519
|
0
|
0
|
|
|
|
|
if ( defined( $fetch_names[0] ) ) { |
|
520
|
0
|
|
|
|
|
|
$self->status_add( type => $type, status => 'Items to fetch: ' . join( ', ', @fetch_names ) ); |
|
521
|
|
|
|
|
|
|
} else { |
|
522
|
0
|
|
|
|
|
|
$self->status_add( type => $type, status => 'Nothing to fetch.' ); |
|
523
|
|
|
|
|
|
|
} |
|
524
|
|
|
|
|
|
|
# figure out if we should template it or not |
|
525
|
0
|
|
|
|
|
|
my $template_it = 0; |
|
526
|
0
|
0
|
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{$type}{template} ) ) { |
|
527
|
0
|
|
|
|
|
|
$template_it = $self->{opts}{xeno_build}{$type}{template}; |
|
528
|
|
|
|
|
|
|
} |
|
529
|
0
|
|
|
|
|
|
foreach my $fetch_name (@fetch_names) { |
|
530
|
0
|
|
|
|
|
|
$self->status_add( type => $type, status => 'Fetching ' . $fetch_name ); |
|
531
|
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
# make sure we have both url and dst for the fetch item |
|
533
|
0
|
|
|
|
|
|
foreach my $fetch_value ( 'url', 'dst' ) { |
|
534
|
0
|
0
|
|
|
|
|
if ( !defined( $self->{opts}{xeno_build}{$type}{items}{$fetch_name}{$fetch_value} ) ) { |
|
535
|
0
|
|
|
|
|
|
$self->status_add( |
|
536
|
|
|
|
|
|
|
type => $type, |
|
537
|
|
|
|
|
|
|
status => 'Fetch "' . $fetch_name . '" missing ' . $fetch_value, |
|
538
|
|
|
|
|
|
|
error => 1 |
|
539
|
|
|
|
|
|
|
); |
|
540
|
0
|
|
|
|
|
|
return $self; |
|
541
|
|
|
|
|
|
|
} |
|
542
|
|
|
|
|
|
|
} ## end foreach my $fetch_value ( 'url', 'dst' ) |
|
543
|
|
|
|
|
|
|
|
|
544
|
0
|
|
|
|
|
|
$self->status_add( type => $type, status => 'Fetching ' . $fetch_name ); |
|
545
|
0
|
|
|
|
|
|
my $url = $self->{opts}{xeno_build}{$type}{items}{$fetch_name}{url}; |
|
546
|
0
|
|
|
|
|
|
my $dst = $self->{opts}{xeno_build}{$type}{items}{$fetch_name}{dst}; |
|
547
|
0
|
|
|
|
|
|
$self->status_add( type => $type, status => 'Fetch "' . $fetch_name . '" URL: ' . $url ); |
|
548
|
0
|
|
|
|
|
|
$self->status_add( type => $type, status => 'Fetch "' . $fetch_name . '" DST: ' . $dst ); |
|
549
|
0
|
|
|
|
|
|
$self->status_add( |
|
550
|
|
|
|
|
|
|
type => $type, |
|
551
|
|
|
|
|
|
|
status => 'Fetch "' . $fetch_name . '" Template: ' . $template_it |
|
552
|
|
|
|
|
|
|
); |
|
553
|
0
|
0
|
|
|
|
|
if ($template_it) { |
|
554
|
|
|
|
|
|
|
# template the url |
|
555
|
0
|
|
|
|
|
|
my $output = ''; |
|
556
|
0
|
|
|
|
|
|
eval { |
|
557
|
0
|
0
|
|
|
|
|
$self->{t}->process( \$url, $self->{template_vars}, \$output ) || die $self->{t}->error; |
|
558
|
0
|
|
|
|
|
|
$url = $output; |
|
559
|
|
|
|
|
|
|
}; |
|
560
|
0
|
0
|
|
|
|
|
if ($@) { |
|
561
|
0
|
|
|
|
|
|
$self->status_add( |
|
562
|
|
|
|
|
|
|
type => $type, |
|
563
|
|
|
|
|
|
|
status => 'Templating failed for "' . $fetch_name . ' for the URL"... ' . $@, |
|
564
|
|
|
|
|
|
|
error => 1, |
|
565
|
|
|
|
|
|
|
); |
|
566
|
0
|
|
|
|
|
|
return $self->{results}; |
|
567
|
|
|
|
|
|
|
} |
|
568
|
0
|
|
|
|
|
|
$self->{opts}{xeno_build}{$type}{items}{url} = $url; |
|
569
|
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
# template the dst |
|
571
|
0
|
|
|
|
|
|
$output = ''; |
|
572
|
0
|
|
|
|
|
|
eval { |
|
573
|
0
|
0
|
|
|
|
|
$self->{t}->process( \$dst, $self->{template_vars}, \$output ) || die $self->{t}->error; |
|
574
|
0
|
|
|
|
|
|
$dst = $output; |
|
575
|
|
|
|
|
|
|
}; |
|
576
|
0
|
0
|
|
|
|
|
if ($@) { |
|
577
|
0
|
|
|
|
|
|
$self->status_add( |
|
578
|
|
|
|
|
|
|
type => $type, |
|
579
|
|
|
|
|
|
|
status => 'Templating failed for "' . $fetch_name . ' for the URL"... ' . $@, |
|
580
|
|
|
|
|
|
|
error => 1, |
|
581
|
|
|
|
|
|
|
); |
|
582
|
0
|
|
|
|
|
|
return $self->{results}; |
|
583
|
|
|
|
|
|
|
} |
|
584
|
0
|
|
|
|
|
|
$self->{opts}{xeno_build}{$type}{items}{dst} = $dst; |
|
585
|
0
|
|
|
|
|
|
$self->status_add( |
|
586
|
|
|
|
|
|
|
type => $type, |
|
587
|
|
|
|
|
|
|
status => 'Fetch "' . $fetch_name . '" URL Template Results: ' . $url |
|
588
|
|
|
|
|
|
|
); |
|
589
|
0
|
|
|
|
|
|
$self->status_add( |
|
590
|
|
|
|
|
|
|
type => $type, |
|
591
|
|
|
|
|
|
|
status => 'Fetch "' . $fetch_name . '" DST Template Results: ' . $dst |
|
592
|
|
|
|
|
|
|
); |
|
593
|
|
|
|
|
|
|
} ## end if ($template_it) |
|
594
|
|
|
|
|
|
|
|
|
595
|
0
|
|
|
|
|
|
my $return_code = 'undef'; |
|
596
|
0
|
|
|
|
|
|
my $return_extra = ''; |
|
597
|
0
|
|
|
|
|
|
eval { |
|
598
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new( timeout => 10 ); |
|
599
|
0
|
0
|
|
|
|
|
if ( defined( $ENV{HTTP_PROXY} ) ) { |
|
600
|
0
|
|
|
|
|
|
$ua->proxy( ['http'], $ENV{HTTP_PROXY} ); |
|
601
|
|
|
|
|
|
|
} |
|
602
|
0
|
0
|
|
|
|
|
if ( defined( $ENV{HTTPS_PROXY} ) ) { |
|
603
|
0
|
|
|
|
|
|
$ua->proxy( ['https'], $ENV{HTTPS_PROXY} ); |
|
604
|
|
|
|
|
|
|
} |
|
605
|
0
|
0
|
|
|
|
|
if ( defined( $ENV{FTP_PROXY} ) ) { |
|
606
|
0
|
|
|
|
|
|
$ua->proxy( ['ftp'], $ENV{FTP_PROXY} ); |
|
607
|
|
|
|
|
|
|
} |
|
608
|
|
|
|
|
|
|
|
|
609
|
0
|
|
|
|
|
|
my $response = $ua->get($url); |
|
610
|
|
|
|
|
|
|
|
|
611
|
0
|
|
|
|
|
|
$return_code = $response->status_line; |
|
612
|
|
|
|
|
|
|
|
|
613
|
0
|
|
|
|
|
|
my $content; |
|
614
|
0
|
0
|
|
|
|
|
if ( $response->is_success ) { |
|
615
|
0
|
|
|
|
|
|
$content = $response->decoded_content; |
|
616
|
|
|
|
|
|
|
} else { |
|
617
|
0
|
|
|
|
|
|
die( $response->status_line ); |
|
618
|
|
|
|
|
|
|
} |
|
619
|
|
|
|
|
|
|
|
|
620
|
0
|
|
|
|
|
|
write_file( $dst, $content ); |
|
621
|
|
|
|
|
|
|
}; |
|
622
|
0
|
|
|
|
|
|
my $fetch_errored = 0; |
|
623
|
0
|
0
|
|
|
|
|
if ($@) { |
|
624
|
0
|
|
|
|
|
|
$return_extra = ' ... ' . $@; |
|
625
|
0
|
|
|
|
|
|
$fetch_errored = 1; |
|
626
|
|
|
|
|
|
|
} |
|
627
|
|
|
|
|
|
|
$self->status_add( |
|
628
|
0
|
|
|
|
|
|
type => $type, |
|
629
|
|
|
|
|
|
|
error => $fetch_errored, |
|
630
|
|
|
|
|
|
|
status => 'Fetch "' . $fetch_name . '" Return Code: ' . $return_code . $return_extra |
|
631
|
|
|
|
|
|
|
); |
|
632
|
|
|
|
|
|
|
} ## end foreach my $fetch_name (@fetch_names) |
|
633
|
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
# save the fetched items as a template var for possible later usage |
|
635
|
0
|
|
|
|
|
|
$self->{template_vars}{ $type . '_items' } = $self->{opts}{xeno_build}{$type}{items}; |
|
636
|
|
|
|
|
|
|
} elsif ( $type =~ /^pkgs[0-9]*$/ && $for_this_system ) { |
|
637
|
|
|
|
|
|
|
## |
|
638
|
|
|
|
|
|
|
## |
|
639
|
|
|
|
|
|
|
## |
|
640
|
|
|
|
|
|
|
## start of pkgs |
|
641
|
|
|
|
|
|
|
## |
|
642
|
|
|
|
|
|
|
## |
|
643
|
|
|
|
|
|
|
## |
|
644
|
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
# handle pkgs.absent |
|
646
|
0
|
0
|
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{$type}{absent}{ $self->{os} }[0] ) ) { |
|
647
|
0
|
|
|
|
|
|
foreach my $pkg ( @{ $self->{opts}{xeno_build}{$type}{absent}{ $self->{os} } } ) { |
|
|
0
|
|
|
|
|
|
|
|
648
|
0
|
|
|
|
|
|
eval { pkg( $pkg, ensure => 'absent' ); }; |
|
|
0
|
|
|
|
|
|
|
|
649
|
0
|
0
|
|
|
|
|
if ($@) { |
|
650
|
|
|
|
|
|
|
$self->status_add( |
|
651
|
|
|
|
|
|
|
type => $type, |
|
652
|
|
|
|
|
|
|
status => 'Failed uninstalling ' . $pkg . ' for ' . $self->{os}, |
|
653
|
0
|
|
|
|
|
|
error => 1, |
|
654
|
|
|
|
|
|
|
); |
|
655
|
0
|
|
|
|
|
|
return $self->{results}; |
|
656
|
|
|
|
|
|
|
} |
|
657
|
|
|
|
|
|
|
} ## end foreach my $pkg ( @{ $self->{opts}{xeno_build}{...}}) |
|
658
|
|
|
|
|
|
|
} ## end if ( defined( $self->{opts}{xeno_build}{$type...})) |
|
659
|
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
# handle .pkgs.present |
|
661
|
0
|
0
|
0
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{$type}{present}{ $self->{os} } ) |
|
662
|
|
|
|
|
|
|
&& defined( $self->{opts}{xeno_build}{$type}{present}{ $self->{os} }[0] ) ) |
|
663
|
|
|
|
|
|
|
{ |
|
664
|
0
|
|
|
|
|
|
foreach my $pkg ( @{ $self->{opts}{xeno_build}{$type}{present}{ $self->{os} } } ) { |
|
|
0
|
|
|
|
|
|
|
|
665
|
|
|
|
|
|
|
$self->status_add( |
|
666
|
|
|
|
|
|
|
type => $type, |
|
667
|
0
|
|
|
|
|
|
status => 'Ensuring ' . $pkg . ' for ' . $self->{os} . ' is present', |
|
668
|
|
|
|
|
|
|
); |
|
669
|
0
|
|
|
|
|
|
eval { pkg( $pkg, ensure => 'present' ); }; |
|
|
0
|
|
|
|
|
|
|
|
670
|
0
|
0
|
|
|
|
|
if ($@) { |
|
671
|
|
|
|
|
|
|
$self->status_add( |
|
672
|
|
|
|
|
|
|
type => $type, |
|
673
|
|
|
|
|
|
|
status => 'Failed installing ' . $pkg . ' for ' . $self->{os}, |
|
674
|
0
|
|
|
|
|
|
error => 1, |
|
675
|
|
|
|
|
|
|
); |
|
676
|
0
|
|
|
|
|
|
return $self->{results}; |
|
677
|
|
|
|
|
|
|
} |
|
678
|
|
|
|
|
|
|
} ## end foreach my $pkg ( @{ $self->{opts}{xeno_build}{...}}) |
|
679
|
|
|
|
|
|
|
} ## end if ( defined( $self->{opts}{xeno_build}{$type...})) |
|
680
|
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
# handle .pkgs.latest |
|
682
|
0
|
0
|
0
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{$type}{latest}{ $self->{os} } ) |
|
683
|
|
|
|
|
|
|
&& defined( $self->{opts}{xeno_build}{$type}{latest}{ $self->{os} }[0] ) ) |
|
684
|
|
|
|
|
|
|
{ |
|
685
|
0
|
|
|
|
|
|
eval { |
|
686
|
0
|
|
|
|
|
|
$self->status_add( type => $type, status => 'updating DB' ); |
|
687
|
0
|
|
|
|
|
|
update_package_db; |
|
688
|
|
|
|
|
|
|
}; |
|
689
|
0
|
0
|
|
|
|
|
if ($@) { |
|
690
|
0
|
|
|
|
|
|
$self->status_add( type => $type, status => 'Pkgs DB update failed...' . $@, error => 1, ); |
|
691
|
|
|
|
|
|
|
} |
|
692
|
0
|
|
|
|
|
|
foreach my $pkg ( @{ $self->{opts}{xeno_build}{$type}{latest}{ $self->{os} } } ) { |
|
|
0
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
$self->status_add( |
|
694
|
|
|
|
|
|
|
type => $type, |
|
695
|
0
|
|
|
|
|
|
status => 'Ensuring latest ' . $pkg . ' for ' . $self->{os} . ' is installed', |
|
696
|
|
|
|
|
|
|
); |
|
697
|
0
|
|
|
|
|
|
eval { pkg( $pkg, ensure => 'latest' ); }; |
|
|
0
|
|
|
|
|
|
|
|
698
|
0
|
0
|
|
|
|
|
if ($@) { |
|
699
|
|
|
|
|
|
|
$self->status_add( |
|
700
|
|
|
|
|
|
|
type => $type, |
|
701
|
|
|
|
|
|
|
status => 'Failed installing latest ' . $pkg . ' for ' . $self->{os}, |
|
702
|
0
|
|
|
|
|
|
error => 1, |
|
703
|
|
|
|
|
|
|
); |
|
704
|
0
|
|
|
|
|
|
return $self->{results}; |
|
705
|
|
|
|
|
|
|
} |
|
706
|
|
|
|
|
|
|
} ## end foreach my $pkg ( @{ $self->{opts}{xeno_build}{...}}) |
|
707
|
|
|
|
|
|
|
} ## end if ( defined( $self->{opts}{xeno_build}{$type...})) |
|
708
|
|
|
|
|
|
|
} elsif ( $type =~ /^perl[0-9]*$/ && $for_this_system ) { |
|
709
|
|
|
|
|
|
|
## |
|
710
|
|
|
|
|
|
|
## |
|
711
|
|
|
|
|
|
|
## |
|
712
|
|
|
|
|
|
|
## start of perl |
|
713
|
|
|
|
|
|
|
## |
|
714
|
|
|
|
|
|
|
## |
|
715
|
|
|
|
|
|
|
## |
|
716
|
|
|
|
|
|
|
|
|
717
|
0
|
|
|
|
|
|
my @modules; |
|
718
|
0
|
0
|
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{$type}{modules} ) ) { |
|
719
|
0
|
|
|
|
|
|
push( @modules, @{ $self->{opts}{xeno_build}{$type}{modules} } ); |
|
|
0
|
|
|
|
|
|
|
|
720
|
|
|
|
|
|
|
} |
|
721
|
|
|
|
|
|
|
$self->status_add( |
|
722
|
0
|
|
|
|
|
|
type => $type, |
|
723
|
|
|
|
|
|
|
status => 'Perl modules to install: ' . join( ', ', @modules ), |
|
724
|
|
|
|
|
|
|
); |
|
725
|
|
|
|
|
|
|
|
|
726
|
|
|
|
|
|
|
# get a list of modules to install via pkgs |
|
727
|
0
|
|
|
|
|
|
my @pkgs; |
|
728
|
0
|
0
|
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{$type}{pkgs} ) ) { |
|
729
|
0
|
|
|
|
|
|
push( @pkgs, @{ $self->{opts}{xeno_build}{$type}{pkgs} } ); |
|
|
0
|
|
|
|
|
|
|
|
730
|
0
|
|
|
|
|
|
$self->status_add( |
|
731
|
|
|
|
|
|
|
type => $type, |
|
732
|
|
|
|
|
|
|
status => 'Perl modules to try to install via pkgs: ' . join( ', ', @pkgs ), |
|
733
|
|
|
|
|
|
|
); |
|
734
|
|
|
|
|
|
|
} |
|
735
|
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
# pkgs_always_try is true, push the modules to onto the heap |
|
737
|
0
|
0
|
0
|
|
|
|
if ( |
|
|
|
|
0
|
|
|
|
|
|
738
|
|
|
|
|
|
|
( |
|
739
|
|
|
|
|
|
|
defined( $self->{opts}{xeno_build}{$type}{pkgs_always_try} ) |
|
740
|
|
|
|
|
|
|
&& $self->{opts}{xeno_build}{$type}{pkgs_always_try} |
|
741
|
|
|
|
|
|
|
) |
|
742
|
|
|
|
|
|
|
|| ( !defined( $self->{opts}{xeno_build}{$type}{pkgs_always_try} ) ) |
|
743
|
|
|
|
|
|
|
) |
|
744
|
|
|
|
|
|
|
{ |
|
745
|
0
|
|
|
|
|
|
push( @pkgs, @modules ); |
|
746
|
0
|
|
|
|
|
|
$self->status_add( |
|
747
|
|
|
|
|
|
|
type => $type, |
|
748
|
|
|
|
|
|
|
status => 'pkgs_always_try=1 set', |
|
749
|
|
|
|
|
|
|
); |
|
750
|
|
|
|
|
|
|
} ## end if ( ( defined( $self->{opts}{xeno_build}{...}))) |
|
751
|
|
|
|
|
|
|
|
|
752
|
|
|
|
|
|
|
# used for checking if the module was installed or not via pkg |
|
753
|
0
|
|
|
|
|
|
my %modules_installed; |
|
754
|
|
|
|
|
|
|
|
|
755
|
|
|
|
|
|
|
# handle Perl modules that must be installed via pkg |
|
756
|
|
|
|
|
|
|
my @pkgs_require; |
|
757
|
0
|
0
|
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{$type}{pkgs_require} ) ) { |
|
758
|
0
|
|
|
|
|
|
push( @pkgs_require, @{ $self->{opts}{xeno_build}{$type}{pkgs_require} } ); |
|
|
0
|
|
|
|
|
|
|
|
759
|
0
|
|
|
|
|
|
$self->status_add( |
|
760
|
|
|
|
|
|
|
type => $type, |
|
761
|
|
|
|
|
|
|
status => 'Perl modules required to be installed via pkgs: ' . join( ', ', @pkgs_require ), |
|
762
|
|
|
|
|
|
|
); |
|
763
|
|
|
|
|
|
|
} |
|
764
|
0
|
|
|
|
|
|
foreach my $module ( @pkgs_require, ) { |
|
765
|
0
|
|
|
|
|
|
$self->status_add( |
|
766
|
|
|
|
|
|
|
type => $type, |
|
767
|
|
|
|
|
|
|
status => 'Trying to install Perl ' . $module . ' via pkg', |
|
768
|
|
|
|
|
|
|
); |
|
769
|
0
|
|
|
|
|
|
my $returned; |
|
770
|
0
|
|
|
|
|
|
eval { perl_module_via_pkg( module => $module ); }; |
|
|
0
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
# if this fails, set error and return as the module is required to be installed via pkg and we can't |
|
772
|
0
|
0
|
|
|
|
|
if ($returned) { |
|
773
|
0
|
|
|
|
|
|
$self->status_add( |
|
774
|
|
|
|
|
|
|
type => $type, |
|
775
|
|
|
|
|
|
|
status => 'Perl module required to be installed via pkgs installed: ' . $module, |
|
776
|
|
|
|
|
|
|
); |
|
777
|
0
|
|
|
|
|
|
$modules_installed{$module} = 1; |
|
778
|
|
|
|
|
|
|
} else { |
|
779
|
0
|
|
|
|
|
|
$self->status_add( |
|
780
|
|
|
|
|
|
|
type => $type, |
|
781
|
|
|
|
|
|
|
status => 'Perl module required to be installed via pkgs failed: ' . $module, |
|
782
|
|
|
|
|
|
|
error => 1, |
|
783
|
|
|
|
|
|
|
); |
|
784
|
0
|
|
|
|
|
|
return $self->{results}; |
|
785
|
|
|
|
|
|
|
} |
|
786
|
|
|
|
|
|
|
} ## end foreach my $module ( @pkgs_require, ) |
|
787
|
|
|
|
|
|
|
|
|
788
|
|
|
|
|
|
|
# try via pkg modules that can be attempted to be installed that way |
|
789
|
0
|
|
|
|
|
|
foreach my $module (@pkgs) { |
|
790
|
0
|
|
|
|
|
|
$self->status_add( |
|
791
|
|
|
|
|
|
|
type => $type, |
|
792
|
|
|
|
|
|
|
status => 'Trying to install Perl ' . $module . ' via pkg', |
|
793
|
|
|
|
|
|
|
); |
|
794
|
0
|
|
|
|
|
|
my $returned; |
|
795
|
0
|
|
|
|
|
|
eval { $returned = perl_module_via_pkg( module => $module ); }; |
|
|
0
|
|
|
|
|
|
|
|
796
|
0
|
0
|
|
|
|
|
if ($returned) { |
|
797
|
0
|
|
|
|
|
|
$self->status_add( |
|
798
|
|
|
|
|
|
|
type => $type, |
|
799
|
|
|
|
|
|
|
status => 'Perl module to be installed via pkgs installed: ' . $module, |
|
800
|
|
|
|
|
|
|
); |
|
801
|
0
|
|
|
|
|
|
$modules_installed{$module} = 1; |
|
802
|
|
|
|
|
|
|
} |
|
803
|
|
|
|
|
|
|
} ## end foreach my $module (@pkgs) |
|
804
|
|
|
|
|
|
|
|
|
805
|
0
|
|
|
|
|
|
my $installed_cpanm; |
|
806
|
|
|
|
|
|
|
# if we don't want to install cpanm, set it as already as being installed |
|
807
|
0
|
0
|
0
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{$type}{cpanm_install} ) |
|
808
|
|
|
|
|
|
|
&& $self->{opts}{xeno_build}{$type}{cpanm_install} ) |
|
809
|
|
|
|
|
|
|
{ |
|
810
|
0
|
|
|
|
|
|
eval { install_cpanm; }; |
|
|
0
|
|
|
|
|
|
|
|
811
|
0
|
0
|
|
|
|
|
if ($@) { |
|
812
|
|
|
|
|
|
|
$self->status_add( |
|
813
|
|
|
|
|
|
|
type => $type, |
|
814
|
0
|
|
|
|
|
|
status => 'Failed installing cpanm for ' . $self->{os} . ' ... ' . $@, |
|
815
|
|
|
|
|
|
|
error => 1, |
|
816
|
|
|
|
|
|
|
); |
|
817
|
0
|
|
|
|
|
|
return $self->{results}; |
|
818
|
|
|
|
|
|
|
} |
|
819
|
0
|
|
|
|
|
|
$installed_cpanm = 1; |
|
820
|
|
|
|
|
|
|
} ## end if ( defined( $self->{opts}{xeno_build}{$type...})) |
|
821
|
|
|
|
|
|
|
|
|
822
|
|
|
|
|
|
|
# try to install each module |
|
823
|
0
|
|
|
|
|
|
foreach my $module (@modules) { |
|
824
|
|
|
|
|
|
|
# if this is defined, it was installed via pkg, so we don't need to try it again |
|
825
|
0
|
0
|
|
|
|
|
if ( !defined( $modules_installed{$module} ) ) { |
|
826
|
0
|
0
|
|
|
|
|
if ( !$installed_cpanm ) { |
|
827
|
0
|
|
|
|
|
|
eval { install_cpanm; }; |
|
|
0
|
|
|
|
|
|
|
|
828
|
0
|
0
|
|
|
|
|
if ($@) { |
|
829
|
|
|
|
|
|
|
$self->status_add( |
|
830
|
|
|
|
|
|
|
type => $type, |
|
831
|
0
|
|
|
|
|
|
status => 'Failed installing cpanm for ' . $self->{os} . ' ... ' . $@, |
|
832
|
|
|
|
|
|
|
error => 1, |
|
833
|
|
|
|
|
|
|
); |
|
834
|
0
|
|
|
|
|
|
return $self->{results}; |
|
835
|
|
|
|
|
|
|
} |
|
836
|
|
|
|
|
|
|
} ## end if ( !$installed_cpanm ) |
|
837
|
|
|
|
|
|
|
|
|
838
|
0
|
|
|
|
|
|
my @cpanm_args = ('cpanm'); |
|
839
|
0
|
0
|
0
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{$type}{reinstall} ) |
|
840
|
|
|
|
|
|
|
&& $self->{opts}{xeno_build}{$type}{reinstall} ) |
|
841
|
|
|
|
|
|
|
{ |
|
842
|
0
|
|
|
|
|
|
push( @cpanm_args, '--reinstall' ); |
|
843
|
|
|
|
|
|
|
} |
|
844
|
0
|
0
|
0
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{$type}{notest} ) |
|
845
|
|
|
|
|
|
|
&& $self->{opts}{xeno_build}{$type}{notest} ) |
|
846
|
|
|
|
|
|
|
{ |
|
847
|
0
|
|
|
|
|
|
push( @cpanm_args, '--notest' ); |
|
848
|
|
|
|
|
|
|
} |
|
849
|
0
|
0
|
0
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{$type}{install_force} ) |
|
850
|
|
|
|
|
|
|
&& $self->{opts}{xeno_build}{$type}{install_force} ) |
|
851
|
|
|
|
|
|
|
{ |
|
852
|
0
|
|
|
|
|
|
push( @cpanm_args, '--force' ); |
|
853
|
|
|
|
|
|
|
} |
|
854
|
0
|
|
|
|
|
|
push( @cpanm_args, $module ); |
|
855
|
0
|
|
|
|
|
|
$self->status_add( |
|
856
|
|
|
|
|
|
|
type => $type, |
|
857
|
|
|
|
|
|
|
status => 'invoking cpanm: ' . join( ' ', @cpanm_args ), |
|
858
|
|
|
|
|
|
|
); |
|
859
|
0
|
|
|
|
|
|
system(@cpanm_args); |
|
860
|
0
|
0
|
|
|
|
|
if ( $? != 0 ) { |
|
861
|
0
|
|
|
|
|
|
$self->status_add( |
|
862
|
|
|
|
|
|
|
type => $type, |
|
863
|
|
|
|
|
|
|
status => 'cpanm failed: ' . join( ' ', @cpanm_args ), |
|
864
|
|
|
|
|
|
|
error => 1, |
|
865
|
|
|
|
|
|
|
); |
|
866
|
0
|
|
|
|
|
|
return $self->{results}; |
|
867
|
|
|
|
|
|
|
} |
|
868
|
|
|
|
|
|
|
} ## end if ( !defined( $modules_installed{$module}...)) |
|
869
|
|
|
|
|
|
|
} ## end foreach my $module (@modules) |
|
870
|
|
|
|
|
|
|
} elsif ( $type =~ /^python[0-9]*$/ && $for_this_system ) { |
|
871
|
|
|
|
|
|
|
## |
|
872
|
|
|
|
|
|
|
## |
|
873
|
|
|
|
|
|
|
## |
|
874
|
|
|
|
|
|
|
## start of python |
|
875
|
|
|
|
|
|
|
## |
|
876
|
|
|
|
|
|
|
## |
|
877
|
|
|
|
|
|
|
## |
|
878
|
|
|
|
|
|
|
|
|
879
|
|
|
|
|
|
|
# keeps track of what was installed |
|
880
|
0
|
|
|
|
|
|
my %installed; |
|
881
|
|
|
|
|
|
|
|
|
882
|
|
|
|
|
|
|
# tracks if pip was already installed or not |
|
883
|
0
|
|
|
|
|
|
my $pip_installed = 0; |
|
884
|
0
|
0
|
0
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{$type}{pip_install} ) |
|
885
|
|
|
|
|
|
|
&& !$self->{opts}{xeno_build}{$type}{pip_install} ) |
|
886
|
|
|
|
|
|
|
{ |
|
887
|
0
|
|
|
|
|
|
$pip_installed = 1; |
|
888
|
|
|
|
|
|
|
} |
|
889
|
|
|
|
|
|
|
|
|
890
|
|
|
|
|
|
|
# holds a list of package to be installed |
|
891
|
0
|
|
|
|
|
|
my @modules; |
|
892
|
0
|
0
|
0
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{$type}{pip} ) |
|
893
|
|
|
|
|
|
|
&& defined( $self->{opts}{xeno_build}{$type}{pip}[0] ) ) |
|
894
|
|
|
|
|
|
|
{ |
|
895
|
0
|
|
|
|
|
|
push( @modules, @{ $self->{opts}{xeno_build}{$type}{pip} } ); |
|
|
0
|
|
|
|
|
|
|
|
896
|
|
|
|
|
|
|
} |
|
897
|
|
|
|
|
|
|
|
|
898
|
|
|
|
|
|
|
# handle stuff that is required to be installed via packages |
|
899
|
0
|
0
|
0
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{$type}{pkgs_require} ) |
|
900
|
|
|
|
|
|
|
&& defined( $self->{opts}{xeno_build}{$type}{pkgs_require}[0] ) ) |
|
901
|
|
|
|
|
|
|
{ |
|
902
|
0
|
|
|
|
|
|
my @pkgs_require; |
|
903
|
0
|
|
|
|
|
|
push( @pkgs_require, @{ $self->{opts}{xeno_build}{$type}{pkgs_require} } ); |
|
|
0
|
|
|
|
|
|
|
|
904
|
0
|
|
|
|
|
|
foreach my $module (@pkgs_require) { |
|
905
|
0
|
|
|
|
|
|
eval { python_module_via_pkg( module => $module ) }; |
|
|
0
|
|
|
|
|
|
|
|
906
|
0
|
0
|
|
|
|
|
if ($@) { |
|
907
|
0
|
|
|
|
|
|
$self->status_add( |
|
908
|
|
|
|
|
|
|
type => $type, |
|
909
|
|
|
|
|
|
|
error => 1, |
|
910
|
|
|
|
|
|
|
status => 'Failed to install required python module "' . $module . '" pkgs... ' . $@, |
|
911
|
|
|
|
|
|
|
); |
|
912
|
0
|
|
|
|
|
|
return $self->{results}; |
|
913
|
|
|
|
|
|
|
} |
|
914
|
|
|
|
|
|
|
} ## end foreach my $module (@pkgs_require) |
|
915
|
|
|
|
|
|
|
} ## end if ( defined( $self->{opts}{xeno_build}{$type...})) |
|
916
|
|
|
|
|
|
|
|
|
917
|
|
|
|
|
|
|
# try to add packages for various modules |
|
918
|
0
|
|
|
|
|
|
my @pkgs; |
|
919
|
0
|
0
|
0
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{$type}{pkgs} ) |
|
920
|
|
|
|
|
|
|
&& defined( $self->{opts}{xeno_build}{$type}{pkgs}[0] ) ) |
|
921
|
|
|
|
|
|
|
{ |
|
922
|
0
|
|
|
|
|
|
push( @pkgs, @{ $self->{opts}{xeno_build}{$type}{pkgs} } ); |
|
|
0
|
|
|
|
|
|
|
|
923
|
|
|
|
|
|
|
} |
|
924
|
0
|
0
|
|
|
|
|
if ( defined( $pkgs[0] ) ) { |
|
925
|
0
|
|
|
|
|
|
foreach my $module (@pkgs) { |
|
926
|
0
|
|
|
|
|
|
eval { python_module_via_pkg( module => $module ) }; |
|
|
0
|
|
|
|
|
|
|
|
927
|
0
|
0
|
|
|
|
|
if ($@) { |
|
928
|
0
|
|
|
|
|
|
push( @modules, $pkg ); |
|
929
|
|
|
|
|
|
|
} else { |
|
930
|
0
|
|
|
|
|
|
$installed{$module} = 1; |
|
931
|
|
|
|
|
|
|
} |
|
932
|
|
|
|
|
|
|
} |
|
933
|
|
|
|
|
|
|
} ## end if ( defined( $pkgs[0] ) ) |
|
934
|
|
|
|
|
|
|
|
|
935
|
|
|
|
|
|
|
# install all modules for python via pip, including ones that could not be installed via packages |
|
936
|
0
|
|
|
|
|
|
foreach my $module (@modules) { |
|
937
|
0
|
0
|
|
|
|
|
if ( !$installed{$module} ) { |
|
938
|
0
|
0
|
|
|
|
|
if ( !$pip_installed ) { |
|
939
|
0
|
|
|
|
|
|
eval { install_pip; }; |
|
|
0
|
|
|
|
|
|
|
|
940
|
0
|
0
|
|
|
|
|
if ($@) { |
|
941
|
0
|
|
|
|
|
|
$self->status_add( |
|
942
|
|
|
|
|
|
|
type => $type, |
|
943
|
|
|
|
|
|
|
status => 'Installing pip failed... ' . $@, |
|
944
|
|
|
|
|
|
|
error => 1, |
|
945
|
|
|
|
|
|
|
); |
|
946
|
0
|
|
|
|
|
|
return $self->{results}; |
|
947
|
|
|
|
|
|
|
} |
|
948
|
0
|
|
|
|
|
|
my @pip_cmd; |
|
949
|
0
|
|
|
|
|
|
my $pip3 = `which pip3 2> /dev/null`; |
|
950
|
0
|
0
|
|
|
|
|
if ( $? == 0 ) { |
|
951
|
0
|
|
|
|
|
|
push( @pip_cmd, 'pip3', 'install', $module ); |
|
952
|
|
|
|
|
|
|
} else { |
|
953
|
0
|
|
|
|
|
|
push( @pip_cmd, 'pip', 'install', $module ); |
|
954
|
|
|
|
|
|
|
} |
|
955
|
0
|
|
|
|
|
|
$self->status_add( |
|
956
|
|
|
|
|
|
|
type => $type, |
|
957
|
|
|
|
|
|
|
status => 'invoking pip: ' . join( ' ', @pip_cmd ), |
|
958
|
|
|
|
|
|
|
); |
|
959
|
0
|
|
|
|
|
|
system(@pip_cmd); |
|
960
|
0
|
0
|
|
|
|
|
if ( $? != 0 ) { |
|
961
|
0
|
|
|
|
|
|
$self->status_add( |
|
962
|
|
|
|
|
|
|
type => $type, |
|
963
|
|
|
|
|
|
|
status => 'pip failed: ' . join( ' ', @pip_cmd ), |
|
964
|
|
|
|
|
|
|
error => 1, |
|
965
|
|
|
|
|
|
|
); |
|
966
|
0
|
|
|
|
|
|
return $self->{results}; |
|
967
|
|
|
|
|
|
|
} |
|
968
|
|
|
|
|
|
|
} ## end if ( !$pip_installed ) |
|
969
|
|
|
|
|
|
|
} ## end if ( !$installed{$module} ) |
|
970
|
|
|
|
|
|
|
} ## end foreach my $module (@modules) |
|
971
|
|
|
|
|
|
|
|
|
972
|
|
|
|
|
|
|
} elsif ( $type =~ /^exec[0-9]*$/ && $for_this_system ) { |
|
973
|
|
|
|
|
|
|
## |
|
974
|
|
|
|
|
|
|
## |
|
975
|
|
|
|
|
|
|
## |
|
976
|
|
|
|
|
|
|
## start of exec |
|
977
|
|
|
|
|
|
|
## |
|
978
|
|
|
|
|
|
|
## |
|
979
|
|
|
|
|
|
|
## |
|
980
|
0
|
|
|
|
|
|
my @commands; |
|
981
|
|
|
|
|
|
|
# if we have the default command, add it to the stack |
|
982
|
0
|
0
|
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{$type}{command} ) ) { |
|
983
|
0
|
|
|
|
|
|
push( @commands, { command => $self->{opts}{xeno_build}{$type}{command} } ); |
|
984
|
|
|
|
|
|
|
} |
|
985
|
|
|
|
|
|
|
|
|
986
|
|
|
|
|
|
|
# if .exec.commands exists shove it onto the stack |
|
987
|
0
|
0
|
0
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{$type}{commands} ) |
|
988
|
|
|
|
|
|
|
&& defined( $self->{opts}{xeno_build}{$type}{commands}[0] ) ) |
|
989
|
|
|
|
|
|
|
{ |
|
990
|
0
|
|
|
|
|
|
push( @commands, @{ $self->{opts}{xeno_build}{$type}{commands} } ); |
|
|
0
|
|
|
|
|
|
|
|
991
|
|
|
|
|
|
|
} |
|
992
|
|
|
|
|
|
|
|
|
993
|
|
|
|
|
|
|
# process each command |
|
994
|
0
|
|
|
|
|
|
my @to_possibly_copy = ( 'command', 'exits', 'template', 'for', 'dir' ); |
|
995
|
0
|
|
|
|
|
|
my $command_int = 0; |
|
996
|
0
|
|
|
|
|
|
foreach my $command_hash (@commands) { |
|
997
|
0
|
0
|
0
|
|
|
|
if ( defined( $self->{opts}{xeno_build}{$type}{command} ) |
|
998
|
|
|
|
|
|
|
|| defined( $command_hash->{command} ) ) |
|
999
|
|
|
|
|
|
|
{ |
|
1000
|
0
|
|
|
|
|
|
foreach my $to_copy (@to_possibly_copy) { |
|
1001
|
0
|
0
|
0
|
|
|
|
if ( !defined( $command_hash->{$to_copy} ) |
|
|
|
0
|
0
|
|
|
|
|
|
1002
|
|
|
|
|
|
|
&& defined( $self->{opts}{xeno_build}{$type}{$to_copy} ) ) |
|
1003
|
|
|
|
|
|
|
{ |
|
1004
|
0
|
|
|
|
|
|
$command_hash->{$to_copy} = $self->{opts}{xeno_build}{$type}{$to_copy}; |
|
1005
|
|
|
|
|
|
|
} elsif ( !defined( $command_hash->{$to_copy} ) |
|
1006
|
|
|
|
|
|
|
&& !defined( $self->{opts}{xeno_build}{$type}{$to_copy} ) ) |
|
1007
|
|
|
|
|
|
|
{ |
|
1008
|
0
|
0
|
|
|
|
|
if ( $to_copy eq 'exits' ) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
1009
|
0
|
|
|
|
|
|
$command_hash->{exits} = [0]; |
|
1010
|
|
|
|
|
|
|
} elsif ( $to_copy eq 'template' ) { |
|
1011
|
0
|
|
|
|
|
|
$command_hash->{template} = 0; |
|
1012
|
|
|
|
|
|
|
} elsif ( $to_copy eq 'for' ) { |
|
1013
|
0
|
|
|
|
|
|
$command_hash->{for} = []; |
|
1014
|
|
|
|
|
|
|
} |
|
1015
|
|
|
|
|
|
|
} ## end elsif ( !defined( $command_hash->{$to_copy} )...) |
|
1016
|
|
|
|
|
|
|
} ## end foreach my $to_copy (@to_possibly_copy) |
|
1017
|
|
|
|
|
|
|
|
|
1018
|
|
|
|
|
|
|
$self->status_add( |
|
1019
|
|
|
|
|
|
|
type => $type, |
|
1020
|
|
|
|
|
|
|
status => 'exec[' . $command_int . '] command: ' . $command_hash->{command}, |
|
1021
|
0
|
|
|
|
|
|
); |
|
1022
|
|
|
|
|
|
|
|
|
1023
|
|
|
|
|
|
|
# if requested to template it, process the command and dir |
|
1024
|
0
|
0
|
|
|
|
|
if ( $command_hash->{template} ) { |
|
1025
|
0
|
|
|
|
|
|
eval { |
|
1026
|
0
|
|
|
|
|
|
my $output = ''; |
|
1027
|
0
|
|
|
|
|
|
my $command = $command_hash->{command}; |
|
1028
|
|
|
|
|
|
|
$self->{t}->process( \$command, $self->{template_vars}, \$output ) |
|
1029
|
0
|
0
|
|
|
|
|
|| die $self->{t}->error; |
|
1030
|
0
|
|
|
|
|
|
$command_hash->{command} = $output; |
|
1031
|
|
|
|
|
|
|
|
|
1032
|
0
|
|
|
|
|
|
$output = ''; |
|
1033
|
0
|
|
|
|
|
|
my $dir = $command_hash->{dir}; |
|
1034
|
|
|
|
|
|
|
$self->{t}->process( \$dir, $self->{template_vars}, \$output ) |
|
1035
|
0
|
0
|
|
|
|
|
|| die $self->{t}->error; |
|
1036
|
0
|
|
|
|
|
|
$command_hash->{dir} = $output; |
|
1037
|
|
|
|
|
|
|
|
|
1038
|
|
|
|
|
|
|
$self->status_add( |
|
1039
|
|
|
|
|
|
|
type => $type, |
|
1040
|
|
|
|
|
|
|
status => 'exec[' . $command_int . '] Templated: ' . $command_hash->{command}, |
|
1041
|
0
|
|
|
|
|
|
); |
|
1042
|
|
|
|
|
|
|
}; |
|
1043
|
0
|
0
|
|
|
|
|
if ($@) { |
|
1044
|
0
|
|
|
|
|
|
$self->status_add( |
|
1045
|
|
|
|
|
|
|
type => $type, |
|
1046
|
|
|
|
|
|
|
status => 'exec[' . $command_int . '] Templating failed... ' . $@, |
|
1047
|
|
|
|
|
|
|
error => 1, |
|
1048
|
|
|
|
|
|
|
); |
|
1049
|
0
|
|
|
|
|
|
return $self->{results}; |
|
1050
|
|
|
|
|
|
|
} |
|
1051
|
|
|
|
|
|
|
} ## end if ( $command_hash->{template} ) |
|
1052
|
|
|
|
|
|
|
|
|
1053
|
|
|
|
|
|
|
$self->status_add( |
|
1054
|
|
|
|
|
|
|
type => $type, |
|
1055
|
|
|
|
|
|
|
status => 'exec[' |
|
1056
|
|
|
|
|
|
|
. $command_int |
|
1057
|
|
|
|
|
|
|
. '] ok exits: ' |
|
1058
|
0
|
|
|
|
|
|
. join( ',', @{ $command_hash->{exits} } ), |
|
|
0
|
|
|
|
|
|
|
|
1059
|
|
|
|
|
|
|
); |
|
1060
|
|
|
|
|
|
|
|
|
1061
|
|
|
|
|
|
|
# chdir to the dir specified if needed |
|
1062
|
0
|
0
|
|
|
|
|
if ( $command_hash->{dir} ) { |
|
1063
|
0
|
|
|
|
|
|
eval { chdir( $command_hash->{dir} ); }; |
|
|
0
|
|
|
|
|
|
|
|
1064
|
0
|
0
|
|
|
|
|
if ($@) { |
|
1065
|
|
|
|
|
|
|
$self->status_add( |
|
1066
|
|
|
|
|
|
|
type => $type, |
|
1067
|
0
|
|
|
|
|
|
status => 'Failed to chdir to "' . $command_hash->{dir} . '"', |
|
1068
|
|
|
|
|
|
|
error => 1, |
|
1069
|
|
|
|
|
|
|
); |
|
1070
|
0
|
|
|
|
|
|
return $self->{results}; |
|
1071
|
|
|
|
|
|
|
} |
|
1072
|
|
|
|
|
|
|
} ## end if ( $command_hash->{dir} ) |
|
1073
|
|
|
|
|
|
|
|
|
1074
|
|
|
|
|
|
|
# if the current dir |
|
1075
|
0
|
0
|
|
|
|
|
if ( getcwd ne $self->{opts}{xeno_build}{options}{tmpdir} ) { |
|
1076
|
0
|
|
|
|
|
|
$self->status_add( type => $type, status => 'exec[' . $command_int . '] dir: ' . getcwd, ); |
|
1077
|
|
|
|
|
|
|
} |
|
1078
|
|
|
|
|
|
|
|
|
1079
|
0
|
|
|
|
|
|
system( $command_hash->{command} ); |
|
1080
|
0
|
|
|
|
|
|
my $exit_code; |
|
1081
|
0
|
0
|
|
|
|
|
if ( $? == -1 ) { |
|
1082
|
0
|
|
|
|
|
|
$exit_code = -1; |
|
1083
|
|
|
|
|
|
|
} else { |
|
1084
|
0
|
|
|
|
|
|
$exit_code = $? >> 8; |
|
1085
|
|
|
|
|
|
|
} |
|
1086
|
0
|
|
|
|
|
|
my $exit_code_matched = 0; |
|
1087
|
0
|
|
|
|
|
|
foreach my $desired_exit_code ( @{ $command_hash->{exits} } ) { |
|
|
0
|
|
|
|
|
|
|
|
1088
|
0
|
0
|
|
|
|
|
if ( $exit_code == $desired_exit_code ) { |
|
1089
|
0
|
|
|
|
|
|
$exit_code_matched = 1; |
|
1090
|
|
|
|
|
|
|
} |
|
1091
|
|
|
|
|
|
|
} |
|
1092
|
0
|
0
|
|
|
|
|
if ( !$exit_code_matched ) { |
|
1093
|
|
|
|
|
|
|
$self->status_add( |
|
1094
|
|
|
|
|
|
|
type => $type, |
|
1095
|
|
|
|
|
|
|
status => 'Exit code mismatch... desired=' |
|
1096
|
0
|
|
|
|
|
|
. join( ',', @{ $command_hash->{exits} } ) |
|
1097
|
|
|
|
|
|
|
. ' actual=' |
|
1098
|
|
|
|
|
|
|
. $exit_code |
|
1099
|
|
|
|
|
|
|
. ' command="' |
|
1100
|
0
|
|
|
|
|
|
. $command_hash->{command} . '"', |
|
1101
|
|
|
|
|
|
|
error => 1, |
|
1102
|
|
|
|
|
|
|
); |
|
1103
|
0
|
|
|
|
|
|
return $self->{results}; |
|
1104
|
|
|
|
|
|
|
} else { |
|
1105
|
0
|
|
|
|
|
|
$self->status_add( |
|
1106
|
|
|
|
|
|
|
type => $type, |
|
1107
|
|
|
|
|
|
|
status => 'exec[' . $command_int . '] Exit Code: ' . $exit_code, |
|
1108
|
|
|
|
|
|
|
); |
|
1109
|
|
|
|
|
|
|
} |
|
1110
|
|
|
|
|
|
|
|
|
1111
|
|
|
|
|
|
|
} ## end if ( defined( $self->{opts}{xeno_build}{$type...})) |
|
1112
|
|
|
|
|
|
|
|
|
1113
|
0
|
|
|
|
|
|
$command_int++; |
|
1114
|
|
|
|
|
|
|
} ## end foreach my $command_hash (@commands) |
|
1115
|
|
|
|
|
|
|
|
|
1116
|
|
|
|
|
|
|
} elsif ( !$for_this_system ) { |
|
1117
|
0
|
|
|
|
|
|
$self->status_add( type => $type, status => 'Not for this system' ); |
|
1118
|
|
|
|
|
|
|
} |
|
1119
|
|
|
|
|
|
|
} ## end foreach my $type (@types) |
|
1120
|
|
|
|
|
|
|
|
|
1121
|
0
|
|
|
|
|
|
chdir( $self->{opts}{xeno_build}{options}{tmpdir} . '/..' ); |
|
1122
|
|
|
|
|
|
|
|
|
1123
|
0
|
|
|
|
|
|
return $self->{results}; |
|
1124
|
|
|
|
|
|
|
} ## end sub action |
|
1125
|
|
|
|
|
|
|
|
|
1126
|
|
|
|
|
|
|
sub short { |
|
1127
|
0
|
|
|
0
|
1
|
|
return 'Builds/installs stuff based on a passed hash ref. Not usable directly. Use xeno action.'; |
|
1128
|
|
|
|
|
|
|
} |
|
1129
|
|
|
|
|
|
|
|
|
1130
|
|
|
|
|
|
|
sub opts_data { |
|
1131
|
0
|
|
|
0
|
1
|
|
return ' |
|
1132
|
|
|
|
|
|
|
'; |
|
1133
|
|
|
|
|
|
|
} |
|
1134
|
|
|
|
|
|
|
|
|
1135
|
|
|
|
|
|
|
sub status_add_error_extra { |
|
1136
|
0
|
|
|
0
|
0
|
|
my ( $self ) = @_; |
|
1137
|
|
|
|
|
|
|
|
|
1138
|
0
|
|
|
|
|
|
chdir( $self->{opts}{xeno_build}{options}{tmpdir} . '/..' ); |
|
1139
|
|
|
|
|
|
|
|
|
1140
|
|
|
|
|
|
|
} ## end sub status_add |
|
1141
|
|
|
|
|
|
|
|
|
1142
|
|
|
|
|
|
|
1; |