File inc/user/packages.inc.php changed (mode: 100644) (index bc36eb0..b3d1d1a) |
... |
... |
include_once(__DIR__ . '/pkg_repo.inc.php'); |
3 |
3 |
include_once(__DIR__ . '/pkg_subrepo.inc.php'); |
include_once(__DIR__ . '/pkg_subrepo.inc.php'); |
4 |
4 |
include_once(__DIR__ . '/pkg_map.inc.php'); |
include_once(__DIR__ . '/pkg_map.inc.php'); |
5 |
5 |
include_once(__DIR__ . '/packages_rpm.inc.php'); |
include_once(__DIR__ . '/packages_rpm.inc.php'); |
|
6 |
|
include_once(__DIR__ . '/packages_deb.inc.php'); |
6 |
7 |
|
|
7 |
8 |
/* |
/* |
8 |
|
* This is called from rgfs.php to validate a creation of a path |
|
|
9 |
|
* Event functions |
9 |
10 |
*/ |
*/ |
10 |
|
function rg_packages_validate_path($db, $path, $allow_paths) |
|
|
11 |
|
$_f = array( |
|
12 |
|
'pkg_event_after_build' => 'rg_pkg_event_after_build' |
|
13 |
|
); |
|
14 |
|
rg_event_register_functions($_f); |
|
15 |
|
|
|
16 |
|
/* |
|
17 |
|
* Some chars are not allowed in package names |
|
18 |
|
*/ |
|
19 |
|
function rg_pkg_transform($type, $s) |
11 |
20 |
{ |
{ |
12 |
|
$ret = array('ok' => 0, 'user_path' => ''); |
|
|
21 |
|
if (strcmp($type, 'deb') == 0) { |
|
22 |
|
$s2 = strtolower($s); |
|
23 |
|
$s2 = preg_replace('/[^-a-z0-9.]/', '-', $s2); |
|
24 |
|
$s2 = str_replace('--', '-', $s2); |
|
25 |
|
} else if (strcmp($type, 'rpm') == 0) { |
|
26 |
|
$s2 = preg_replace('/[^-A-Za-z0-9._]/', '-', $s); |
|
27 |
|
} |
|
28 |
|
rg_log_debug('pkg_transform[' . $type . ']: [' . $s . '] -> [' . $s2 . ']'); |
|
29 |
|
|
|
30 |
|
return $s2; |
|
31 |
|
} |
|
32 |
|
|
|
33 |
|
/* |
|
34 |
|
* This is called after a push and before sendint the job to a builder |
|
35 |
|
*/ |
|
36 |
|
function rg_pkg_prepare_for_build($db, &$a) |
|
37 |
|
{ |
|
38 |
|
rg_log_enter('pkg_prepare_for_build'); |
|
39 |
|
rg_log_debug('a: ' . rg_array2string_short($a)); |
|
40 |
|
|
|
41 |
|
$ret = array('ok' => 0); |
13 |
42 |
do { |
do { |
14 |
|
$r = rg_envs_tree($db, TRUE /*only enabled*/); |
|
|
43 |
|
rg_pkg_prepare_for_rgfs($db, $a); |
|
44 |
|
|
|
45 |
|
$ei = rg_env_info($a['env']); |
|
46 |
|
$a['env_codename'] = $ei['codename']; |
|
47 |
|
|
|
48 |
|
if (isset($a['repo_name'])) |
|
49 |
|
$a['repo_name_allowed'] = rg_pkg_transform($ei['pkg_type'], |
|
50 |
|
$a['repo_name']); |
|
51 |
|
$a['repo_username_allowed'] = rg_pkg_transform($ei['pkg_type'], |
|
52 |
|
$a['repo_username']); |
|
53 |
|
|
|
54 |
|
if (!isset($a['event_callbacks'])) |
|
55 |
|
$a['event_callbacks'] = array(); |
|
56 |
|
$a['event_callbacks'][] = 'pkg_event_after_build'; |
|
57 |
|
|
|
58 |
|
if (isset($a['pkg_subrepo_id_list'])) { |
|
59 |
|
$r = rg_pkg_maps_prepare($db, $a); |
|
60 |
|
if ($r['ok'] != 1) { |
|
61 |
|
$ret['errmsg'] = $r['errmsg']; |
|
62 |
|
break; |
|
63 |
|
} |
|
64 |
|
} |
|
65 |
|
|
|
66 |
|
$r = array('ok' => 1); |
|
67 |
|
if (strcmp($ei['pkg_type'], 'rpm') == 0) { |
|
68 |
|
$r = rg_pkg_prepare_for_build_rpm($db, $a); |
|
69 |
|
} else if (strcmp($ei['pkg_type'], 'deb') == 0) { |
|
70 |
|
$r = rg_pkg_prepare_for_build_deb($db, $a); |
|
71 |
|
} |
15 |
72 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
16 |
|
$ret['errmsg'] = 'cannot load envs: ' . $r['errmsg']; |
|
|
73 |
|
rg_log('Cannot prepare ev: ' . $r['errmsg']); |
17 |
74 |
break; |
break; |
18 |
75 |
} |
} |
19 |
|
$d = $r['tree']; |
|
20 |
76 |
|
|
21 |
|
$x = explode('/', $path); |
|
22 |
|
$junk = array_shift($x); // because path starts with '/', we ignore the empty element |
|
|
77 |
|
// Prio is 2 less than normal (10) |
|
78 |
|
$r = rg_builder_add($db, $a['build_repo_id'], 8 /*prio*/, $a); |
|
79 |
|
if ($r['ok'] != 1) { |
|
80 |
|
$ret['errmsg'] = $r['errmsg']; |
|
81 |
|
break; |
|
82 |
|
} |
23 |
83 |
|
|
24 |
|
$distro = array_shift($x); |
|
25 |
|
if (!isset($d[$distro])) { |
|
26 |
|
$ret['errmsg'] = 'invalid distro [' . $distro . ']'; |
|
|
84 |
|
$ret['ok'] = 1; |
|
85 |
|
} while (0); |
|
86 |
|
|
|
87 |
|
rg_log_exit(); |
|
88 |
|
return $ret; |
|
89 |
|
} |
|
90 |
|
|
|
91 |
|
/* |
|
92 |
|
* Event called after a build is done |
|
93 |
|
*/ |
|
94 |
|
function rg_pkg_event_after_build($db, $ev) |
|
95 |
|
{ |
|
96 |
|
rg_log_enter('pkg_event_after_build'); |
|
97 |
|
rg_log_debug('ev: ' . rg_array2string_short($ev)); |
|
98 |
|
|
|
99 |
|
$ret = FALSE; |
|
100 |
|
do { |
|
101 |
|
$req = $ev['job']['request']; |
|
102 |
|
$e = $req['env']; |
|
103 |
|
$ei = rg_env_info($e); |
|
104 |
|
|
|
105 |
|
if (!isset($req['orig_job_id'])) { |
|
106 |
|
rg_log_debug('TODO orig_job_id is not set, so set it to ' . $ev['job']['id']); |
|
107 |
|
$ev['job']['request']['orig_job_id'] = $ev['job']['id']; |
|
108 |
|
} else { |
|
109 |
|
rg_log_debug('req[orig_job_id] is already set to ' . $req['orig_job_id']); |
|
110 |
|
} |
|
111 |
|
|
|
112 |
|
$r = array('ok' => 1); |
|
113 |
|
if (strcmp($ei['pkg_type'], 'rpm') == 0) { |
|
114 |
|
$r = rg_pkg_after_build_rpm($db, $ev); |
|
115 |
|
} else if (strcmp($ei['pkg_type'], 'deb') == 0) { |
|
116 |
|
$r = rg_pkg_after_build_deb($db, $ev); |
|
117 |
|
} |
|
118 |
|
if ($r['ok'] != 1) { |
|
119 |
|
rg_log('error: ' . $r['errmsg']); |
|
120 |
|
break; |
|
121 |
|
} |
|
122 |
|
|
|
123 |
|
$ret = array(); |
|
124 |
|
} while (0); |
|
125 |
|
|
|
126 |
|
rg_log_exit(); |
|
127 |
|
return $ret; |
|
128 |
|
} |
|
129 |
|
|
|
130 |
|
/* |
|
131 |
|
* Validate path for Debian |
|
132 |
|
* Example x: [11]/[main] |
|
133 |
|
*/ |
|
134 |
|
function rg_packages_validate_path_deb($distro, &$x, $m) |
|
135 |
|
{ |
|
136 |
|
rg_log_enter('packages_validate_path_deb'); |
|
137 |
|
//rg_log_debug('x: ' . print_r($x, TRUE)); |
|
138 |
|
|
|
139 |
|
$ret = array('ok' => 0); |
|
140 |
|
do { |
|
141 |
|
$codename = array_shift($x); |
|
142 |
|
$major = rg_env_codename2major($distro, $codename); |
|
143 |
|
if (!isset($m[$major])) { |
|
144 |
|
$ret['errmsg'] = 'invalid codename [' . $codename . ']' |
|
145 |
|
. ' for distro ' . $distro; |
|
146 |
|
break; |
|
147 |
|
} |
|
148 |
|
|
|
149 |
|
if (empty($x)) { |
|
150 |
|
$ret['ok'] = 1; |
27 |
151 |
break; |
break; |
28 |
152 |
} |
} |
29 |
153 |
|
|
|
154 |
|
$junk_main = array_shift($x); |
|
155 |
|
|
30 |
156 |
if (empty($x)) { |
if (empty($x)) { |
31 |
157 |
$ret['ok'] = 1; |
$ret['ok'] = 1; |
32 |
158 |
break; |
break; |
33 |
159 |
} |
} |
34 |
160 |
|
|
|
161 |
|
$binary_or_source = array_shift($x); |
|
162 |
|
|
|
163 |
|
$ret['ok'] = 1; |
|
164 |
|
} while (0); |
|
165 |
|
|
|
166 |
|
rg_log_exit(); |
|
167 |
|
return $ret; |
|
168 |
|
} |
|
169 |
|
|
|
170 |
|
/* |
|
171 |
|
* Validate path for Fedora/CentOS/CentOS Stream |
|
172 |
|
*/ |
|
173 |
|
function rg_packages_validate_path_rpm($distro, &$x, $m) |
|
174 |
|
{ |
|
175 |
|
rg_log_enter('packages_validate_path_rpm'); |
|
176 |
|
|
|
177 |
|
$ret = array('ok' => 0); |
|
178 |
|
do { |
35 |
179 |
$major = array_shift($x); |
$major = array_shift($x); |
36 |
|
if (!isset($d[$distro]['versions'][$major])) { |
|
|
180 |
|
if (!isset($m[$major])) { |
37 |
181 |
$ret['errmsg'] = 'invalid major [' . $major . ']'; |
$ret['errmsg'] = 'invalid major [' . $major . ']'; |
38 |
182 |
break; |
break; |
39 |
183 |
} |
} |
|
... |
... |
function rg_packages_validate_path($db, $path, $allow_paths) |
44 |
188 |
} |
} |
45 |
189 |
|
|
46 |
190 |
$arch = array_shift($x); |
$arch = array_shift($x); |
47 |
|
if (!isset($d[$distro]['versions'][$major]['archs'][$arch])) { |
|
|
191 |
|
if (!isset($m[$major]['archs'][$arch])) { |
48 |
192 |
$ret['errmsg'] = 'invalid arch [' . $arch . ']'; |
$ret['errmsg'] = 'invalid arch [' . $arch . ']'; |
49 |
193 |
break; |
break; |
50 |
194 |
} |
} |
|
... |
... |
function rg_packages_validate_path($db, $path, $allow_paths) |
54 |
198 |
break; |
break; |
55 |
199 |
} |
} |
56 |
200 |
|
|
57 |
|
if (strcmp($d[$distro]['pkg_type'], 'rpm') != 0) { |
|
58 |
|
$ret['errmsg'] = 'unsupported pkg type'; |
|
59 |
|
break; |
|
60 |
|
} |
|
61 |
|
|
|
62 |
201 |
$type = array_shift($x); |
$type = array_shift($x); |
63 |
202 |
$allow = array('os', 'debug', 'src'); |
$allow = array('os', 'debug', 'src'); |
64 |
203 |
if (!in_array($type, $allow)) { |
if (!in_array($type, $allow)) { |
|
... |
... |
function rg_packages_validate_path($db, $path, $allow_paths) |
66 |
205 |
break; |
break; |
67 |
206 |
} |
} |
68 |
207 |
|
|
|
208 |
|
$ret['ok'] = 1; |
|
209 |
|
} while (0); |
|
210 |
|
|
|
211 |
|
rg_log_exit(); |
|
212 |
|
return $ret; |
|
213 |
|
} |
|
214 |
|
|
|
215 |
|
/* |
|
216 |
|
* This is called from rgfs.php to validate the creation of a path |
|
217 |
|
*/ |
|
218 |
|
function rg_packages_validate_path($db, $path, $allow_paths) |
|
219 |
|
{ |
|
220 |
|
rg_log_enter('packages_validate_path: path=' . $path); |
|
221 |
|
|
|
222 |
|
$ret = array('ok' => 0, 'user_path' => ''); |
|
223 |
|
do { |
|
224 |
|
$r = rg_envs_tree($db, TRUE /*only enabled*/); |
|
225 |
|
if ($r['ok'] != 1) { |
|
226 |
|
$ret['errmsg'] = 'cannot load envs: ' . $r['errmsg']; |
|
227 |
|
break; |
|
228 |
|
} |
|
229 |
|
$d = $r['tree']; |
|
230 |
|
|
|
231 |
|
$x = explode('/', $path); |
|
232 |
|
$junk = array_shift($x); // because path starts with '/', we ignore the empty element |
|
233 |
|
|
|
234 |
|
$distro = array_shift($x); |
|
235 |
|
if (!isset($d[$distro])) { |
|
236 |
|
$ret['errmsg'] = 'invalid distro [' . $distro . ']'; |
|
237 |
|
break; |
|
238 |
|
} |
|
239 |
|
|
|
240 |
|
if (empty($x)) { |
|
241 |
|
$ret['ok'] = 1; |
|
242 |
|
break; |
|
243 |
|
} |
|
244 |
|
|
|
245 |
|
$m = $d[$distro]['versions']; |
|
246 |
|
switch ($d[$distro]['pkg_type']) { |
|
247 |
|
case 'rpm': $r = rg_packages_validate_path_rpm($distro, $x, $m); break; |
|
248 |
|
case 'deb': $r = rg_packages_validate_path_deb($distro, $x, $m); break; |
|
249 |
|
default: $r = array('ok' => 0, 'errmsg' => 'yet unsupported distro' |
|
250 |
|
. ' (' . $distro . ')'); break; |
|
251 |
|
} |
|
252 |
|
if ($r['ok'] != 1) { |
|
253 |
|
$ret['errmsg'] = $r['errmsg']; |
|
254 |
|
break; |
|
255 |
|
} |
|
256 |
|
|
69 |
257 |
if (empty($x)) { |
if (empty($x)) { |
70 |
258 |
$ret['ok'] = 1; |
$ret['ok'] = 1; |
71 |
259 |
break; |
break; |
|
... |
... |
function rg_packages_validate_path($db, $path, $allow_paths) |
76 |
264 |
$match = FALSE; |
$match = FALSE; |
77 |
265 |
$next1 = array_shift($x); |
$next1 = array_shift($x); |
78 |
266 |
$next2 = !empty($x) ? array_shift($x) : ''; |
$next2 = !empty($x) ? array_shift($x) : ''; |
|
267 |
|
$next3 = !empty($x) ? array_shift($x) : ''; |
79 |
268 |
foreach ($allow_paths as $i) { |
foreach ($allow_paths as $i) { |
80 |
|
rg_log_debug('[' . $next1 . ']/[' . $next2 . '] vs [' . $i['next1'] . ']/[' . $i['next2'] . ']'); |
|
|
269 |
|
rg_log_debug('testing [' . $next1 . ']/[' . $next2 . ']/[' . $next3 . ']' |
|
270 |
|
. ' vs [' . $i['next1'] . ']/[' . $i['next2'] . ']/[' . $i['next3'] . ']'); |
81 |
271 |
|
|
82 |
272 |
if (preg_match('/^' . $i['next1'] . '$/uD', $next1) !== 1) |
if (preg_match('/^' . $i['next1'] . '$/uD', $next1) !== 1) |
83 |
273 |
continue; |
continue; |
|
... |
... |
function rg_packages_validate_path($db, $path, $allow_paths) |
86 |
276 |
&& preg_match('/^' . $i['next2'] . '$/uD', $next2) !== 1) |
&& preg_match('/^' . $i['next2'] . '$/uD', $next2) !== 1) |
87 |
277 |
continue; |
continue; |
88 |
278 |
|
|
|
279 |
|
if (!empty($next3) |
|
280 |
|
&& preg_match('/^' . $i['next3'] . '$/uD', $next3) !== 1) |
|
281 |
|
continue; |
|
282 |
|
|
89 |
283 |
$match = TRUE; |
$match = TRUE; |
90 |
284 |
break; |
break; |
91 |
285 |
} |
} |
92 |
286 |
if (!$match) { |
if (!$match) { |
93 |
|
$ret['errmsg'] = 'not allowed path [' . $next1 . ']/[' . $next2 . ']'; |
|
|
287 |
|
$ret['errmsg'] = 'not allowed path [' . $next1 . ']' |
|
288 |
|
. '/[' . $next2 . ']/[' . $next3 . ']'; |
94 |
289 |
break; |
break; |
95 |
290 |
} |
} |
96 |
291 |
|
|
97 |
292 |
$ret['ok'] = 1; |
$ret['ok'] = 1; |
98 |
293 |
} while (0); |
} while (0); |
99 |
294 |
|
|
|
295 |
|
rg_log_exit(); |
100 |
296 |
return $ret; |
return $ret; |
101 |
297 |
} |
} |
102 |
298 |
|
|
103 |
299 |
function rg_packages_get_link($db, $a) |
function rg_packages_get_link($db, $a) |
104 |
300 |
{ |
{ |
105 |
|
if (strcmp($a['distro_pkg_type'], 'rpm') == 0) |
|
|
301 |
|
if (strcmp($a['pkg_type'], 'rpm') == 0) |
106 |
302 |
return rg_packages_rpm_get_link($db, $a); |
return rg_packages_rpm_get_link($db, $a); |
107 |
303 |
|
|
|
304 |
|
if (strcmp($a['pkg_type'], 'deb') == 0) |
|
305 |
|
return rg_packages_deb_get_link($db, $a); |
|
306 |
|
|
108 |
307 |
return FALSE; |
return FALSE; |
109 |
308 |
} |
} |
110 |
309 |
|
|
|
... |
... |
function rg_packages_get_link($db, $a) |
113 |
312 |
*/ |
*/ |
114 |
313 |
function rg_packages_howto($a, $user, $repo_name, $meta) |
function rg_packages_howto($a, $user, $repo_name, $meta) |
115 |
314 |
{ |
{ |
116 |
|
if (strcmp($a['distro_pkg_type'], 'rpm') == 0) |
|
|
315 |
|
if (strcmp($a['pkg_type'], 'rpm') == 0) |
117 |
316 |
return rg_packages_rpm_howto($a, $user, $repo_name, $meta); |
return rg_packages_rpm_howto($a, $user, $repo_name, $meta); |
|
317 |
|
else if (strcmp($a['pkg_type'], 'deb') == 0) |
|
318 |
|
return rg_packages_deb_howto($a, $user, $repo_name, $meta); |
118 |
319 |
|
|
119 |
320 |
return 'TODO'; |
return 'TODO'; |
120 |
321 |
} |
} |
|
... |
... |
function rg_packages_howto($a, $user, $repo_name, $meta) |
125 |
326 |
function rg_packages_meta_split($meta) |
function rg_packages_meta_split($meta) |
126 |
327 |
{ |
{ |
127 |
328 |
$ret = array(); |
$ret = array(); |
|
329 |
|
|
128 |
330 |
foreach ($meta as $path => $i) { |
foreach ($meta as $path => $i) { |
129 |
|
$a = explode('/', $path, 5); |
|
130 |
|
$distro = $a[1]; |
|
131 |
|
$major = $a[2]; |
|
132 |
|
$arch = $a[3]; |
|
133 |
|
$rest = $a[4]; |
|
|
331 |
|
if (isset($i['env'])) { // new way |
|
332 |
|
$ei = rg_env_info($i['env']); |
|
333 |
|
$distro = $ei['distro']; |
|
334 |
|
$major = $ei['major']; |
|
335 |
|
$arch = $ei['arch']; |
|
336 |
|
|
|
337 |
|
$a = explode('/', $path); |
|
338 |
|
$c = count($a); |
|
339 |
|
$rest = $a[$c - 1]; |
|
340 |
|
} else { // old way |
|
341 |
|
$a = explode('/', $path, 5); |
|
342 |
|
$distro = $a[1]; |
|
343 |
|
$major = $a[2]; |
|
344 |
|
$arch = $a[3]; |
|
345 |
|
|
|
346 |
|
$rest = $a[4]; |
|
347 |
|
} |
134 |
348 |
|
|
135 |
349 |
if (!isset($ret[$distro])) |
if (!isset($ret[$distro])) |
136 |
350 |
$ret[$distro] = array(); |
$ret[$distro] = array(); |
|
... |
... |
function rg_packages_meta_split($meta) |
154 |
368 |
*/ |
*/ |
155 |
369 |
function rg_packages_are_available($a, $repo_id) |
function rg_packages_are_available($a, $repo_id) |
156 |
370 |
{ |
{ |
157 |
|
rg_log_enter_ml('packages_are_available: ' |
|
|
371 |
|
rg_log_enter('packages_are_available:' |
158 |
372 |
. ' pr=' . $a['pkg_repo_info']['id'] |
. ' pr=' . $a['pkg_repo_info']['id'] |
159 |
373 |
. ' psr=' . $a['pkg_subrepo_info']['id'] |
. ' psr=' . $a['pkg_subrepo_info']['id'] |
160 |
374 |
. ' repo_id=' . $repo_id); |
. ' repo_id=' . $repo_id); |
161 |
375 |
|
|
162 |
376 |
$ret = FALSE; |
$ret = FALSE; |
163 |
377 |
do { |
do { |
164 |
|
$d = '/var/lib/rocketgit/pkg_repos' |
|
|
378 |
|
$d = '/var/lib/rocketgit/pkg_repos' // TODO: replace with the global variable |
165 |
379 |
. '/' . $a['pkg_repo_info']['id'] |
. '/' . $a['pkg_repo_info']['id'] |
166 |
380 |
. '/' . $a['pkg_subrepo_info']['id']; |
. '/' . $a['pkg_subrepo_info']['id']; |
167 |
381 |
$f = $d . '/meta/' . $repo_id . '.json'; |
$f = $d . '/meta/' . $repo_id . '.json'; |
|
... |
... |
function rg_packages_are_available($a, $repo_id) |
172 |
386 |
} |
} |
173 |
387 |
|
|
174 |
388 |
$u = rg_unserialize($c); |
$u = rg_unserialize($c); |
175 |
|
if ($u === FALSE) |
|
|
389 |
|
if ($u === FALSE) { |
|
390 |
|
rg_internal_error('canot unserialize ' . $c); |
176 |
391 |
break; // TODO: return a temporary error? |
break; // TODO: return a temporary error? |
|
392 |
|
} |
|
393 |
|
rg_log_debug('Loaded ' . count($u) . ' entries'); |
|
394 |
|
//rg_log_debug('Loaded from file ' . $f . ': ' . print_r($u, TRUE)); |
177 |
395 |
|
|
178 |
396 |
// Load more info about files (size and nlink) |
// Load more info about files (size and nlink) |
179 |
397 |
foreach ($u as $subpath => &$i) { |
foreach ($u as $subpath => &$i) { |
|
398 |
|
if (strstr($subpath, '/+pending/')) { |
|
399 |
|
unset($u[$subpath]); |
|
400 |
|
continue; |
|
401 |
|
} |
|
402 |
|
|
180 |
403 |
$s = @stat($d . $subpath); |
$s = @stat($d . $subpath); |
181 |
404 |
if ($s === FALSE) { |
if ($s === FALSE) { |
182 |
|
rg_log('cannot stat ' . $d . '/' . $subpath); |
|
|
405 |
|
//rg_log_debug('cannot stat ' . $d . $subpath); // TODO: what to do with this? |
183 |
406 |
unset($u[$subpath]); |
unset($u[$subpath]); |
184 |
407 |
continue; |
continue; |
185 |
408 |
} |
} |
|
... |
... |
function rg_packages_are_available($a, $repo_id) |
191 |
414 |
unset($i); |
unset($i); |
192 |
415 |
|
|
193 |
416 |
$ret = rg_packages_meta_split($u); |
$ret = rg_packages_meta_split($u); |
194 |
|
rg_log_debug('meta: ' . print_r($ret, TRUE)); |
|
|
417 |
|
//rg_log_debug('return: ' . print_r($ret, TRUE)); |
195 |
418 |
} while (0); |
} while (0); |
196 |
419 |
|
|
197 |
420 |
rg_log_exit(); |
rg_log_exit(); |
|
... |
... |
function rg_packages_prepare_meta(&$m, $repo_url) |
231 |
454 |
} |
} |
232 |
455 |
|
|
233 |
456 |
/* |
/* |
234 |
|
* Returns a tree table with all available repositories+distro+major+arch |
|
|
457 |
|
* Returns a tree with all available repositories+distro+major+arch |
235 |
458 |
* for @uid. |
* for @uid. |
236 |
459 |
* TODO: get rid of $rg? |
* TODO: get rid of $rg? |
237 |
460 |
*/ |
*/ |
238 |
|
function rg_packages_info($db, $uid, $rg, $needed_flags) |
|
|
461 |
|
function rg_packages_info($db, $uid, $rg) |
239 |
462 |
{ |
{ |
240 |
|
rg_log_enter('packages_info needed_flags=' . $needed_flags); |
|
|
463 |
|
rg_log_enter('packages_info'); |
241 |
464 |
|
|
242 |
465 |
$ret = array('ok' => 0); |
$ret = array('ok' => 0); |
243 |
466 |
do { |
do { |
244 |
467 |
$ui_page = rg_ui_page(); |
$ui_page = rg_ui_page(); |
245 |
468 |
//rg_log_debug('ui_page: ' . print_r($ui_page, TRUE)); |
//rg_log_debug('ui_page: ' . print_r($ui_page, TRUE)); |
246 |
469 |
|
|
|
470 |
|
// If user can edit ('E') the repo, she should be able to see job details |
|
471 |
|
$can_see_details = 0; |
|
472 |
|
if ($ui_page['uid'] > 0) { |
|
473 |
|
$obj_id = $rg['ri']['repo_id']; |
|
474 |
|
$r = rg_rights_allow2($db, 'repo', $obj_id, 'E', ''); |
|
475 |
|
$can_see_details = ($r === TRUE) ? 1 : 0; |
|
476 |
|
} |
|
477 |
|
rg_log_debug('can_see_details=' . $can_see_details); |
|
478 |
|
|
247 |
479 |
// Load available pkg repos for an uid (including global ones) |
// Load available pkg repos for an uid (including global ones) |
248 |
480 |
$repo_list = rg_pkg_repo_list($db, $uid); |
$repo_list = rg_pkg_repo_list($db, $uid); |
249 |
481 |
if ($repo_list === FALSE) { |
if ($repo_list === FALSE) { |
|
... |
... |
function rg_packages_info($db, $uid, $rg, $needed_flags) |
252 |
484 |
} |
} |
253 |
485 |
//rg_log_debug('pkg_repo_list returned: ' . print_r($repo_list, TRUE)); |
//rg_log_debug('pkg_repo_list returned: ' . print_r($repo_list, TRUE)); |
254 |
486 |
|
|
255 |
|
// Filter repo_list based by @flags/rights |
|
|
487 |
|
// Filter repo_list based by rights |
256 |
488 |
foreach ($repo_list as $pri => &$ri) { |
foreach ($repo_list as $pri => &$ri) { |
257 |
|
$skip = FALSE; |
|
258 |
|
$nf = $needed_flags; |
|
259 |
|
while (1) { |
|
260 |
|
$f = substr($nf, 0, 1); |
|
261 |
|
if (empty($f)) |
|
262 |
|
break; |
|
263 |
|
|
|
264 |
|
if (strstr($ri['flags'], $f) === FALSE) { |
|
265 |
|
rg_log_debug('skip ' . $ri['name'] |
|
266 |
|
. ' because it does not contain flag ' . $f); |
|
267 |
|
$skip = TRUE; |
|
268 |
|
break; |
|
269 |
|
} |
|
270 |
|
$nf = substr($nf, 1); |
|
271 |
|
} |
|
272 |
|
if ($skip && rg_pkg_has_rights($db, $ri, $rg, 'A')) |
|
273 |
|
$skip = FALSE; |
|
274 |
|
if ($skip) { |
|
275 |
|
unset($repo_list[$pri]); |
|
276 |
|
continue; |
|
277 |
|
} |
|
278 |
|
|
|
279 |
489 |
// We do not need this variables |
// We do not need this variables |
280 |
490 |
unset($ri['gpg_priv_key']); |
unset($ri['gpg_priv_key']); |
281 |
491 |
unset($ri['gpg_pub_key']); |
unset($ri['gpg_pub_key']); |
282 |
492 |
unset($ri['rgfs_key']); |
unset($ri['rgfs_key']); |
283 |
493 |
|
|
284 |
|
if ($ri['uid'] > 0) { // is a user repo |
|
285 |
|
$ui = rg_user_info($db, $ri['uid'], '', ''); |
|
286 |
|
if ($ui['exists'] != 1) { |
|
287 |
|
rg_internal_error('user missing for a repo'); |
|
288 |
|
unset($repo_list[$pri]); |
|
289 |
|
continue; |
|
290 |
|
} |
|
291 |
|
$repo_list[$pri]['username'] = $ui['username']; |
|
292 |
|
} |
|
|
494 |
|
rg_pkg_repo_cosmetic($db, $repo_list[$pri]); |
293 |
495 |
|
|
294 |
496 |
$repo_list[$pri]['subrepos'] = array(); |
$repo_list[$pri]['subrepos'] = array(); |
|
497 |
|
|
|
498 |
|
if ($ri['uid'] == 0) // public pkg repo? |
|
499 |
|
continue; |
|
500 |
|
|
|
501 |
|
if (strstr($ri['flags'], 'P')) // pkg repo is public |
|
502 |
|
continue; |
|
503 |
|
|
|
504 |
|
if (rg_pkg_has_rights($db, $ri, 'A')) |
|
505 |
|
continue; |
|
506 |
|
|
|
507 |
|
unset($repo_list[$pri]); |
295 |
508 |
} |
} |
296 |
509 |
unset($ri); |
unset($ri); |
297 |
510 |
|
|
|
... |
... |
function rg_packages_info($db, $uid, $rg, $needed_flags) |
318 |
531 |
} |
} |
319 |
532 |
unset($subrepo_list); |
unset($subrepo_list); |
320 |
533 |
|
|
|
534 |
|
$r = rg_envs_tree($db, TRUE); |
|
535 |
|
if ($r['ok'] != 1) { |
|
536 |
|
$ret['errmsg'] = $r['errmsg']; |
|
537 |
|
break; |
|
538 |
|
} |
|
539 |
|
$envs = $r['tree']; |
|
540 |
|
//rg_log_debug('TODO: envs: ' . print_r($envs, TRUE)); |
|
541 |
|
|
321 |
542 |
$ret['ok'] = 1; |
$ret['ok'] = 1; |
322 |
543 |
$ret['list'] = array(); |
$ret['list'] = array(); |
323 |
544 |
$a = array(); |
$a = array(); |
|
... |
... |
function rg_packages_info($db, $uid, $rg, $needed_flags) |
332 |
553 |
$list_subrepo = array(); |
$list_subrepo = array(); |
333 |
554 |
foreach ($subrepos as $pkg_subrepo_id => $sri) { |
foreach ($subrepos as $pkg_subrepo_id => $sri) { |
334 |
555 |
rg_log_enter('pkg_subrepo_id: ' . $pkg_subrepo_id . ' [' . $sri['name'] . ']'); |
rg_log_enter('pkg_subrepo_id: ' . $pkg_subrepo_id . ' [' . $sri['name'] . ']'); |
335 |
|
rg_log_debug('sri[distro_info]: ' . print_r($sri['distro_info'], TRUE)); |
|
336 |
|
|
|
337 |
|
if (empty($sri['distro_info'])) { |
|
338 |
|
rg_log_debug('empty sri distros => skip it'); |
|
339 |
|
rg_log_exit(); |
|
340 |
|
continue; |
|
341 |
|
} |
|
342 |
|
$distros = rg_distro_info2tree($sri['distro_info']); |
|
|
556 |
|
//rg_log_debug('sri[distro_info]: ' . print_r($sri['distro_info'], TRUE)); |
343 |
557 |
|
|
344 |
558 |
$a['pkg_subrepo_info'] = $sri; |
$a['pkg_subrepo_info'] = $sri; |
345 |
559 |
|
|
346 |
|
// If we are on /opt/pkg_repos, we do not have a repo |
|
|
560 |
|
// If we are on /op/pkg_repos, we do not have a repo |
347 |
561 |
if ($ui_page['uid'] > 0) |
if ($ui_page['uid'] > 0) |
348 |
562 |
$meta = rg_packages_are_available($a, $rg['ri']['repo_id']); |
$meta = rg_packages_are_available($a, $rg['ri']['repo_id']); |
349 |
563 |
|
|
350 |
564 |
$list_distro = array(); |
$list_distro = array(); |
351 |
|
foreach ($distros as $distro => $per_distro) { |
|
352 |
|
rg_log_enter('distro ' . $distro); |
|
353 |
|
|
|
354 |
|
$env_info = rg_env_info($distro); |
|
|
565 |
|
foreach ($envs as $distro => $per_distro) { |
|
566 |
|
$versions = $per_distro['versions']; unset($per_distro['versions']); |
355 |
567 |
$a['distro'] = $distro; |
$a['distro'] = $distro; |
|
568 |
|
$a['pkg_type'] = $per_distro['pkg_type']; |
356 |
569 |
|
|
357 |
570 |
$list_major = array(); |
$list_major = array(); |
358 |
|
foreach ($per_distro['versions'] as $major => $per_major) { |
|
359 |
|
rg_log_enter('major: ' . $major); |
|
360 |
|
|
|
|
571 |
|
foreach ($versions as $major => $per_major) { |
361 |
572 |
$a['major'] = $major; |
$a['major'] = $major; |
|
573 |
|
$a['codename'] = rg_env_major2codename($distro, $major); |
362 |
574 |
|
|
363 |
575 |
$list_arch = array(); |
$list_arch = array(); |
364 |
576 |
foreach ($per_major['archs'] as $arch => $per_arch) { |
foreach ($per_major['archs'] as $arch => $per_arch) { |
365 |
|
rg_log_enter('arch ' . $arch); |
|
|
577 |
|
$e = $distro . '-' . $major . '-' . $arch; |
366 |
578 |
|
|
|
579 |
|
if (!isset($sri['distro_info'][$e])) { |
|
580 |
|
//rg_log_debug('distro_info[' . $e . '] is missing; skip'); |
|
581 |
|
continue; |
|
582 |
|
} |
|
583 |
|
$di = $sri['distro_info'][$e]; |
|
584 |
|
|
|
585 |
|
if (strcmp($per_distro['pkg_type'], 'rpm') == 0) { |
|
586 |
|
if (!isset($di['dotrepo'])) { |
|
587 |
|
//rg_log_debug('dotrepo is missing; skip'); |
|
588 |
|
continue; |
|
589 |
|
} |
|
590 |
|
} else if (strcmp($per_distro['pkg_type'], 'deb') == 0) { |
|
591 |
|
if (!isset($di['has_packages'])) { |
|
592 |
|
//rg_log_debug('has_packages is missing; skip'); |
|
593 |
|
continue; |
|
594 |
|
} |
|
595 |
|
} |
|
596 |
|
|
|
597 |
|
$m = FALSE; |
367 |
598 |
if ($ui_page['uid'] > 0) { |
if ($ui_page['uid'] > 0) { |
368 |
|
if (empty($meta[$distro][$major][$arch])) { |
|
369 |
|
rg_log_debug('skip arch ' . $arch |
|
370 |
|
. ' because meta[distro][major][arch] is empty'); |
|
371 |
|
rg_log_exit(); |
|
|
599 |
|
if (!isset($meta[$distro][$major])) { |
|
600 |
|
//rg_log_debug('meta[' . $distro . ']' |
|
601 |
|
// . '[' . $major . '] is not set; skip'); |
372 |
602 |
continue; |
continue; |
373 |
603 |
} |
} |
374 |
604 |
|
|
375 |
|
$m = $meta[$distro][$major][$arch]; |
|
376 |
|
} else { |
|
377 |
|
$m = FALSE; |
|
|
605 |
|
$m = $meta[$distro][$major]; |
|
606 |
|
|
|
607 |
|
if (empty($m[$arch])) { |
|
608 |
|
//rg_log_debug('m[' . $arch . '] is not set; skip'); |
|
609 |
|
continue; |
|
610 |
|
} |
|
611 |
|
|
|
612 |
|
$m = $m[$arch]; |
378 |
613 |
} |
} |
379 |
614 |
|
|
|
615 |
|
rg_log_enter($e); |
|
616 |
|
//if ($m !== FALSE) rg_log_debug('meta: ' . print_r($m, TRUE)); |
|
617 |
|
|
380 |
618 |
$a['arch'] = $arch; |
$a['arch'] = $arch; |
381 |
|
foreach ($per_arch as $k => $v) |
|
382 |
|
$a[$k] = $v; |
|
|
619 |
|
$a['env'] = $e; |
|
620 |
|
|
383 |
621 |
$r = rg_packages_get_link($db, $a); |
$r = rg_packages_get_link($db, $a); |
384 |
|
$a['dotrepo_pkg_name'] = $r['dotrepo_pkg_name']; |
|
385 |
|
$a['dotrepo_pkg_url'] = $r['dotrepo_pkg_url']; |
|
|
622 |
|
foreach ($r as $k => $v) |
|
623 |
|
$a[$k] = $v; |
386 |
624 |
|
|
387 |
625 |
if ($ui_page['uid'] > 0) { |
if ($ui_page['uid'] > 0) { |
388 |
626 |
$_user = $ui_page['username']; |
$_user = $ui_page['username']; |
|
... |
... |
function rg_packages_info($db, $uid, $rg, $needed_flags) |
390 |
628 |
$repo_url = rg_re_repopage($ui_page, $_repo_name); |
$repo_url = rg_re_repopage($ui_page, $_repo_name); |
391 |
629 |
|
|
392 |
630 |
// Filter meta |
// Filter meta |
393 |
|
$p = $_user . '+' . $_repo_name . '-'; |
|
394 |
|
$p_len = strlen($p); |
|
395 |
|
$m2 = array(); |
|
396 |
631 |
foreach ($m as $f => $i) { |
foreach ($m as $f => $i) { |
397 |
|
$f2 = basename($f); |
|
398 |
|
if (strncmp($f2, $p, $p_len) != 0) { |
|
399 |
|
rg_log_debug('no match [' . $f2 . '] [' . $p . ']'); |
|
|
632 |
|
if (strstr($f, '/+pending/')) { |
|
633 |
|
unset($m[$f]); |
400 |
634 |
continue; |
continue; |
401 |
635 |
} |
} |
402 |
|
|
|
403 |
|
$i['f2'] = $f2; |
|
404 |
|
$m2[$f] = $i; |
|
405 |
636 |
} |
} |
406 |
|
$m = $m2; |
|
407 |
637 |
if (empty($m)) { |
if (empty($m)) { |
408 |
638 |
rg_log_debug('empty meta after filtering'); |
rg_log_debug('empty meta after filtering'); |
409 |
639 |
rg_log_exit(); |
rg_log_exit(); |
|
... |
... |
function rg_packages_info($db, $uid, $rg, $needed_flags) |
415 |
645 |
$_repo_name = ''; |
$_repo_name = ''; |
416 |
646 |
} |
} |
417 |
647 |
|
|
|
648 |
|
$a['can_see_details'] = $can_see_details; |
418 |
649 |
$list_arch[$arch] = array( |
$list_arch[$arch] = array( |
419 |
650 |
'howto' => rg_packages_howto($a, $_user, $_repo_name, $m), |
'howto' => rg_packages_howto($a, $_user, $_repo_name, $m), |
420 |
|
'meta' => $m |
|
421 |
|
); |
|
|
651 |
|
'meta' => $m); |
422 |
652 |
rg_log_exit(); |
rg_log_exit(); |
423 |
653 |
} |
} |
424 |
654 |
if (!empty($list_arch)) |
if (!empty($list_arch)) |
425 |
655 |
$list_major[$major] = $list_arch; |
$list_major[$major] = $list_arch; |
426 |
|
rg_log_exit(); |
|
427 |
656 |
} |
} |
428 |
657 |
if (!empty($list_major)) |
if (!empty($list_major)) |
429 |
658 |
$list_distro[$distro] = |
$list_distro[$distro] = |
430 |
|
array('info' => $env_info, 'list' => $list_major); |
|
431 |
|
rg_log_exit(); |
|
|
659 |
|
array('info' => $per_distro, 'list' => $list_major); |
432 |
660 |
} |
} |
433 |
661 |
if (!empty($list_distro)) |
if (!empty($list_distro)) |
434 |
662 |
$list_subrepo[$pkg_subrepo_id] = |
$list_subrepo[$pkg_subrepo_id] = |
435 |
663 |
array('info' => $sri, 'list' => $list_distro); |
array('info' => $sri, 'list' => $list_distro); |
436 |
664 |
rg_log_exit(); |
rg_log_exit(); |
437 |
665 |
} |
} |
438 |
|
if (!empty($list_subrepo)) |
|
439 |
|
$list[$pkg_repo_id] = |
|
|
666 |
|
if (!empty($list_subrepo)) { |
|
667 |
|
isset($list[$global]) || $list[$global] = array(); |
|
668 |
|
$list[$global][$pkg_repo_id] = |
440 |
669 |
array('info' => $ri, 'list' => $list_subrepo); |
array('info' => $ri, 'list' => $list_subrepo); |
|
670 |
|
} |
441 |
671 |
rg_log_exit(); |
rg_log_exit(); |
442 |
672 |
} |
} |
443 |
|
if (!empty($list)) |
|
444 |
|
$ret['list'][$global] = $list; |
|
|
673 |
|
$ret['list'] = $list; |
445 |
674 |
} while (0); |
} while (0); |
446 |
675 |
|
|
447 |
676 |
rg_log_exit(); |
rg_log_exit(); |
|
... |
... |
function rg_packages_repo_page($db, $rg) |
462 |
691 |
// TODO: We must switch to normal rights check! |
// TODO: We must switch to normal rights check! |
463 |
692 |
$ui_page = rg_ui_page(); |
$ui_page = rg_ui_page(); |
464 |
693 |
$uid = $ui_page['uid']; |
$uid = $ui_page['uid']; |
465 |
|
$ui_login = rg_ui_login(); |
|
466 |
|
$flags = $ui_login['uid'] == $uid ? '' : 'P'; |
|
467 |
694 |
|
|
468 |
|
$r = rg_packages_info($db, $uid, $rg, $flags); |
|
|
695 |
|
$r = rg_packages_info($db, $uid, $rg); |
469 |
696 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
470 |
697 |
$rg['errmsg'] = $r['errmsg']; |
$rg['errmsg'] = $r['errmsg']; |
471 |
698 |
$ret = rg_template('internal_err.html', $rg, TRUE /*xss*/); |
$ret = rg_template('internal_err.html', $rg, TRUE /*xss*/); |
472 |
699 |
break; |
break; |
473 |
700 |
} |
} |
474 |
|
rg_log_debug('packages_info returned: ' . print_r($r['list'], TRUE)); |
|
|
701 |
|
//rg_log_debug('packages_info returned: ' . print_r($r['list'], TRUE)); |
|
702 |
|
rg_debug_html_set('pkg_info', $r['list']); |
475 |
703 |
|
|
476 |
704 |
if (empty($r['list'])) { |
if (empty($r['list'])) { |
477 |
705 |
$ret = rg_template('user/pkg/no_packages.html', $rg, TRUE /*xss*/); |
$ret = rg_template('user/pkg/no_packages.html', $rg, TRUE /*xss*/); |
|
... |
... |
function rg_packages_repo_page($db, $rg) |
482 |
710 |
foreach ($r['list'] as $global => $per_type) { |
foreach ($r['list'] as $global => $per_type) { |
483 |
711 |
$ret .= '<details open><summary>Type: <b>' . ($global == 1 ? 'Global' : 'User') . '</b></summary>'; |
$ret .= '<details open><summary>Type: <b>' . ($global == 1 ? 'Global' : 'User') . '</b></summary>'; |
484 |
712 |
foreach ($per_type as $pkg_repo_id => $per_repo) { |
foreach ($per_type as $pkg_repo_id => $per_repo) { |
485 |
|
// TODO: remove this: rg_pkg_repo_cosmetic($per_repo['info']); |
|
486 |
713 |
$ret .= '<details open>' |
$ret .= '<details open>' |
487 |
714 |
. '<summary>Repo: <b>' . rg_xss_safe($per_repo['info']['name']) . '</b>' |
. '<summary>Repo: <b>' . rg_xss_safe($per_repo['info']['name']) . '</b>' |
488 |
715 |
. ' - ' . (strstr($per_repo['info']['flags'], 'P') ? 'public' : 'private') |
. ' - ' . (strstr($per_repo['info']['flags'], 'P') ? 'public' : 'private') |
|
... |
... |
function rg_packages_repo_page($db, $rg) |
491 |
718 |
foreach ($per_repo['list'] as $pkg_subrepo_id => $per_subrepo) { |
foreach ($per_repo['list'] as $pkg_subrepo_id => $per_subrepo) { |
492 |
719 |
$ret .= '<details open><summary>Subrepo: <b>' . rg_xss_safe($per_subrepo['info']['name']) . '</b></summary>'; |
$ret .= '<details open><summary>Subrepo: <b>' . rg_xss_safe($per_subrepo['info']['name']) . '</b></summary>'; |
493 |
720 |
foreach ($per_subrepo['list'] as $distro => $per_distro) { |
foreach ($per_subrepo['list'] as $distro => $per_distro) { |
494 |
|
$ret .= '<details open><summary>Distribution: <b>' . rg_xss_safe($per_distro['info']['distro_nice']) . '</b></summary>'; |
|
|
721 |
|
$ret .= '<details open><summary>Distribution: <b>' . rg_xss_safe($per_distro['info']['nice']) . '</b></summary>'; |
495 |
722 |
foreach ($per_distro['list'] as $major => $per_major) { |
foreach ($per_distro['list'] as $major => $per_major) { |
496 |
|
$ret .= '<details open><summary>Major version: <b>' . rg_xss_safe($major) . '</b></summary>'; |
|
|
723 |
|
$codename = rg_env_major2codename($distro, $major); |
|
724 |
|
$add = strcmp($codename, $major) == 0 ? '' : ' (' . rg_xss_safe($codename) . ')'; |
|
725 |
|
$ret .= '<details open><summary>Major version: <b>' . rg_xss_safe($major) . '</b>' . $add . '</summary>'; |
497 |
726 |
foreach ($per_major as $arch => $per_arch) { |
foreach ($per_major as $arch => $per_arch) { |
498 |
727 |
$ret .= '<details open><summary>Architecture: <b>' . rg_xss_safe($arch) . '</b></summary>'; |
$ret .= '<details open><summary>Architecture: <b>' . rg_xss_safe($arch) . '</b></summary>'; |
499 |
728 |
$ret .= $per_arch['howto']; |
$ret .= $per_arch['howto']; |
|
... |
... |
function rg_packages_high_level($db, &$rg, $paras) |
525 |
754 |
rg_log_enter('packages_high_level'); |
rg_log_enter('packages_high_level'); |
526 |
755 |
|
|
527 |
756 |
$ret = ''; |
$ret = ''; |
528 |
|
while (1) { |
|
|
757 |
|
do { |
529 |
758 |
$op = empty($paras) ? 'repo' : array_shift($paras); |
$op = empty($paras) ? 'repo' : array_shift($paras); |
530 |
759 |
$rg['menu2']['packages'] = array($op => 1); |
$rg['menu2']['packages'] = array($op => 1); |
531 |
760 |
|
|
|
... |
... |
function rg_packages_high_level($db, &$rg, $paras) |
545 |
774 |
|
|
546 |
775 |
$rg['HTML:menu_level2'] = |
$rg['HTML:menu_level2'] = |
547 |
776 |
rg_template('user/settings/packages/menu.html', $rg, TRUE /*xss*/); |
rg_template('user/settings/packages/menu.html', $rg, TRUE /*xss*/); |
548 |
|
|
|
549 |
|
break; |
|
550 |
|
} |
|
|
777 |
|
} while (0); |
551 |
778 |
|
|
552 |
779 |
rg_log_exit(); |
rg_log_exit(); |
553 |
780 |
rg_prof_end('packages_high_level'); |
rg_prof_end('packages_high_level'); |
|
... |
... |
function rg_packages_web($db, $rg, $paras, $pass) |
583 |
810 |
break; |
break; |
584 |
811 |
} |
} |
585 |
812 |
$distros = $r['tree']; |
$distros = $r['tree']; |
586 |
|
rg_log_debug('distros: ' . rg_array2string($distros)); |
|
|
813 |
|
//rg_log_debug('distros: ' . rg_array2string($distros)); |
587 |
814 |
|
|
588 |
815 |
if (!isset($distros[$a['distro']])) { |
if (!isset($distros[$a['distro']])) { |
589 |
816 |
rg_log('unsupported distro [' . $a['distro'] . ']'); |
rg_log('unsupported distro [' . $a['distro'] . ']'); |
|
... |
... |
function rg_packages_web($db, $rg, $paras, $pass) |
592 |
819 |
break; |
break; |
593 |
820 |
} |
} |
594 |
821 |
$di = $distros[$a['distro']]; |
$di = $distros[$a['distro']]; |
|
822 |
|
//rg_log_debug('di: ' . print_r($di, TRUE)); |
595 |
823 |
|
|
596 |
|
if (strcmp($di['pkg_type'], 'rpm') != 0) { |
|
597 |
|
rg_log('unsupported pkg repo type'); |
|
598 |
|
header($rg['proto'] . ' 404 unsupported pkg repo type'); |
|
599 |
|
echo 'unsupported pkg repo type' . "\n"; |
|
|
824 |
|
if (strcmp($di['pkg_type'], 'rpm') == 0) { |
|
825 |
|
$a['major'] = preg_replace('/[^0-9]/', '', @array_shift($paras)); |
|
826 |
|
$a['arch'] = preg_replace('/[^-_0-9a-zA-Z]/', '', @array_shift($paras)); |
|
827 |
|
$a['type'] = @array_shift($paras); |
|
828 |
|
$a['path'] = implode('/', $paras); |
|
829 |
|
|
|
830 |
|
rg_packages_rpm_helper($db, $rg, $a); |
600 |
831 |
break; |
break; |
601 |
832 |
} |
} |
602 |
833 |
|
|
603 |
|
$a['major'] = preg_replace('/[^0-9]/', '', @array_shift($paras)); |
|
604 |
|
$a['arch'] = preg_replace('/[^-_0-9a-zA-Z]/', '', @array_shift($paras)); |
|
605 |
|
$a['type'] = @array_shift($paras); |
|
606 |
|
$a['path'] = implode('/', $paras); |
|
|
834 |
|
if (strcmp($di['pkg_type'], 'deb') == 0) { |
|
835 |
|
rg_log_debug('paras: ' . rg_array2string_short($paras)); |
|
836 |
|
$x = @array_shift($paras); |
|
837 |
|
if (strcmp($x, 'dists') == 0) { // eg dists/buster/InRelease |
|
838 |
|
$a['codename'] = @array_shift($paras); // example: 'buster' |
|
839 |
|
} else { // eg buster/pool/main/c/a/catab+rgfs_0.1_amd64.deb |
|
840 |
|
$a['codename'] = $x; |
|
841 |
|
} |
|
842 |
|
$a['path'] = implode('/', $paras); |
|
843 |
|
|
|
844 |
|
rg_packages_deb_helper($db, $rg, $a); |
|
845 |
|
break; |
|
846 |
|
} |
607 |
847 |
|
|
608 |
|
rg_packages_rpm_helper($db, $rg, $a); |
|
|
848 |
|
rg_log('unsupported pkg repo type'); |
|
849 |
|
header($rg['proto'] . ' 404 unsupported pkg repo type'); |
|
850 |
|
echo 'unsupported pkg repo type' . "\n"; |
609 |
851 |
} while (0); |
} while (0); |
610 |
852 |
|
|
611 |
853 |
rg_log_exit(); |
rg_log_exit(); |
File inc/user/packages_deb.inc.php added (mode: 100644) (index 0000000..580521b) |
|
1 |
|
<?php |
|
2 |
|
require_once(__DIR__ . '/../events.inc.php'); |
|
3 |
|
require_once(__DIR__ . '/../mime.inc.php'); |
|
4 |
|
require_once(__DIR__ . '/../rgfs.inc.php'); |
|
5 |
|
require_once(__DIR__ . '/packages_core.inc.php'); |
|
6 |
|
|
|
7 |
|
/* |
|
8 |
|
* Event functions |
|
9 |
|
*/ |
|
10 |
|
//$_f = array( |
|
11 |
|
// 'pkg_generate_dotrepo_deb_callback' => 'rg_pkg_event_generate_dotrepo_deb_callback', |
|
12 |
|
// 'pkg_generate_dotrepo_deb' => 'rg_pkg_event_generate_dotrepo_deb' |
|
13 |
|
//); |
|
14 |
|
//rg_event_register_functions($_f); |
|
15 |
|
|
|
16 |
|
/* |
|
17 |
|
* This is called after a push and before sendint the job to a builder |
|
18 |
|
*/ |
|
19 |
|
function rg_pkg_prepare_for_build_deb($db, &$a) |
|
20 |
|
{ |
|
21 |
|
rg_log_enter('pkg_prepare_for_build_deb'); |
|
22 |
|
|
|
23 |
|
$ret = array('ok' => 0); |
|
24 |
|
do { |
|
25 |
|
$ret['ok'] = 1; |
|
26 |
|
} while (0); |
|
27 |
|
|
|
28 |
|
rg_log_exit(); |
|
29 |
|
return $ret; |
|
30 |
|
} |
|
31 |
|
|
|
32 |
|
/* |
|
33 |
|
* Called from rg_pkg_event_build_done |
|
34 |
|
*/ |
|
35 |
|
function rg_pkg_after_build_deb($db, $ev) |
|
36 |
|
{ |
|
37 |
|
rg_log_enter('pkg_after_build_deb'); |
|
38 |
|
rg_log_debug('ev: ' . rg_array2string_short($ev)); |
|
39 |
|
|
|
40 |
|
$ret = array('ok' => 0); |
|
41 |
|
do { |
|
42 |
|
// Clean not needed stuff |
|
43 |
|
unset($ev['head']); |
|
44 |
|
unset($ev['repo_name']); unset($ev['repo_name_allowed']); |
|
45 |
|
unset($ev['repo_username']); unset($ev['repo_username_allowed']); |
|
46 |
|
|
|
47 |
|
$req = $ev['job']['request']; |
|
48 |
|
$s = $ev['status']; |
|
49 |
|
|
|
50 |
|
$ei = rg_env_info($req['env']); |
|
51 |
|
|
|
52 |
|
// First, we deal with user pkg repos (debs are signed with user key) |
|
53 |
|
foreach ($req['pkg_subrepos'] as $pkg_subrepo_id => $junk) { |
|
54 |
|
rg_log_debug('pkg_subrepo_id ' . $pkg_subrepo_id); |
|
55 |
|
|
|
56 |
|
// Dirty repos can be the global ones only // TODO: can happen? |
|
57 |
|
if (in_array($pkg_subrepo_id, $s['pkg_subrepo_dirty'])) { |
|
58 |
|
rg_log_debug('subrepo is marked dirty, skip this step'); |
|
59 |
|
continue; |
|
60 |
|
} |
|
61 |
|
|
|
62 |
|
$sri = rg_pkg_subrepo_info($db, $req['uid'], $pkg_subrepo_id); |
|
63 |
|
if ($sri['exists'] != 1) { |
|
64 |
|
$ret['errmsg'] = $sri['errmsg']; |
|
65 |
|
break; |
|
66 |
|
} |
|
67 |
|
|
|
68 |
|
$ri = rg_pkg_repo_info($db, $req['uid'], $sri['pkg_repo_id']); |
|
69 |
|
if ($ri['exists'] != 1) { |
|
70 |
|
$ret['errmsg'] = $ri['errmsg']; |
|
71 |
|
break; |
|
72 |
|
} |
|
73 |
|
|
|
74 |
|
$repo_dir = '/var/lib/rocketgit/pkg_repos' |
|
75 |
|
. '/' . $ri['id']; |
|
76 |
|
$subrepo_dir = $repo_dir |
|
77 |
|
. '/' . $pkg_subrepo_id; |
|
78 |
|
$distro_dir = $ei['distro'] . '/' . $ei['codename']; |
|
79 |
|
$dir = $subrepo_dir . '/' . $distro_dir; |
|
80 |
|
|
|
81 |
|
$r = rg_gpg_save_public_kr($dir . '/keyring.gpg', |
|
82 |
|
$ri['gpg_pub_key']); |
|
83 |
|
if ($r['ok'] != 1) { |
|
84 |
|
$ret['errmsg'] = $r['errmsg']; |
|
85 |
|
break; |
|
86 |
|
} |
|
87 |
|
|
|
88 |
|
rg_log_debug('TODO job[id]=' . $ev['job']['id'] . ' req[orig_job_id]=' . $req['orig_job_id']); |
|
89 |
|
$r = rg_packages_deb_repo_update($db, $subrepo_dir, |
|
90 |
|
$distro_dir, $ei['codename'], $req['orig_job_id'], |
|
91 |
|
$ev['job']['repo_id'], $req['env'], $ri, $sri); |
|
92 |
|
if ($r['ok'] != 1) { |
|
93 |
|
$ret['errmsg'] = $r['errmsg']; |
|
94 |
|
break; |
|
95 |
|
} |
|
96 |
|
|
|
97 |
|
// Mark the environment as 'available' |
|
98 |
|
$di = array($req['env'] => array('has_packages' => 1)); |
|
99 |
|
$r = rg_pkg_subrepo_update_distro_info($db, |
|
100 |
|
$req['uid'], $pkg_subrepo_id, $di); |
|
101 |
|
if ($r['ok'] != 1) { |
|
102 |
|
$ret['errmsg'] = $r['errmsg']; |
|
103 |
|
break; |
|
104 |
|
} |
|
105 |
|
} |
|
106 |
|
if (isset($ret['errmsg'])) |
|
107 |
|
break; |
|
108 |
|
|
|
109 |
|
if (empty($s['pkg_subrepo_dirty'])) { |
|
110 |
|
$ret['ok'] = 1; |
|
111 |
|
break; |
|
112 |
|
} |
|
113 |
|
|
|
114 |
|
// Now, we deal with pkg repositories which need .deb signing |
|
115 |
|
|
|
116 |
|
$a = array(); |
|
117 |
|
$a['worker_must_be_global'] = 1; // for security reasons |
|
118 |
|
$a['exec'] = array(); |
|
119 |
|
$a['source'] = 'pkg_after_build_deb'; |
|
120 |
|
$a['uid'] = 0; |
|
121 |
|
$a['repo_id'] = $req['repo_id']; |
|
122 |
|
$a['repo_uid'] = $req['repo_uid']; |
|
123 |
|
$a['repo_username'] = $req['repo_username']; |
|
124 |
|
$a['head'] = $req['head']; |
|
125 |
|
$a['orig_job_id'] = $req['orig_job_id']; |
|
126 |
|
$a['log_sid'] = $req['log_sid']; |
|
127 |
|
$a['pkg_subrepo_id_list'] = $s['pkg_subrepo_dirty']; |
|
128 |
|
$a['env'] = $req['env']; |
|
129 |
|
$a['build_repo_id'] = $req['build_repo_id']; // this is NOT a meta repo operation like on rpm |
|
130 |
|
|
|
131 |
|
$r = rg_pkg_prepare_for_build($db, $a); |
|
132 |
|
if ($r['ok'] != 1) { |
|
133 |
|
$ret['errmsg'] = $r['errmsg']; |
|
134 |
|
break; |
|
135 |
|
} |
|
136 |
|
|
|
137 |
|
$ret['ok'] = 1; |
|
138 |
|
} while (0); |
|
139 |
|
|
|
140 |
|
rg_log_exit(); |
|
141 |
|
return $ret; |
|
142 |
|
} |
|
143 |
|
|
|
144 |
|
/* |
|
145 |
|
* Helper for 'packages_deb' |
|
146 |
|
*/ |
|
147 |
|
function rg_packages_deb_helper($db, $rg, $a) |
|
148 |
|
{ |
|
149 |
|
rg_log_enter('packages_deb_helper'); |
|
150 |
|
rg_log_debug('a: ' . print_r($a, TRUE)); |
|
151 |
|
|
|
152 |
|
do { |
|
153 |
|
if (!empty($a['username'])) { |
|
154 |
|
$ui = rg_user_info($db, 0, $a['username'], ''); |
|
155 |
|
if ($ui['exists'] != 1) { |
|
156 |
|
rg_log('invalid user ' . $a['username']); |
|
157 |
|
header($rg['proto'] . ' 404 Not found'); |
|
158 |
|
echo 'invalid user' . "\n"; |
|
159 |
|
break; |
|
160 |
|
} |
|
161 |
|
$uid = $ui['uid']; |
|
162 |
|
} else { |
|
163 |
|
$uid = 0; |
|
164 |
|
} |
|
165 |
|
|
|
166 |
|
// TODO: this must be in generic code; but we may be missing user? |
|
167 |
|
$ri = rg_pkg_repo_info_by_name($db, $uid, $a['pkg_repo_name']); |
|
168 |
|
if ($ri['exists'] != 1) { |
|
169 |
|
rg_log('Cannot find pkg repo ' . $a['pkg_repo_name']); |
|
170 |
|
header($rg['proto'] . ' 404 Not found'); |
|
171 |
|
echo 'invalid repo' . "\n"; |
|
172 |
|
break; |
|
173 |
|
} |
|
174 |
|
|
|
175 |
|
$sri = rg_pkg_subrepo_info_by_name($db, $uid, |
|
176 |
|
$ri['id'], $a['pkg_subrepo_name']); |
|
177 |
|
if ($sri['exists'] != 1) { |
|
178 |
|
rg_log('Cannot find pkg subrepo ' . $a['pkg_subrepo_name']); |
|
179 |
|
header($rg['proto'] . ' 404 Not found'); |
|
180 |
|
echo 'invalid subrepo' . "\n"; |
|
181 |
|
break; |
|
182 |
|
} |
|
183 |
|
|
|
184 |
|
// TODO: should be this in generic code? |
|
185 |
|
if (!strstr($ri['flags'], 'P')) { // pkg repo is private |
|
186 |
|
if (!rg_pkg_has_rights($db, $ri, 'A')) { |
|
187 |
|
if (strcmp($a['sent_pass'], $ri['password']) != 0) { |
|
188 |
|
rg_log('provided password is not correct!'); |
|
189 |
|
header($rg['proto'] . ' 404 Not found'); |
|
190 |
|
echo 'pkg repository not found or you do not' |
|
191 |
|
. ' have access' . "\n"; |
|
192 |
|
break; |
|
193 |
|
} |
|
194 |
|
} |
|
195 |
|
} |
|
196 |
|
|
|
197 |
|
$subrepo_dir = '/var/lib/rocketgit/pkg_repos' |
|
198 |
|
. '/' . $ri['id'] |
|
199 |
|
. '/' . $sri['id']; |
|
200 |
|
$distro_dir = $a['distro'] . '/' . $a['codename']; |
|
201 |
|
rg_log_debug('subrepo_dir=' . $subrepo_dir); |
|
202 |
|
rg_log_debug('distro_dir=' . $distro_dir); |
|
203 |
|
$dir = $subrepo_dir . '/' . $distro_dir; |
|
204 |
|
|
|
205 |
|
if ($ri['uid'] == 0) { |
|
206 |
|
$type_and_owner = 'main'; |
|
207 |
|
$global_and_user = 'global'; |
|
208 |
|
} else { |
|
209 |
|
rg_pkg_repo_cosmetic($db, $ri); |
|
210 |
|
$type_and_owner = 'user/' . $ri['owner']; |
|
211 |
|
$global_and_user = 'user-' . $ri['owner']; |
|
212 |
|
} |
|
213 |
|
|
|
214 |
|
if (strcmp($a['path'], 'keyring') == 0) { |
|
215 |
|
$f = @file_get_contents($dir . '/keyring.gpg'); |
|
216 |
|
if ($f === FALSE) { |
|
217 |
|
rg_log('Cannot load key file: ' . rg_php_err()); |
|
218 |
|
header($rg['proto'] . ' 500 Internal server error'); |
|
219 |
|
echo 'error loading key file' . "\n"; |
|
220 |
|
break; |
|
221 |
|
} |
|
222 |
|
$len = strlen($f); |
|
223 |
|
$file = 'rocketgit-' . $global_and_user . '-' . $ri['name'] . '.gpg'; |
|
224 |
|
|
|
225 |
|
header('Content-Length: ' . $len); |
|
226 |
|
header('Content-Type: application/octet-stream'); |
|
227 |
|
header('Content-Disposition: attachment; filename="' . $file . '"'); // TODO: escape |
|
228 |
|
echo $f; |
|
229 |
|
|
|
230 |
|
rg_stats_conns_set('bytes_out', $len); |
|
231 |
|
break; |
|
232 |
|
} else if (strcmp($a['path'], 'auth') == 0) { |
|
233 |
|
$url = rg_base_url($db, '', '') |
|
234 |
|
. '/op/pkgrepo' |
|
235 |
|
. '/' . $type_and_owner |
|
236 |
|
. '/' . $ri['name']; |
|
237 |
|
$url = str_replace('http://', '', $url); |
|
238 |
|
$url = str_replace('https://', '', $url); |
|
239 |
|
$f = 'machine ' . $url . ' login rg password ' . $ri['password']; |
|
240 |
|
$len = strlen($f); |
|
241 |
|
$file = 'rocketgit-' . $global_and_user . '-' . $ri['name'] . '.conf'; |
|
242 |
|
|
|
243 |
|
header('Content-Length: ' . $len); |
|
244 |
|
header('Content-Type: text/plain'); |
|
245 |
|
header('Content-Disposition: attachment; filename="' . $file . '"'); // TODO: escape |
|
246 |
|
echo $f; |
|
247 |
|
|
|
248 |
|
rg_stats_conns_set('bytes_out', $len); |
|
249 |
|
break; |
|
250 |
|
} |
|
251 |
|
|
|
252 |
|
// TODO: this function should return the size to not do an extra stat |
|
253 |
|
$r = rg_path_validate($dir, $a['path']); |
|
254 |
|
if ($r === FALSE) { |
|
255 |
|
rg_security_violation_no_exit('path=' . $a['path']); |
|
256 |
|
header($rg['proto'] . ' 404 Not found'); |
|
257 |
|
echo 'invalid file' . "\n"; |
|
258 |
|
break; |
|
259 |
|
} |
|
260 |
|
|
|
261 |
|
$s = @stat($dir . '/' . $a['path']); |
|
262 |
|
if ($s === FALSE) { |
|
263 |
|
rg_log('Cannot stat file: ' . rg_php_err()); |
|
264 |
|
header($rg['proto'] . ' 500 Internal server error'); |
|
265 |
|
echo 'missing file' . "\n"; |
|
266 |
|
break; |
|
267 |
|
} |
|
268 |
|
|
|
269 |
|
header('Content-Length: ' . $s['size']); |
|
270 |
|
|
|
271 |
|
$ext = strrchr($a['path'], '.'); |
|
272 |
|
$ct = rg_content_type_by_ext($ext); |
|
273 |
|
header('Content-Type: ' . $ct); |
|
274 |
|
$r = @readfile($dir . '/' . $a['path']); |
|
275 |
|
|
|
276 |
|
if ($r === FALSE) { |
|
277 |
|
rg_log('Cannot send file: ' . rg_php_err()); |
|
278 |
|
header($rg['proto'] . ' 404 Not found'); |
|
279 |
|
echo 'missing file' . "\n"; |
|
280 |
|
break; |
|
281 |
|
} |
|
282 |
|
|
|
283 |
|
rg_stats_conns_set('bytes_out', $r); |
|
284 |
|
} while (0); |
|
285 |
|
|
|
286 |
|
rg_log_exit(); |
|
287 |
|
} |
|
288 |
|
|
|
289 |
|
/* |
|
290 |
|
* Builds a link to a pkg repo |
|
291 |
|
*/ |
|
292 |
|
function rg_packages_deb_get_link($db, $a) |
|
293 |
|
{ |
|
294 |
|
//rg_log_debug('get_link: a: ' . rg_array2string($a)); |
|
295 |
|
|
|
296 |
|
$ret = array(); |
|
297 |
|
|
|
298 |
|
// Both pkg repo and subrepo names cannot contain '+' and '-'. |
|
299 |
|
|
|
300 |
|
if ($a['pkg_repo_info']['uid'] == 0) |
|
301 |
|
$type_and_owner = 'main'; |
|
302 |
|
else |
|
303 |
|
$type_and_owner = 'user/' . $a['pkg_repo_info']['owner']; |
|
304 |
|
|
|
305 |
|
$x = rg_base_url($db, '', '') |
|
306 |
|
. '/op/pkgrepo' |
|
307 |
|
. '/' . $type_and_owner |
|
308 |
|
. '/' . $a['pkg_repo_info']['name'] |
|
309 |
|
. '/' . $a['pkg_subrepo_info']['name'] |
|
310 |
|
. '/' . $a['distro']; |
|
311 |
|
|
|
312 |
|
$ret['keyring_url'] = $x . '/' . $a['codename'] . '/keyring'; |
|
313 |
|
$ret['auth_url'] = $x . '/' . $a['codename'] . '/auth'; |
|
314 |
|
$ret['repo_url'] = $x; |
|
315 |
|
$ret['repo_codename'] = $a['codename']; |
|
316 |
|
$ret['repo_components'] = 'main'; |
|
317 |
|
|
|
318 |
|
return $ret; |
|
319 |
|
} |
|
320 |
|
|
|
321 |
|
/* |
|
322 |
|
* Instructions on how to install a package |
|
323 |
|
* TODO: Showing the details of other packages versions has no place here! |
|
324 |
|
*/ |
|
325 |
|
function rg_packages_deb_howto($a, $user, $repo_name, $meta) |
|
326 |
|
{ |
|
327 |
|
//rg_log_debug('packages_deb_howto: a: ' . rg_array2string_short($a)); |
|
328 |
|
//rg_log_debug('packages_deb_howto: meta: ' . rg_array2string_short($meta)); |
|
329 |
|
|
|
330 |
|
$private = !strstr($a['pkg_repo_info']['flags'], 'P'); |
|
331 |
|
|
|
332 |
|
$pkg_list = array(); |
|
333 |
|
$src_pkg_list = array(); |
|
334 |
|
$debug_pkg_list = array(); |
|
335 |
|
$other = ''; |
|
336 |
|
if ($meta !== FALSE) { |
|
337 |
|
$other .= "\n"; |
|
338 |
|
$other .= '<details><summary>Details about all versions</summary>' . "\n"; |
|
339 |
|
$other .= '<table><tr><th>Name</th><th>Size</th><th>Head</th><th>Date (UTC)</th>'; |
|
340 |
|
if ($a['can_see_details'] == 1) |
|
341 |
|
$other .= '<th>Job</th><th>Worker</th><th>Copies</th>'; |
|
342 |
|
$other .= '</tr>' . "\n"; |
|
343 |
|
foreach ($meta as $f => $i) { |
|
344 |
|
$other .= '<tr><td>' . rg_xss_safe($f) . '</td>' |
|
345 |
|
. '<td>' . $i['size_nice'] . '</td>'; |
|
346 |
|
|
|
347 |
|
$other .= '<td>' . $i['head_link'] . '</td>' |
|
348 |
|
. '<td>' . gmdate('Y-m-d H:i', $i['ctime']) . '</td>'; |
|
349 |
|
|
|
350 |
|
if ($a['can_see_details'] == 1) |
|
351 |
|
$other .= '<td>' . rg_xss_safe($i['job_id']) . '</td>' |
|
352 |
|
. '<td>' . rg_xss_safe($i['worker_name']) . '</td>' |
|
353 |
|
. '<td>' . $i['nlink'] . '</td>'; |
|
354 |
|
|
|
355 |
|
$other .= '</tr>' . "\n"; |
|
356 |
|
|
|
357 |
|
if (isset($i['source_pkg_name'])) { |
|
358 |
|
$src_pkg_list[] = array('name' => $i['source_pkg_name']); |
|
359 |
|
} else if (isset($i['real_pkg_name'])) { |
|
360 |
|
$last7 = substr($i['real_pkg_name'], -7); |
|
361 |
|
if (strcmp($last7, '-dbgsym') == 0) |
|
362 |
|
$debug_pkg_list[] = array('name' => $i['real_pkg_name']); |
|
363 |
|
else |
|
364 |
|
$pkg_list[] = array('name' => $i['real_pkg_name']); |
|
365 |
|
} |
|
366 |
|
} |
|
367 |
|
$other .= '</table>'; |
|
368 |
|
$other .= '</details>'; |
|
369 |
|
} |
|
370 |
|
|
|
371 |
|
$rg = array(); |
|
372 |
|
|
|
373 |
|
$global_and_user = ($a['pkg_repo_info']['uid'] == 0) ? '' : ('user-' . $user . '-'); |
|
374 |
|
|
|
375 |
|
// Seems I cannot use '+' (.list file is ignored) |
|
376 |
|
$a['list_file'] = $global_and_user |
|
377 |
|
. $a['pkg_repo_info']['name'] |
|
378 |
|
. '-' . $a['pkg_subrepo_info']['name']; |
|
379 |
|
$a['auth_file'] = $global_and_user . $a['pkg_repo_info']['name']; |
|
380 |
|
$a['gpg_file'] = $global_and_user . $a['pkg_repo_info']['name']; |
|
381 |
|
$a['user'] = $user; |
|
382 |
|
$a['repo_name'] = $repo_name; |
|
383 |
|
$a['cmd'] = 'apt install'; // TODO: move this in distro array! |
|
384 |
|
$a['src_cmd'] = 'apt source'; // TODO: move this in distro array! |
|
385 |
|
$a['HTML:other'] = $other; |
|
386 |
|
$rg['pkg'] = $a; |
|
387 |
|
|
|
388 |
|
$rg['HTML:pkg_list'] = rg_template_table('user/pkg/deb/pkg_list', $pkg_list, $rg); |
|
389 |
|
$rg['HTML:src_pkg_list'] = rg_template_table('user/pkg/deb/src_pkg_list', |
|
390 |
|
$src_pkg_list, $rg); |
|
391 |
|
$rg['HTML:debug_pkg_list'] = rg_template_table('user/pkg/deb/debug_pkg_list', |
|
392 |
|
$debug_pkg_list, $rg); |
|
393 |
|
|
|
394 |
|
$howto = rg_template('user/pkg/deb/add_repo_howto.html', $rg, TRUE /*xss*/); |
|
395 |
|
$rg['HTML:add_repo_howto'] = trim($howto); |
|
396 |
|
|
|
397 |
|
if ($private) { |
|
398 |
|
// We cannot do it like with the private pkg repo. |
|
399 |
|
// We do not want to put the password on the screen. |
|
400 |
|
return rg_template('user/pkg/deb/priv_download.html', |
|
401 |
|
$rg, TRUE /*xss*/); |
|
402 |
|
} else { |
|
403 |
|
return rg_template('user/pkg/deb/pub_download.html', |
|
404 |
|
$rg, TRUE /*xss*/); |
|
405 |
|
} |
|
406 |
|
} |
|
407 |
|
|
|
408 |
|
/* |
|
409 |
|
* Saves a debian file |
|
410 |
|
*/ |
|
411 |
|
// TODO - do we need to sort it? |
|
412 |
|
function rg_deb_save($dst, $a) |
|
413 |
|
{ |
|
414 |
|
rg_log_enter('deb_save: dst=' . $dst); |
|
415 |
|
|
|
416 |
|
$ret = array('ok' => 0); |
|
417 |
|
do { |
|
418 |
|
$c = ''; |
|
419 |
|
$add_pi = ''; |
|
420 |
|
foreach ($a as $pkg => $pi) { |
|
421 |
|
$c .= $add_pi; |
|
422 |
|
foreach ($pi as $k => $v) { |
|
423 |
|
//rg_log_debug('k ' . $k . ' v:' . print_r($v, TRUE)); |
|
424 |
|
$c .= $k . ':'; |
|
425 |
|
if (is_array($v)) { |
|
426 |
|
$add = ' '; |
|
427 |
|
foreach ($v as $line) { |
|
428 |
|
if (!empty($line)) |
|
429 |
|
$c .= $add . $line; |
|
430 |
|
$add = "\n" . ' '; |
|
431 |
|
} |
|
432 |
|
} else { |
|
433 |
|
$c .= ' ' . $v; |
|
434 |
|
} |
|
435 |
|
$c .= "\n"; |
|
436 |
|
} |
|
437 |
|
|
|
438 |
|
$add_pi = "\n"; |
|
439 |
|
} |
|
440 |
|
|
|
441 |
|
$r = @file_put_contents($dst, $c); |
|
442 |
|
if ($r === FALSE) { |
|
443 |
|
$ret['errmsg'] = 'cannot save'; |
|
444 |
|
break; |
|
445 |
|
} |
|
446 |
|
|
|
447 |
|
$ret['size'] = strlen($c); |
|
448 |
|
$ret['sha256'] = hash('sha256', $c); |
|
449 |
|
$ret['ok'] = 1; |
|
450 |
|
} while (0); |
|
451 |
|
|
|
452 |
|
rg_log_exit(); |
|
453 |
|
return $ret; |
|
454 |
|
} |
|
455 |
|
|
|
456 |
|
/* |
|
457 |
|
* Loads a debian 'key: value file |
|
458 |
|
*/ |
|
459 |
|
function rg_deb_load($f) |
|
460 |
|
{ |
|
461 |
|
$ret = array('ok' => 0, 'c' => array()); |
|
462 |
|
do { |
|
463 |
|
$c = @file_get_contents($f); |
|
464 |
|
if ($c === FALSE) { |
|
465 |
|
$ret['errmsg'] = 'cannot load file'; |
|
466 |
|
break; |
|
467 |
|
} |
|
468 |
|
|
|
469 |
|
$e = explode("\n", $c); |
|
470 |
|
foreach ($e as $line) { |
|
471 |
|
if (empty($line)) |
|
472 |
|
continue; |
|
473 |
|
|
|
474 |
|
if (strncmp($line, ' ', 1) == 0) { // continuation |
|
475 |
|
if (!is_array($ret['c'][$prev_k])) |
|
476 |
|
$ret['c'][$prev_k] = array($ret['c'][$prev_k]); |
|
477 |
|
$ret['c'][$prev_k][] = substr($line, 1); |
|
478 |
|
continue; |
|
479 |
|
} |
|
480 |
|
$p = explode(':', $line, 2); |
|
481 |
|
if (!isset($p[1])) { |
|
482 |
|
rg_log_debug(' line without : [' . $line . ']'); |
|
483 |
|
continue; |
|
484 |
|
} |
|
485 |
|
$k = rtrim($p[0]); |
|
486 |
|
$ret['c'][$k] = ltrim($p[1]); |
|
487 |
|
$prev_k = $k; |
|
488 |
|
} |
|
489 |
|
|
|
490 |
|
$ret['ok'] = 1; |
|
491 |
|
} while (0); |
|
492 |
|
|
|
493 |
|
return $ret; |
|
494 |
|
} |
|
495 |
|
|
|
496 |
|
/* |
|
497 |
|
* Creates/updates a Debian repository subdir (source, binary-amd64 etc.) |
|
498 |
|
* ri and sri seems to not be used! |
|
499 |
|
*/ |
|
500 |
|
function rg_packages_deb_repo_update_subdir($subrepo_dir, $distro_dir, |
|
501 |
|
$subdir, $codename, $job_id, $repo_id, $env) |
|
502 |
|
{ |
|
503 |
|
rg_log_enter('packages_deb_repo_update_subdir: job_id=' . $job_id |
|
504 |
|
. ' subdir=' . $subdir); |
|
505 |
|
|
|
506 |
|
$ret = array('ok' => 0, 'files_changed' => array()); |
|
507 |
|
do { |
|
508 |
|
rg_log_debug('subrepo_dir=' . $subrepo_dir); |
|
509 |
|
rg_log_debug('distro_dir=' . $distro_dir); |
|
510 |
|
|
|
511 |
|
$dir = $subrepo_dir . '/' . $distro_dir; |
|
512 |
|
|
|
513 |
|
$s = $dir . '/main/' . $subdir; |
|
514 |
|
$pool = $dir . '/pool/main'; |
|
515 |
|
$jd = $s . '/+pending/' . $job_id; |
|
516 |
|
|
|
517 |
|
// Check +pending dir and integrate it |
|
518 |
|
if (!is_dir($s . '/+pending/' . $job_id)) { |
|
519 |
|
rg_log_debug('+pending dir not found'); |
|
520 |
|
$ret['ok'] = 1; |
|
521 |
|
break; |
|
522 |
|
} |
|
523 |
|
|
|
524 |
|
// Creating Release file |
|
525 |
|
// We regenerate it any time to generate the hash |
|
526 |
|
$f = $s . '/Release'; |
|
527 |
|
$arch = str_replace('binary-', '', $subdir); |
|
528 |
|
|
|
529 |
|
$c = '' |
|
530 |
|
. 'Archive: stable' . "\n" |
|
531 |
|
. 'Origin: RocketGit' . "\n" |
|
532 |
|
. 'Label: RocketGit' . "\n" |
|
533 |
|
. 'Version: 1' . "\n" |
|
534 |
|
. 'Component: main' . "\n" |
|
535 |
|
. 'Architecture: ' . $arch . "\n"; |
|
536 |
|
$r = rg_save_plain($f, $c); |
|
537 |
|
if ($r === FALSE) { |
|
538 |
|
$ret['errmsg'] = 'cannot save Release file'; |
|
539 |
|
break; |
|
540 |
|
} |
|
541 |
|
|
|
542 |
|
$k = $subdir . '/Release'; |
|
543 |
|
$ret['files_changed'][$k] = array( |
|
544 |
|
'sha256' => hash('sha256', $c), |
|
545 |
|
'size' => strlen($c) |
|
546 |
|
); |
|
547 |
|
|
|
548 |
|
// list.json is used to keep the information about the packages |
|
549 |
|
// to be able to generate Sources/Packages files. |
|
550 |
|
if (file_exists($s . '/list.json')) { |
|
551 |
|
$r = @file_get_contents($s . '/list.json'); |
|
552 |
|
if ($r === FALSE) { |
|
553 |
|
$ret['errmsg'] = 'cannot load list.json'; |
|
554 |
|
break; |
|
555 |
|
} |
|
556 |
|
$list = @json_decode($r, TRUE, 20); |
|
557 |
|
if (empty($list)) { |
|
558 |
|
$ret['errmsg'] = 'error loading json'; |
|
559 |
|
break; |
|
560 |
|
} |
|
561 |
|
} else { |
|
562 |
|
$list = array(); |
|
563 |
|
} |
|
564 |
|
|
|
565 |
|
if (strcmp($subdir, 'source') == 0) { |
|
566 |
|
// Info is loaded from .dsc files |
|
567 |
|
$si = $s . '/Sources'; |
|
568 |
|
$si_short = $subdir . '/Sources'; |
|
569 |
|
$ext = '.*\.dsc$'; |
|
570 |
|
} else { |
|
571 |
|
$si = $s . '/Packages'; |
|
572 |
|
$si_short = $subdir . '/Packages'; |
|
573 |
|
$ext = '.*\.deb$'; |
|
574 |
|
} |
|
575 |
|
|
|
576 |
|
$to_add_remove = array(); |
|
577 |
|
$to_delete = array(); |
|
578 |
|
|
|
579 |
|
$r = rg_dir_load_pattern($jd, $ext); |
|
580 |
|
if ($r === FALSE) { |
|
581 |
|
$ret['errmsg'] = 'cannot load +pending/job_id files'; |
|
582 |
|
break; |
|
583 |
|
} |
|
584 |
|
//rg_log_debug('files matching [' . $ext . ']: ' . print_r($r, TRUE)); |
|
585 |
|
|
|
586 |
|
foreach ($r as $f) { |
|
587 |
|
rg_log_debug('f: ' . $f); |
|
588 |
|
|
|
589 |
|
$u1 = substr($f, 0, 1); |
|
590 |
|
$u2 = substr($f, 1, 1); |
|
591 |
|
$d = $pool . '/' . $u1 . '/' . $u2; |
|
592 |
|
|
|
593 |
|
// Loading control file |
|
594 |
|
if (strcmp($subdir, 'source') == 0) { |
|
595 |
|
$r = rg_deb_load($jd . '/' . $f); |
|
596 |
|
} else { |
|
597 |
|
$r = rg_deb_load($jd . '/' . $f . 'c'); // .debc file |
|
598 |
|
|
|
599 |
|
$to_add_remove[] = array( |
|
600 |
|
'root' => $subrepo_dir, |
|
601 |
|
'del' => rg_dir_cut($jd, $subrepo_dir) . '/' . $f . 'c', |
|
602 |
|
'repo_id' => $repo_id); |
|
603 |
|
} |
|
604 |
|
if ($r['ok'] != 1) { |
|
605 |
|
$ret['errmsg'] = 'cannot load control file for ' . $f; |
|
606 |
|
continue; |
|
607 |
|
} |
|
608 |
|
$c = $r['c']; |
|
609 |
|
//rg_log_debug('loaded control file: ' . print_r($c, TRUE)); |
|
610 |
|
|
|
611 |
|
// Unset some old things |
|
612 |
|
unset($c['Checksums-Sha1']); |
|
613 |
|
|
|
614 |
|
$a = array(); |
|
615 |
|
$meta = array('env' => $env); |
|
616 |
|
if (strcmp($subdir, 'source') == 0) { |
|
617 |
|
$a['Package'] = $c['Source']; |
|
618 |
|
$a['Directory'] = $codename . '/pool/main/' . $u1 . '/' . $u2; |
|
619 |
|
} else { |
|
620 |
|
$a['Package'] = $c['Package']; |
|
621 |
|
$a['Filename'] = $codename . '/pool/main/' . $u1 . '/' . $u2 . '/' . $f; |
|
622 |
|
$meta['real_pkg_name'] = $c['Package']; // this is used in 'apt instal ...' |
|
623 |
|
} |
|
624 |
|
|
|
625 |
|
$l = array('Version', 'Maintainer', |
|
626 |
|
'Architecture', 'Description', |
|
627 |
|
'Homepage', 'Section', 'Priority'); |
|
628 |
|
|
|
629 |
|
// TODO: Description: is missing from force-bind, but in Sources-big it exists. |
|
630 |
|
if (strcmp($subdir, 'source') == 0) { |
|
631 |
|
$l[] = 'Binary'; |
|
632 |
|
$l[] = 'Build-Depends'; |
|
633 |
|
$l[] = 'Standards-Version'; |
|
634 |
|
$l[] = 'Format'; |
|
635 |
|
$l[] = 'Files'; |
|
636 |
|
$l[] = 'Vcs-Browser'; |
|
637 |
|
$l[] = 'Vcs-Git'; |
|
638 |
|
$l[] = 'Checksums-Sha256'; |
|
639 |
|
|
|
640 |
|
foreach ($l as $k) |
|
641 |
|
if (isset($c[$k])) |
|
642 |
|
$a[$k] = $c[$k]; |
|
643 |
|
|
|
644 |
|
$a['Priority'] = 'source'; |
|
645 |
|
|
|
646 |
|
// Add .dsc file to the 'Sources' file (sh256) |
|
647 |
|
$r = rg_hash_load('sha256', $jd . '/' . $f); |
|
648 |
|
if ($r['ok'] != 1) { |
|
649 |
|
$ret['errmsg'] = $r['errmsg']; |
|
650 |
|
break; |
|
651 |
|
} |
|
652 |
|
$a['Checksums-Sha256'][] = $r['hash'] . ' ' . $r['size'] . ' ' . $f; |
|
653 |
|
|
|
654 |
|
// We must move all listed files (before adding .dsc file) |
|
655 |
|
foreach ($a['Checksums-Sha256'] as $_line) { |
|
656 |
|
$_line = trim($_line); |
|
657 |
|
if (empty($_line)) |
|
658 |
|
continue; |
|
659 |
|
|
|
660 |
|
$meta2 = $meta; |
|
661 |
|
$_ext = substr($_line, -4); |
|
662 |
|
if (strcmp($_ext, '.dsc') == 0) |
|
663 |
|
$meta2['source_pkg_name'] = $a['Package']; |
|
664 |
|
|
|
665 |
|
$_x = explode(' ', $_line, 3); |
|
666 |
|
$to_add_remove[] = array( |
|
667 |
|
'root' => $subrepo_dir, |
|
668 |
|
'del' => rg_dir_cut($jd, $subrepo_dir) . '/' . $_x[2], |
|
669 |
|
'add' => rg_dir_cut($d, $subrepo_dir) . '/' . $_x[2], |
|
670 |
|
'repo_id' => $repo_id, |
|
671 |
|
'meta' => $meta2); |
|
672 |
|
} |
|
673 |
|
|
|
674 |
|
// Add .dsc file to the 'Sources' file (md5) |
|
675 |
|
$r = rg_hash_load('md5', $jd . '/' . $f); |
|
676 |
|
if ($r['ok'] != 1) { |
|
677 |
|
$ret['errmsg'] = $r['errmsg']; |
|
678 |
|
break; |
|
679 |
|
} |
|
680 |
|
$a['Files'][] = $r['hash'] . ' ' . $r['size'] . ' ' . $f; |
|
681 |
|
} else { |
|
682 |
|
$l[] = 'Source'; |
|
683 |
|
$l[] = 'Depends'; |
|
684 |
|
$l[] = 'Pre-Depends'; |
|
685 |
|
$l[] = 'Installed-Size'; |
|
686 |
|
$l[] = 'Multi-Arch'; |
|
687 |
|
|
|
688 |
|
foreach ($l as $k) |
|
689 |
|
if (isset($c[$k])) |
|
690 |
|
$a[$k] = $c[$k]; |
|
691 |
|
|
|
692 |
|
$r = rg_hash_load('sha256', $jd . '/' . $f); |
|
693 |
|
if ($r['ok'] != 1) { |
|
694 |
|
$ret['errmsg'] = $r['errmsg']; |
|
695 |
|
break; |
|
696 |
|
} |
|
697 |
|
$a['SHA256'] = $r['hash']; |
|
698 |
|
$a['Size'] = $r['size']; |
|
699 |
|
|
|
700 |
|
$to_add_remove[] = array( |
|
701 |
|
'repo_id' => $repo_id, |
|
702 |
|
'root' => $subrepo_dir, |
|
703 |
|
'del' => rg_dir_cut($jd, $subrepo_dir) . '/' . $f, |
|
704 |
|
'add' => rg_dir_cut($d, $subrepo_dir) . '/' . $f, |
|
705 |
|
'meta' => $meta); |
|
706 |
|
} |
|
707 |
|
|
|
708 |
|
$list[$f] = $a; |
|
709 |
|
} |
|
710 |
|
if (isset($ret['errmsg'])) |
|
711 |
|
break; |
|
712 |
|
|
|
713 |
|
$to_delete[] = $jd; |
|
714 |
|
|
|
715 |
|
if (!empty($list)) { |
|
716 |
|
rg_log_debug('saving list: ' . print_r($list, TRUE)); |
|
717 |
|
$r = @rg_save($s . '/list.json', $list); |
|
718 |
|
if ($r === FALSE) { |
|
719 |
|
$ret['errmsg'] = 'canot save list.json'; |
|
720 |
|
break; |
|
721 |
|
} |
|
722 |
|
} |
|
723 |
|
|
|
724 |
|
// TODO: if we rename it and something crashes, we cannot recover: suffix c is present, but the deb not |
|
725 |
|
$r = rg_rgfs_add_remove($subrepo_dir, $to_add_remove, TRUE /*exec*/); |
|
726 |
|
if ($r['ok'] != 1) { |
|
727 |
|
$ret['errmsg'] = $r['errmsg']; |
|
728 |
|
break; |
|
729 |
|
} |
|
730 |
|
|
|
731 |
|
$r = rg_deb_save($si, $list); |
|
732 |
|
if ($r['ok'] != 1) { |
|
733 |
|
$ret['errmsg'] = $r['errmsg']; |
|
734 |
|
break; |
|
735 |
|
} |
|
736 |
|
$ret['files_changed'][$si_short] = array( |
|
737 |
|
'sha256' => $r['sha256'], |
|
738 |
|
'size' => $r['size'] |
|
739 |
|
); |
|
740 |
|
|
|
741 |
|
$r = rg_xz_compress($si, '--keep --force -6 --quiet'); // TODO: should we generate also the sha256? |
|
742 |
|
if ($r['ok'] != 1) { |
|
743 |
|
$ret['errmsg'] = $r['errmsg']; |
|
744 |
|
break; |
|
745 |
|
} |
|
746 |
|
$r = rg_hash_load('sha256', $si . '.xz'); |
|
747 |
|
if ($r['ok'] != 1) { |
|
748 |
|
$ret['errmsg'] = $r['errmsg']; |
|
749 |
|
break; |
|
750 |
|
} |
|
751 |
|
$ret['files_changed'][$si_short . '.xz'] = array( |
|
752 |
|
'sha256' => $r['hash'], |
|
753 |
|
'size' => $r['size'] |
|
754 |
|
); |
|
755 |
|
|
|
756 |
|
foreach ($to_delete as $i) |
|
757 |
|
rg_del_tree($i); |
|
758 |
|
|
|
759 |
|
$ret['ok'] = 1; |
|
760 |
|
} while (0); |
|
761 |
|
isset($ret['errmsg']) && rg_log_debug('ERROR: ' . $ret['errmsg']); |
|
762 |
|
|
|
763 |
|
rg_log_exit(); |
|
764 |
|
return $ret; |
|
765 |
|
} |
|
766 |
|
|
|
767 |
|
/* |
|
768 |
|
* Create InRelease(.xz) file(s) |
|
769 |
|
*/ |
|
770 |
|
function rg_packages_deb_create_inrelease($dir, $codename, $ri, $archs, |
|
771 |
|
$files_changed) |
|
772 |
|
{ |
|
773 |
|
rg_log_enter('packages_deb_create_inrelease'); |
|
774 |
|
rg_log_debug('files_changed: ' . print_r($files_changed, TRUE)); |
|
775 |
|
|
|
776 |
|
$ret = array('ok' => 0); |
|
777 |
|
do { |
|
778 |
|
// Loading info about files, if exists |
|
779 |
|
$files = array(); |
|
780 |
|
while (file_exists($dir . '/InRelease.json')) { |
|
781 |
|
if (empty($files_changed)) { |
|
782 |
|
rg_log_debug('no file changed, skip'); |
|
783 |
|
$ret['ok'] = 1; |
|
784 |
|
break; |
|
785 |
|
} |
|
786 |
|
|
|
787 |
|
$c = @file_get_contents($dir . '/InRelease.json'); |
|
788 |
|
if ($c !== FALSE) { |
|
789 |
|
$files = @json_decode($c, TRUE, 20); |
|
790 |
|
if (!empty($files)) |
|
791 |
|
break; |
|
792 |
|
} |
|
793 |
|
|
|
794 |
|
// We need to reload it |
|
795 |
|
$subdirs = array('.'); |
|
796 |
|
foreach ($archs as $a) { |
|
797 |
|
if (strcmp($a, 'source') == 0) { |
|
798 |
|
$subdirs[] = 'source'; |
|
799 |
|
continue; |
|
800 |
|
} |
|
801 |
|
|
|
802 |
|
$subdirs[] = 'binary-' . $a; |
|
803 |
|
} |
|
804 |
|
|
|
805 |
|
foreach ($subdirs as $subdir) { |
|
806 |
|
$d = $dir . '/main/' . $subdir; |
|
807 |
|
|
|
808 |
|
$r = rg_dir_load_pattern($d, '(Packages|Sources)(\.xz)?$'); |
|
809 |
|
if ($r === FALSE) { |
|
810 |
|
$ret['errmsg'] = 'cannot load subdir ' . $d; |
|
811 |
|
break; |
|
812 |
|
} |
|
813 |
|
|
|
814 |
|
foreach ($r as $f) { |
|
815 |
|
rg_log_debug($subdir . ' file ' . $f); |
|
816 |
|
|
|
817 |
|
$r = rg_hash_load('sha256', $d . '/' . $f); |
|
818 |
|
if ($r['ok'] != 1) { |
|
819 |
|
$ret['errmsg'] = $r['errmsg']; |
|
820 |
|
break; |
|
821 |
|
} |
|
822 |
|
|
|
823 |
|
$k = $subdir . '/' . $f; |
|
824 |
|
$files[$k] = array( |
|
825 |
|
'size' => $r['size'], |
|
826 |
|
'sha256' => $r['hash'] |
|
827 |
|
); |
|
828 |
|
} |
|
829 |
|
if (isset($ret['errmsg'])) |
|
830 |
|
break; |
|
831 |
|
} |
|
832 |
|
break; |
|
833 |
|
} |
|
834 |
|
if (isset($ret['errmsg'])) |
|
835 |
|
break; |
|
836 |
|
|
|
837 |
|
$files = rg_array_merge($files, '', $files_changed); |
|
838 |
|
//rg_log_debug('files final: ' . print_r($files, TRUE)); |
|
839 |
|
|
|
840 |
|
$r = rg_save($dir . '/InRelease.json', $files); |
|
841 |
|
if ($r === FALSE) { |
|
842 |
|
$ret['errmsg'] = 'cannot save json file'; |
|
843 |
|
break; |
|
844 |
|
} |
|
845 |
|
|
|
846 |
|
$archs_without_source = $archs; |
|
847 |
|
unset($archs_without_source['source']); |
|
848 |
|
|
|
849 |
|
$out = '' |
|
850 |
|
. 'Origin: Debian' . "\n" |
|
851 |
|
. 'Label: Debian' . "\n" |
|
852 |
|
. 'Suite: stable' . "\n" |
|
853 |
|
. 'Version: 11.1' . "\n" |
|
854 |
|
. 'Codename: ' . $codename . "\n" |
|
855 |
|
// . '#Changelogs: https://metadata.ftp-master.debian.org/changelogs/@CHANGEPATH@_changelog' . "\n" |
|
856 |
|
. 'Date: ' . gmdate(DATE_RFC2822) . "\n" |
|
857 |
|
// . '#Acquire-By-Hash: no' . "\n" |
|
858 |
|
. 'No-Support-for-Architecture-all: Packages' . "\n" // TODO: What is this? |
|
859 |
|
. 'Architectures: ' . implode(' ', $archs_without_source) . "\n" |
|
860 |
|
. 'Components: main' . "\n" |
|
861 |
|
. 'Description: Debian repo at RocketGit' . "\n" |
|
862 |
|
. 'SHA256:' . "\n"; |
|
863 |
|
|
|
864 |
|
foreach ($files as $file => $i) |
|
865 |
|
$out .= ' ' . $i['sha256'] . ' ' |
|
866 |
|
. str_pad($i['size'], 12, ' ', STR_PAD_LEFT) |
|
867 |
|
. ' main/' . $file . "\n"; |
|
868 |
|
|
|
869 |
|
$r = rg_save_plain($dir . '/InRelease.pre_sign', $out); |
|
870 |
|
if ($r === FALSE) { |
|
871 |
|
$ret['errmsg'] = 'cannot save InRelease.pre_sign file'; |
|
872 |
|
break; |
|
873 |
|
} |
|
874 |
|
|
|
875 |
|
$r = rg_gpg_sign($dir . '/InRelease', $dir . '/InRelease.pre_sign', |
|
876 |
|
$ri['gpg_priv_key'], '--clear-sign'); |
|
877 |
|
if ($r['ok'] != 1) { |
|
878 |
|
rg_log('Cannot sign InRelease file: ' . $r['errmsg']); |
|
879 |
|
break; |
|
880 |
|
} |
|
881 |
|
|
|
882 |
|
@unlink($dir . '/InRelease.pre_sign'); |
|
883 |
|
|
|
884 |
|
$ret['ok'] = 1; |
|
885 |
|
} while (0); |
|
886 |
|
|
|
887 |
|
rg_log_exit(); |
|
888 |
|
return $ret; |
|
889 |
|
} |
|
890 |
|
|
|
891 |
|
/* |
|
892 |
|
* Creates/updates a Debian repository |
|
893 |
|
*/ |
|
894 |
|
function rg_packages_deb_repo_update($db, $subrepo_dir, $distro_dir, $codename, |
|
895 |
|
$job_id, $repo_id, $env, $ri, $sri) |
|
896 |
|
{ |
|
897 |
|
rg_log_enter('packages_deb_repo_update: job_id=' . $job_id); |
|
898 |
|
|
|
899 |
|
$ret = array('ok' => 0); |
|
900 |
|
do { |
|
901 |
|
$dir = $subrepo_dir . '/' . $distro_dir; |
|
902 |
|
|
|
903 |
|
$files_changed = array(); |
|
904 |
|
|
|
905 |
|
// Locking TODO |
|
906 |
|
|
|
907 |
|
// Gather architectures |
|
908 |
|
$subdirs = rg_dir_load_pattern($dir . '/main', '^binary-.*'); |
|
909 |
|
if ($subdirs === FALSE) { |
|
910 |
|
$ret['errmsg'] = 'cannot load subdirs'; |
|
911 |
|
break; |
|
912 |
|
} |
|
913 |
|
$subdirs[] = 'source'; |
|
914 |
|
//rg_log_debug('subdirs final: ' . print_r($subdirs, TRUE)); |
|
915 |
|
|
|
916 |
|
$archs = array(); |
|
917 |
|
foreach ($subdirs as $subdir) { |
|
918 |
|
if (!is_dir($dir . '/main/' . $subdir)) { |
|
919 |
|
rg_log_debug($subdir . ' does not exists; ignore it'); |
|
920 |
|
continue; |
|
921 |
|
} |
|
922 |
|
|
|
923 |
|
$archs[] = str_replace('binary-', '', $subdir); |
|
924 |
|
|
|
925 |
|
$r = rg_packages_deb_repo_update_subdir($subrepo_dir, |
|
926 |
|
$distro_dir, $subdir, $codename, $job_id, |
|
927 |
|
$repo_id, $env); |
|
928 |
|
if ($r['ok'] != 1) { |
|
929 |
|
$ret['errmsg'] = $r['errmsg']; |
|
930 |
|
break; |
|
931 |
|
} |
|
932 |
|
if (!empty($r['files_changed'])) |
|
933 |
|
$files_changed = rg_array_merge($files_changed, |
|
934 |
|
'', $r['files_changed']); |
|
935 |
|
} |
|
936 |
|
if (isset($ret['errmsg'])) |
|
937 |
|
break; |
|
938 |
|
|
|
939 |
|
// Create main/i18n/Translation-en.xz |
|
940 |
|
|
|
941 |
|
$r = rg_packages_deb_create_inrelease($dir, $codename, |
|
942 |
|
$ri, $archs, $files_changed); |
|
943 |
|
if ($r['ok'] != 1) { |
|
944 |
|
$ret['errmsg'] = $r['errmsg']; |
|
945 |
|
break; |
|
946 |
|
} |
|
947 |
|
|
|
948 |
|
$ret['ok'] = 1; |
|
949 |
|
} while (0); |
|
950 |
|
|
|
951 |
|
rg_log_exit(); |
|
952 |
|
return $ret; |
|
953 |
|
} |
File inc/user/packages_rpm.inc.php changed (mode: 100644) (index 803219f..cdf24bc) |
... |
... |
require_once(__DIR__ . '/packages_core.inc.php'); |
7 |
7 |
* Event functions |
* Event functions |
8 |
8 |
*/ |
*/ |
9 |
9 |
$_f = array( |
$_f = array( |
10 |
|
'pkg_generate_dotrepo_rpm_callback' => 'rg_pkg_event_generate_dotrepo_rpm_callback', |
|
11 |
10 |
'pkg_generate_dotrepo_rpm' => 'rg_pkg_event_generate_dotrepo_rpm' |
'pkg_generate_dotrepo_rpm' => 'rg_pkg_event_generate_dotrepo_rpm' |
12 |
11 |
); |
); |
13 |
12 |
rg_event_register_functions($_f); |
rg_event_register_functions($_f); |
14 |
13 |
|
|
15 |
14 |
/* |
/* |
16 |
|
* Called when a dotrepo was done |
|
17 |
|
* TODO: what happens when there is an error building the dotrepo? |
|
|
15 |
|
* This is called after a push and before sendint the job to a builder |
18 |
16 |
*/ |
*/ |
19 |
|
function rg_pkg_event_generate_dotrepo_rpm_callback($db, $ev) |
|
|
17 |
|
function rg_pkg_prepare_for_build_rpm($db, &$a) |
20 |
18 |
{ |
{ |
21 |
|
rg_log_enter('pkg_event_generate_dotrepo_rpm_callback'); |
|
22 |
|
//rg_log_debug('req: ' . rg_array2string($ev['job']['request'])); |
|
|
19 |
|
rg_log_enter('pkg_prepare_for_build_rpm'); |
23 |
20 |
|
|
24 |
|
$ret = FALSE; |
|
|
21 |
|
$ret = array('ok' => 0); |
25 |
22 |
do { |
do { |
26 |
|
$req = $ev['job']['request']; |
|
27 |
|
|
|
28 |
|
$err = FALSE; |
|
29 |
|
foreach ($req['rpm_repo_files'] as $pkg_subrepo_id => $junk) { |
|
30 |
|
$sri = $req['pkg_subrepos'][$pkg_subrepo_id]; |
|
31 |
|
$ver = $sri['version']; |
|
32 |
|
$di = array($req['env'] => array('dotrepo' => $ver)); |
|
33 |
|
$r = rg_pkg_subrepo_update_distro_info($db, |
|
34 |
|
$req['uid'], $pkg_subrepo_id, $di); |
|
35 |
|
if ($r['ok'] != 1) { |
|
36 |
|
$err = TRUE; |
|
37 |
|
break; |
|
38 |
|
} |
|
39 |
|
} |
|
40 |
|
if ($err) |
|
|
23 |
|
$r = rg_pkg_prepare_for_dotrepo($db, $a); |
|
24 |
|
if ($r['ok'] != 1) { |
|
25 |
|
$ret['errmsg'] = $r['errmsg']; |
41 |
26 |
break; |
break; |
42 |
|
|
|
43 |
|
$ret = array(); |
|
44 |
|
|
|
45 |
|
$s = $ev['status']; |
|
46 |
|
//rg_log_debug('status: ' . rg_array2string($s)); |
|
47 |
|
if (!empty($s['pkg_subrepo_dirty'])) { |
|
48 |
|
rg_log_debug('trigger ev pkg_subrepo_regenerate'); |
|
49 |
|
$a = array( |
|
50 |
|
'category' => 'pkg_subrepo_regenerate', |
|
51 |
|
'prio' => 100, |
|
52 |
|
'uid' => 0, |
|
53 |
|
'repo_id' => $req['repo_id'], |
|
54 |
|
'repo_username' => $req['repo_username'], |
|
55 |
|
'head' => $req['head'], |
|
56 |
|
'orig_job_id' => $ev['job']['id'], |
|
57 |
|
'log_sid' => $req['log_sid'], |
|
58 |
|
'pkg_subrepo_id_list' => $s['pkg_subrepo_dirty'], |
|
59 |
|
'env' => $req['env'] |
|
60 |
|
); |
|
61 |
|
$ret[] = $a; |
|
62 |
27 |
} |
} |
|
28 |
|
|
|
29 |
|
$ret['ok'] = 1; |
63 |
30 |
} while (0); |
} while (0); |
64 |
31 |
|
|
65 |
32 |
rg_log_exit(); |
rg_log_exit(); |
|
... |
... |
function rg_pkg_event_generate_dotrepo_rpm_callback($db, $ev) |
68 |
35 |
|
|
69 |
36 |
/* |
/* |
70 |
37 |
* Prepares 'ev' for dotrepo building. |
* Prepares 'ev' for dotrepo building. |
71 |
|
* Helper for rg_pkg_subrepo_event_regenerate and |
|
72 |
|
* rg_pkg_event_generate_dotrepo_rpm. |
|
73 |
|
* TODO: add a generic function which will call this function for rpm. |
|
74 |
38 |
*/ |
*/ |
75 |
39 |
function rg_pkg_prepare_for_dotrepo($db, &$ev) |
function rg_pkg_prepare_for_dotrepo($db, &$ev) |
76 |
40 |
{ |
{ |
77 |
41 |
rg_log_enter('pkg_prepare_for_dotrepo'); |
rg_log_enter('pkg_prepare_for_dotrepo'); |
|
42 |
|
rg_log_debug('TODO: check if distro_info is passed here, to remove it below'); |
|
43 |
|
rg_log_debug('ev: ' . print_r($ev, TRUE)); |
78 |
44 |
|
|
79 |
45 |
$ret = array('ok' => 0); |
$ret = array('ok' => 0); |
80 |
46 |
do { |
do { |
|
... |
... |
function rg_pkg_prepare_for_dotrepo($db, &$ev) |
83 |
49 |
$ret['errmsg'] = $r['errmsg']; |
$ret['errmsg'] = $r['errmsg']; |
84 |
50 |
break; |
break; |
85 |
51 |
} |
} |
86 |
|
rg_log_debug('tree: ' . print_r($r['tree'], TRUE)); |
|
|
52 |
|
//rg_log_debug('tree: ' . print_r($r['tree'], TRUE)); |
87 |
53 |
|
|
88 |
54 |
if (!rg_envs_tree_is_enabled($r['tree'], $ev['env'])) { |
if (!rg_envs_tree_is_enabled($r['tree'], $ev['env'])) { |
89 |
55 |
rg_log_debug('env ' . $ev['env'] . ' is not enabled in rg_envs_tree!'); |
rg_log_debug('env ' . $ev['env'] . ' is not enabled in rg_envs_tree!'); |
|
... |
... |
function rg_pkg_prepare_for_dotrepo($db, &$ev) |
91 |
57 |
break; |
break; |
92 |
58 |
} |
} |
93 |
59 |
|
|
94 |
|
$ti = rg_envs_tree_info($r['tree'], $ev['env']); |
|
95 |
|
if (strcmp($ti['pkg_type'], 'rpm') != 0) { |
|
96 |
|
$ret['ok'] = 1; |
|
97 |
|
break; |
|
98 |
|
} |
|
99 |
|
|
|
100 |
60 |
rg_log_debug('adding rpm_repo_files...'); |
rg_log_debug('adding rpm_repo_files...'); |
101 |
61 |
$files = array(); |
$files = array(); |
102 |
62 |
foreach ($ev['pkg_maps'] as $mi) { |
foreach ($ev['pkg_maps'] as $mi) { |
|
... |
... |
function rg_pkg_prepare_for_dotrepo($db, &$ev) |
105 |
65 |
$pkg_repo_id = $sri['pkg_repo_id']; |
$pkg_repo_id = $sri['pkg_repo_id']; |
106 |
66 |
|
|
107 |
67 |
$ri = $ev['pkg_repos'][$pkg_repo_id]; |
$ri = $ev['pkg_repos'][$pkg_repo_id]; |
108 |
|
//rg_log_debug('ri: ' . rg_array2string($ri)); |
|
109 |
68 |
if ($ev['uid'] != $ri['uid']) { |
if ($ev['uid'] != $ri['uid']) { |
110 |
69 |
rg_log_debug('we cannot build this' |
rg_log_debug('we cannot build this' |
111 |
70 |
. ' dotrepo because pkg_repo_uid(' . $ri['uid'] |
. ' dotrepo because pkg_repo_uid(' . $ri['uid'] |
|
... |
... |
function rg_pkg_prepare_for_dotrepo($db, &$ev) |
124 |
83 |
} |
} |
125 |
84 |
} |
} |
126 |
85 |
|
|
127 |
|
// TODO: replace $di (used above) with below $d? |
|
128 |
|
$di = rg_env_info($ev['env']); |
|
129 |
|
|
|
|
86 |
|
$ei = rg_env_info($ev['env']); |
130 |
87 |
$r = rg_packages_rpm_add_dotrepo_files($db, $ev['uid'], |
$r = rg_packages_rpm_add_dotrepo_files($db, $ev['uid'], |
131 |
|
$pkg_subrepo_id, $di['distro']); |
|
|
88 |
|
$pkg_subrepo_id, $ei['distro']); |
132 |
89 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
133 |
90 |
$ret['errmsg'] = $r['errmsg']; |
$ret['errmsg'] = $r['errmsg']; |
134 |
91 |
break; |
break; |
|
... |
... |
function rg_pkg_prepare_for_dotrepo($db, &$ev) |
138 |
95 |
} |
} |
139 |
96 |
$ev['rpm_repo_files'] = $files; |
$ev['rpm_repo_files'] = $files; |
140 |
97 |
|
|
141 |
|
$ev['event_callbacks'] = array('pkg_generate_dotrepo_rpm_callback'); |
|
142 |
|
|
|
143 |
|
$ev['exec']['prepare_rpms'] = 1; |
|
144 |
|
$ev['exec']['copy_to_rgfs'] = 1; |
|
|
98 |
|
$ev['exec']['prepare_pkgs'] = 1; |
145 |
99 |
|
|
146 |
100 |
$ret['ok'] = 1; |
$ret['ok'] = 1; |
147 |
101 |
} while (0); |
} while (0); |
|
... |
... |
function rg_pkg_prepare_for_dotrepo($db, &$ev) |
151 |
105 |
} |
} |
152 |
106 |
|
|
153 |
107 |
/* |
/* |
154 |
|
* This is called when a (sub)repo is created/updated to generate the dotrepo rpm. |
|
155 |
|
* It is also called when the first package is added to a pkg subrepo. |
|
|
108 |
|
* This is called when a (sub)repo is created/updated to generate the dotrepo rpm |
|
109 |
|
* (pkg_subrepo_event_edit). |
|
110 |
|
* TODO: this duplicates some code with build_send_one/rg_pkg_prepare_for_build |
156 |
111 |
*/ |
*/ |
157 |
112 |
function rg_pkg_event_generate_dotrepo_rpm($db, $ev) |
function rg_pkg_event_generate_dotrepo_rpm($db, $ev) |
158 |
113 |
{ |
{ |
159 |
114 |
rg_log_enter('pkg_event_generate_dotrepo_rpm'); |
rg_log_enter('pkg_event_generate_dotrepo_rpm'); |
160 |
|
rg_log_debug('ev: ' . rg_array2string($ev)); |
|
|
115 |
|
rg_log_debug('ev: ' . rg_array2string_short($ev)); |
|
116 |
|
rg_log_debug('TODO: is repo_uid still defined?'); |
161 |
117 |
|
|
162 |
118 |
$ret = FALSE; |
$ret = FALSE; |
163 |
119 |
do { |
do { |
164 |
|
// Clean not needed stuff |
|
165 |
|
unset($ev['head']); |
|
166 |
|
unset($ev['repo_id']); |
|
167 |
|
unset($ev['repo_username']); |
|
168 |
|
|
|
169 |
120 |
$ev['exec'] = array(); |
$ev['exec'] = array(); |
|
121 |
|
|
170 |
122 |
// For security: we do not want to allow a malformed repo. |
// For security: we do not want to allow a malformed repo. |
171 |
123 |
$ev['worker_must_be_global'] = 1; |
$ev['worker_must_be_global'] = 1; |
172 |
124 |
|
|
173 |
|
$ev['pkg_maps'] = array(); |
|
174 |
|
$ev['pkg_repos'] = array(); |
|
175 |
|
$ev['pkg_subrepos'] = array(); |
|
|
125 |
|
$ev['build_repo_id'] = 0; |
176 |
126 |
|
|
177 |
|
$pkg_subrepo_id = $ev['pkg_subrepo_id']; |
|
178 |
|
$sri = rg_pkg_subrepo_info($db, $ev['uid'], $pkg_subrepo_id); |
|
179 |
|
if ($sri['ok'] != 1) |
|
|
127 |
|
$r = rg_pkg_prepare_for_build($db, $ev); |
|
128 |
|
if ($r['ok'] != 1) { |
|
129 |
|
rg_log('Error: ' . $r['errmsg']); |
|
130 |
|
$ret = FALSE; |
180 |
131 |
break; |
break; |
181 |
|
$ev['pkg_subrepos'][$pkg_subrepo_id] = $sri; |
|
|
132 |
|
} |
182 |
133 |
|
|
183 |
|
$pkg_repo_id = $sri['pkg_repo_id']; |
|
184 |
|
$ri = rg_pkg_repo_info($db, $ev['uid'], $pkg_repo_id); |
|
185 |
|
if ($ri['ok'] != 1) |
|
186 |
|
break; |
|
187 |
|
$ev['pkg_repos'][$pkg_repo_id] = $ri; |
|
|
134 |
|
$ret = array(); |
|
135 |
|
} while (0); |
188 |
136 |
|
|
189 |
|
// Fake pkg_maps |
|
190 |
|
$ev['pkg_maps'][] = array( |
|
191 |
|
'pkg_subrepo_id' => $pkg_subrepo_id, |
|
192 |
|
'flags' => '' |
|
193 |
|
); |
|
|
137 |
|
rg_log_exit(); |
|
138 |
|
return $ret; |
|
139 |
|
} |
194 |
140 |
|
|
195 |
|
rg_pkg_prepare_for_rgfs($db, $ev); |
|
|
141 |
|
/* |
|
142 |
|
* This is called after a job is done |
|
143 |
|
*/ |
|
144 |
|
function rg_pkg_after_build_rpm($db, $ev) |
|
145 |
|
{ |
|
146 |
|
rg_log_enter('pkg_after_build_rpm'); |
196 |
147 |
|
|
197 |
|
$r = rg_pkg_prepare_for_dotrepo($db, $ev); |
|
198 |
|
if ($r['ok'] != 1) { |
|
199 |
|
rg_log('Cannot prepare ev: ' . $r['errmsg']); |
|
|
148 |
|
$ret = array('ok' => 0); |
|
149 |
|
do { |
|
150 |
|
$req = $ev['job']['request']; |
|
151 |
|
|
|
152 |
|
foreach ($req['rpm_repo_files'] as $pkg_subrepo_id => $junk) { |
|
153 |
|
$sri = $req['pkg_subrepos'][$pkg_subrepo_id]; // TODO: should we trust these or we should reload them? |
|
154 |
|
$ver = $sri['version']; |
|
155 |
|
$di = array($req['env'] => array('dotrepo' => $ver)); |
|
156 |
|
$r = rg_pkg_subrepo_update_distro_info($db, |
|
157 |
|
$req['uid'], $pkg_subrepo_id, $di); |
|
158 |
|
if ($r['ok'] != 1) { |
|
159 |
|
$ret['errmsg'] = $r['errmsg']; |
|
160 |
|
break; |
|
161 |
|
} |
|
162 |
|
} |
|
163 |
|
|
|
164 |
|
$s = $ev['status']; |
|
165 |
|
//rg_log_debug('status: ' . rg_array2string_short($s)); |
|
166 |
|
if (empty($s['pkg_subrepo_dirty'])) { |
|
167 |
|
$ret['ok'] = 1; |
200 |
168 |
break; |
break; |
201 |
169 |
} |
} |
202 |
170 |
|
|
203 |
|
// Prio is 2 less than normal (10) |
|
204 |
|
$r = rg_builder_add($db, 0 /*repo_id*/, 8 /*prio*/, $ev); |
|
|
171 |
|
$a = array(); |
|
172 |
|
$a['worker_must_be_global'] = 1; // for security reasons |
|
173 |
|
$a['exec'] = array(); |
|
174 |
|
$a['source'] = 'pkg_after_build_rpm'; |
|
175 |
|
$a['uid'] = 0; |
|
176 |
|
$a['repo_id'] = $req['repo_id']; |
|
177 |
|
$a['repo_uid'] = $req['repo_uid']; |
|
178 |
|
$a['repo_username'] = $req['repo_username']; |
|
179 |
|
$a['head'] = $req['head']; |
|
180 |
|
$a['orig_job_id'] = $req['orig_job_id']; |
|
181 |
|
$a['log_sid'] = $req['log_sid']; |
|
182 |
|
$a['pkg_subrepo_id_list'] = $s['pkg_subrepo_dirty']; |
|
183 |
|
$a['env'] = $req['env']; |
|
184 |
|
$a['build_repo_id'] = 0; // this is meta repo operation |
|
185 |
|
|
|
186 |
|
$r = rg_pkg_prepare_for_build($db, $a); |
205 |
187 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
206 |
|
rg_log('Cannot add builder job: ' . $r['errmsg']); |
|
207 |
|
$ret = FALSE; |
|
|
188 |
|
$ret['errmsg'] = $r['errmsg']; |
208 |
189 |
break; |
break; |
209 |
190 |
} |
} |
210 |
191 |
|
|
211 |
|
$ret = array(); |
|
|
192 |
|
$ret['ok'] = 1; |
212 |
193 |
} while (0); |
} while (0); |
213 |
194 |
|
|
214 |
195 |
rg_log_exit(); |
rg_log_exit(); |
|
... |
... |
function rg_packages_rpm_helper($db, $rg, $a) |
331 |
312 |
|
|
332 |
313 |
// TODO: should be this in generic code? |
// TODO: should be this in generic code? |
333 |
314 |
if (!strstr($ri['flags'], 'P')) { // pkg repo is private |
if (!strstr($ri['flags'], 'P')) { // pkg repo is private |
334 |
|
if (!rg_pkg_has_rights($db, $ri, $rg, 'A')) { |
|
|
315 |
|
if (!rg_pkg_has_rights($db, $ri, 'A')) { |
335 |
316 |
if (strcmp($a['sent_pass'], $ri['password']) != 0) { |
if (strcmp($a['sent_pass'], $ri['password']) != 0) { |
336 |
317 |
rg_log('provided password is not correct!'); |
rg_log('provided password is not correct!'); |
337 |
318 |
header($rg['proto'] . ' 404 Not found'); |
header($rg['proto'] . ' 404 Not found'); |
|
... |
... |
function rg_packages_rpm_helper($db, $rg, $a) |
390 |
371 |
*/ |
*/ |
391 |
372 |
function rg_packages_rpm_get_link($db, $a) |
function rg_packages_rpm_get_link($db, $a) |
392 |
373 |
{ |
{ |
393 |
|
//rg_log_debug('get_link: a: ' . rg_array2string($a)); |
|
|
374 |
|
//rg_log_debug('get_link: a: ' . rg_array2string_short($a)); |
|
375 |
|
//rg_log_debug('get_link: a: ' . print_r($a, TRUE)); |
394 |
376 |
|
|
395 |
377 |
$ret = array(); |
$ret = array(); |
396 |
378 |
|
|
397 |
379 |
// Both pkg repo and subrepo names cannot contain '+' and '-'. |
// Both pkg repo and subrepo names cannot contain '+' and '-'. |
398 |
380 |
|
|
399 |
381 |
if ($a['pkg_repo_info']['uid'] == 0) { |
if ($a['pkg_repo_info']['uid'] == 0) { |
400 |
|
$type_and_username = 'main'; |
|
401 |
|
$username = ''; |
|
|
382 |
|
$type_and_owner = 'main'; |
|
383 |
|
$owner = ''; |
402 |
384 |
} else { |
} else { |
403 |
|
$type_and_username = 'user/' . $a['pkg_repo_info']['username']; |
|
404 |
|
$username = $a['pkg_repo_info']['username'] . '-'; |
|
|
385 |
|
$type_and_owner = 'user/' . $a['pkg_repo_info']['owner']; |
|
386 |
|
$owner = $a['pkg_repo_info']['owner'] . '-'; |
405 |
387 |
} |
} |
406 |
388 |
|
|
407 |
|
$ret['dotrepo_pkg_name'] = 'rocketgit-' . $username |
|
|
389 |
|
$env = $a['env']; |
|
390 |
|
$di = $a['pkg_subrepo_info']['distro_info'][$env]; |
|
391 |
|
|
|
392 |
|
$ret['dotrepo_pkg_name'] = 'rocketgit-' . $owner |
408 |
393 |
. $a['pkg_repo_info']['name'] |
. $a['pkg_repo_info']['name'] |
409 |
394 |
. '-' . $a['pkg_subrepo_info']['name'] |
. '-' . $a['pkg_subrepo_info']['name'] |
410 |
|
. '-' . $a['pkg_repo_info']['version'] . '.' . $a['dotrepo'] |
|
|
395 |
|
. '-' . $a['pkg_repo_info']['version'] . '.' . $di['dotrepo'] |
411 |
396 |
. '-1.noarch.rpm'; |
. '-1.noarch.rpm'; |
412 |
397 |
|
|
413 |
398 |
$ret['dotrepo_pkg_url'] = rg_base_url($db, '', '') |
$ret['dotrepo_pkg_url'] = rg_base_url($db, '', '') |
414 |
399 |
. '/op/pkgrepo' |
. '/op/pkgrepo' |
415 |
|
. '/' . $type_and_username |
|
|
400 |
|
. '/' . $type_and_owner |
416 |
401 |
. '/' . $a['pkg_repo_info']['name'] |
. '/' . $a['pkg_repo_info']['name'] |
417 |
402 |
. '/' . $a['pkg_subrepo_info']['name'] |
. '/' . $a['pkg_subrepo_info']['name'] |
418 |
403 |
. '/' . $a['distro'] |
. '/' . $a['distro'] |
|
... |
... |
function rg_packages_rpm_add_dotrepo_files($db, $uid, $pkg_subrepo_id, $distro) |
437 |
422 |
do { |
do { |
438 |
423 |
$sri = rg_pkg_subrepo_info($db, $uid, $pkg_subrepo_id); |
$sri = rg_pkg_subrepo_info($db, $uid, $pkg_subrepo_id); |
439 |
424 |
if ($sri['exists'] != 1) { |
if ($sri['exists'] != 1) { |
440 |
|
$ret['errmsg'] = 'cannot find subrepo ' . $pkg_subrepo_id; |
|
|
425 |
|
$ret['errmsg'] = $sri['errmsg']; |
441 |
426 |
break; |
break; |
442 |
427 |
} |
} |
443 |
428 |
|
|
444 |
429 |
$pri = rg_pkg_repo_info($db, $uid, $sri['pkg_repo_id']); |
$pri = rg_pkg_repo_info($db, $uid, $sri['pkg_repo_id']); |
445 |
430 |
if ($pri['exists'] != 1) { |
if ($pri['exists'] != 1) { |
446 |
|
$ret['errmsg'] = 'cannot find repo ' . $sri['pkg_repo_id']; |
|
|
431 |
|
$ret['errmsg'] = $pri['errmsg']; |
447 |
432 |
break; |
break; |
448 |
433 |
} |
} |
449 |
434 |
|
|
|
... |
... |
function rg_packages_rpm_add_dotrepo_files($db, $uid, $pkg_subrepo_id, $distro) |
507 |
492 |
|
|
508 |
493 |
/* |
/* |
509 |
494 |
* Instructions on how to install a package |
* Instructions on how to install a package |
510 |
|
* TODO: Showing the details of older packages has no place here! |
|
|
495 |
|
* TODO: Showing the details of other packages versions has no place here! |
511 |
496 |
*/ |
*/ |
512 |
497 |
function rg_packages_rpm_howto($a, $user, $repo_name, $meta) |
function rg_packages_rpm_howto($a, $user, $repo_name, $meta) |
513 |
498 |
{ |
{ |
514 |
|
rg_log_debug('packages_rpm_howto: a: ' . print_r($a, TRUE)); |
|
|
499 |
|
rg_log_debug('packages_rpm_howto: a: ' . rg_array2string_short($a)); |
|
500 |
|
//rg_log_debug('meta: ' . print_r($meta, TRUE)); |
515 |
501 |
|
|
516 |
502 |
$private = !strstr($a['pkg_repo_info']['flags'], 'P'); |
$private = !strstr($a['pkg_repo_info']['flags'], 'P'); |
517 |
503 |
|
|
518 |
504 |
$other = ''; |
$other = ''; |
519 |
|
if ($meta) { |
|
|
505 |
|
if ($meta !== FALSE) { |
520 |
506 |
$other .= "\n"; |
$other .= "\n"; |
521 |
507 |
$other .= '<details><summary>Details about all versions</summary>' . "\n"; |
$other .= '<details><summary>Details about all versions</summary>' . "\n"; |
522 |
|
$other .= '<table><tr><th>Name</th><th>Size</th><th>Copies</th><th>Job</th><th>Head</th><th>Worker</th><th>Date (UTC)</th></tr>' . "\n"; |
|
|
508 |
|
$other .= '<table><tr><th>Name</th><th>Size</th><th>Head</th><th>Date (UTC)</th>'; |
|
509 |
|
if ($a['can_see_details'] == 1) |
|
510 |
|
$other .= '<th>Job</th><th>Worker</th><th>Copies</th>'; |
|
511 |
|
$other .= '</tr>' . "\n"; |
523 |
512 |
foreach ($meta as $f => $i) { |
foreach ($meta as $f => $i) { |
524 |
513 |
$other .= '<tr><td>' . rg_xss_safe($f) . '</td>' |
$other .= '<tr><td>' . rg_xss_safe($f) . '</td>' |
525 |
|
. '<td>' . $i['size_nice'] . '</td>' |
|
526 |
|
. '<td>' . $i['nlink'] . '</td>' |
|
527 |
|
. '<td>' . rg_xss_safe($i['job_id']) . '</td>' |
|
528 |
|
. '<td>' . $i['head_link'] . '</td>' |
|
|
514 |
|
. '<td>' . $i['size_nice'] . '</td>'; |
|
515 |
|
|
|
516 |
|
$other .= '<td>' . $i['head_link'] . '</td>' |
|
517 |
|
. '<td>' . gmdate('Y-m-d H:i', $i['ctime']) . '</td>'; |
|
518 |
|
|
|
519 |
|
if ($a['can_see_details'] == 1) |
|
520 |
|
$other .= '<td>' . rg_xss_safe($i['job_id']) . '</td>' |
529 |
521 |
. '<td>' . rg_xss_safe($i['worker_name']) . '</td>' |
. '<td>' . rg_xss_safe($i['worker_name']) . '</td>' |
530 |
|
. '<td>' . gmdate('Y-m-d H:i', $i['ctime']) . '</td>' |
|
531 |
|
. '</tr>' . "\n"; |
|
|
522 |
|
. '<td>' . $i['nlink'] . '</td>'; |
|
523 |
|
|
|
524 |
|
$other .= '</tr>' . "\n"; |
532 |
525 |
} |
} |
533 |
526 |
$other .= '</table>'; |
$other .= '</table>'; |
534 |
527 |
$other .= '</details>'; |
$other .= '</details>'; |
|
... |
... |
function rg_packages_rpm_howto($a, $user, $repo_name, $meta) |
551 |
544 |
if ($private) { |
if ($private) { |
552 |
545 |
// We cannot do it like with the private pkg repo. |
// We cannot do it like with the private pkg repo. |
553 |
546 |
// We do not want to put the password on the screen. |
// We do not want to put the password on the screen. |
554 |
|
return rg_template('user/pkg/redhat/priv_download.html', |
|
|
547 |
|
return rg_template('user/pkg/rpm/priv_download.html', |
555 |
548 |
$rg, TRUE /*xss*/); |
$rg, TRUE /*xss*/); |
556 |
549 |
} else { |
} else { |
557 |
|
return rg_template('user/pkg/redhat/pub_download.html', |
|
|
550 |
|
return rg_template('user/pkg/rpm/pub_download.html', |
558 |
551 |
$rg, TRUE /*xss*/); |
$rg, TRUE /*xss*/); |
559 |
552 |
} |
} |
560 |
553 |
} |
} |
File scripts/worker.php changed (mode: 100644) (index 31a44da..f7790f9) |
... |
... |
function load_config_file($file) |
106 |
106 |
if (strncmp($value, '/', 1) != 0) |
if (strncmp($value, '/', 1) != 0) |
107 |
107 |
$value = dirname($file) . '/' . $value; |
$value = dirname($file) . '/' . $value; |
108 |
108 |
load_config_file($value); |
load_config_file($value); |
|
109 |
|
} else if (strcmp($var, 'debug') == 0) { |
|
110 |
|
rg_debug_set(intval($value)); |
109 |
111 |
} else { |
} else { |
110 |
112 |
$conf[$var] = $value; |
$conf[$var] = $value; |
111 |
113 |
$last_parent = FALSE; |
$last_parent = FALSE; |
|
... |
... |
function load_config($file) |
238 |
240 |
$i['pkg_cmd'] = 'apt --assume-yes --ignore-hold' |
$i['pkg_cmd'] = 'apt --assume-yes --ignore-hold' |
239 |
241 |
. ' --allow-downgrades --allow-remove-essential' |
. ' --allow-downgrades --allow-remove-essential' |
240 |
242 |
. ' --allow-change-held-packages' |
. ' --allow-change-held-packages' |
241 |
|
. ' -o Dpkg::Options::=--force-confnew install'; |
|
|
243 |
|
. ' -o Dpkg::Options::=--force-confnew install' |
|
244 |
|
. ' --no-install-recommends'; |
242 |
245 |
} else if (strcasecmp($x, 'fedora') == 0) { |
} else if (strcasecmp($x, 'fedora') == 0) { |
243 |
246 |
$i['pkg_cmd'] = 'dnf -y install'; |
$i['pkg_cmd'] = 'dnf -y install'; |
244 |
247 |
} else if (strcasecmp($x, 'rocky') == 0) { |
} else if (strcasecmp($x, 'rocky') == 0) { |
245 |
248 |
$i['pkg_cmd'] = 'dnf -y install'; |
$i['pkg_cmd'] = 'dnf -y install'; |
|
249 |
|
} else if (strcasecmp($x, 'centos_stream') == 0) { |
|
250 |
|
$i['pkg_cmd'] = 'dnf -y install'; |
246 |
251 |
} else if (strcasecmp($x, 'centos') == 0) { |
} else if (strcasecmp($x, 'centos') == 0) { |
247 |
252 |
if ($y > 7) |
if ($y > 7) |
248 |
253 |
$i['pkg_cmd'] = 'dnf -y install'; |
$i['pkg_cmd'] = 'dnf -y install'; |
|
... |
... |
function load_config($file) |
252 |
257 |
$i['pkg_cmd'] = 'zypper --non-interactive install'; |
$i['pkg_cmd'] = 'zypper --non-interactive install'; |
253 |
258 |
} else if (strcasecmp($x, 'archlinux') == 0) { |
} else if (strcasecmp($x, 'archlinux') == 0) { |
254 |
259 |
$i['pkg_cmd'] = 'pacman --sync --refresh --noconfirm --needed'; |
$i['pkg_cmd'] = 'pacman --sync --refresh --noconfirm --needed'; |
|
260 |
|
} else if (strcasecmp($x, 'alpine') == 0) { |
|
261 |
|
$i['pkg_cmd'] = 'apk --force add'; |
255 |
262 |
} else { |
} else { |
256 |
263 |
rg_log('Error! I do not know how to install packages on ' . $x |
rg_log('Error! I do not know how to install packages on ' . $x |
257 |
264 |
. ' (name ' . $name . '). Ignore it.'); |
. ' (name ' . $name . '). Ignore it.'); |
|
... |
... |
function load_config($file) |
282 |
289 |
if (!isset($conf['libvirtd_group'])) |
if (!isset($conf['libvirtd_group'])) |
283 |
290 |
$conf['libvirtd_group'] = 'qemu'; |
$conf['libvirtd_group'] = 'qemu'; |
284 |
291 |
|
|
285 |
|
rg_log_ml('conf: ' . rg_array2string($conf)); |
|
|
292 |
|
rg_log_ml('conf: ' . rg_array2string_short($conf)); |
286 |
293 |
} |
} |
287 |
294 |
|
|
288 |
295 |
/* |
/* |
|
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
376 |
383 |
. "\n" |
. "\n" |
377 |
384 |
. '# Export global variables' . "\n" |
. '# Export global variables' . "\n" |
378 |
385 |
. 'export job_id=' . escapeshellarg($job['id']) . "\n" |
. 'export job_id=' . escapeshellarg($job['id']) . "\n" |
379 |
|
. 'export repo_username=' . escapeshellarg(isset($job['repo_username']) ? $job['repo_username'] : '') . "\n" |
|
|
386 |
|
. 'export orig_job_id=' . escapeshellarg(isset($job['orig_job_id']) ? $job['orig_job_id'] : $job['id']) . "\n" |
|
387 |
|
. 'export repo_name=' . (isset($job['repo_name']) ? escapeshellarg($job['repo_name']) : '') . "\n" |
|
388 |
|
. 'export repo_name_allowed=' |
|
389 |
|
. (isset($job['repo_name_allowed']) |
|
390 |
|
? escapeshellarg($job['repo_name_allowed']) : '${repo_name}') . "\n" |
|
391 |
|
. 'export repo_username=' . (isset($job['repo_username']) ? escapeshellarg($job['repo_username']) : '') . "\n" |
|
392 |
|
. 'export repo_username_allowed=' |
|
393 |
|
. (isset($job['repo_username_allowed']) ? |
|
394 |
|
escapeshellarg($job['repo_username_allowed']) : '${repo_username}') . "\n" |
380 |
395 |
. 'export job_uid=' . (isset($job['uid']) ? $job['uid'] : '') . "\n" |
. 'export job_uid=' . (isset($job['uid']) ? $job['uid'] : '') . "\n" |
381 |
396 |
. 'export job_url=' . (isset($job['url']) ? $job['url'] : '') . "\n" |
. 'export job_url=' . (isset($job['url']) ? $job['url'] : '') . "\n" |
382 |
397 |
. 'export job_head=' . (isset($job['head']) ? $job['head'] : '') . "\n" |
. 'export job_head=' . (isset($job['head']) ? $job['head'] : '') . "\n" |
|
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
384 |
399 |
. 'export env_distro=' . escapeshellarg($job['env_distro']) . "\n" |
. 'export env_distro=' . escapeshellarg($job['env_distro']) . "\n" |
385 |
400 |
. 'export env_major=' . escapeshellarg($job['env_major']) . "\n" |
. 'export env_major=' . escapeshellarg($job['env_major']) . "\n" |
386 |
401 |
. 'export env_arch=' . escapeshellarg($job['env_arch']) . "\n" |
. 'export env_arch=' . escapeshellarg($job['env_arch']) . "\n" |
|
402 |
|
. 'export env_codename=' . (isset($job['env_codename']) ? escapeshellarg($job['env_codename']) : '') . "\n" |
387 |
403 |
. 'export rg_pkg_cmd="' . $env['pkg_cmd'] . '"' . "\n" |
. 'export rg_pkg_cmd="' . $env['pkg_cmd'] . '"' . "\n" |
388 |
404 |
. '# Debian/Ubuntu stuff' . "\n" |
. '# Debian/Ubuntu stuff' . "\n" |
389 |
405 |
. 'export DEBIAN_FRONTEND=noninteractive' . "\n" |
. 'export DEBIAN_FRONTEND=noninteractive' . "\n" |
|
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
398 |
414 |
. 'export RGFS_name=' . 'wj' . $job['id'] . "\n" |
. 'export RGFS_name=' . 'wj' . $job['id'] . "\n" |
399 |
415 |
. 'export RGFS_head=' . escapeshellarg($job['head']) . "\n" |
. 'export RGFS_head=' . escapeshellarg($job['head']) . "\n" |
400 |
416 |
. 'export RGFS_repo_id=' . escapeshellarg($job['repo_id']) . "\n" |
. 'export RGFS_repo_id=' . escapeshellarg($job['repo_id']) . "\n" |
401 |
|
. 'export RGFS_uid=' . escapeshellarg($job['uid']) . "\n" |
|
402 |
|
. 'export RGFS_job_id=' . escapeshellarg($job['id']) . "\n" |
|
|
417 |
|
. 'export RGFS_uid=${job_uid}' . "\n" |
|
418 |
|
. 'export RGFS_job_id=${orig_job_id}' . "\n" |
403 |
419 |
. 'export RGFS_env=' . escapeshellarg($job['env']) . "\n" |
. 'export RGFS_env=' . escapeshellarg($job['env']) . "\n" |
404 |
420 |
. 'export RGFS_worker_id=' . escapeshellarg($job['worker_id']) . "\n" |
. 'export RGFS_worker_id=' . escapeshellarg($job['worker_id']) . "\n" |
405 |
421 |
. 'export RGFS_worker_name=' . escapeshellarg($job['worker_name']) . "\n" |
. 'export RGFS_worker_name=' . escapeshellarg($job['worker_name']) . "\n" |
|
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
426 |
442 |
. "\n" |
. "\n" |
427 |
443 |
. 'E=0; E_CMD=""' . "\n" |
. 'E=0; E_CMD=""' . "\n" |
428 |
444 |
. "\n" |
. "\n" |
429 |
|
. 'function rg_notify()' . "\n" |
|
430 |
|
. '{' . "\n" |
|
431 |
|
. ' echo "M${@}" > /dev/virtio-ports/rgw &' . "\n" // TODO: CentOS 7, for example, returns "Resource busy" |
|
432 |
|
. ' echo "M${@}" >> /mnt/status/history' . "\n" |
|
433 |
|
. '}' . "\n" |
|
434 |
|
. "\n" |
|
435 |
|
. 'function rg_notify_err()' . "\n" |
|
436 |
|
. '{' . "\n" |
|
437 |
|
. ' echo "E${@}" > /dev/virtio-ports/rgw &' . "\n" |
|
438 |
|
. ' echo "E${@}" >> /mnt/status/history' . "\n" |
|
439 |
|
. '}' . "\n" |
|
440 |
|
. "\n" |
|
441 |
|
. 'function rg_notify_warn()' . "\n" |
|
442 |
|
. '{' . "\n" |
|
443 |
|
. ' echo "W${@}" > /dev/virtio-ports/rgw &' . "\n" |
|
444 |
|
. ' echo "W${@}" >> /mnt/status/history' . "\n" |
|
445 |
|
. '}' . "\n" |
|
446 |
|
. "\n" |
|
447 |
445 |
. 'rg_log_prefix=""' . "\n" |
. 'rg_log_prefix=""' . "\n" |
448 |
446 |
. 'function xecho()' . "\n" |
. 'function xecho()' . "\n" |
449 |
447 |
. '{' . "\n" |
. '{' . "\n" |
|
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
453 |
451 |
. 'function rg_log_push()' . "\n" |
. 'function rg_log_push()' . "\n" |
454 |
452 |
. '{' . "\n" |
. '{' . "\n" |
455 |
453 |
. ' [ "${1}" = "" ] || rg_notify "${1}"' . "\n" |
. ' [ "${1}" = "" ] || rg_notify "${1}"' . "\n" |
456 |
|
. ' [ "${1}" = "" ] || xecho "${1} [`date`]"' . "\n" |
|
457 |
454 |
. ' rg_log_prefix+=" "' . "\n" |
. ' rg_log_prefix+=" "' . "\n" |
458 |
455 |
. '}' . "\n" |
. '}' . "\n" |
459 |
456 |
. "\n" |
. "\n" |
|
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
463 |
460 |
. ' rg_log_prefix=${rg_log_prefix:2}' . "\n" |
. ' rg_log_prefix=${rg_log_prefix:2}' . "\n" |
464 |
461 |
. '}' . "\n" |
. '}' . "\n" |
465 |
462 |
. "\n" |
. "\n" |
466 |
|
. 'function rg_op_basic()' . "\n" |
|
|
463 |
|
. 'function rg_notify()' . "\n" |
|
464 |
|
. '{' . "\n" |
|
465 |
|
. ' xecho "${@} [$(date)]"' . "\n" |
|
466 |
|
. ' echo "M${@} [$(date)]" > /dev/virtio-ports/rgw 2>/dev/null' . "\n" // TODO: CentOS 7, for example, returns "Resource busy"; not only CentOS7. Also Debian 11 |
|
467 |
|
. ' echo "M${@} [$(date)]" >> /mnt/status/history' . "\n" |
|
468 |
|
. '}' . "\n" |
|
469 |
|
. "\n" |
|
470 |
|
. 'function rg_notify_err()' . "\n" |
|
471 |
|
. '{' . "\n" |
|
472 |
|
. ' xecho "${@} [$(date)]"' . "\n" |
|
473 |
|
. ' echo "E${@} [$(date)]" > /dev/virtio-ports/rgw 2>/dev/null' . "\n" |
|
474 |
|
. ' echo "E${@} [$(date)]" >> /mnt/status/history' . "\n" |
|
475 |
|
. '}' . "\n" |
|
476 |
|
. "\n" |
|
477 |
|
. 'function rg_notify_warn()' . "\n" |
|
478 |
|
. '{' . "\n" |
|
479 |
|
. ' xecho "${@}"' . "\n" |
|
480 |
|
. ' echo "W${@} [$(date)]" > /dev/virtio-ports/rgw 2>/dev/null' . "\n" |
|
481 |
|
. ' echo "W${@} [$(date)]" >> /mnt/status/history' . "\n" |
|
482 |
|
. '}' . "\n" |
|
483 |
|
. "\n" |
|
484 |
|
. 'function rg_op_basic()' . "\n" // TODO: we have a problem here: errors are not sent to rg_notify! |
467 |
485 |
. '{' . "\n" |
. '{' . "\n" |
468 |
486 |
. ' E_CMD=${@}' . "\n" |
. ' E_CMD=${@}' . "\n" |
469 |
|
. ' xecho " X: ${E_CMD}" 1>&2' . "\n" // we do not want to interfere with user redirection (rg_op cmd > out) |
|
470 |
|
. ' "${@}" 2>~/rg_op.err' . "\n" |
|
|
487 |
|
. ' rg_notify " X: ${E_CMD}" 1>&2' . "\n" // we do not want to interfere with user redirection (rg_op cmd > out) |
|
488 |
|
. ' "${@}" 2>/tmp/rg_op_${USER}.err' . "\n" |
471 |
489 |
. ' E=${?}' . "\n" |
. ' E=${?}' . "\n" |
472 |
|
. ' [ -r ~/rg_op.err ] \\' . "\n" |
|
473 |
|
. ' && sed -e "s|^|${rg_log_prefix} |" ~/rg_op.err 1>&2' . "\n" |
|
|
490 |
|
. ' (' . "\n" |
474 |
491 |
. ' if [ "${E}" != "0" ]; then' . "\n" |
. ' if [ "${E}" != "0" ]; then' . "\n" |
475 |
|
. ' xecho " Cannot execute [${E_CMD}] [E=${E}]" 1>&2' . "\n" |
|
|
492 |
|
. ' rg_notify_err " Cannot execute [E=${E}]"' . "\n" |
|
493 |
|
. ' rg_notify_err $(sed -e "s|^|${rg_log_prefix} |" /tmp/rg_op_${USER}.err)' . "\n" |
476 |
494 |
. ' fi' . "\n" |
. ' fi' . "\n" |
|
495 |
|
. ' ) 1>&2' . "\n" |
477 |
496 |
. ' return ${E}' . "\n" |
. ' return ${E}' . "\n" |
478 |
497 |
. '}' . "\n" |
. '}' . "\n" |
479 |
498 |
. "\n" |
. "\n" |
480 |
|
. 'function rg_op()' . "\n" |
|
|
499 |
|
. 'function rg_op()' . "\n" // The output will be captured by the caller |
481 |
500 |
. '{' . "\n" |
. '{' . "\n" |
482 |
501 |
. ' rg_op_basic "${@}"' . "\n" |
. ' rg_op_basic "${@}"' . "\n" |
483 |
502 |
. ' return ${E}' . "\n" |
. ' return ${E}' . "\n" |
484 |
503 |
. '}' . "\n" |
. '}' . "\n" |
485 |
504 |
. "\n" |
. "\n" |
486 |
|
. '# No output redirect version - the output will not be captured by the caller' . "\n" |
|
487 |
|
. 'function rg_op_s()' . "\n" |
|
|
505 |
|
. 'function rg_op_s()' . "\n" // The output will not be captured by the caller' . "\n" |
488 |
506 |
. '{' . "\n" |
. '{' . "\n" |
489 |
|
. ' rg_op_basic "${@}" >~/rg_op.out' . "\n" |
|
490 |
|
. ' sed -e "s|^|${rg_log_prefix} |" ~/rg_op.out' . "\n" |
|
|
507 |
|
. ' rg_op_basic "${@}" | sed -e "s|^|${rg_log_prefix} |"' . "\n" |
491 |
508 |
. ' return ${E}' . "\n" |
. ' return ${E}' . "\n" |
492 |
509 |
. '}' . "\n" |
. '}' . "\n" |
493 |
510 |
. "\n" |
. "\n" |
|
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
510 |
527 |
. ' local dir=${1}; shift' . "\n" |
. ' local dir=${1}; shift' . "\n" |
511 |
528 |
. ' local pkg_list_file=${1}; shift' . "\n" |
. ' local pkg_list_file=${1}; shift' . "\n" |
512 |
529 |
. "\n" |
. "\n" |
513 |
|
. ' xecho "rg_rpm_sign: pkg_list_file=${pkg_list_file} key=repo_id-${pkg_repo_id} dir=${dir} [`date`]"' . "\n" |
|
|
530 |
|
. ' rg_notify "rg_rpm_sign: pkg_list_file=${pkg_list_file} key=repo_id-${pkg_repo_id} dir=${dir} [`date`]"' . "\n" |
514 |
531 |
. ' if [ ! -s "${pkg_list_file}" ]; then' . "\n" |
. ' if [ ! -s "${pkg_list_file}" ]; then' . "\n" |
515 |
|
. ' xecho " No packages available."' . "\n" |
|
|
532 |
|
. ' rg_notify " No packages available."' . "\n" |
516 |
533 |
. ' return 0' . "\n" |
. ' return 0' . "\n" |
517 |
534 |
. ' fi' . "\n" |
. ' fi' . "\n" |
518 |
535 |
. ' if [ ! -d "${dir}" ]; then' . "\n" |
. ' if [ ! -d "${dir}" ]; then' . "\n" |
519 |
|
. ' xecho " Dir ${dir} not found."' . "\n" |
|
|
536 |
|
. ' rg_notify " Dir ${dir} not found."' . "\n" |
520 |
537 |
. ' return 0' . "\n" |
. ' return 0' . "\n" |
521 |
538 |
. ' fi' . "\n" |
. ' fi' . "\n" |
522 |
539 |
. "\n" |
. "\n" |
523 |
540 |
. ' local old_dir=${PWD}' . "\n" |
. ' local old_dir=${PWD}' . "\n" |
524 |
|
. ' xecho "rg_rpm_sign: switching to [${dir}]"' . "\n" |
|
525 |
541 |
. ' cd "${dir}"' . "\n" |
. ' cd "${dir}"' . "\n" |
|
542 |
|
. ' rg_notify "Signing in dir ${dir}:" $(< "${pkg_list_file}")' . "\n" |
526 |
543 |
. ' rg_op_s rpmsign --define "_gpg_name repo_id-${pkg_repo_id}" \\' . "\n" |
. ' rg_op_s rpmsign --define "_gpg_name repo_id-${pkg_repo_id}" \\' . "\n" |
527 |
544 |
. ' --define "_gpg_sign_cmd_extra_args --no-autostart --batch" \\' . "\n" |
. ' --define "_gpg_sign_cmd_extra_args --no-autostart --batch" \\' . "\n" |
528 |
545 |
. ' --resign $(< "${pkg_list_file}") </dev/null' . "\n" |
. ' --resign $(< "${pkg_list_file}") </dev/null' . "\n" |
529 |
546 |
. ' cd "${old_dir}"' . "\n" |
. ' cd "${old_dir}"' . "\n" |
|
547 |
|
. ' rg_notify "Signing done (E=${E})"' . "\n" |
530 |
548 |
. ' return ${E}' . "\n" |
. ' return ${E}' . "\n" |
531 |
549 |
. '}' . "\n" |
. '}' . "\n" |
532 |
550 |
. "\n" |
. "\n" |
533 |
|
. 'function rg_create_list()' . "\n" |
|
|
551 |
|
. 'function rg_deb_extract_control()' . "\n" |
534 |
552 |
. '{' . "\n" |
. '{' . "\n" |
535 |
553 |
. ' local dir=${1}; shift' . "\n" |
. ' local dir=${1}; shift' . "\n" |
|
554 |
|
. "\n" |
|
555 |
|
. ' rg_notify "rg_deb_extract_control: dir=[${dir}]"' . "\n" |
|
556 |
|
. ' if [ ! -d "${dir}" ]; then' . "\n" |
|
557 |
|
. ' rg_notify " dir does not exists."; return 0' . "\n" |
|
558 |
|
. ' fi' . "\n" |
|
559 |
|
. ' local old_dir=${PWD}' . "\n" |
|
560 |
|
. ' cd "${dir}"' . "\n" |
|
561 |
|
. ' while read file; do' . "\n" |
|
562 |
|
. ' [ "${file}" = "" ] && continue' . "\n" |
|
563 |
|
. ' rg_notify " Extracting control from ${file}"' . "\n" |
|
564 |
|
. ' if [ "${env_distro}" = "ubuntu" ]; then' . "\n" |
|
565 |
|
. ' cf="control.tar.zst"' . "\n" |
|
566 |
|
. ' tar_opts="--zstd"' . "\n" |
|
567 |
|
. ' else' . "\n" |
|
568 |
|
. ' cf="control.tar.xz"' . "\n" |
|
569 |
|
. ' tar_opts="--xz"' . "\n" |
|
570 |
|
. ' fi' . "\n" |
|
571 |
|
. ' ar x "${file}" ${cf}' . "\n" |
|
572 |
|
. ' if [ "${?}" != "0" ]; then' . "\n" |
|
573 |
|
. ' rg_notify_err " Cannot extract control.tar.xz"' . "\n" |
|
574 |
|
. ' E=1; break' . "\n" |
|
575 |
|
. ' fi' . "\n" |
|
576 |
|
. ' [ "${E}" = "0" ] || break' . "\n" |
|
577 |
|
. "\n" |
|
578 |
|
. ' tar xf ${cf} ${tar_opts} ./control' . "\n" |
|
579 |
|
. ' if [ "${?}" != "0" ]; then' . "\n" |
|
580 |
|
. ' rg_notify_err " Cannot extract ./control"' . "\n" |
|
581 |
|
. ' E=1; break' . "\n" |
|
582 |
|
. ' fi' . "\n" |
|
583 |
|
. ' [ "${E}" = "0" ] || break' . "\n" |
|
584 |
|
. "\n" |
|
585 |
|
. ' rm -f ${cf}' . "\n" |
|
586 |
|
. ' mv control "${file}c"' . "\n" // here is build .debc and .ddebc files |
|
587 |
|
. ' if [ "${?}" != "0" ]; then' . "\n" |
|
588 |
|
. ' rg_notify_err " Cannot rename"' . "\n" |
|
589 |
|
. ' E=1; break' . "\n" |
|
590 |
|
. ' fi' . "\n" |
|
591 |
|
. ' [ "${E}" = "0" ] || break' . "\n" |
|
592 |
|
. ' done < <(ls *.deb *.ddeb)' . "\n" |
|
593 |
|
. ' cd "${old_dir}"' . "\n" |
|
594 |
|
. ' return ${E}' . "\n" |
|
595 |
|
. '}' . "\n" |
|
596 |
|
. "\n" |
|
597 |
|
. 'function rg_deb_sign()' . "\n" |
|
598 |
|
. '{' . "\n" |
|
599 |
|
. ' local pkg_repo_id=${1}; shift' . "\n" |
|
600 |
|
. ' local dir=${1}; shift' . "\n" |
536 |
601 |
. ' local pkg_list_file=${1}; shift' . "\n" |
. ' local pkg_list_file=${1}; shift' . "\n" |
537 |
602 |
. "\n" |
. "\n" |
538 |
|
. ' xecho "rg_create_list: pkg_list_file=${pkg_list_file} dir=${dir} [`date`]"' . "\n" |
|
|
603 |
|
. ' rg_notify "rg_deb_sign: pkg_list_file=${pkg_list_file} key=repo_id-${pkg_repo_id} dir=${dir} [`date`]"' . "\n" |
|
604 |
|
. ' if [ ! -s "${pkg_list_file}" ]; then' . "\n" |
|
605 |
|
. ' rg_notify " No packages available."' . "\n" |
|
606 |
|
. ' return 0' . "\n" |
|
607 |
|
. ' fi' . "\n" |
539 |
608 |
. ' if [ ! -d "${dir}" ]; then' . "\n" |
. ' if [ ! -d "${dir}" ]; then' . "\n" |
540 |
|
. ' xecho " Dir ${dir} not found."' . "\n" |
|
|
609 |
|
. ' rg_notify " Dir ${dir} not found."' . "\n" |
541 |
610 |
. ' return 0' . "\n" |
. ' return 0' . "\n" |
542 |
611 |
. ' fi' . "\n" |
. ' fi' . "\n" |
543 |
|
. ' export dir' . "\n" |
|
544 |
|
. ' (cd "${dir}"; find . -type f -iname "*.rpm") > "${pkg_list_file}"' . "\n" |
|
|
612 |
|
. "\n" |
|
613 |
|
. ' local old_dir=${PWD}' . "\n" |
|
614 |
|
. ' cd "${dir}"' . "\n" |
|
615 |
|
. ' rg_notify "Signing in dir ${dir}:" $(< "${pkg_list_file}")' . "\n" |
|
616 |
|
. ' rg_op_s dpkg-sig --verbose -k repo_id-${pkg_repo_id} \\' . "\n" |
|
617 |
|
. ' --sign rg --verbose \\' . "\n" |
|
618 |
|
. ' $(< "${pkg_list_file}") </dev/null' . "\n" |
|
619 |
|
. ' cd "${old_dir}"' . "\n" |
|
620 |
|
. ' rg_notify "Signing done (E=${E})"' . "\n" |
|
621 |
|
. ' return ${E}' . "\n" |
|
622 |
|
. '}' . "\n" |
|
623 |
|
. "\n" |
|
624 |
|
. 'function rg_rpm_create_list()' . "\n" |
|
625 |
|
. '{' . "\n" |
|
626 |
|
. ' local dir=${1}; shift' . "\n" |
|
627 |
|
. ' local pkg_list_file=${1}; shift' . "\n" |
|
628 |
|
. "\n" |
|
629 |
|
. ' rg_notify "rg_rpm_create_list: pkg_list_file=${pkg_list_file} dir=${dir} [`date`]"' . "\n" |
|
630 |
|
. ' if [ ! -d "${dir}" ]; then' . "\n" |
|
631 |
|
. ' rg_notify_err " Dir ${dir} not found."' . "\n" |
|
632 |
|
. ' return 0' . "\n" |
|
633 |
|
. ' fi' . "\n" |
|
634 |
|
. ' (cd "${dir}"; find . -type f -name "*.rpm") > "${pkg_list_file}"' . "\n" |
|
635 |
|
. ' if [ ! -s "${pkg_list_file}" ]; then' . "\n" |
|
636 |
|
. ' rg_notify " No files!"' . "\n" |
|
637 |
|
. ' return 0' . "\n" |
|
638 |
|
. ' fi' . "\n" |
|
639 |
|
. ' rg_notify " content:" $(< "${pkg_list_file}")' . "\n" |
|
640 |
|
. '}' . "\n" |
|
641 |
|
. "\n" |
|
642 |
|
. 'function rg_deb_create_deb_list()' . "\n" |
|
643 |
|
. '{' . "\n" |
|
644 |
|
. ' local dir=${1}; shift' . "\n" |
|
645 |
|
. ' local pkg_list_file=${1}; shift' . "\n" |
|
646 |
|
. "\n" |
|
647 |
|
. ' rg_notify "rg_deb_create_deb_list: pkg_list_file=${pkg_list_file} dir=${dir} [`date`]"' . "\n" |
|
648 |
|
. ' if [ ! -d "${dir}" ]; then' . "\n" |
|
649 |
|
. ' rg_notify " Dir ${dir} not found."' . "\n" |
|
650 |
|
. ' return 0' . "\n" |
|
651 |
|
. ' fi' . "\n" |
|
652 |
|
. ' (cd "${dir}"; find . -type f -name "*.deb" -o -name "*.ddeb") > "${pkg_list_file}"' . "\n" |
545 |
653 |
. ' if [ ! -s "${pkg_list_file}" ]; then' . "\n" |
. ' if [ ! -s "${pkg_list_file}" ]; then' . "\n" |
546 |
|
. ' xecho " No files!"' . "\n" |
|
|
654 |
|
. ' rg_notify " No files!"' . "\n" |
547 |
655 |
. ' return 0' . "\n" |
. ' return 0' . "\n" |
548 |
656 |
. ' fi' . "\n" |
. ' fi' . "\n" |
549 |
|
. ' xecho " content: "`cat "${pkg_list_file}"`' . "\n" |
|
|
657 |
|
. ' rg_notify " content:" $(< "${pkg_list_file}")' . "\n" |
|
658 |
|
. '}' . "\n" |
|
659 |
|
. "\n" |
|
660 |
|
. 'function rg_create_list()' . "\n" |
|
661 |
|
. '{' . "\n" |
|
662 |
|
. ' local dir=${1}; shift' . "\n" |
|
663 |
|
. ' local file=${1}; shift' . "\n" |
|
664 |
|
. "\n" |
|
665 |
|
. ' rg_notify "rg_create_list: file=${file} dir=${dir} [`date`]"' . "\n" |
|
666 |
|
. ' if [ ! -d "${dir}" ]; then' . "\n" |
|
667 |
|
. ' rg_notify " Dir ${dir} not found."' . "\n" |
|
668 |
|
. ' return 0' . "\n" |
|
669 |
|
. ' fi' . "\n" |
|
670 |
|
. ' (cd "${dir}"; find . -type f | grep -v "\.list\$") > "${file}"' . "\n" |
|
671 |
|
. ' if [ ! -s "${file}" ]; then' . "\n" |
|
672 |
|
. ' rg_notify " No files!"' . "\n" |
|
673 |
|
. ' return 0' . "\n" |
|
674 |
|
. ' fi' . "\n" |
|
675 |
|
. ' rg_notify " content:" $(< "${file}")' . "\n" |
550 |
676 |
. '}' . "\n" |
. '}' . "\n" |
551 |
677 |
. "\n" |
. "\n" |
552 |
678 |
. 'function rg_rpm_createrepo()' . "\n" |
. 'function rg_rpm_createrepo()' . "\n" |
|
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
556 |
682 |
. ' local pkg_list_file=${1}; shift' . "\n" |
. ' local pkg_list_file=${1}; shift' . "\n" |
557 |
683 |
. ' local oldpackagedirs=${1}; shift' . "\n" |
. ' local oldpackagedirs=${1}; shift' . "\n" |
558 |
684 |
. "\n" |
. "\n" |
559 |
|
. ' xecho "rg_rpm_createrepo dir=${dir} pkg_list_file=${pkg_list_file} oldpackagedirs=${oldpackagedirs} [`date`]"' . "\n" |
|
|
685 |
|
. ' rg_notify "rg_rpm_createrepo dir=${dir} pkg_list_file=${pkg_list_file} oldpackagedirs=${oldpackagedirs} [`date`]"' . "\n" |
560 |
686 |
. ' rm -rf "${dir}/.repodata"' . "\n" |
. ' rm -rf "${dir}/.repodata"' . "\n" |
561 |
687 |
. "\n" |
. "\n" |
562 |
688 |
. ' local extra_paras=""' . "\n" |
. ' local extra_paras=""' . "\n" |
|
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
566 |
692 |
. "\n" |
. "\n" |
567 |
693 |
. ' local old_dir="${PWD}"' . "\n" |
. ' local old_dir="${PWD}"' . "\n" |
568 |
694 |
. ' cd "${dir}"' . "\n" |
. ' cd "${dir}"' . "\n" |
569 |
|
. ' xecho " Switch to dir ${dir}"' . "\n" |
|
570 |
|
. ' xecho "DEBUG: Files:"' . "\n" |
|
|
695 |
|
. ' rg_notify " Switch to dir ${dir}"' . "\n" |
|
696 |
|
. ' rg_notify "DEBUG: Files:"' . "\n" |
571 |
697 |
. ' find .' . "\n" |
. ' find .' . "\n" |
572 |
698 |
. ' rg_op_s createrepo -v --update ${extra_paras} \\' . "\n" |
. ' rg_op_s createrepo -v --update ${extra_paras} \\' . "\n" |
573 |
699 |
. ' --recycle-pkglist \\' . "\n" |
. ' --recycle-pkglist \\' . "\n" |
|
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
582 |
708 |
. ' return ${E}' . "\n" |
. ' return ${E}' . "\n" |
583 |
709 |
. '}' . "\n" |
. '}' . "\n" |
584 |
710 |
. "\n" |
. "\n" |
585 |
|
. 'function rg_extract_rpm_info()' . "\n" |
|
|
711 |
|
. 'function rg_rpm_extract_info()' . "\n" |
586 |
712 |
. '{' . "\n" |
. '{' . "\n" |
587 |
713 |
. ' local dir=${1}; shift' . "\n" |
. ' local dir=${1}; shift' . "\n" |
588 |
714 |
. "\n" |
. "\n" |
589 |
715 |
. ' rg_notify "Extracting .spec info"' . "\n" |
. ' rg_notify "Extracting .spec info"' . "\n" |
590 |
|
. ' xecho "rg_extract_rpm_info: dir=${dir} [`date`]"' . "\n" |
|
|
716 |
|
. ' rg_notify "rg_rpm_extract_info: dir=${dir} [`date`]"' . "\n" |
591 |
717 |
. ' spec_file=`find "${dir}" -iname \'*.spec\' -type f -printf "%d %p\n" | sort -n | head -n1 | awk \'{print $2}\'`' . "\n" |
. ' spec_file=`find "${dir}" -iname \'*.spec\' -type f -printf "%d %p\n" | sort -n | head -n1 | awk \'{print $2}\'`' . "\n" |
592 |
718 |
. ' if [ "${spec_file}" = "" ]; then' . "\n" |
. ' if [ "${spec_file}" = "" ]; then' . "\n" |
593 |
|
. ' xecho " Cannot find any .spec file in ${dir}!"' . "\n" |
|
594 |
|
. ' ls -l "${dir}"' . "\n" |
|
|
719 |
|
. ' rg_notify " Cannot find any .spec file in ${dir}!"' . "\n" |
595 |
720 |
. ' return' . "\n" |
. ' return' . "\n" |
596 |
721 |
. ' fi' . "\n" |
. ' fi' . "\n" |
597 |
722 |
. "\n" |
. "\n" |
598 |
723 |
. ' spec_file_base=`basename "${spec_file}"`' . "\n" |
. ' spec_file_base=`basename "${spec_file}"`' . "\n" |
599 |
|
. ' xecho " .spec file: ${spec_file} basename=[${spec_file_base}]."' . "\n" |
|
|
724 |
|
. ' rg_notify " .spec file: ${spec_file} basename=[${spec_file_base}]."' . "\n" |
600 |
725 |
. "\n" |
. "\n" |
601 |
|
. ' xecho " Extracting info about version"' . "\n" |
|
602 |
|
. ' spec_name=`grep ^Name: "${spec_file}" | cut -d: -f2| tr -d " \t\r\n"`' . "\n" |
|
603 |
|
. ' spec_ver=`grep ^Version: "${spec_file}" | cut -d: -f2 | tr -d " \t\r\n"`' . "\n" |
|
604 |
|
. ' spec_rel=`grep ^Release: "${spec_file}" | cut -d: -f2 | tr -d " \t\r\n"`' . "\n" |
|
605 |
|
. ' spec_deps=`rpmspec --parse "${spec_file}" | grep ^BuildRequires | cut -d: -f2 | tr ",\t\r\n" " "`' . "\n" |
|
606 |
|
. ' xecho " DEBUG: name=${spec_name}, ver=${spec_ver}, rel=${spec_rel}"' . "\n" |
|
|
726 |
|
. ' rg_notify " Extracting info..."' . "\n" |
|
727 |
|
. ' pkg_name=`grep ^Name: "${spec_file}" | cut -d: -f2| tr -d " \t\r\n"`' . "\n" |
|
728 |
|
. ' pkg_ver=`grep ^Version: "${spec_file}" | cut -d: -f2 | tr -d " \t\r\n"`' . "\n" |
|
729 |
|
. ' pkg_rel=`grep ^Release: "${spec_file}" | cut -d: -f2 | tr -d " \t\r\n"`' . "\n" |
|
730 |
|
. ' pkg_deps=`rpmspec --parse "${spec_file}" | grep ^BuildRequires | cut -d: -f2- | tr ",\t\r\n" " "`' . "\n" |
|
731 |
|
. ' rg_notify " DEBUG: name=${pkg_name}, ver=${pkg_ver}, rel=${pkg_rel}"' . "\n" |
|
732 |
|
. ' echo' . "\n" |
|
733 |
|
. '}' . "\n" |
|
734 |
|
. "\n" |
|
735 |
|
. 'function rg_deb_extract_info()' . "\n" |
|
736 |
|
. '{' . "\n" |
|
737 |
|
. ' local dir=${1}; shift' . "\n" |
|
738 |
|
. "\n" |
|
739 |
|
. ' rg_notify "Extracting deb info dir=${dir}"' . "\n" |
|
740 |
|
. ' control_file=`find "${dir}" -iname control -type f -printf "%d %p\n" | sort -n | head -n1 | awk \'{print $2}\'`' . "\n" |
|
741 |
|
. ' if [ "${control_file}" = "" ]; then' . "\n" |
|
742 |
|
. ' rg_notify_err " Cannot find any control file in ${dir}!"' . "\n" |
|
743 |
|
. ' return' . "\n" |
|
744 |
|
. ' fi' . "\n" |
|
745 |
|
. "\n" |
|
746 |
|
. ' rg_notify " Extracting info..."' . "\n" |
|
747 |
|
. ' pkg_name=$(grep ^Source: "${control_file}" | cut -d: -f2| tr -d " \t\r\n")' . "\n" |
|
748 |
|
. ' pkg_deps=$(grep ^Depends: "${control_file}" | cut -d: -f2- | tr ",\t\r\n" " " | sed -e \'s/\${[^}]*}//g\')' . "\n" |
|
749 |
|
. ' rg_notify " DEBUG: name=${pkg_name}"' . "\n" |
607 |
750 |
. ' echo' . "\n" |
. ' echo' . "\n" |
608 |
751 |
. '}' . "\n" |
. '}' . "\n" |
609 |
752 |
. "\n" |
. "\n" |
|
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
613 |
756 |
. "\n" |
. "\n" |
614 |
757 |
. ' rg_log_push "rg_build_dotrepo dir=${dir}"' . "\n" |
. ' rg_log_push "rg_build_dotrepo dir=${dir}"' . "\n" |
615 |
758 |
. ' while [ 1 ]; do' . "\n" |
. ' while [ 1 ]; do' . "\n" |
616 |
|
. ' rg_extract_rpm_info "${dir}"' . "\n" |
|
617 |
|
. ' if [ "${spec_name}" = "" ]; then' . "\n" |
|
618 |
|
. ' xecho "Malformed .spec file?"' . "\n" |
|
|
759 |
|
. ' rg_rpm_extract_info "${dir}"' . "\n" |
|
760 |
|
. ' if [ "${pkg_name}" = "" ]; then' . "\n" |
|
761 |
|
. ' rg_notify "Malformed .spec file?"' . "\n" |
619 |
762 |
. ' E=1' . "\n" |
. ' E=1' . "\n" |
620 |
763 |
. ' break' . "\n" |
. ' break' . "\n" |
621 |
764 |
. ' fi' . "\n" |
. ' fi' . "\n" |
622 |
765 |
. "\n" |
. "\n" |
623 |
|
. ' local dst_tar_gz="/mnt/rpmbuild/SOURCES/${spec_name}-${spec_ver}.tar.gz"' . "\n" |
|
|
766 |
|
. ' local dst_tar_gz="/mnt/rpmbuild/SOURCES/${pkg_name}-${pkg_ver}.tar.gz"' . "\n" |
624 |
767 |
. ' local dst_spec="/mnt/rpmbuild/SPECS/${spec_file_base}"' . "\n" |
. ' local dst_spec="/mnt/rpmbuild/SPECS/${spec_file_base}"' . "\n" |
625 |
|
. ' local xecho "DEBUG: dst_spec=${dst_spec}."' . "\n" |
|
|
768 |
|
. ' local rg_notify "DEBUG: dst_spec=${dst_spec}."' . "\n" |
626 |
769 |
. "\n" |
. "\n" |
627 |
|
. ' xecho "Creating tar archive [${dst_tar_gz}]"' . "\n" |
|
628 |
|
. ' rg_op_s tar czf "${dst_tar_gz}" --transform "s:^:./${spec_name}-${spec_ver}/:g" \\' . "\n" |
|
|
770 |
|
. ' rg_notify "Creating tar archive [${dst_tar_gz}]"' . "\n" |
|
771 |
|
. ' rg_notify "Creating tar"' . "\n" |
|
772 |
|
. ' rg_op_s tar czf "${dst_tar_gz}" --transform "s:^:./${pkg_name}-${pkg_ver}/:g" \\' . "\n" |
629 |
773 |
. ' -C "${dir}" . || break' . "\n" |
. ' -C "${dir}" . || break' . "\n" |
630 |
774 |
. "\n" |
. "\n" |
631 |
|
. ' xecho "Copying spec file [${spec_file}] -> [${dst_spec}]"' . "\n" |
|
|
775 |
|
. ' rg_notify "Copying spec file [${spec_file}] -> [${dst_spec}]"' . "\n" |
632 |
776 |
. ' rg_cp "${spec_file}" "${dst_spec}"' . "\n" |
. ' rg_cp "${spec_file}" "${dst_spec}"' . "\n" |
633 |
777 |
. "\n" |
. "\n" |
634 |
|
. ' xecho "Making only binary packages"' . "\n" |
|
|
778 |
|
. ' rg_notify "Making only binary packages"' . "\n" |
|
779 |
|
. ' rg_notify "Creating rpm"' . "\n" |
635 |
780 |
. ' rg_op_s rpmbuild --define "_topdir /mnt/rpmbuild" \\' . "\n" |
. ' rg_op_s rpmbuild --define "_topdir /mnt/rpmbuild" \\' . "\n" |
636 |
781 |
. ' -bb "${dst_spec}" || break' . "\n" |
. ' -bb "${dst_spec}" || break' . "\n" |
637 |
782 |
. ' break' . "\n" |
. ' break' . "\n" |
|
... |
... |
function start_worker_build_tools($job, &$reason, &$reason2) |
643 |
788 |
. 'function rg_build_rpm()' . "\n" |
. 'function rg_build_rpm()' . "\n" |
644 |
789 |
. '{' . "\n" |
. '{' . "\n" |
645 |
790 |
. ' local dir=${1}; shift' . "\n" |
. ' local dir=${1}; shift' . "\n" |
646 |
|
. "\n" |
|
|
791 |
|
. "\n" |
647 |
792 |
. ' rg_log_push "rg_build_rpm: dir=${dir}"' . "\n" |
. ' rg_log_push "rg_build_rpm: dir=${dir}"' . "\n" |
648 |
793 |
. ' while [ 1 ]; do' . "\n" |
. ' while [ 1 ]; do' . "\n" |
649 |
|
. ' rg_extract_rpm_info "${dir}"' . "\n" |
|
650 |
|
. ' if [ "${spec_name}" = "" ]; then' . "\n" |
|
651 |
|
. ' xecho "Malformed .spec file?"' . "\n" |
|
|
794 |
|
. ' rg_rpm_extract_info "${dir}"' . "\n" |
|
795 |
|
. ' if [ "${pkg_name}" = "" ]; then' . "\n" |
|
796 |
|
. ' rg_notify_err "Malformed .spec file?"' . "\n" |
652 |
797 |
. ' E=1' . "\n" |
. ' E=1' . "\n" |
653 |
798 |
. ' break' . "\n" |
. ' break' . "\n" |
654 |
799 |
. ' fi' . "\n" |
. ' fi' . "\n" |
655 |
|
. ' local dst_tar_gz="/mnt/rpmbuild/SOURCES/${repo_username}+${spec_name}-${spec_ver}.tar.gz"' . "\n" |
|
|
800 |
|
. ' local dst_tar_gz="/mnt/rpmbuild/SOURCES/${repo_username}+${pkg_name}-${pkg_ver}.tar.gz"' . "\n" |
656 |
801 |
. ' local dst_spec="/mnt/rpmbuild/SPECS/${repo_username}+${spec_file_base}"' . "\n" |
. ' local dst_spec="/mnt/rpmbuild/SPECS/${repo_username}+${spec_file_base}"' . "\n" |
657 |
|
. "\n" |
|
658 |
|
. ' xecho "Creating archive from git repo [${dst_tar_gz}]"' . "\n" |
|
|
802 |
|
. "\n" |
|
803 |
|
. ' rg_notify "Creating archive from git repo [${dst_tar_gz}]"' . "\n" |
|
804 |
|
. ' rg_notify "Creating tar"' . "\n" |
659 |
805 |
. ' rg_op_s git -C "${dir}" archive -v \\' . "\n" |
. ' rg_op_s git -C "${dir}" archive -v \\' . "\n" |
660 |
|
. ' --prefix "./${repo_username}+${spec_name}-${spec_ver}/" \\' . "\n" |
|
|
806 |
|
. ' --prefix "./${repo_username}+${pkg_name}-${pkg_ver}/" \\' . "\n" |
661 |
807 |
. ' -o "${dst_tar_gz}" rgw || break' . "\n" |
. ' -o "${dst_tar_gz}" rgw || break' . "\n" |
662 |
|
. "\n" |
|
663 |
|
. ' xecho "Processing spec file [${spec_file}] -> [${dst_spec}]"' . "\n" |
|
|
808 |
|
. "\n" |
|
809 |
|
. ' rg_notify "Processing spec file [${spec_file}] -> [${dst_spec}]"' . "\n" |
664 |
810 |
. ' rg_op sed -r -e "s|^Name:(\s*)(.*)(\s*)|Name:\1${repo_username}+\2\3|" \\' . "\n" |
. ' rg_op sed -r -e "s|^Name:(\s*)(.*)(\s*)|Name:\1${repo_username}+\2\3|" \\' . "\n" |
665 |
811 |
. ' "${spec_file}" > "${dst_spec}" || break' . "\n" |
. ' "${spec_file}" > "${dst_spec}" || break' . "\n" |
666 |
|
. "\n" |
|
667 |
|
. ' xecho "Making source and binary packages"' . "\n" |
|
|
812 |
|
. "\n" |
|
813 |
|
. ' rg_notify "Making source and binary packages"' . "\n" |
|
814 |
|
. ' rg_notify "Creating source and binary packages"' . "\n" |
668 |
815 |
. ' rg_op_s rpmbuild --define "_topdir /mnt/rpmbuild" \\' . "\n" |
. ' rg_op_s rpmbuild --define "_topdir /mnt/rpmbuild" \\' . "\n" |
669 |
816 |
. ' -ba "${dst_spec}" || break' . "\n" |
. ' -ba "${dst_spec}" || break' . "\n" |
670 |
817 |
. ' break' . "\n" |
. ' break' . "\n" |
671 |
818 |
. ' done' . "\n" |
. ' done' . "\n" |
672 |
819 |
. ' rg_log_pop' . "\n" |
. ' rg_log_pop' . "\n" |
673 |
820 |
. ' return ${E}' . "\n" |
. ' return ${E}' . "\n" |
674 |
|
. '}' . "\n\n" |
|
|
821 |
|
. '}' . "\n" |
|
822 |
|
. "\n" |
|
823 |
|
. 'function rg_build_deb()' . "\n" |
|
824 |
|
. '{' . "\n" |
|
825 |
|
. ' local dir=${1}; shift' . "\n" |
|
826 |
|
. "\n" |
|
827 |
|
. ' rg_log_push "rg_build_deb: dir=${dir}"' . "\n" |
|
828 |
|
. ' local old_dir="${PWD}"' . "\n" |
|
829 |
|
. ' cd "${dir}"' . "\n" |
|
830 |
|
. ' while [ 1 ]; do' . "\n" |
|
831 |
|
. ' rg_deb_extract_info "${dir}"' . "\n" |
|
832 |
|
. ' if [ "${pkg_name}" = "" ]; then' . "\n" |
|
833 |
|
. ' rg_notify_err "Malformed debian/control file?"' . "\n" |
|
834 |
|
. ' E=1' . "\n" |
|
835 |
|
. ' break' . "\n" |
|
836 |
|
. ' fi' . "\n" |
|
837 |
|
. "\n" |
|
838 |
|
. ' rg_notify "Processing control file"' . "\n" |
|
839 |
|
. ' # Changing Source: and Package: to prepend the user name' . "\n" |
|
840 |
|
. ' rg_op sed -i -r \\' . "\n" |
|
841 |
|
. ' -e "s#(Source|Package):(\s*)(.*)#\1:\2${repo_username_allowed}+\3#" \\' . "\n" |
|
842 |
|
. ' "debian/control" || break' . "\n" |
|
843 |
|
. ' rg_op sed -i -r \\' . "\n" |
|
844 |
|
. ' -e "s#^(\S+.*)\$#${repo_username_allowed}+\1#" \\' . "\n" |
|
845 |
|
. ' "debian/changelog" || break' . "\n" |
|
846 |
|
. "\n" |
|
847 |
|
. ' rg_notify "Creating source and binary packages"' . "\n" |
|
848 |
|
. ' rg_op_s dpkg-buildpackage --no-check-builddeps \\' . "\n" |
|
849 |
|
. ' -uc -us || break' . "\n" |
|
850 |
|
. ' # Because Ubuntu generates .ddeb files we need to rename them' . "\n" |
|
851 |
|
. ' cd ..' . "\n" |
|
852 |
|
. ' while read f; do' . "\n" |
|
853 |
|
. ' rg_notify "Renaming ${f} to ${f%.ddeb}.deb..."' . "\n" |
|
854 |
|
. ' mv -fv "${f}" "${f%.ddeb}.deb"' . "\n" |
|
855 |
|
. ' done < <(ls *.ddeb 2>/dev/null)' . "\n" |
|
856 |
|
. ' break' . "\n" |
|
857 |
|
. ' done' . "\n" |
|
858 |
|
. ' cd "${old_dir}"' . "\n" |
|
859 |
|
. ' xecho "Done E=${E}"' . "\n" |
|
860 |
|
. ' rg_log_pop' . "\n" |
|
861 |
|
. ' return ${E}' . "\n" |
|
862 |
|
. '}' . "\n" |
|
863 |
|
. "\n" |
675 |
864 |
. 'mkdir -p /mnt/status' . "\n" |
. 'mkdir -p /mnt/status' . "\n" |
676 |
|
. 'touch /mnt/status/history' . "\n" |
|
677 |
|
. 'chmod a+w /mnt/status/history' . "\n\n"; |
|
|
865 |
|
. 'touch /mnt/status/history 2>/dev/null' . "\n" |
|
866 |
|
. 'chmod a+w /mnt/status/history 2>/dev/null' . "\n\n"; |
678 |
867 |
|
|
679 |
868 |
$f = $job['main'] . '/root/build_tools.sh'; |
$f = $job['main'] . '/root/build_tools.sh'; |
680 |
869 |
$r = @file_put_contents($f, $s); |
$r = @file_put_contents($f, $s); |
|
... |
... |
function start_worker_build_rpms($job, $conf, &$reason, &$reason2) |
709 |
898 |
. "\n" |
. "\n" |
710 |
899 |
. 'source /mnt/build_tools.sh' . "\n" |
. 'source /mnt/build_tools.sh' . "\n" |
711 |
900 |
. "\n" |
. "\n" |
712 |
|
. 'env_distro=' . escapeshellarg($job['env_distro']) . "\n" |
|
713 |
|
. 'env_major=' . escapeshellarg($job['env_major']) . "\n" |
|
714 |
|
. 'env_arch=' . escapeshellarg($job['env_arch']) . "\n" |
|
715 |
|
. "\n" |
|
716 |
|
. 'mkdir -p /mnt/rpmbuild/{SOURCES,SPECS}' . "\n"; |
|
717 |
|
|
|
718 |
|
if (isset($job['repo_username'])) |
|
719 |
|
$s .= 'repo_username=' . escapeshellarg($job['repo_username']) . "\n"; |
|
720 |
|
|
|
721 |
|
$s .= '' |
|
|
901 |
|
. 'id' . "\n" |
|
902 |
|
. 'mkdir -p /mnt/rpmbuild/{SOURCES,SPECS}' . "\n" |
722 |
903 |
. "\n" |
. "\n" |
723 |
904 |
. 'while [ 1 ]; do' . "\n"; |
. 'while [ 1 ]; do' . "\n"; |
724 |
905 |
|
|
725 |
906 |
if (isset($job['url'])) |
if (isset($job['url'])) |
726 |
|
$s .= ' rg_build_rpm /mnt/target || break' . "\n"; |
|
|
907 |
|
$s .= ' rg_build_rpm /mnt/target/source || break' . "\n"; |
727 |
908 |
|
|
728 |
909 |
if (isset($job['rpm_repo_files'])) |
if (isset($job['rpm_repo_files'])) |
729 |
910 |
foreach ($job['rpm_repo_files'] as $pkg_subrepo_id => $junk) |
foreach ($job['rpm_repo_files'] as $pkg_subrepo_id => $junk) |
|
... |
... |
function start_worker_build_rpms($job, $conf, &$reason, &$reason2) |
731 |
912 |
|
|
732 |
913 |
$s .= '' |
$s .= '' |
733 |
914 |
. ' break' . "\n" |
. ' break' . "\n" |
734 |
|
. 'done' . "\n"; |
|
|
915 |
|
. 'done' . "\n" |
|
916 |
|
. 'exit ${E}' . "\n"; |
735 |
917 |
|
|
736 |
918 |
$f = $job['main'] . '/root/build_rpms.sh'; |
$f = $job['main'] . '/root/build_rpms.sh'; |
737 |
919 |
$r = @file_put_contents($f, $s); |
$r = @file_put_contents($f, $s); |
|
... |
... |
function start_worker_build_rpms($job, $conf, &$reason, &$reason2) |
751 |
933 |
return TRUE; |
return TRUE; |
752 |
934 |
} |
} |
753 |
935 |
|
|
|
936 |
|
/* |
|
937 |
|
* Building debs script |
|
938 |
|
*/ |
|
939 |
|
function start_worker_build_debs($job, $conf, &$reason, &$reason2) |
|
940 |
|
{ |
|
941 |
|
//rg_log_debug('job: ' . print_r($job, TRUE)); |
|
942 |
|
//rg_log_debug('conf: ' . print_r($conf, TRUE)); |
|
943 |
|
|
|
944 |
|
$env = $conf['env'][$job['env']]; |
|
945 |
|
|
|
946 |
|
$s = '' |
|
947 |
|
. '#!/bin/bash' . "\n" |
|
948 |
|
. "\n" |
|
949 |
|
. 'source /mnt/build_tools.sh' . "\n" |
|
950 |
|
. "\n" |
|
951 |
|
. 'id' . "\n" |
|
952 |
|
. 'while [ 1 ]; do' . "\n"; |
|
953 |
|
|
|
954 |
|
if (isset($job['url'])) |
|
955 |
|
$s .= ' rg_build_deb /mnt/target/source || break' . "\n"; |
|
956 |
|
|
|
957 |
|
$s .= '' |
|
958 |
|
. ' break' . "\n" |
|
959 |
|
. 'done' . "\n" |
|
960 |
|
. 'exit ${E}' . "\n"; |
|
961 |
|
|
|
962 |
|
$f = $job['main'] . '/root/build_debs.sh'; |
|
963 |
|
$r = @file_put_contents($f, $s); |
|
964 |
|
if ($r === FALSE) { |
|
965 |
|
$reason = 'cannot save ' . $f; |
|
966 |
|
$reason2 = 'cannot save ' . $f . ': ' . rg_php_err(); |
|
967 |
|
return FALSE; |
|
968 |
|
} |
|
969 |
|
|
|
970 |
|
$r = @chmod($f, 0755); |
|
971 |
|
if ($r === FALSE) { |
|
972 |
|
$reason = 'cannot chmod ' . $f; |
|
973 |
|
$reason2 = 'cannot chmod ' . $f . ': (' . rg_php_err() . ')'; |
|
974 |
|
return FALSE; |
|
975 |
|
} |
|
976 |
|
|
|
977 |
|
return TRUE; |
|
978 |
|
} |
|
979 |
|
|
754 |
980 |
/* |
/* |
755 |
981 |
* Building rgfs building script |
* Building rgfs building script |
756 |
982 |
* This is temporary, till we will have it on the main rocketgit repo. |
* This is temporary, till we will have it on the main rocketgit repo. |
|
... |
... |
function start_worker_build_rgfs($job, &$reason, &$reason2) |
760 |
986 |
$s = '' |
$s = '' |
761 |
987 |
. '#!/bin/bash' . "\n" |
. '#!/bin/bash' . "\n" |
762 |
988 |
. "\n" |
. "\n" |
|
989 |
|
. 'source /mnt/build_tools.sh' . "\n" |
|
990 |
|
. "\n" |
763 |
991 |
. 'set -e' . "\n" |
. 'set -e' . "\n" |
764 |
992 |
. "\n" |
. "\n" |
|
993 |
|
. 'rg_notify "Starting rgfs building"' . "\n" |
|
994 |
|
. "\n" |
765 |
995 |
. 'if [ -x /usr/bin/rgfs ]; then' . "\n" |
. 'if [ -x /usr/bin/rgfs ]; then' . "\n" |
766 |
|
. ' echo "rgfs binary already exists. Exit."' . "\n" |
|
|
996 |
|
. ' rg_notify "rgfs binary already exists. Exit."' . "\n" |
767 |
997 |
. ' exit 0' . "\n" |
. ' exit 0' . "\n" |
768 |
998 |
. 'fi' . "\n" |
. 'fi' . "\n" |
769 |
999 |
. "\n" |
. "\n" |
|
... |
... |
function start_worker_build_rgfs($job, &$reason, &$reason2) |
771 |
1001 |
. 'cd rgfs' . "\n" |
. 'cd rgfs' . "\n" |
772 |
1002 |
. './configure' . "\n" |
. './configure' . "\n" |
773 |
1003 |
. 'make' . "\n" |
. 'make' . "\n" |
774 |
|
. 'make install' . "\n"; |
|
|
1004 |
|
. 'make install' . "\n" |
|
1005 |
|
. 'rg_notify "rgfs building done"' . "\n"; |
775 |
1006 |
|
|
776 |
1007 |
$f = $job['main'] . '/root/build_rgfs.sh'; |
$f = $job['main'] . '/root/build_rgfs.sh'; |
777 |
1008 |
$r = @file_put_contents($f, $s); |
$r = @file_put_contents($f, $s); |
|
... |
... |
function start_worker_build_repo($job, $conf, &$reason, &$reason2) |
846 |
1077 |
$s = '' |
$s = '' |
847 |
1078 |
. '#!/bin/bash' . "\n" |
. '#!/bin/bash' . "\n" |
848 |
1079 |
. "\n" |
. "\n" |
849 |
|
. 'source /mnt/build_tools.sh' . "\n"; |
|
850 |
|
|
|
851 |
|
$s .= "\n" |
|
852 |
|
. 'xecho "`date`"' . "\n" |
|
853 |
|
. 'xecho "I: job_id=${job_id} job_uid=${job_uid} repo_username=${repo_username}"' . "\n" |
|
854 |
|
. 'xecho "I: distro=${env_distro} major=${env_major} arch=${env_arch}"' . "\n" |
|
|
1080 |
|
. 'source /mnt/build_tools.sh' . "\n" |
|
1081 |
|
. 'id' . "\n" |
|
1082 |
|
. "\n" |
|
1083 |
|
. 'rg_notify "I: job_id=${job_id} orig_job_id=${orig_job_id} job_uid=${job_uid} repo_username=${repo_username}"' . "\n" |
|
1084 |
|
. 'rg_notify "I: distro=${env_distro} major=${env_major} arch=${env_arch}"' . "\n" |
|
1085 |
|
. 'rg_notify "I: do_sensitive_ops=$(do_sensitive_ops)"' . "\n" |
855 |
1086 |
. "\n" |
. "\n" |
856 |
1087 |
. 'while [ 1 ]; do' |
. 'while [ 1 ]; do' |
857 |
1088 |
. ' echo ' . "\n" |
. ' echo ' . "\n" |
858 |
|
. ' rg_log_push "Locating package files in /mnt/rpmbuild"' . "\n" |
|
859 |
|
. ' files=`find /mnt/rpmbuild -type f -iname "*.rpm" -o -iname "*.deb" | head -n1`' . "\n" |
|
|
1089 |
|
. ' case "${env_distro}" in' . "\n" |
|
1090 |
|
. ' fedora|centos|rocky) sp="/mnt/rpmbuild"; name="*.rpm" ;;' . "\n" |
|
1091 |
|
. ' debian|ubuntu) sp="/mnt/target"; name="*.deb" ;;' . "\n" |
|
1092 |
|
. ' *) break ;;' . "\n" |
|
1093 |
|
. ' esac' . "\n" |
|
1094 |
|
. ' rg_log_push "Locating package files in ${sp}"' . "\n" |
|
1095 |
|
. ' files=$(find ${sp} -type f -iname "${name}" 2>/dev/null | head -n1)' . "\n" |
860 |
1096 |
. ' if [ "${files}" = "" ]; then' . "\n" |
. ' if [ "${files}" = "" ]; then' . "\n" |
861 |
|
. ' xecho "Not found."' . "\n" |
|
|
1097 |
|
. ' rg_notify "Not found."' . "\n" |
862 |
1098 |
. ' else' . "\n" |
. ' else' . "\n" |
863 |
|
. ' xecho "Found ["${files}"]"' . "\n" |
|
|
1099 |
|
. ' rg_notify "Found ["${files}"]"' . "\n" |
864 |
1100 |
. ' fi' . "\n" |
. ' fi' . "\n" |
865 |
1101 |
. ' rg_log_pop' . "\n" |
. ' rg_log_pop' . "\n" |
866 |
1102 |
. "\n"; |
. "\n"; |
|
... |
... |
function start_worker_build_repo($job, $conf, &$reason, &$reason2) |
868 |
1104 |
if ($keys > 0) |
if ($keys > 0) |
869 |
1105 |
$s .= '' |
$s .= '' |
870 |
1106 |
. ' echo ' . "\n" |
. ' echo ' . "\n" |
871 |
|
. ' xecho "Importing ' . $keys . ' key(s)"' . "\n" |
|
|
1107 |
|
. ' rg_notify "Importing ' . $keys . ' key(s)"' . "\n" |
872 |
1108 |
. ' rg_op_s gpg --import /mnt/build2/gpg_priv_key_*.asc || break' . "\n" |
. ' rg_op_s gpg --import /mnt/build2/gpg_priv_key_*.asc || break' . "\n" |
873 |
1109 |
. ' # Signing something for test' . "\n" |
. ' # Signing something for test' . "\n" |
874 |
1110 |
. ' rm -f /tmp/rg-sign-junk' . "\n" |
. ' rm -f /tmp/rg-sign-junk' . "\n" |
875 |
1111 |
. ' rg_op_s gpg --output /tmp/rg-sign-junk --no-autostart --batch \\' . "\n" |
. ' rg_op_s gpg --output /tmp/rg-sign-junk --no-autostart --batch \\' . "\n" |
876 |
1112 |
. ' --armour --sign /etc/hosts || break' . "\n" |
. ' --armour --sign /etc/hosts || break' . "\n" |
877 |
1113 |
. ' # list supported configuration' . "\n" |
. ' # list supported configuration' . "\n" |
|
1114 |
|
. ' rg_notify "GPG supported configuration:"' . "\n" |
878 |
1115 |
. ' gpg --with-colons --list-config' . "\n"; |
. ' gpg --with-colons --list-config' . "\n"; |
879 |
1116 |
|
|
880 |
1117 |
$s .= "\n" |
$s .= "\n" |
881 |
1118 |
. ' declare -A rgfs_mounted=()' . "\n"; |
. ' declare -A rgfs_mounted=()' . "\n"; |
882 |
1119 |
|
|
883 |
|
if (isset($job['exec']['prepare_rpms'])) |
|
|
1120 |
|
if (isset($job['exec']['prepare_pkgs'])) |
884 |
1121 |
$s .= "\n" |
$s .= "\n" |
885 |
1122 |
. ' echo' . "\n" |
. ' echo' . "\n" |
886 |
|
. ' rg_log_push "== prepare rpms phase ====="' . "\n" |
|
|
1123 |
|
. ' rg_log_push "== prepare pkgs phase ====="' . "\n" |
887 |
1124 |
. ' case "${env_distro}" in' . "\n" |
. ' case "${env_distro}" in' . "\n" |
888 |
1125 |
. ' fedora|centos|rocky)' . "\n" |
. ' fedora|centos|rocky)' . "\n" |
|
1126 |
|
. ' src0="/mnt/rpmbuild"' . "\n" |
|
1127 |
|
. ' src1="${src0}/RPMS"' . "\n" |
|
1128 |
|
. ' src2="${src0}/SRPMS"' . "\n" |
|
1129 |
|
. "\n" |
889 |
1130 |
. ' for i in debug src os; do' . "\n" |
. ' for i in debug src os; do' . "\n" |
890 |
|
. ' src0="/mnt/rpmbuild"' . "\n" |
|
891 |
|
. ' src1="${src0}/RPMS"' . "\n" |
|
892 |
|
. ' src2="${src0}/SRPMS"' . "\n" |
|
893 |
|
. "\n" |
|
894 |
1131 |
. ' rg_log_push "== ${i} ====="' . "\n" |
. ' rg_log_push "== ${i} ====="' . "\n" |
895 |
1132 |
. ' for pkg_repo_id in ${pkg_repos_list}; do' . "\n" |
. ' for pkg_repo_id in ${pkg_repos_list}; do' . "\n" |
896 |
1133 |
. ' pkg_repo_uid=${pri2uid[${pkg_repo_id}]}' . "\n" |
. ' pkg_repo_uid=${pri2uid[${pkg_repo_id}]}' . "\n" |
897 |
1134 |
. ' rg_log_push "== pkg_repo_id ${pkg_repo_id} [uid ${pkg_repo_uid}] ====="' . "\n" |
. ' rg_log_push "== pkg_repo_id ${pkg_repo_id} [uid ${pkg_repo_uid}] ====="' . "\n" |
898 |
1135 |
. ' dir="/mnt/build2/rpms/${pkg_repo_id}/${i}"' . "\n" |
. ' dir="/mnt/build2/rpms/${pkg_repo_id}/${i}"' . "\n" |
899 |
1136 |
. ' if [ "`do_sensitive_ops`" = "1" ]; then' . "\n" |
. ' if [ "`do_sensitive_ops`" = "1" ]; then' . "\n" |
900 |
|
. ' xecho "DEBUG: do_sensitive_ops==1: do not add username"' . "\n" |
|
|
1137 |
|
. ' rg_notify "DEBUG: do_sensitive_ops==1: do not add username"' . "\n" |
901 |
1138 |
. ' udir="${dir}"' . "\n" |
. ' udir="${dir}"' . "\n" |
902 |
1139 |
. ' else' . "\n" |
. ' else' . "\n" |
903 |
|
. ' xecho "DEBUG: do_sensitive_ops!=1: add username"' . "\n" |
|
|
1140 |
|
. ' rg_notify "DEBUG: do_sensitive_ops!=1: add username"' . "\n" |
904 |
1141 |
. ' udir="${dir}/${repo_username}"' . "\n" |
. ' udir="${dir}/${repo_username}"' . "\n" |
905 |
1142 |
. ' fi' . "\n" |
. ' fi' . "\n" |
906 |
|
. "\n" |
|
907 |
|
. ' xecho "Copying RPMs to ${udir}"' . "\n" |
|
|
1143 |
|
. "\n" |
|
1144 |
|
. ' rg_notify "Copying RPMs to ${udir}"' . "\n" |
908 |
1145 |
. ' rg_op_s mkdir -p "${udir}" || break' . "\n" |
. ' rg_op_s mkdir -p "${udir}" || break' . "\n" |
909 |
1146 |
. ' case ${i} in' . "\n" |
. ' case ${i} in' . "\n" |
910 |
1147 |
. ' debug)' . "\n" |
. ' debug)' . "\n" |
|
... |
... |
function start_worker_build_repo($job, $conf, &$reason, &$reason2) |
931 |
1168 |
. ' done' . "\n" |
. ' done' . "\n" |
932 |
1169 |
. ' rg_log_pop' . "\n" |
. ' rg_log_pop' . "\n" |
933 |
1170 |
. ' [ "${E}" = "0" ] || break' . "\n" |
. ' [ "${E}" = "0" ] || break' . "\n" |
934 |
|
. "\n" |
|
|
1171 |
|
. "\n" |
935 |
1172 |
. ' # We must remove debug packages after copy, else we will copy them also in "os" dir' . "\n" |
. ' # We must remove debug packages after copy, else we will copy them also in "os" dir' . "\n" |
936 |
1173 |
. ' if [ "${i}" = "debug" ]; then' . "\n" |
. ' if [ "${i}" = "debug" ]; then' . "\n" |
937 |
1174 |
. ' rm -f "${src1}"/*/*-debuginfo-*.rpm' . "\n" |
. ' rm -f "${src1}"/*/*-debuginfo-*.rpm' . "\n" |
|
... |
... |
function start_worker_build_repo($job, $conf, &$reason, &$reason2) |
939 |
1176 |
. ' fi' . "\n" |
. ' fi' . "\n" |
940 |
1177 |
. ' done' . "\n" |
. ' done' . "\n" |
941 |
1178 |
. ' ;;' . "\n" |
. ' ;;' . "\n" |
942 |
|
. ' *) xecho "Unsupported distro!"; E=1 ;;' . "\n" |
|
|
1179 |
|
. "\n" |
|
1180 |
|
. ' debian|ubuntu)' . "\n" // TODO: we should check if no package found and return error |
|
1181 |
|
. ' src0="/mnt/target"' . "\n" |
|
1182 |
|
. ' rg_deb_extract_control "${src0}" || break' . "\n" |
|
1183 |
|
. ' for i in source binary-all binary-${env_arch}; do' . "\n" |
|
1184 |
|
. ' rg_log_push "== ${i} ====="' . "\n" |
|
1185 |
|
. ' for pkg_repo_id in ${pkg_repos_list}; do' . "\n" |
|
1186 |
|
. ' pkg_repo_uid=${pri2uid[${pkg_repo_id}]}' . "\n" |
|
1187 |
|
. ' rg_log_push "== pkg_repo_id ${pkg_repo_id} [uid ${pkg_repo_uid}] ====="' . "\n" |
|
1188 |
|
. ' dir="/mnt/build2/debs/${pkg_repo_id}/${i}"' . "\n" |
|
1189 |
|
. "\n" |
|
1190 |
|
. ' copy_add=""' . "\n" |
|
1191 |
|
. ' case ${i} in' . "\n" |
|
1192 |
|
. ' source)' . "\n" |
|
1193 |
|
. ' list=$(ls "${src0}"/*.tar.* "${src0}"/*.dsc "${src0}"/*.diff.gz)' . "\n" |
|
1194 |
|
. ' copy_add=" --link"' . "\n" |
|
1195 |
|
. ' ;;' . "\n" |
|
1196 |
|
. ' binary-all)' . "\n" |
|
1197 |
|
. ' list=$(ls "${src0}"/*_all.debc "${src0}"/*_all.deb)' . "\n" |
|
1198 |
|
. ' ;;' . "\n" |
|
1199 |
|
. ' binary-${env_arch})' . "\n" |
|
1200 |
|
. ' list=$(ls "${src0}"/*_${env_arch}.deb "${src0}"/*_${env_arch}.debc)' . "\n" |
|
1201 |
|
. ' list+=" "$(ls "${src0}"/*_${env_arch}.ddeb "${src0}"/*_${env_arch}.ddebc)' . "\n" |
|
1202 |
|
. ' ;;' . "\n" |
|
1203 |
|
. ' esac 2>/dev/null' . "\n" |
|
1204 |
|
. ' if [ "${list}" != "" ]; then' . "\n" |
|
1205 |
|
. ' rg_notify "Copying files from ${src0} to ${dir}"' . "\n" |
|
1206 |
|
. ' ls -l "${src0}"' . "\n" |
|
1207 |
|
. ' rg_op_s mkdir -p "${dir}" || break' . "\n" |
|
1208 |
|
. ' for f in ${list}; do' . "\n" |
|
1209 |
|
. ' rg_notify "Copying ${f}..."' . "\n" |
|
1210 |
|
. ' rg_cp -v ${copy_add} "${f}" "${dir}/"' . "\n" |
|
1211 |
|
. ' done' . "\n" |
|
1212 |
|
. ' fi' . "\n" |
|
1213 |
|
. ' rg_log_pop' . "\n" |
|
1214 |
|
. ' [ "${E}" = "0" ] || break' . "\n" |
|
1215 |
|
. ' done' . "\n" |
|
1216 |
|
. ' rg_log_pop' . "\n" |
|
1217 |
|
. ' [ "${E}" = "0" ] || break' . "\n" |
|
1218 |
|
. ' done' . "\n" |
|
1219 |
|
. ' rg_log_pop' . "\n" |
|
1220 |
|
. ' [ "${E}" = "0" ] || break' . "\n" |
|
1221 |
|
. ' ;;' . "\n" |
|
1222 |
|
. "\n" |
|
1223 |
|
. ' *) rg_notify_err "Unsupported distro!"; E=0 ;;' . "\n" // TODO: should we return 0? What about supported case? We should not fail the build job! Only if user wants that! |
943 |
1224 |
. ' esac' . "\n" |
. ' esac' . "\n" |
944 |
1225 |
. ' rg_log_pop' . "\n" |
. ' rg_log_pop' . "\n" |
945 |
1226 |
. ' [ "${E}" = "0" ] || break' . "\n\n"; |
. ' [ "${E}" = "0" ] || break' . "\n\n"; |
946 |
1227 |
|
|
947 |
|
if (isset($job['exec']['prepare_rpms'])) |
|
|
1228 |
|
if (isset($job['exec']['prepare_pkgs'])) |
948 |
1229 |
foreach ($job['pkg_repos'] as $pkg_repo_id => $info) |
foreach ($job['pkg_repos'] as $pkg_repo_id => $info) |
949 |
1230 |
$s .= "\n" |
$s .= "\n" |
950 |
1231 |
. ' pkg_repo_id=' . $pkg_repo_id . "\n" |
. ' pkg_repo_id=' . $pkg_repo_id . "\n" |
|
... |
... |
function start_worker_build_repo($job, $conf, &$reason, &$reason2) |
957 |
1238 |
. ' rg_log_push "== ${i} ====="' . "\n" |
. ' rg_log_push "== ${i} ====="' . "\n" |
958 |
1239 |
. ' dir="/mnt/build2/rpms/${pkg_repo_id}/${i}"' . "\n" |
. ' dir="/mnt/build2/rpms/${pkg_repo_id}/${i}"' . "\n" |
959 |
1240 |
. ' pkg_list_file="${dir}/pkg.list"' . "\n" |
. ' pkg_list_file="${dir}/pkg.list"' . "\n" |
960 |
|
. "\n" |
|
961 |
|
. ' rg_create_list "${dir}" "${pkg_list_file}" || break' . "\n" |
|
962 |
|
. "\n" |
|
963 |
|
. ' if [ "`do_sensitive_ops`" != "1" ]; then' . "\n" |
|
964 |
|
. ' xecho "DEBUG: do_sensitive_ops!=1: skip rpm signing"' . "\n" |
|
965 |
|
. ' else' . "\n" |
|
966 |
|
. ' xecho "DEBUG: do_sensitive_ops==1: do signing"' . "\n" |
|
967 |
|
. ' rg_rpm_sign ${pkg_repo_id} "${dir}" "${pkg_list_file}" || break' . "\n" |
|
968 |
|
. ' fi' . "\n" |
|
|
1241 |
|
. "\n" |
|
1242 |
|
. ' while [ 1 ]; do' . "\n" |
|
1243 |
|
. ' rg_rpm_create_list "${dir}" "${pkg_list_file}" || break' . "\n" |
|
1244 |
|
. "\n" |
|
1245 |
|
. ' if [ "`do_sensitive_ops`" != "1" ]; then' . "\n" |
|
1246 |
|
. ' rg_notify "DEBUG: do_sensitive_ops!=1: skip rpm signing"' . "\n" |
|
1247 |
|
. ' else' . "\n" |
|
1248 |
|
. ' rg_notify "DEBUG: do_sensitive_ops==1: do signing"' . "\n" |
|
1249 |
|
. ' rg_rpm_sign ${pkg_repo_id} "${dir}" "${pkg_list_file}" || break' . "\n" |
|
1250 |
|
. ' fi' . "\n" |
|
1251 |
|
. ' break' . "\n" |
|
1252 |
|
. ' done' . "\n" |
969 |
1253 |
. ' rg_log_pop' . "\n" |
. ' rg_log_pop' . "\n" |
970 |
|
. ' done' . "\n" |
|
971 |
|
. ' ;;' . "\n" |
|
972 |
|
. ' *) xecho "Unsupported distro!"; E=1 ;;' . "\n" |
|
|
1254 |
|
. ' done ;;' . "\n" |
|
1255 |
|
. "\n" |
|
1256 |
|
. ' debian|ubuntu)' . "\n" |
|
1257 |
|
. ' pdir="/mnt/build2/debs/${pkg_repo_id}"' . "\n" |
|
1258 |
|
. ' for i in source binary-all binary-${env_arch}; do' . "\n" |
|
1259 |
|
. ' rg_log_push "== ${i} ====="' . "\n" |
|
1260 |
|
. ' dir="${pdir}/${i}"' . "\n" |
|
1261 |
|
. ' pkg_list_file="${dir}.pkg.list"' . "\n" |
|
1262 |
|
. ' copy_list_file="${dir}.copy.list"' . "\n" |
|
1263 |
|
. "\n" |
|
1264 |
|
. ' while [ 1 ]; do' . "\n" |
|
1265 |
|
. ' rg_deb_create_deb_list "${dir}" "${pkg_list_file}" || break' . "\n" |
|
1266 |
|
. ' rg_create_list "${dir}" "${copy_list_file}" || break' . "\n" |
|
1267 |
|
. ' [ -s "${pkg_list_file}" ] || break' . "\n" |
|
1268 |
|
. "\n" |
|
1269 |
|
. ' if [ "`do_sensitive_ops`" != "1" ]; then' . "\n" |
|
1270 |
|
. ' rg_notify "DEBUG: do_sensitive_ops!=1: skip .deb signing"' . "\n" |
|
1271 |
|
. ' else' . "\n" |
|
1272 |
|
. ' rg_notify "DEBUG: do_sensitive_ops==1: do signing"' . "\n" |
|
1273 |
|
. ' rg_deb_sign ${pkg_repo_id} "${dir}" "${pkg_list_file}" || break' . "\n" |
|
1274 |
|
. ' fi' . "\n" |
|
1275 |
|
. ' break' . "\n" |
|
1276 |
|
. ' done' . "\n" |
|
1277 |
|
. ' rg_log_pop' . "\n" |
|
1278 |
|
. ' done ;;' . "\n" |
|
1279 |
|
. "\n" |
|
1280 |
|
. ' *) rg_notify_err "Unsupported distro!"; E=0 ;;' . "\n" |
973 |
1281 |
. ' esac' . "\n" |
. ' esac' . "\n" |
974 |
1282 |
. ' rg_log_pop' . "\n" |
. ' rg_log_pop' . "\n" |
975 |
1283 |
. ' [ "${E}" = "0" ] || break' . "\n\n"; |
. ' [ "${E}" = "0" ] || break' . "\n\n"; |
976 |
1284 |
|
|
|
1285 |
|
if (isset($job['rgfs_server'])) |
977 |
1286 |
foreach ($job['pkg_maps'] as $junk => $info) { |
foreach ($job['pkg_maps'] as $junk => $info) { |
978 |
1287 |
$pkg_subrepo_id = $info['pkg_subrepo_id']; |
$pkg_subrepo_id = $info['pkg_subrepo_id']; |
979 |
1288 |
$si = $job['pkg_subrepos'][$pkg_subrepo_id]; |
$si = $job['pkg_subrepos'][$pkg_subrepo_id]; |
980 |
1289 |
$pkg_repo_id = $si['pkg_repo_id']; |
$pkg_repo_id = $si['pkg_repo_id']; |
981 |
1290 |
$ri = $job['pkg_repos'][$pkg_repo_id]; |
$ri = $job['pkg_repos'][$pkg_repo_id]; |
982 |
|
if (!isset($job['rgfs_server'])) { |
|
983 |
|
$s .= '# rgfs not set' . "\n"; |
|
984 |
|
continue; |
|
985 |
|
} |
|
986 |
1291 |
$s .= "\n" |
$s .= "\n" |
987 |
1292 |
. ' export pkg_repo_id=' . $pkg_repo_id . "\n" |
. ' export pkg_repo_id=' . $pkg_repo_id . "\n" |
988 |
1293 |
. ' export pkg_repo_uid=' . $ri['uid'] . "\n" |
. ' export pkg_repo_uid=' . $ri['uid'] . "\n" |
989 |
1294 |
. ' export pkg_subrepo_id=' . $pkg_subrepo_id . "\n" |
. ' export pkg_subrepo_id=' . $pkg_subrepo_id . "\n" |
990 |
1295 |
. "\n" |
. "\n" |
991 |
1296 |
. ' echo' . "\n" |
. ' echo' . "\n" |
992 |
|
. ' rg_log_push "== rgfs phase pkg_repo_id=${pkg_repo_id} pkg_subrepo_id=${pkg_subrepo_id} ====="' . "\n" |
|
993 |
|
. ' xecho "Mounting rgfs pkg_repo_id/pkg_subrepo_id=${pkg_repo_id}/${pkg_subrepo_id}"' . "\n" |
|
|
1297 |
|
. ' rg_log_push "== rgfs phase pkg_repo_id=${pkg_repo_id} pkg_repo_uid=${pkg_repo_uid} pkg_subrepo_id=${pkg_subrepo_id} ====="' . "\n" |
994 |
1298 |
. ' export RGFS_LOG="/mnt/build2/rgfs/rgfs-${pkg_repo_id}-${pkg_subrepo_id}.log"' . "\n" |
. ' export RGFS_LOG="/mnt/build2/rgfs/rgfs-${pkg_repo_id}-${pkg_subrepo_id}.log"' . "\n" |
995 |
1299 |
. ' export RGFS_pkg_repo_id=${pkg_repo_id}' . "\n" |
. ' export RGFS_pkg_repo_id=${pkg_repo_id}' . "\n" |
996 |
1300 |
. ' export RGFS_pkg_subrepo_id=${pkg_subrepo_id}' . "\n" |
. ' export RGFS_pkg_subrepo_id=${pkg_subrepo_id}' . "\n" |
|
... |
... |
function start_worker_build_repo($job, $conf, &$reason, &$reason2) |
999 |
1303 |
. ' mkdir -p "${dir}"' . "\n" |
. ' mkdir -p "${dir}"' . "\n" |
1000 |
1304 |
. ' # -s -> disable multithreading - not supported and not needed' . "\n" |
. ' # -s -> disable multithreading - not supported and not needed' . "\n" |
1001 |
1305 |
. ' # Please note, we cannot run strace on rgfs!' . "\n" |
. ' # Please note, we cannot run strace on rgfs!' . "\n" |
|
1306 |
|
. ' rg_notify "Mounting rgfs pkg_repo_id/pkg_subrepo_id=${pkg_repo_id}/${pkg_subrepo_id}"' . "\n" |
1002 |
1307 |
. ' rg_op_s /usr/bin/rgfs -s -o kernel_cache -o auto_cache \\' . "\n" |
. ' rg_op_s /usr/bin/rgfs -s -o kernel_cache -o auto_cache \\' . "\n" |
1003 |
1308 |
. ' -o noforget -o use_ino "${dir}" || break' . "\n" |
. ' -o noforget -o use_ino "${dir}" || break' . "\n" |
1004 |
1309 |
. ' rgfs_mounted[${pkg_repo_id}-${pkg_subrepo_id}]=1' . "\n" |
. ' rgfs_mounted[${pkg_repo_id}-${pkg_subrepo_id}]=1' . "\n" |
1005 |
1310 |
. "\n" |
. "\n" |
1006 |
1311 |
. ' rgfs_subrepo_root="/mnt/build2/rgfs/${pkg_repo_id}/${pkg_subrepo_id}"' . "\n" |
. ' rgfs_subrepo_root="/mnt/build2/rgfs/${pkg_repo_id}/${pkg_subrepo_id}"' . "\n" |
1007 |
|
. ' xecho "DEBUG: env_distro=${env_distro}"' . "\n" |
|
1008 |
1312 |
. ' case "${env_distro}" in' . "\n" |
. ' case "${env_distro}" in' . "\n" |
1009 |
1313 |
. ' fedora|centos|rocky)' . "\n" |
. ' fedora|centos|rocky)' . "\n" |
1010 |
1314 |
. ' for i in os debug src; do' . "\n" |
. ' for i in os debug src; do' . "\n" |
|
... |
... |
function start_worker_build_repo($job, $conf, &$reason, &$reason2) |
1020 |
1324 |
. "\n" |
. "\n" |
1021 |
1325 |
. ' if [ "${job_uid}" = "0" ]; then' . "\n" |
. ' if [ "${job_uid}" = "0" ]; then' . "\n" |
1022 |
1326 |
. ' if [ -d "${rgfs}/+pending" ]; then' . "\n" |
. ' if [ -d "${rgfs}/+pending" ]; then' . "\n" |
1023 |
|
. ' xecho "DEBUG: dir +pending found"' . "\n" |
|
1024 |
|
. ' rg_create_list "${rgfs}/+pending" "${pkg_pend_list_file}" || break' . "\n" |
|
|
1327 |
|
. ' rg_notify "DEBUG: dir +pending found"' . "\n" |
|
1328 |
|
. ' rg_rpm_create_list "${rgfs}/+pending" "${pkg_pend_list_file}" || break' . "\n" |
1025 |
1329 |
. ' else' . "\n" |
. ' else' . "\n" |
1026 |
|
. ' xecho "DEBUG: dir +pending does not exists."' . "\n" |
|
|
1330 |
|
. ' rg_notify "DEBUG: dir +pending does not exists."' . "\n" |
1027 |
1331 |
. ' fi' . "\n" |
. ' fi' . "\n" |
1028 |
1332 |
. ' fi' . "\n" |
. ' fi' . "\n" |
1029 |
1333 |
. "\n" |
. "\n" |
1030 |
1334 |
. ' if [ ! -s "${pkg_list_file}" ] && [ ! -s "${pkg_pend_list_file}" ]; then' . "\n" |
. ' if [ ! -s "${pkg_list_file}" ] && [ ! -s "${pkg_pend_list_file}" ]; then' . "\n" |
1031 |
|
. ' xecho "pkg_list_file/pkg_pend_list_file are both empty; continue"' . "\n" |
|
|
1335 |
|
. ' rg_notify "pkg_list_file/pkg_pend_list_file are both empty; continue"' . "\n" |
1032 |
1336 |
. ' rg_log_pop' . "\n" |
. ' rg_log_pop' . "\n" |
1033 |
1337 |
. ' continue' . "\n" |
. ' continue' . "\n" |
1034 |
1338 |
. ' fi' . "\n" |
. ' fi' . "\n" |
|
... |
... |
function start_worker_build_repo($job, $conf, &$reason, &$reason2) |
1038 |
1342 |
. ' while read file; do' . "\n" |
. ' while read file; do' . "\n" |
1039 |
1343 |
. ' [ "${file}" = "" ] && continue' . "\n" |
. ' [ "${file}" = "" ] && continue' . "\n" |
1040 |
1344 |
. ' if [ -r "${rgfs}/${file}" ]; then' . "\n" |
. ' if [ -r "${rgfs}/${file}" ]; then' . "\n" |
1041 |
|
. ' xecho "- ${rgfs}/${file}"' . "\n" |
|
|
1345 |
|
. ' rg_notify "- ${rgfs}/${file}"' . "\n" |
1042 |
1346 |
. ' continue' . "\n" |
. ' continue' . "\n" |
1043 |
1347 |
. ' fi' . "\n" |
. ' fi' . "\n" |
1044 |
|
. ' xecho "+ ${rgfs}/${file}"' . "\n" |
|
|
1348 |
|
. ' rg_notify "+ ${rgfs}/${file}"' . "\n" |
1045 |
1349 |
. ' echo "${file}" >> ${pkg_filter_list_file}' . "\n" |
. ' echo "${file}" >> ${pkg_filter_list_file}' . "\n" |
1046 |
1350 |
. ' done < <(cat "${pkg_list_file}"; echo; cat "${pkg_pend_list_file}"; echo)' . "\n" |
. ' done < <(cat "${pkg_list_file}"; echo; cat "${pkg_pend_list_file}"; echo)' . "\n" |
1047 |
1351 |
. ' rg_log_pop' . "\n" |
. ' rg_log_pop' . "\n" |
1048 |
1352 |
. "\n" |
. "\n" |
1049 |
1353 |
. ' if [ "${job_uid}" = "0" ]; then' . "\n" |
. ' if [ "${job_uid}" = "0" ]; then' . "\n" |
1050 |
1354 |
. ' if [ -d "${rgfs}/+pending" ]; then' . "\n" |
. ' if [ -d "${rgfs}/+pending" ]; then' . "\n" |
1051 |
|
. ' xecho "+pending dir exists"' . "\n" |
|
|
1355 |
|
. ' rg_notify "+pending dir exists"' . "\n" |
1052 |
1356 |
. ' rg_rpm_sign ${pkg_repo_id} "${rgfs}/+pending" "${pkg_pend_list_file}" || break' . "\n" |
. ' rg_rpm_sign ${pkg_repo_id} "${rgfs}/+pending" "${pkg_pend_list_file}" || break' . "\n" |
1053 |
1357 |
. ' for username in `(cd "${rgfs}/+pending"; ls)`; do' . "\n" |
. ' for username in `(cd "${rgfs}/+pending"; ls)`; do' . "\n" |
1054 |
1358 |
. ' mkdir -p "${rgfs}/${username}"' . "\n" |
. ' mkdir -p "${rgfs}/${username}"' . "\n" |
|
... |
... |
function start_worker_build_repo($job, $conf, &$reason, &$reason2) |
1058 |
1362 |
. ' [ "${E}" = "0" ] || break' . "\n" |
. ' [ "${E}" = "0" ] || break' . "\n" |
1059 |
1363 |
. ' rg_op_s rmdir "${rgfs}/+pending" || break' . "\n" |
. ' rg_op_s rmdir "${rgfs}/+pending" || break' . "\n" |
1060 |
1364 |
. ' else' . "\n" |
. ' else' . "\n" |
1061 |
|
. ' xecho "+pending dir not found"' . "\n" |
|
|
1365 |
|
. ' rg_notify "+pending dir not found"' . "\n" |
1062 |
1366 |
. ' fi' . "\n" |
. ' fi' . "\n" |
1063 |
|
. ' fi' . "\n"; |
|
1064 |
|
|
|
1065 |
|
// TODO: job_uid -> repo_uid (everywhere)? |
|
1066 |
|
|
|
1067 |
|
if (isset($job['exec']['copy_to_rgfs'])) |
|
1068 |
|
$s .= "\n" |
|
1069 |
|
. ' xecho "exec:copy_to_rgfs"' . "\n" |
|
|
1367 |
|
. ' fi' . "\n" |
|
1368 |
|
. "\n" |
|
1369 |
|
. ' rg_notify "copy_to_rgfs"' . "\n" |
1070 |
1370 |
. ' if [ -s "${pkg_list_file}" ]; then' . "\n" |
. ' if [ -s "${pkg_list_file}" ]; then' . "\n" |
1071 |
1371 |
. ' rg_log_push "Copying packages from ${rpms_dir} to ${rgfs}"' . "\n" |
. ' rg_log_push "Copying packages from ${rpms_dir} to ${rgfs}"' . "\n" |
1072 |
|
. ' rg_op_s mkdir -p "${rgfs}" || break' . "\n" |
|
1073 |
1372 |
. ' if [ "${job_uid}" = "${pkg_repo_uid}" ]; then' . "\n" |
. ' if [ "${job_uid}" = "${pkg_repo_uid}" ]; then' . "\n" |
|
1373 |
|
. ' rg_op_s mkdir -p "${rgfs}" || break' . "\n" |
1074 |
1374 |
. ' rg_cp -av "${rpms_dir}"/*.rpm "${rgfs}/" || break' . "\n" |
. ' rg_cp -av "${rpms_dir}"/*.rpm "${rgfs}/" || break' . "\n" |
1075 |
1375 |
. ' else' . "\n" // TODO: shouldn't I copy directly to ${rgfs}/${repo_username} if do_sensitive_ops==1? Seems it cannot happen! when we are uid 0, we do not need to copy! |
. ' else' . "\n" // TODO: shouldn't I copy directly to ${rgfs}/${repo_username} if do_sensitive_ops==1? Seems it cannot happen! when we are uid 0, we do not need to copy! |
1076 |
1376 |
. ' # "+" is used because it is not allowed in username' . "\n" |
. ' # "+" is used because it is not allowed in username' . "\n" |
|
... |
... |
function start_worker_build_repo($job, $conf, &$reason, &$reason2) |
1078 |
1378 |
. ' rg_cp -av "${rpms_dir}/${repo_username}"/*.rpm "${rgfs}/+pending/${repo_username}/" || break' . "\n" |
. ' rg_cp -av "${rpms_dir}/${repo_username}"/*.rpm "${rgfs}/+pending/${repo_username}/" || break' . "\n" |
1079 |
1379 |
. ' fi' . "\n" |
. ' fi' . "\n" |
1080 |
1380 |
. "\n" |
. "\n" |
1081 |
|
. ' if [ "`do_sensitive_ops`" != "1" ]; then' . "\n" |
|
1082 |
|
. ' xecho "Triggering the rebuild of subrepo"' . "\n" |
|
1083 |
|
. ' echo "${pkg_subrepo_id}" >> /mnt/build2/pkg_subrepo_dirty' . "\n" // TODO: Shouldn't be done by rgfs? |
|
|
1381 |
|
. ' if [ "$(do_sensitive_ops)" != "1" ]; then' . "\n" |
|
1382 |
|
. ' rg_notify "Triggering the rebuild of subrepo"' . "\n" |
|
1383 |
|
. ' echo "${pkg_subrepo_id}" >> /mnt/build2/pkg_subrepo_dirty' . "\n" |
1084 |
1384 |
. ' fi' . "\n" |
. ' fi' . "\n" |
1085 |
1385 |
. ' rg_log_pop' . "\n" |
. ' rg_log_pop' . "\n" |
1086 |
1386 |
. ' else' . "\n" |
. ' else' . "\n" |
1087 |
|
. ' xecho "No packages in pkg_list_file."' . "\n" |
|
|
1387 |
|
. ' rg_notify "No packages in pkg_list_file."' . "\n" |
1088 |
1388 |
. ' fi'. "\n" |
. ' fi'. "\n" |
1089 |
1389 |
. "\n" |
. "\n" |
1090 |
1390 |
. ' if [ "`do_sensitive_ops`" = "1" ]; then' . "\n" |
. ' if [ "`do_sensitive_ops`" = "1" ]; then' . "\n" |
1091 |
1391 |
. ' rg_rpm_createrepo "${env_distro}" "${rgfs}" \\' . "\n" |
. ' rg_rpm_createrepo "${env_distro}" "${rgfs}" \\' . "\n" |
1092 |
1392 |
. ' "${pkg_filter_list_file}" "${repo_username}" || break' . "\n" |
. ' "${pkg_filter_list_file}" "${repo_username}" || break' . "\n" |
1093 |
|
. ' fi' . "\n"; |
|
1094 |
|
|
|
1095 |
|
$s .= "\n" |
|
|
1393 |
|
. ' fi' . "\n" |
1096 |
1394 |
. ' rg_log_pop' . "\n" |
. ' rg_log_pop' . "\n" |
1097 |
|
. ' done ;;' . "\n" |
|
1098 |
|
. ' *) xecho "Unsupported distro!"; E=1 ;;' . "\n" |
|
|
1395 |
|
. ' done' . "\n" |
|
1396 |
|
. ' ;;' . "\n" |
|
1397 |
|
. "\n" |
|
1398 |
|
. ' debian|ubuntu)' . "\n" |
|
1399 |
|
. ' for i in source binary-all binary-${env_arch}; do' . "\n" |
|
1400 |
|
. ' rgfs="${rgfs_subrepo_root}/${env_distro}/${env_codename}/main/${i}"' . "\n" |
|
1401 |
|
. ' debs_dir="/mnt/build2/debs/${pkg_repo_id}/${i}"' . "\n" |
|
1402 |
|
. ' pkg_list_file="${debs_dir}.pkg.list"' . "\n" |
|
1403 |
|
. ' list_file="${debs_dir}.copy.list"' . "\n" |
|
1404 |
|
. "\n" |
|
1405 |
|
. ' rg_log_push "== ${i} ====="' . "\n" |
|
1406 |
|
. ' while [ -s "${list_file}" ]; do' . "\n" |
|
1407 |
|
. ' rg_notify "Copying files from ${debs_dir} to ${rgfs}"' . "\n" |
|
1408 |
|
. ' # "+" is used because it is not allowed in username' . "\n" |
|
1409 |
|
. ' rg_op_s mkdir -p "${rgfs}/+pending/${job_id}" || break' . "\n" |
|
1410 |
|
. ' rg_cp -av "${debs_dir}"/* "${rgfs}/+pending/${job_id}/" || break' . "\n" |
|
1411 |
|
. ' if [ "$(do_sensitive_ops)" != "1" ]; then' . "\n" |
|
1412 |
|
. ' rg_notify "Triggering the rebuild of subrepo"' . "\n" |
|
1413 |
|
. ' echo "${pkg_subrepo_id}" >> /mnt/build2/pkg_subrepo_dirty' . "\n" |
|
1414 |
|
. ' fi' . "\n" |
|
1415 |
|
. ' break' . "\n" |
|
1416 |
|
. ' done'. "\n" |
|
1417 |
|
. ' while [ "${job_uid}" = "0" ]; do' . "\n" |
|
1418 |
|
. ' [ "${orig_job_id}" = "" ] && break' . "\n" |
|
1419 |
|
. ' pkg_sign_file="/tmp/pkg.sign.list"' . "\n" |
|
1420 |
|
. ' rg_deb_create_deb_list "${rgfs}/+pending/${orig_job_id}" "${pkg_sign_file}" || break' . "\n" |
|
1421 |
|
. ' [ -s "${pkg_sign_file}" ] || break' . "\n" |
|
1422 |
|
. ' rg_deb_sign ${pkg_repo_id} "${rgfs}/+pending/${orig_job_id}" "${pkg_sign_file}" || break' . "\n" |
|
1423 |
|
. ' break' . "\n" |
|
1424 |
|
. ' done' . "\n" |
|
1425 |
|
. ' rg_log_pop' . "\n" |
|
1426 |
|
. ' [ "${E}" = "0" ] || break' . "\n" |
|
1427 |
|
. ' done' . "\n" |
|
1428 |
|
. ' ;;' . "\n" |
|
1429 |
|
. "\n" |
|
1430 |
|
. ' *) rg_notify_err "Unsupported distro!"; E=0 ;;' . "\n" |
1099 |
1431 |
. ' esac' . "\n" |
. ' esac' . "\n" |
1100 |
|
. ' [ "${E}" = "0" ] || break' . "\n" |
|
1101 |
1432 |
. "\n" |
. "\n" |
1102 |
1433 |
. ' if [ "${rgfs_mounted[${pkg_repo_id}-${pkg_subrepo_id}]}" = "1" ]; then' . "\n" |
. ' if [ "${rgfs_mounted[${pkg_repo_id}-${pkg_subrepo_id}]}" = "1" ]; then' . "\n" |
1103 |
|
. ' xecho "Unmounting rgfs"' . "\n" |
|
|
1434 |
|
. ' rg_notify "Unmounting rgfs"' . "\n" |
1104 |
1435 |
. ' umount "/mnt/build2/rgfs/${pkg_repo_id}/${pkg_subrepo_id}"' . "\n" |
. ' umount "/mnt/build2/rgfs/${pkg_repo_id}/${pkg_subrepo_id}"' . "\n" |
|
1436 |
|
. ' rg_notify "Unmounting rgfs done"' . "\n" |
1105 |
1437 |
. ' fi' . "\n" |
. ' fi' . "\n" |
1106 |
|
. ' rg_log_pop' . "\n"; |
|
|
1438 |
|
. ' rg_log_pop' . "\n" |
|
1439 |
|
. ' [ "${E}" = "0" ] || break' . "\n"; |
1107 |
1440 |
} |
} |
1108 |
1441 |
|
|
1109 |
1442 |
$s .= "\n" |
$s .= "\n" |
1110 |
|
. ' xecho "Done [E=${E}] [`date`]"' . "\n" |
|
1111 |
1443 |
. ' break' . "\n" |
. ' break' . "\n" |
1112 |
1444 |
. 'done' . "\n" |
. 'done' . "\n" |
|
1445 |
|
. 'rg_notify "Done [E=${E}]"' . "\n" |
1113 |
1446 |
. 'exit ${E}' . "\n"; |
. 'exit ${E}' . "\n"; |
1114 |
1447 |
|
|
1115 |
1448 |
$f = $job['main'] . '/root/build_repo.sh'; |
$f = $job['main'] . '/root/build_repo.sh'; |
|
... |
... |
function start_worker($job) |
1269 |
1602 |
|
|
1270 |
1603 |
$out_dir = $job['main'] . '/root/target'; |
$out_dir = $job['main'] . '/root/target'; |
1271 |
1604 |
|
|
|
1605 |
|
$r = @mkdir($out_dir, 0775); |
|
1606 |
|
if ($r === FALSE) { |
|
1607 |
|
$reason = 'cannot create root/target dir'; |
|
1608 |
|
$reason2 = 'cannot create root/target dir (' . rg_php_err() . ')'; |
|
1609 |
|
break; |
|
1610 |
|
} |
|
1611 |
|
|
1272 |
1612 |
if (isset($job['rpm_repo_files'])) { |
if (isset($job['rpm_repo_files'])) { |
1273 |
1613 |
$err = FALSE; |
$err = FALSE; |
1274 |
1614 |
foreach ($job['rpm_repo_files'] as $pkg_subrepo_id => $files) { |
foreach ($job['rpm_repo_files'] as $pkg_subrepo_id => $files) { |
1275 |
1615 |
rg_log_debug('Storing dotrepo files for subrepo ' . $pkg_subrepo_id); |
rg_log_debug('Storing dotrepo files for subrepo ' . $pkg_subrepo_id); |
1276 |
1616 |
$_out_dir = $out_dir . '-dotrepo-' . $pkg_subrepo_id; |
$_out_dir = $out_dir . '-dotrepo-' . $pkg_subrepo_id; |
1277 |
1617 |
foreach ($files as $f => $c) { |
foreach ($files as $f => $c) { |
1278 |
|
$r = rg_create_dirs($_out_dir . '/' . $f); |
|
|
1618 |
|
$r = rg_create_dirs($_out_dir . '/' . $f, 0700); |
1279 |
1619 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
1280 |
1620 |
$reason = 'cannot create dir'; |
$reason = 'cannot create dir'; |
1281 |
1621 |
$reason2 = 'cannot create dir: ' . $r['errmsg']; |
$reason2 = 'cannot create dir: ' . $r['errmsg']; |
|
... |
... |
function start_worker($job) |
1314 |
1654 |
//TODO . ' --shallow-submodules' |
//TODO . ' --shallow-submodules' |
1315 |
1655 |
. ' --no-checkout' |
. ' --no-checkout' |
1316 |
1656 |
. ' ' . escapeshellarg($job['url']) |
. ' ' . escapeshellarg($job['url']) |
1317 |
|
. ' ' . $emain . '/root/target'; |
|
|
1657 |
|
. ' ' . $emain . '/root/target/source'; |
1318 |
1658 |
$r = rg_exec($cmd, '', FALSE, FALSE, FALSE); |
$r = rg_exec($cmd, '', FALSE, FALSE, FALSE); |
1319 |
1659 |
rg_log_debug('clone: ' . print_r($r, TRUE)); |
rg_log_debug('clone: ' . print_r($r, TRUE)); |
1320 |
1660 |
@file_put_contents($job['main'] . '/root/T_clone', time() - $_s); |
@file_put_contents($job['main'] . '/root/T_clone', time() - $_s); |
|
... |
... |
function start_worker($job) |
1332 |
1672 |
$s .= 'export RG_LABELS=/mnt/status/RG_LABELS' . "\n\n"; |
$s .= 'export RG_LABELS=/mnt/status/RG_LABELS' . "\n\n"; |
1333 |
1673 |
|
|
1334 |
1674 |
// build.sh: secrets |
// build.sh: secrets |
|
1675 |
|
$s .= '# Secrets' . "\n"; |
1335 |
1676 |
if (isset($job['secrets']) && !empty($job['secrets'])) { |
if (isset($job['secrets']) && !empty($job['secrets'])) { |
1336 |
|
$s .= '# Secrets' . "\n"; |
|
1337 |
1677 |
foreach ($job['secrets'] as $i => $info) { |
foreach ($job['secrets'] as $i => $info) { |
1338 |
1678 |
if (empty($info['name'])) |
if (empty($info['name'])) |
1339 |
1679 |
continue; |
continue; |
|
... |
... |
function start_worker($job) |
1343 |
1683 |
$s .= "\n"; |
$s .= "\n"; |
1344 |
1684 |
} |
} |
1345 |
1685 |
|
|
1346 |
|
$s .= 'cd /mnt/target' . "\n\n"; |
|
|
1686 |
|
$s .= 'cd /mnt/target/source' . "\n\n"; |
1347 |
1687 |
|
|
1348 |
|
// To be able to run 'configure' without './' |
|
|
1688 |
|
// To be able to run 'configure' without './...' |
1349 |
1689 |
$s .= 'export PATH="${PATH}:."' . "\n\n"; |
$s .= 'export PATH="${PATH}:."' . "\n\n"; |
1350 |
1690 |
|
|
1351 |
1691 |
if (!isset($job['cmds'])) |
if (!isset($job['cmds'])) |
|
... |
... |
function start_worker($job) |
1406 |
1746 |
rg_log_debug('packages: ' . $job['packages'] . '.'); |
rg_log_debug('packages: ' . $job['packages'] . '.'); |
1407 |
1747 |
$p_i_cmd .= 'rg_notify "Installing webhook specified packages"' . "\n"; |
$p_i_cmd .= 'rg_notify "Installing webhook specified packages"' . "\n"; |
1408 |
1748 |
|
|
|
1749 |
|
// In some versions, we did not replaced \n\r\t correctly. Do it here |
|
1750 |
|
$job['packages'] = preg_replace('/\s/', ' ', $job['packages']); |
|
1751 |
|
|
1409 |
1752 |
$pkgs = explode(' ', $job['packages']); |
$pkgs = explode(' ', $job['packages']); |
1410 |
1753 |
$p_i_cmd .= '> /mnt/packages.log' . "\n"; |
$p_i_cmd .= '> /mnt/packages.log' . "\n"; |
1411 |
1754 |
|
|
|
... |
... |
function start_worker($job) |
1414 |
1757 |
. 'p=' . escapeshellarg($p) . "\n" |
. 'p=' . escapeshellarg($p) . "\n" |
1415 |
1758 |
. 'if [[ ${p} =~ :// ]]; then' . "\n" |
. 'if [[ ${p} =~ :// ]]; then' . "\n" |
1416 |
1759 |
. ' rg_notify_warn "We do not allow remote packages for security reasons"' . "\n" |
. ' rg_notify_warn "We do not allow remote packages for security reasons"' . "\n" |
|
1760 |
|
. 'elif [ -r "/etc/rgw/pkg/${p}" ]; then' . "\n" |
|
1761 |
|
. ' rg_notify "Package ${p} was already installed by rgw"' . "\n" |
1417 |
1762 |
. 'else' . "\n" |
. 'else' . "\n" |
1418 |
1763 |
. ' rg_notify "Installing package ${p}"' . "\n" |
. ' rg_notify "Installing package ${p}"' . "\n" |
1419 |
|
. ' echo "=== ${p} ==="' . "\n" |
|
1420 |
1764 |
. ' ${rg_pkg_cmd} "${p}"' . "\n" |
. ' ${rg_pkg_cmd} "${p}"' . "\n" |
1421 |
1765 |
. 'fi' . "\n" |
. 'fi' . "\n" |
1422 |
1766 |
. 'echo; echo' . "\n" |
. 'echo; echo' . "\n" |
|
... |
... |
function start_worker($job) |
1432 |
1776 |
if ($r === FALSE) |
if ($r === FALSE) |
1433 |
1777 |
break; |
break; |
1434 |
1778 |
|
|
|
1779 |
|
$r = start_worker_build_debs($job, $conf, $reason, $reason2); |
|
1780 |
|
if ($r === FALSE) |
|
1781 |
|
break; |
|
1782 |
|
|
1435 |
1783 |
$r = start_worker_build_rgfs($job, $reason, $reason2); |
$r = start_worker_build_rgfs($job, $reason, $reason2); |
1436 |
1784 |
if ($r === FALSE) |
if ($r === FALSE) |
1437 |
1785 |
break; |
break; |
|
... |
... |
function start_worker($job) |
1457 |
1805 |
. 'mkdir -p /mnt/var/tmp && chmod 1777 /mnt/var/tmp' . "\n" |
. 'mkdir -p /mnt/var/tmp && chmod 1777 /mnt/var/tmp' . "\n" |
1458 |
1806 |
. 'mount --bind /mnt/var/tmp /var/tmp' . "\n" |
. 'mount --bind /mnt/var/tmp /var/tmp' . "\n" |
1459 |
1807 |
. "\n" |
. "\n" |
1460 |
|
. 'mkdir -p /mnt/target /mnt/rpmbuild /mnt/status' . "\n" |
|
1461 |
|
. 'chown -R build:build /mnt/target* /mnt/rpmbuild /mnt/status' . "\n" |
|
|
1808 |
|
. 'mkdir -p /mnt/rpmbuild /mnt/status' . "\n" |
|
1809 |
|
. 'chown -R build:build /mnt/target /mnt/rpmbuild /mnt/status' . "\n" |
1462 |
1810 |
. 'mkdir -p /mnt/build2' . "\n" |
. 'mkdir -p /mnt/build2' . "\n" |
1463 |
1811 |
. 'chown -R build2:build2 /mnt/build2; chmod go= /mnt/build2' . "\n" |
. 'chown -R build2:build2 /mnt/build2; chmod go= /mnt/build2' . "\n" |
1464 |
1812 |
. 'echo "PATH=${PATH}"' . "\n" |
. 'echo "PATH=${PATH}"' . "\n" |
|
... |
... |
function start_worker($job) |
1486 |
1834 |
. 'sysctl kernel.dmesg_restrict=1' . "\n" |
. 'sysctl kernel.dmesg_restrict=1' . "\n" |
1487 |
1835 |
. "\n" |
. "\n" |
1488 |
1836 |
. '# Disabling root login' . "\n" |
. '# Disabling root login' . "\n" |
1489 |
|
. 'chage -E 0 root' . "\n" |
|
|
1837 |
|
//TODO . 'chage -E 0 root' . "\n" |
1490 |
1838 |
. 'if [ "${?}" != "0" ]; then' . "\n" |
. 'if [ "${?}" != "0" ]; then' . "\n" |
1491 |
1839 |
. ' ERR="cannot disable root account"' . "\n" |
. ' ERR="cannot disable root account"' . "\n" |
1492 |
1840 |
. 'fi' . "\n" |
. 'fi' . "\n" |
|
... |
... |
function start_worker($job) |
1505 |
1853 |
. ' if [ "${job_url}" != "" ]; then' . "\n" |
. ' if [ "${job_url}" != "" ]; then' . "\n" |
1506 |
1854 |
. ' rg_notify "Checkout..."' . "\n" |
. ' rg_notify "Checkout..."' . "\n" |
1507 |
1855 |
. ' echo; echo "`date`: Checkout"' . "\n" |
. ' echo; echo "`date`: Checkout"' . "\n" |
1508 |
|
. ' su - build -c "cd /mnt/target && git branch -f rgw ${job_head} && git checkout --force rgw" >/mnt/status/checkout 2>&1' . "\n" |
|
|
1856 |
|
. ' su - build -c "cd /mnt/target/source && git branch -f rgw ${job_head} && git checkout --force rgw" >/mnt/status/checkout 2>&1' . "\n" |
1509 |
1857 |
. ' if [ "${?}" != "0" ]; then' . "\n" |
. ' if [ "${?}" != "0" ]; then' . "\n" |
1510 |
1858 |
. ' sleep 3' . "\n" |
. ' sleep 3' . "\n" |
1511 |
1859 |
. ' continue' . "\n" |
. ' continue' . "\n" |
|
... |
... |
function start_worker($job) |
1514 |
1862 |
. ' fi' . "\n" |
. ' fi' . "\n" |
1515 |
1863 |
. ' fi' . "\n" |
. ' fi' . "\n" |
1516 |
1864 |
. "\n" |
. "\n" |
1517 |
|
. ' # Extract .spec file info' . "\n" |
|
1518 |
|
. ' rg_extract_rpm_info /mnt/target' . "\n" |
|
1519 |
|
. ' if [ "${spec_deps}" != "" ]; then' . "\n" |
|
1520 |
|
. ' echo; echo "`date`: Installing dependencies [${spec_deps}]"' . "\n" |
|
1521 |
|
. ' for p in ${spec_deps}; do' . "\n" |
|
|
1865 |
|
. ' case ${env_distro} in' . "\n" |
|
1866 |
|
. ' fedora|centos|rocky)' . "\n" |
|
1867 |
|
. ' rg_rpm_extract_info /mnt/target/source ;;' . "\n" |
|
1868 |
|
. ' debian|ubuntu)' . "\n" |
|
1869 |
|
. ' rg_deb_extract_info /mnt/target/source ;;' . "\n" |
|
1870 |
|
. ' esac' . "\n" |
|
1871 |
|
. "\n" |
|
1872 |
|
. ' if [ "${pkg_deps}" != "" ]; then' . "\n" |
|
1873 |
|
. ' echo; echo "`date`: Installing dependencies [${pkg_deps}]"' . "\n" |
|
1874 |
|
. ' for p in ${pkg_deps}; do' . "\n" |
1522 |
1875 |
. ' if [[ ${p} =~ :// ]]; then' . "\n" |
. ' if [[ ${p} =~ :// ]]; then' . "\n" |
1523 |
|
. ' rg_notify_warn "We do not allow remote packages for security reasons"' . "\n" // TODO: the net is already disabled |
|
|
1876 |
|
. ' rg_notify_warn "We do not allow remote packages for security reasons"' . "\n" // TODO: the net is already disabled; only for user! |
1524 |
1877 |
. ' continue' . "\n" |
. ' continue' . "\n" |
1525 |
1878 |
. ' fi' . "\n" |
. ' fi' . "\n" |
1526 |
|
. ' rg_notify "Installing package ${p}"' . "\n" |
|
1527 |
|
. ' ${rg_pkg_cmd} "${p}" 2>/tmp/install_pkg.err' . "\n" |
|
1528 |
|
. ' [ "${?}" = "0" ] || rg_notify_warn "Cannot install ${p}: "$(< /tmp/install_pkg.err)' . "\n" |
|
|
1879 |
|
. ' if [ -r "/etc/rgw/pkg/${p}" ]; then' . "\n" |
|
1880 |
|
. ' rg_notify "Package ${p} was already installed by rgw"' . "\n" |
|
1881 |
|
. ' else' . "\n" |
|
1882 |
|
. ' rg_notify "Installing package ${p}"' . "\n" |
|
1883 |
|
. ' ${rg_pkg_cmd} "${p}" 2>/tmp/install_pkg.err' . "\n" |
|
1884 |
|
. ' [ "${?}" = "0" ] || rg_notify_warn "Cannot install ${p}: "$(< /tmp/install_pkg.err)' . "\n" |
|
1885 |
|
. ' fi' . "\n" |
1529 |
1886 |
. ' done' . "\n" |
. ' done' . "\n" |
1530 |
1887 |
. ' fi' . "\n" |
. ' fi' . "\n" |
1531 |
1888 |
. "\n" |
. "\n" |
|
... |
... |
function start_worker($job) |
1542 |
1899 |
. ' break' . "\n" |
. ' break' . "\n" |
1543 |
1900 |
. ' fi' . "\n" |
. ' fi' . "\n" |
1544 |
1901 |
. "\n" |
. "\n" |
1545 |
|
. ' rg_notify "Starting build_rpms.sh script"' . "\n" |
|
1546 |
|
. ' echo; echo "`date`: Running build_rpms.sh script"' . "\n" |
|
1547 |
|
. ' date +%s > /mnt/T_RPMS_START' . "\n" |
|
1548 |
|
. ' su - build -c "bash /mnt/build_rpms.sh" &>/mnt/status/build_rpms.log' . "\n" |
|
|
1902 |
|
. ' rg_notify "Starting build_rpms/debs.sh script"' . "\n" |
|
1903 |
|
. ' echo; echo "`date`: Running build_rpms/debs.sh script"' . "\n" |
|
1904 |
|
. ' date +%s > /mnt/T_MKPKGS_START' . "\n" // TODO: not exposed |
|
1905 |
|
. ' case ${env_distro} in' . "\n" |
|
1906 |
|
. ' fedora|centos|rocky)' . "\n" // TODO: pass 'rpm' not the distro? Same for 'deb'. |
|
1907 |
|
. ' chown -Rv build:build /mnt/target-dotrepo-*' . "\n" |
|
1908 |
|
. ' su - build -c "bash /mnt/build_rpms.sh" &>/mnt/status/build_pkgs.log ;;' . "\n" // TODO replace everywhere build_rpms.log with build_pkgs.log |
|
1909 |
|
. ' debian|ubuntu)' . "\n" |
|
1910 |
|
. ' su - build -c "bash /mnt/build_debs.sh" &>/mnt/status/build_pkgs.log ;;' . "\n" |
|
1911 |
|
. ' *) echo "Unsupported distro" ;;' . "\n" |
|
1912 |
|
. ' esac' . "\n" |
1549 |
1913 |
. ' E=${?}' . "\n" |
. ' E=${?}' . "\n" |
1550 |
|
. ' date +%s > /mnt/T_RPMS_END' . "\n" |
|
1551 |
|
. ' rg_notify "build_rpms.sh finished with code ${E}"' . "\n" |
|
|
1914 |
|
. ' E=0' . "\n" // TODO: for now, we do not error on this |
|
1915 |
|
. ' date +%s > /mnt/T_MKPKGS_END' . "\n" |
|
1916 |
|
. ' rg_notify "finished with code ${E}"' . "\n" |
1552 |
1917 |
. ' if [ "${E}" != "0" ]; then' . "\n" |
. ' if [ "${E}" != "0" ]; then' . "\n" |
1553 |
|
. ' ERR="build_rpms.sh returned ${E}"' . "\n" |
|
|
1918 |
|
. ' ERR="build_rpms/debs.sh returned ${E}"' . "\n" |
1554 |
1919 |
. ' break' . "\n" |
. ' break' . "\n" |
1555 |
1920 |
. ' fi' . "\n" |
. ' fi' . "\n" |
1556 |
1921 |
. "\n" |
. "\n" |
1557 |
|
. ' rm -f ~/rg_op.err # it was owned by build user till now' . "\n" |
|
1558 |
1922 |
. ' # Moving everything to build2 dir. TODO: Why?' . "\n" |
. ' # Moving everything to build2 dir. TODO: Why?' . "\n" |
1559 |
|
. ' [ -d /mnt/target/rocketgit ] && mv -f /mnt/target/rocketgit /mnt/build2' . "\n" |
|
|
1923 |
|
. ' [ -d /mnt/target/source/rocketgit ] && cp -rf /mnt/target/source/rocketgit /mnt/build2' . "\n" |
|
1924 |
|
. ' # /mnt/target/* because we need the deb programs to access packages' . "\n" |
|
1925 |
|
. ' chown build2:build2 /mnt/target' . "\n" |
|
1926 |
|
. ' find /mnt/target -type f -maxdepth 1 -exec chown build2:build2 {} \;' . "\n" |
1560 |
1927 |
. ' chown -R build2:build2 /mnt/build2 /mnt/rpmbuild' . "\n" |
. ' chown -R build2:build2 /mnt/build2 /mnt/rpmbuild' . "\n" |
1561 |
1928 |
. "\n" |
. "\n" |
1562 |
1929 |
. ' rg_notify "Starting build_rgfs.sh script"' . "\n" |
. ' rg_notify "Starting build_rgfs.sh script"' . "\n" |
1563 |
1930 |
. ' echo; echo "`date`: Running build_rgfs.sh script"' . "\n" |
. ' echo; echo "`date`: Running build_rgfs.sh script"' . "\n" |
1564 |
1931 |
. ' bash /mnt/build_rgfs.sh &>/mnt/status/build_rgfs.log' . "\n" |
. ' bash /mnt/build_rgfs.sh &>/mnt/status/build_rgfs.log' . "\n" |
1565 |
1932 |
. ' if [ "${?}" != "0" ]; then' . "\n" |
. ' if [ "${?}" != "0" ]; then' . "\n" |
1566 |
|
. ' echo "error building rgfs; trying to continue"' . "\n" |
|
|
1933 |
|
. ' rg_notify "error building rgfs; trying to continue"' . "\n" |
1567 |
1934 |
. ' fi' . "\n" |
. ' fi' . "\n" |
1568 |
1935 |
. "\n" |
. "\n" |
1569 |
1936 |
. ' if [ -x /mnt/build_repo.sh ]; then' . "\n" |
. ' if [ -x /mnt/build_repo.sh ]; then' . "\n" |
1570 |
1937 |
. ' rg_notify "Starting build_repo.sh script"' . "\n" |
. ' rg_notify "Starting build_repo.sh script"' . "\n" |
1571 |
1938 |
. ' echo; echo "`date`: Running build_repo.sh script"' . "\n" |
. ' echo; echo "`date`: Running build_repo.sh script"' . "\n" |
1572 |
1939 |
. ' date +%s > /mnt/T_REPO_START' . "\n" |
. ' date +%s > /mnt/T_REPO_START' . "\n" |
|
1940 |
|
. ' ls -l /home; mkdir -p /home/build2; chown build2:build2 /home/build2' . "\n" |
1573 |
1941 |
. ' su - build2 -c "bash /mnt/build_repo.sh" &>/mnt/status/build_repo.log' . "\n" |
. ' su - build2 -c "bash /mnt/build_repo.sh" &>/mnt/status/build_repo.log' . "\n" |
1574 |
1942 |
. ' E=${?}' . "\n" |
. ' E=${?}' . "\n" |
1575 |
1943 |
. ' date +%s > /mnt/T_REPO_END' . "\n" |
. ' date +%s > /mnt/T_REPO_END' . "\n" |
|
... |
... |
function xhandle_one($key, $data) |
1720 |
2088 |
} |
} |
1721 |
2089 |
|
|
1722 |
2090 |
if (strcmp($op, 'BLD') == 0) { |
if (strcmp($op, 'BLD') == 0) { |
1723 |
|
rg_log($key . ': ' . $jid . ': build job: ' . rg_array2string($u)); |
|
|
2091 |
|
rg_log($key . ': ' . $jid . ': build job: ' . rg_array2string_short($u)); |
1724 |
2092 |
|
|
1725 |
2093 |
if (isset($jobs[$jid])) { |
if (isset($jobs[$jid])) { |
1726 |
2094 |
// TODO: this should not happen, right? |
// TODO: this should not happen, right? |
|
... |
... |
function xhandle_one($key, $data) |
1748 |
2116 |
if (!isset($jobs[$jid]['cpus'])) |
if (!isset($jobs[$jid]['cpus'])) |
1749 |
2117 |
$jobs[$jid]['cpus'] = '2'; |
$jobs[$jid]['cpus'] = '2'; |
1750 |
2118 |
$jobs[$jid]['state'] = RG_JOB_INIT; |
$jobs[$jid]['state'] = RG_JOB_INIT; |
|
2119 |
|
$jobs[$jid]['tmp'] = array(); |
1751 |
2120 |
$jobs[$jid]['dirty'] = 1; |
$jobs[$jid]['dirty'] = 1; |
1752 |
2121 |
return; |
return; |
1753 |
2122 |
} |
} |
|
... |
... |
function rg_job_upload_artifacts(&$job) |
2099 |
2468 |
global $rg_log_dir; |
global $rg_log_dir; |
2100 |
2469 |
global $last_reconnect; |
global $last_reconnect; |
2101 |
2470 |
|
|
2102 |
|
rg_log('rg_job_upload_artifacts'); |
|
|
2471 |
|
$jid = $job['id']; |
|
2472 |
|
|
|
2473 |
|
rg_log($jid . ': rg_job_upload_artifacts'); |
2103 |
2474 |
|
|
2104 |
2475 |
$f = $job['main'] . '/root/build2/rocketgit/artifacts'; |
$f = $job['main'] . '/root/build2/rocketgit/artifacts'; |
2105 |
2476 |
if (!file_exists($f)) { |
if (!file_exists($f)) { |
2106 |
|
rg_log('No artifacts file - no work to do [' . $f . ']'); |
|
|
2477 |
|
rg_log($jid . ': No artifacts file - no work to do [' . $f . ']'); |
2107 |
2478 |
// TODO: Should we update the builder with the new state? Yes! |
// TODO: Should we update the builder with the new state? Yes! |
2108 |
2479 |
$job['state'] = RG_JOB_FINISH; |
$job['state'] = RG_JOB_FINISH; |
2109 |
2480 |
$job['dirty'] = 1; |
$job['dirty'] = 1; |
2110 |
2481 |
return TRUE; |
return TRUE; |
2111 |
2482 |
} |
} |
2112 |
2483 |
|
|
2113 |
|
$jid = $job['id']; |
|
2114 |
|
$root = $job['main'] . '/root/target/'; |
|
|
2484 |
|
$root = $job['main'] . '/root/target/source/'; |
2115 |
2485 |
$root_len = strlen($root); |
$root_len = strlen($root); |
2116 |
2486 |
|
|
2117 |
2487 |
if (!isset($job['artifacts'])) { |
if (!isset($job['artifacts'])) { |
|
... |
... |
function rg_job_extract_info(&$job) |
2282 |
2652 |
{ |
{ |
2283 |
2653 |
global $conf; |
global $conf; |
2284 |
2654 |
|
|
2285 |
|
rg_log_debug('extract_info: job: ' . rg_array2string($job)); |
|
2286 |
|
|
|
2287 |
2655 |
$jid = $job['id']; |
$jid = $job['id']; |
|
2656 |
|
rg_log_debug($jid . ': extract_info: job: ' . rg_array2string($job)); |
|
2657 |
|
|
2288 |
2658 |
$emain = escapeshellarg($job['main']); |
$emain = escapeshellarg($job['main']); |
2289 |
2659 |
|
|
2290 |
2660 |
$ret = FALSE; |
$ret = FALSE; |
|
... |
... |
function rg_job_extract_info(&$job) |
2298 |
2668 |
$m = 'Main dir [' . $job['main'] |
$m = 'Main dir [' . $job['main'] |
2299 |
2669 |
. '] not present;' |
. '] not present;' |
2300 |
2670 |
. ' probably disk space problems'; |
. ' probably disk space problems'; |
2301 |
|
rg_log($m); |
|
|
2671 |
|
rg_log($jid . ': ' . $m); |
2302 |
2672 |
$job['error2'] = $m; |
$job['error2'] = $m; |
2303 |
2673 |
break; |
break; |
2304 |
2674 |
} |
} |
|
... |
... |
function rg_job_extract_info(&$job) |
2306 |
2676 |
$r = @file_get_contents($job['main'] . '/error.log'); |
$r = @file_get_contents($job['main'] . '/error.log'); |
2307 |
2677 |
if ($r !== FALSE) { |
if ($r !== FALSE) { |
2308 |
2678 |
if (!empty($r)) |
if (!empty($r)) |
2309 |
|
rg_log('error set from file to [' . $r . ']'); |
|
|
2679 |
|
rg_log($jid . ': error set from file to [' . $r . ']'); |
2310 |
2680 |
$job['error'] = trim($r); |
$job['error'] = trim($r); |
2311 |
2681 |
break; |
break; |
2312 |
2682 |
} |
} |
|
... |
... |
function rg_job_extract_info(&$job) |
2314 |
2684 |
$r = @file_get_contents($job['main'] . '/error2.log'); |
$r = @file_get_contents($job['main'] . '/error2.log'); |
2315 |
2685 |
if ($r !== FALSE) { |
if ($r !== FALSE) { |
2316 |
2686 |
if (!empty($r)) |
if (!empty($r)) |
2317 |
|
rg_log('error2 set from file to [' . $r . ']'); |
|
|
2687 |
|
rg_log($jid . ': error2 set from file to [' . $r . ']'); |
2318 |
2688 |
$job['error2'] = trim($r); |
$job['error2'] = trim($r); |
2319 |
2689 |
break; |
break; |
2320 |
2690 |
} |
} |
|
... |
... |
function rg_job_extract_info(&$job) |
2325 |
2695 |
$r = @stat($job['main'] . '/image2.raw'); |
$r = @stat($job['main'] . '/image2.raw'); |
2326 |
2696 |
if ($r === FALSE) { |
if ($r === FALSE) { |
2327 |
2697 |
$m = 'missing image2 file'; |
$m = 'missing image2 file'; |
2328 |
|
rg_log($m); |
|
|
2698 |
|
rg_log($jid . ': ' . $m); |
2329 |
2699 |
$job['error'] = $m; |
$job['error'] = $m; |
2330 |
2700 |
break; |
break; |
2331 |
2701 |
} |
} |
|
... |
... |
function rg_job_extract_info(&$job) |
2342 |
2712 |
$r = rg_exec($cmd, '', FALSE, FALSE, FALSE); |
$r = rg_exec($cmd, '', FALSE, FALSE, FALSE); |
2343 |
2713 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
2344 |
2714 |
$m = 'could not mount image: ' . $r['errmsg']; |
$m = 'could not mount image: ' . $r['errmsg']; |
2345 |
|
rg_log($m); |
|
|
2715 |
|
rg_log($jid . ': ' . $m); |
2346 |
2716 |
$job['error'] = $m; |
$job['error'] = $m; |
2347 |
2717 |
break; |
break; |
2348 |
2718 |
} |
} |
|
... |
... |
function rg_job_extract_info(&$job) |
2429 |
2799 |
unset($job['url']); |
unset($job['url']); |
2430 |
2800 |
unset($job['head']); |
unset($job['head']); |
2431 |
2801 |
unset($job['env']); |
unset($job['env']); |
2432 |
|
rg_log_debug('state set to JOB_ARTIFACTS'); |
|
|
2802 |
|
rg_log_debug($jid . ': state set to JOB_ARTIFACTS'); |
2433 |
2803 |
$job['state'] = RG_JOB_ARTIFACTS; |
$job['state'] = RG_JOB_ARTIFACTS; |
2434 |
2804 |
break; |
break; |
2435 |
2805 |
} |
} |
2436 |
2806 |
|
|
2437 |
2807 |
if (!empty($job['error'])) { |
if (!empty($job['error'])) { |
2438 |
|
rg_log_debug('state set to JOB_ERROR (' . $job['error'] . ')'); |
|
|
2808 |
|
rg_log($jid . ': state set to JOB_ERROR (' . $job['error'] . ')'); |
2439 |
2809 |
$job['state'] = RG_JOB_ERROR; |
$job['state'] = RG_JOB_ERROR; |
2440 |
2810 |
return; |
return; |
2441 |
2811 |
} |
} |
|
... |
... |
function vm_extract_info($name) |
2451 |
2821 |
$cmd = 'virsh domstats --raw ' . escapeshellarg($name); |
$cmd = 'virsh domstats --raw ' . escapeshellarg($name); |
2452 |
2822 |
$r = rg_exec($cmd, '', FALSE, FALSE, FALSE); |
$r = rg_exec($cmd, '', FALSE, FALSE, FALSE); |
2453 |
2823 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
2454 |
|
rg_log('Could not get dom stats: ' . $r['errmsg']); |
|
|
2824 |
|
//rg_log('Could not get dom stats: ' . $r['errmsg']); // Probably child finished |
2455 |
2825 |
break; |
break; |
2456 |
2826 |
} |
} |
2457 |
2827 |
|
|
2458 |
|
rg_debug() && rg_log_debug('domstats: ' . rg_array2string($r['data'])); |
|
|
2828 |
|
//rg_log_debug('domstats: ' . rg_array2string_short($r['data'])); |
2459 |
2829 |
$data = array(); |
$data = array(); |
2460 |
2830 |
$t = explode("\n", $r['data']); |
$t = explode("\n", $r['data']); |
2461 |
2831 |
foreach ($t as $line) { |
foreach ($t as $line) { |
|
... |
... |
function vm_extract_info($name) |
2466 |
2836 |
$data[$x[0]] = $x[1]; |
$data[$x[0]] = $x[1]; |
2467 |
2837 |
} |
} |
2468 |
2838 |
|
|
2469 |
|
$ret = array(); |
|
2470 |
2839 |
if (!isset($data['net.0.rx.bytes'])) |
if (!isset($data['net.0.rx.bytes'])) |
2471 |
2840 |
break; |
break; |
2472 |
2841 |
|
|
|
2842 |
|
$ret = array(); |
|
2843 |
|
$ret['ts'] = time(); |
2473 |
2844 |
$ret['rx_bytes'] = $data['net.0.rx.bytes']; |
$ret['rx_bytes'] = $data['net.0.rx.bytes']; |
2474 |
2845 |
$ret['rx_pkts'] = $data['net.0.rx.pkts']; |
$ret['rx_pkts'] = $data['net.0.rx.pkts']; |
2475 |
2846 |
$ret['tx_bytes'] = $data['net.0.tx.bytes']; |
$ret['tx_bytes'] = $data['net.0.tx.bytes']; |
|
... |
... |
function vm_extract_info($name) |
2490 |
2861 |
return $ret; |
return $ret; |
2491 |
2862 |
} |
} |
2492 |
2863 |
|
|
|
2864 |
|
/* |
|
2865 |
|
* Store stats per minute and send them to the server |
|
2866 |
|
* @cd - Current data |
|
2867 |
|
*/ |
|
2868 |
|
function vm_do_stats(&$job, $cd) |
|
2869 |
|
{ |
|
2870 |
|
global $features; |
|
2871 |
|
|
|
2872 |
|
do { |
|
2873 |
|
if (!isset($features['stats'])) { |
|
2874 |
|
rg_log_debug('stats feature is not supported by the server'); |
|
2875 |
|
break; |
|
2876 |
|
} |
|
2877 |
|
|
|
2878 |
|
$now = $cd['ts']; |
|
2879 |
|
if (!isset($job['tmp']['stats_1m'])) { |
|
2880 |
|
$job['tmp']['stats_1m'] = $cd; |
|
2881 |
|
break; |
|
2882 |
|
} |
|
2883 |
|
|
|
2884 |
|
if ($job['tmp']['stats_1m']['ts'] + 60 > $now) |
|
2885 |
|
break; |
|
2886 |
|
|
|
2887 |
|
$ignore = array('ballon_current_mib', 'ballon_rss_mib'); |
|
2888 |
|
$d = array(); |
|
2889 |
|
foreach ($cd as $k => $v) { |
|
2890 |
|
if (!isset($job['tmp']['stats_1m'][$k])) |
|
2891 |
|
continue; |
|
2892 |
|
|
|
2893 |
|
if (in_array($k, $ignore)) |
|
2894 |
|
continue; |
|
2895 |
|
|
|
2896 |
|
$d[$k] = $v - $job['tmp']['stats_1m'][$k]; |
|
2897 |
|
} |
|
2898 |
|
$d['ts'] = $now; |
|
2899 |
|
//rg_log_debug('d: ' . print_r($d, TRUE)); |
|
2900 |
|
|
|
2901 |
|
$j = array( |
|
2902 |
|
'op' => 'stats', |
|
2903 |
|
'id' => $job['id'], |
|
2904 |
|
'stats' => $d); |
|
2905 |
|
rg_conn_enq('master', @json_encode($j) . "\n"); |
|
2906 |
|
|
|
2907 |
|
$job['tmp']['stats_1m'] = $cd; |
|
2908 |
|
} while (0); |
|
2909 |
|
|
|
2910 |
|
$job['stats'] = $cd; |
|
2911 |
|
} |
|
2912 |
|
|
2493 |
2913 |
/* |
/* |
2494 |
2914 |
* Send stats about the worker |
* Send stats about the worker |
2495 |
2915 |
*/ |
*/ |
|
... |
... |
$stats = array('jobs' => 0); |
2639 |
3059 |
|
|
2640 |
3060 |
$jobs = rg_load_files($conf['state'], 'job-[0-9]*.ser', 'id'); |
$jobs = rg_load_files($conf['state'], 'job-[0-9]*.ser', 'id'); |
2641 |
3061 |
if (!empty($jobs)) |
if (!empty($jobs)) |
2642 |
|
rg_log_ml('Jobs loaded from dir: ' . print_r($jobs, TRUE)); |
|
|
3062 |
|
rg_log_debug('Jobs loaded from dir: ' . rg_array2string_short($jobs)); |
2643 |
3063 |
|
|
2644 |
3064 |
rg_worker_connect(); |
rg_worker_connect(); |
2645 |
3065 |
|
|
|
... |
... |
while(1) { |
2761 |
3181 |
// TODO: what if we cannot extract info?! Wouldn't we lost stats?!! |
// TODO: what if we cannot extract info?! Wouldn't we lost stats?!! |
2762 |
3182 |
$r = vm_extract_info($name); |
$r = vm_extract_info($name); |
2763 |
3183 |
if ($r !== FALSE) |
if ($r !== FALSE) |
2764 |
|
$job['stats'] = $r; |
|
|
3184 |
|
vm_do_stats($job, $r); |
2765 |
3185 |
|
|
2766 |
3186 |
// TODO: timeout must be controlled by user |
// TODO: timeout must be controlled by user |
|
3187 |
|
// TODO: we may judje progress also about CPU/I/O/net activity |
2767 |
3188 |
if ($job['start'] + 1 * 3600 < time()) { |
if ($job['start'] + 1 * 3600 < time()) { |
2768 |
|
rg_log($jid . ': More than 6 hours without progress! Kill VM!'); |
|
|
3189 |
|
rg_log($jid . ': More than 1 hour without progress! Kill VM!'); |
2769 |
3190 |
$_name = 'rg-worker-' . $conf['id'] . '-' . $jid; |
$_name = 'rg-worker-' . $conf['id'] . '-' . $jid; |
2770 |
3191 |
$cmd = 'virsh destroy ' . escapeshellarg($_name); |
$cmd = 'virsh destroy ' . escapeshellarg($_name); |
2771 |
3192 |
$r = rg_exec($cmd, '', FALSE, FALSE, FALSE); |
$r = rg_exec($cmd, '', FALSE, FALSE, FALSE); |
|
... |
... |
while(1) { |
2839 |
3260 |
unset($xjob['last_reconnect']); |
unset($xjob['last_reconnect']); |
2840 |
3261 |
unset($xjob['info_confirmed']); |
unset($xjob['info_confirmed']); |
2841 |
3262 |
unset($xjob['dirty']); |
unset($xjob['dirty']); |
|
3263 |
|
unset($xjob['tmp']); |
2842 |
3264 |
$j_xjob = @json_encode($xjob); |
$j_xjob = @json_encode($xjob); |
2843 |
3265 |
if ($j_xjob !== FALSE) { |
if ($j_xjob !== FALSE) { |
2844 |
3266 |
// TODO: this is fragile. Better to iterate all jobs to compute stats. |
// TODO: this is fragile. Better to iterate all jobs to compute stats. |
File tests/wh_build.php changed (mode: 100644) (index 766c6ae..3e6c880) |
... |
... |
$INC = dirname(__FILE__) . '/../inc'; |
11 |
11 |
require_once(dirname(__FILE__) . '/config.php'); |
require_once(dirname(__FILE__) . '/config.php'); |
12 |
12 |
require_once($INC . '/init.inc.php'); |
require_once($INC . '/init.inc.php'); |
13 |
13 |
require_once($INC . '/user.inc.php'); |
require_once($INC . '/user.inc.php'); |
|
14 |
|
require_once($INC . '/user/packages.inc.php'); |
14 |
15 |
require_once('helpers.inc.php'); |
require_once('helpers.inc.php'); |
15 |
16 |
require_once('http.inc.php'); |
require_once('http.inc.php'); |
16 |
17 |
|
|
|
... |
... |
$extra = array( |
77 |
78 |
'wh::idata::secrets::0::name' => 'secret1', // we cannot use <xss> here - it will be rejected by bash |
'wh::idata::secrets::0::name' => 'secret1', // we cannot use <xss> here - it will be rejected by bash |
78 |
79 |
'wh::idata::secrets::0::value' => 'value1<xss>', |
'wh::idata::secrets::0::value' => 'value1<xss>', |
79 |
80 |
'wh::idata::events' => 'P', |
'wh::idata::events' => 'P', |
80 |
|
'wh::idata::envs[fedora-34-x86_64]' => 'on', |
|
|
81 |
|
'wh::idata::envs[fedora-35-x86_64]' => 'on', |
|
82 |
|
'wh::idata::envs[debian-11-amd64]' => 'on', |
81 |
83 |
'wh::idata::packages' => 'nano', |
'wh::idata::packages' => 'nano', |
82 |
84 |
'wh::idata::cmds::1::cmd' => 'make', |
'wh::idata::cmds::1::cmd' => 'make', |
83 |
85 |
'wh::idata::cmds::1::label_ok' => 'success <xss>', |
'wh::idata::cmds::1::label_ok' => 'success <xss>', |
84 |
|
'wh::idata::cmds::1::label_nok' => 'fail <xss>' |
|
85 |
|
); |
|
|
86 |
|
'wh::idata::cmds::1::label_nok' => 'fail <xss>'); |
86 |
87 |
rg_test_wh_add_edit($db, $rg_ui, 'build', 'generic', $extra); |
rg_test_wh_add_edit($db, $rg_ui, 'build', 'generic', $extra); |
87 |
88 |
$wh_id = $extra['id']; |
$wh_id = $extra['id']; |
88 |
89 |
rg_log('wh_id=' . $wh_id); |
rg_log('wh_id=' . $wh_id); |
|
... |
... |
$pkg_repo_pub = array( |
100 |
101 |
rg_test_pkg_repo_add_edit($db, $rg_ui, $pkg_repo_pub); |
rg_test_pkg_repo_add_edit($db, $rg_ui, $pkg_repo_pub); |
101 |
102 |
|
|
102 |
103 |
|
|
103 |
|
$pkg_subrepo_pub = array('sr::name' => 'stable'); |
|
|
104 |
|
$pkg_subrepo_pub = array('sr::name' => 'stablepub'); |
104 |
105 |
rg_test_pkg_subrepo_add_edit($db, $rg_ui, $pkg_repo_pub, $pkg_subrepo_pub); |
rg_test_pkg_subrepo_add_edit($db, $rg_ui, $pkg_repo_pub, $pkg_subrepo_pub); |
105 |
106 |
|
|
106 |
107 |
|
|
|
... |
... |
$pkg_repo_priv = array( |
111 |
112 |
); |
); |
112 |
113 |
rg_test_pkg_repo_add_edit($db, $rg_ui, $pkg_repo_priv); |
rg_test_pkg_repo_add_edit($db, $rg_ui, $pkg_repo_priv); |
113 |
114 |
|
|
114 |
|
$pkg_subrepo_priv = array('sr::name' => 'stable'); |
|
|
115 |
|
$pkg_subrepo_priv = array('sr::name' => 'stablepriv'); |
115 |
116 |
rg_test_pkg_subrepo_add_edit($db, $rg_ui, $pkg_repo_priv, $pkg_subrepo_priv); |
rg_test_pkg_subrepo_add_edit($db, $rg_ui, $pkg_repo_priv, $pkg_subrepo_priv); |
116 |
117 |
|
|
117 |
118 |
|
|
|
... |
... |
rg_log_exit(); |
156 |
157 |
|
|
157 |
158 |
rg_log(''); |
rg_log(''); |
158 |
159 |
rg_log_enter('Testing if hook executed with success'); |
rg_log_enter('Testing if hook executed with success'); |
159 |
|
$key = 'DEBUG::' . $rg_ui['uid'] . '::webhooks::' . $wh_id; |
|
160 |
|
$r = test_wait_cache($key, 600); |
|
161 |
|
$p = @$r['status']['cmds'][1]; |
|
162 |
|
if (strcmp($p['status'], '0') != 0) { |
|
163 |
|
rg_log_ml('r: ' . print_r($r, TRUE)); |
|
164 |
|
rg_log('Sseems the build did not work well' |
|
165 |
|
. ' [' . $p['status'] . ']! See above.'); |
|
166 |
|
exit(1); |
|
167 |
|
} |
|
|
160 |
|
$r = rg_test_packages($rg_ui, $repo); |
|
161 |
|
// We have 1 more build for createrepo and one for Debian |
|
162 |
|
do { |
|
163 |
|
$r = rg_test_packages($rg_ui, $repo); |
|
164 |
|
file_put_contents('wh_build_pkg_r.out', json_encode($r, JSON_PRETTY_PRINT)); |
|
165 |
|
file_put_contents('wh_build_pkg_debug.out', json_encode($r['rg_debug_html'], JSON_PRETTY_PRINT)); |
|
166 |
|
|
|
167 |
|
$_base = '/op/pkgrepo/user/' . $rg_ui['username'] |
|
168 |
|
. '/' . $pkg_repo_pub['pi::name'] . '/' . $pkg_subrepo_pub['sr::name']; |
|
169 |
|
$pub_rpm_ready = strstr($r['body'], $_base . '/fedora'); |
|
170 |
|
$pub_deb_ready = strstr($r['body'], $_base . '/debian'); |
|
171 |
|
|
|
172 |
|
$_base = '/op/pkgrepo/user/' . $rg_ui['username'] |
|
173 |
|
. '/' . $pkg_repo_priv['pi::name'] . '/' . $pkg_subrepo_priv['sr::name']; |
|
174 |
|
$priv_rpm_ready = strstr($r['body'], $_base . '/fedora'); |
|
175 |
|
$priv_deb_ready = strstr($r['body'], $_base . '/debian'); |
|
176 |
|
rg_log('pub_rpm_ready=' . ($pub_rpm_ready !== FALSE ? 'true' : 'false')); |
|
177 |
|
rg_log('pub_deb_ready=' . ($pub_deb_ready !== FALSE ? 'true' : 'false')); |
|
178 |
|
rg_log('priv_rpm_ready=' . ($priv_rpm_ready !== FALSE ? 'true' : 'false')); |
|
179 |
|
rg_log('priv_deb_ready=' . ($priv_deb_ready !== FALSE ? 'true' : 'false')); |
|
180 |
|
if ($pub_rpm_ready && $pub_deb_ready && $priv_rpm_ready && $priv_deb_ready) |
|
181 |
|
break; |
|
182 |
|
|
|
183 |
|
sleep(5); |
|
184 |
|
} while (1); |
168 |
185 |
rg_log_exit(); |
rg_log_exit(); |
169 |
186 |
|
|
170 |
187 |
|
|
|
... |
... |
rg_log_exit(); |
175 |
192 |
rg_log(''); |
rg_log(''); |
176 |
193 |
rg_log_enter('Checking packages'); |
rg_log_enter('Checking packages'); |
177 |
194 |
$r = rg_test_packages($rg_ui, $repo); |
$r = rg_test_packages($rg_ui, $repo); |
178 |
|
$e = '>os/+pending/' . $rg_ui['username'] |
|
179 |
|
. '/' . $rg_ui['username'] . '+' . $repo['name'] . '-0.1-1.x86_64.rpm<'; |
|
|
195 |
|
$e = '>' . $rg_ui['username'] . '+' . $repo['name'] . '-0.1-1.x86_64.rpm<'; |
180 |
196 |
if (!strstr($r['body'], $e)) { |
if (!strstr($r['body'], $e)) { |
181 |
197 |
rg_log_ml('packages page: ' . $r['body']); |
rg_log_ml('packages page: ' . $r['body']); |
182 |
|
rg_log('Link to os package not found [' . $e . ']!'); |
|
|
198 |
|
rg_log('Link to os rpm package not found [' . $e . ']!'); |
183 |
199 |
exit(1); |
exit(1); |
184 |
200 |
} |
} |
185 |
201 |
// TODO: check meta? |
// TODO: check meta? |
|
... |
... |
rg_log_exit(); |
190 |
206 |
rg_log(''); |
rg_log(''); |
191 |
207 |
rg_log_enter('Checking public dotrepo download'); |
rg_log_enter('Checking public dotrepo download'); |
192 |
208 |
$r = rg_test_packages_file($rg_ui, $rg_ui, 'user', |
$r = rg_test_packages_file($rg_ui, $rg_ui, 'user', |
193 |
|
$pkg_repo_pub_name, 'stable', |
|
194 |
|
'os/rocketgit-' . $rg_ui['username'] . '-' |
|
195 |
|
. $pkg_repo_pub_name . '-stable-1.1-1.noarch.rpm'); |
|
|
209 |
|
$pkg_repo_pub_name, $pkg_subrepo_pub['sr::name'], 'fedora', 35, |
|
210 |
|
'x86_64/os/rocketgit-' . $rg_ui['username'] . '-' |
|
211 |
|
. $pkg_repo_pub_name . '-' . $pkg_subrepo_pub['sr::name'] . '-1.1-1.noarch.rpm'); |
196 |
212 |
// TODO: try to unpack the rpm? |
// TODO: try to unpack the rpm? |
197 |
213 |
$e = 'content-type: application/x-rpm'; |
$e = 'content-type: application/x-rpm'; |
198 |
214 |
if (!stristr($r['header'], $e)) { |
if (!stristr($r['header'], $e)) { |
|
... |
... |
rg_log_exit(); |
207 |
223 |
rg_log(''); |
rg_log(''); |
208 |
224 |
rg_log_enter('Checking private dotrepo download'); |
rg_log_enter('Checking private dotrepo download'); |
209 |
225 |
$r = rg_test_packages_file($rg_ui, $rg_ui, 'user', |
$r = rg_test_packages_file($rg_ui, $rg_ui, 'user', |
210 |
|
$pkg_repo_priv_name, 'stable', |
|
211 |
|
'os/rocketgit-' . $rg_ui['username'] . '-' |
|
212 |
|
. $pkg_repo_priv_name . '-stable-1.1-1.noarch.rpm'); |
|
|
226 |
|
$pkg_repo_priv_name, $pkg_subrepo_priv['sr::name'], 'fedora', 35, |
|
227 |
|
'x86_64/os/rocketgit-' . $rg_ui['username'] . '-' |
|
228 |
|
. $pkg_repo_priv_name . '-' . $pkg_subrepo_priv['sr::name'] . '-1.1-1.noarch.rpm'); |
213 |
229 |
// TODO: try to unpack the rpm? |
// TODO: try to unpack the rpm? |
214 |
230 |
$e = 'content-type: application/x-rpm'; |
$e = 'content-type: application/x-rpm'; |
215 |
231 |
if (!stristr($r['header'], $e)) { |
if (!stristr($r['header'], $e)) { |
|
... |
... |
rg_log_exit(); |
223 |
239 |
rg_log(''); |
rg_log(''); |
224 |
240 |
rg_log_enter('Checking private dotrepo download (by bad user)'); |
rg_log_enter('Checking private dotrepo download (by bad user)'); |
225 |
241 |
$r = rg_test_packages_file($rg_bad, $rg_ui, 'user', |
$r = rg_test_packages_file($rg_bad, $rg_ui, 'user', |
226 |
|
$pkg_repo_priv_name, 'stable', |
|
227 |
|
'os/rocketgit-' . $rg_ui['username'] . '-' |
|
228 |
|
. $pkg_repo_priv_name . '-stable-1.1-1.noarch.rpm'); |
|
|
242 |
|
$pkg_repo_priv_name, $pkg_subrepo_priv['sr::name'], 'fedora', 35, |
|
243 |
|
'x86_64/os/rocketgit-' . $rg_ui['username'] . '-' |
|
244 |
|
. $pkg_repo_priv_name . '-' . $pkg_subrepo_priv['sr::name'] . '-1.1-1.noarch.rpm'); |
229 |
245 |
// TODO: try to unpack the rpm? |
// TODO: try to unpack the rpm? |
230 |
246 |
if ($r['ci']['http_code'] != 404) { |
if ($r['ci']['http_code'] != 404) { |
231 |
247 |
rg_log('We must get 404 instead of ' . $r['ci']['http_code'] |
rg_log('We must get 404 instead of ' . $r['ci']['http_code'] |
|
... |
... |
rg_log_exit(); |
238 |
254 |
rg_log(''); |
rg_log(''); |
239 |
255 |
rg_log_enter('Checking packages repomd download'); |
rg_log_enter('Checking packages repomd download'); |
240 |
256 |
$r = rg_test_packages_file($rg_ui, $rg_ui, 'user', |
$r = rg_test_packages_file($rg_ui, $rg_ui, 'user', |
241 |
|
$pkg_repo_pub_name, 'stable', |
|
242 |
|
'os/repodata/repomd.xml'); |
|
|
257 |
|
$pkg_repo_pub_name, $pkg_subrepo_pub['sr::name'], 'fedora', 35, |
|
258 |
|
'x86_64/os/repodata/repomd.xml'); |
243 |
259 |
$e = '<?xml '; |
$e = '<?xml '; |
244 |
260 |
if (!strstr($r['body'], $e)) { |
if (!strstr($r['body'], $e)) { |
245 |
261 |
rg_log_ml('packages repomd page: ' . $r['body']); |
rg_log_ml('packages repomd page: ' . $r['body']); |
|
... |
... |
rg_log_exit(); |
258 |
274 |
rg_log(''); |
rg_log(''); |
259 |
275 |
rg_log_enter('Checking packages rpm download'); |
rg_log_enter('Checking packages rpm download'); |
260 |
276 |
$r = rg_test_packages_file($rg_ui, $rg_ui, 'user', |
$r = rg_test_packages_file($rg_ui, $rg_ui, 'user', |
261 |
|
$pkg_repo_pub_name, 'stable', |
|
262 |
|
'os/' . $rg_ui['username'] . '+' . $repo['name'] . '-0.1-1.x86_64.rpm'); |
|
|
277 |
|
$pkg_repo_pub_name, $pkg_subrepo_pub['sr::name'], 'fedora', 35, |
|
278 |
|
'x86_64/os/' . $rg_ui['username'] . '+' . $repo['name'] . '-0.1-1.x86_64.rpm'); |
263 |
279 |
$e = 'content-type: application/x-rpm'; |
$e = 'content-type: application/x-rpm'; |
264 |
280 |
if (!stristr($r['header'], $e)) { |
if (!stristr($r['header'], $e)) { |
265 |
281 |
rg_log_ml('headers: ' . $r['header']); |
rg_log_ml('headers: ' . $r['header']); |
|
... |
... |
if (!stristr($r['header'], $e)) { |
269 |
285 |
rg_log_exit(); |
rg_log_exit(); |
270 |
286 |
|
|
271 |
287 |
|
|
|
288 |
|
|
|
289 |
|
////////////////////////// Debian area starts |
|
290 |
|
|
|
291 |
|
rg_log(''); |
|
292 |
|
rg_log_enter('Checking keyring as owner user'); |
|
293 |
|
$r = rg_test_packages_file($rg_ui, $rg_ui, 'user', |
|
294 |
|
$pkg_repo_pub_name, $pkg_subrepo_pub['sr::name'], |
|
295 |
|
'debian', 'bullseye', 'keyring'); |
|
296 |
|
$e = 'content-type: application/octet-stream'; |
|
297 |
|
if (!stristr($r['header'], $e) || ($r['ci']['http_code'] != 200)) { |
|
298 |
|
rg_log_ml('headers: ' . $r['header']); |
|
299 |
|
rg_log('Code/Content-Type is not ok [' . $e . ']!'); |
|
300 |
|
exit(1); |
|
301 |
|
} |
|
302 |
|
rg_log_exit(); |
|
303 |
|
|
|
304 |
|
rg_log(''); |
|
305 |
|
rg_log_enter('Checking auth as owner user'); |
|
306 |
|
$r = rg_test_packages_file($rg_ui, $rg_ui, 'user', |
|
307 |
|
$pkg_repo_pub_name, $pkg_subrepo_pub['sr::name'], |
|
308 |
|
'debian', 'bullseye', 'auth'); |
|
309 |
|
$e = 'content-type: text/plain'; |
|
310 |
|
if (!stristr($r['header'], $e) || ($r['ci']['http_code'] != 200)) { |
|
311 |
|
rg_log_ml('headers: ' . $r['header']); |
|
312 |
|
rg_log('Content-Type is not ok [' . $e . ']!'); |
|
313 |
|
exit(1); |
|
314 |
|
} |
|
315 |
|
if (strncmp($r['body'], 'machine ', 8) != 0) { |
|
316 |
|
rg_log('Content of auth file does not start with machine keyword: [' . $r['body'] . ']!'); |
|
317 |
|
exit(1); |
|
318 |
|
} |
|
319 |
|
// TODO: check if password is ok |
|
320 |
|
rg_log_exit(); |
|
321 |
|
|
|
322 |
|
rg_log(''); |
|
323 |
|
rg_log_enter('Downloading package as good (owner) user'); |
|
324 |
|
$u = rg_pkg_transform('deb', $rg_ui['username']); |
|
325 |
|
$u1 = substr($u, 0, 1); $u2 = substr($u, 1, 1); |
|
326 |
|
$r = rg_test_packages_file($rg_ui, $rg_ui, 'user', |
|
327 |
|
$pkg_repo_priv_name, $pkg_subrepo_priv['sr::name'], |
|
328 |
|
'debian', 'bullseye', |
|
329 |
|
'pool/main/' . $u1 . '/' . $u2 . '/' . $u |
|
330 |
|
. '+' . rg_pkg_transform('deb', $repo['name']) . '_0.1_amd64.deb'); |
|
331 |
|
rg_log_ml('r: ' . print_r($r, TRUE)); |
|
332 |
|
$e = 'content-type: application/octet-stream'; |
|
333 |
|
if (!stristr($r['header'], $e) || ($r['ci']['http_code'] != 200)) { |
|
334 |
|
rg_log_ml('headers: ' . $r['header']); |
|
335 |
|
rg_log('Content-Type is not ok [' . $e . ']!'); |
|
336 |
|
exit(1); |
|
337 |
|
} |
|
338 |
|
rg_log_exit(); |
|
339 |
|
|
|
340 |
|
|
|
341 |
|
rg_log(''); |
|
342 |
|
rg_log_enter('Checking auth as bad (not owner) user'); |
|
343 |
|
$r = rg_test_packages_file($rg_bad, $rg_ui, 'user', |
|
344 |
|
$pkg_repo_priv_name, $pkg_subrepo_priv['sr::name'], |
|
345 |
|
'debian', 'bullseye', 'auth'); |
|
346 |
|
if ($r['ci']['http_code'] != 404) { |
|
347 |
|
rg_log_ml('headers: ' . $r['header']); |
|
348 |
|
rg_log('We must get 404!'); |
|
349 |
|
exit(1); |
|
350 |
|
} |
|
351 |
|
rg_log_exit(); |
|
352 |
|
|
|
353 |
|
// TODO: bad user + password? |
|
354 |
|
|
|
355 |
|
rg_log(''); |
|
356 |
|
rg_log_enter('Downloading package as bad (not owner) user'); |
|
357 |
|
$u = rg_pkg_transform('deb', $rg_ui['username']); |
|
358 |
|
$u1 = substr($u, 0, 1); $u2 = substr($u, 1, 1); |
|
359 |
|
$r = rg_test_packages_file($rg_bad, $rg_ui, 'user', |
|
360 |
|
$pkg_repo_priv_name, $pkg_subrepo_priv['sr::name'], |
|
361 |
|
'debian', 'bullseye', |
|
362 |
|
'pool/main/' . $u1 . '/' . $u2 . '/' . $u |
|
363 |
|
. '+' . rg_pkg_transform('deb', $repo['name']) . '_0.1_amd64.deb'); |
|
364 |
|
rg_log_ml('r: ' . print_r($r, TRUE)); |
|
365 |
|
if ($r['ci']['http_code'] != 404) { |
|
366 |
|
rg_log_ml('headers: ' . $r['header']); |
|
367 |
|
rg_log('We must get 404!'); |
|
368 |
|
exit(1); |
|
369 |
|
} |
|
370 |
|
rg_log_exit(); |
|
371 |
|
|
|
372 |
|
////////////////////////// Debian area ends |
|
373 |
|
|
|
374 |
|
|
|
375 |
|
|
272 |
376 |
rg_log(''); |
rg_log(''); |
273 |
377 |
rg_log_enter('Checking artifacts 1'); |
rg_log_enter('Checking artifacts 1'); |
274 |
|
$r = rg_test_artifacts_page($rg_ui, $repo, '/envs/fedora-34-x86_64'); |
|
275 |
|
$e = '<a href="/user/' . $rg_ui['username'] . '/' . $repo['name'] . '/artifacts/download/envs/fedora-34-x86_64/bla%C8%99.out">Download</a>'; |
|
|
378 |
|
$r = rg_test_artifacts_page($rg_ui, $repo, '/envs/fedora-35-x86_64'); |
|
379 |
|
$e = '<a href="/user/' . $rg_ui['username'] . '/' . $repo['name'] . '/artifacts/download/envs/fedora-35-x86_64/bla%C8%99.out">Download</a>'; |
276 |
380 |
if (!strstr($r['body'], $e)) { |
if (!strstr($r['body'], $e)) { |
277 |
381 |
rg_log_ml('artifacts: ' . $r['body']); |
rg_log_ml('artifacts: ' . $r['body']); |
278 |
382 |
rg_log('Link to artifact not found [' . $e . ']!'); |
rg_log('Link to artifact not found [' . $e . ']!'); |
279 |
383 |
exit(1); |
exit(1); |
280 |
384 |
} |
} |
281 |
|
$r = rg_test_artifacts_file($rg_ui, $repo, '/envs/fedora-34-x86_64/blaș.out'); |
|
|
385 |
|
$r = rg_test_artifacts_file($rg_ui, $repo, '/envs/fedora-35-x86_64/blaș.out'); |
282 |
386 |
rg_log_ml('blaș.out: ' . print_r($r, TRUE)); |
rg_log_ml('blaș.out: ' . print_r($r, TRUE)); |
283 |
387 |
$e = 'blaș' . "\n"; |
$e = 'blaș' . "\n"; |
284 |
388 |
if (strcmp($r['body'], $e) != 0) { |
if (strcmp($r['body'], $e) != 0) { |
|
... |
... |
if (!stristr($r['header'], $e)) { |
301 |
405 |
rg_log_exit(); |
rg_log_exit(); |
302 |
406 |
|
|
303 |
407 |
|
|
|
408 |
|
rg_log('OK!'); |
|
409 |
|
exit(0); |
|
410 |
|
// We ignore the rest for now, because we do 4 builds and test nothing! |
|
411 |
|
|
304 |
412 |
rg_log(''); |
rg_log(''); |
305 |
413 |
rg_log_enter('Make a change and push again (for delta packages)'); |
rg_log_enter('Make a change and push again (for delta packages)'); |
306 |
|
rg_cache_unset($key, 0); // to not get the same cache info |
|
307 |
414 |
$r = rg_exec('cd temp_repos/wh_build' |
$r = rg_exec('cd temp_repos/wh_build' |
308 |
415 |
. ' && sed -i -e "s/^Version:.*0.1/Version: 0.2/" wh_build.spec' |
. ' && sed -i -e "s/^Version:.*0.1/Version: 0.2/" wh_build.spec' |
|
416 |
|
. ' && sed -i -e "s/0.1/0.2/" debian/changelog' |
309 |
417 |
. ' && git commit -a -m "new version"' |
. ' && git commit -a -m "new version"' |
310 |
418 |
. ' && git push', |
. ' && git push', |
311 |
419 |
'', FALSE, FALSE, FALSE); |
'', FALSE, FALSE, FALSE); |
|
... |
... |
rg_log_exit(); |
331 |
439 |
|
|
332 |
440 |
|
|
333 |
441 |
// TODO: test artifacts 2 (overwrite) |
// TODO: test artifacts 2 (overwrite) |
334 |
|
// TODO: test rfs/rpm packages (by http) |
|
|
442 |
|
// TODO: test rgfs/rpm packages (by http) |
335 |
443 |
|
|
336 |
444 |
|
|
337 |
445 |
// TODO: add a test for 'map_into_source' |
// TODO: add a test for 'map_into_source' |
338 |
446 |
|
|
339 |
447 |
|
|
340 |
|
// TODO: test that packages are in +pending (time race?) |
|
341 |
448 |
rg_log('OK!'); |
rg_log('OK!'); |