File inc/git.inc.php changed (mode: 100644) (index 421394a..45f72f6) |
... |
... |
function rg_git_init($dst) |
134 |
134 |
if (!is_dir($dst . "/rocketgit")) { |
if (!is_dir($dst . "/rocketgit")) { |
135 |
135 |
$dst2 = $dst . '.tmp'; |
$dst2 = $dst . '.tmp'; |
136 |
136 |
$cmd = 'git init --bare ' . escapeshellarg($dst2); |
$cmd = 'git init --bare ' . escapeshellarg($dst2); |
137 |
|
$a = rg_exec($cmd, '', FALSE); |
|
|
137 |
|
$a = rg_exec($cmd, '', FALSE, FALSE); |
138 |
138 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
139 |
139 |
rg_git_set_error("error on init " . $a['errmsg'] . ")"); |
rg_git_set_error("error on init " . $a['errmsg'] . ")"); |
140 |
140 |
break; |
break; |
|
... |
... |
function rg_git_clone($src, $dst) |
185 |
185 |
if (!file_exists($dst . "/rocketgit")) { |
if (!file_exists($dst . "/rocketgit")) { |
186 |
186 |
$cmd = "git clone --bare " . escapeshellarg($src) |
$cmd = "git clone --bare " . escapeshellarg($src) |
187 |
187 |
. " " . escapeshellarg($dst); |
. " " . escapeshellarg($dst); |
188 |
|
$a = rg_exec($cmd, '', FALSE); |
|
|
188 |
|
$a = rg_exec($cmd, '', FALSE, FALSE); |
189 |
189 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
190 |
190 |
rg_git_set_error("error on clone (" . $a['errmsg'] . ")"); |
rg_git_set_error("error on clone (" . $a['errmsg'] . ")"); |
191 |
191 |
break; |
break; |
|
... |
... |
function rg_git_type($obj) |
216 |
216 |
{ |
{ |
217 |
217 |
global $rg_git_zero; |
global $rg_git_zero; |
218 |
218 |
|
|
219 |
|
rg_prof_start("git_type"); |
|
220 |
|
rg_log_enter("git_type: obj=$obj"); |
|
|
219 |
|
rg_prof_start('git_type'); |
|
220 |
|
rg_log_enter('git_type: obj=' . $obj); |
221 |
221 |
|
|
222 |
222 |
$ret = FALSE; |
$ret = FALSE; |
223 |
223 |
while (1) { |
while (1) { |
224 |
224 |
if (strcmp($obj, $rg_git_zero) == 0) { |
if (strcmp($obj, $rg_git_zero) == 0) { |
225 |
|
$ret = "zero"; |
|
|
225 |
|
$ret = 'zero'; |
226 |
226 |
break; |
break; |
227 |
227 |
} |
} |
228 |
228 |
|
|
229 |
|
$cmd = "git cat-file -t '" . escapeshellarg($obj) . "'"; |
|
230 |
|
$a = rg_exec($cmd, '', FALSE); |
|
|
229 |
|
$cmd = 'git cat-file -t ' . escapeshellarg($obj); |
|
230 |
|
$a = rg_exec($cmd, '', FALSE, FALSE); |
231 |
231 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
232 |
|
rg_git_set_error("error on cat-file (" . $a['errmsg'] . ")"); |
|
|
232 |
|
rg_git_set_error('error on cat-file (' . $a['errmsg'] . ')'); |
233 |
233 |
break; |
break; |
234 |
234 |
} |
} |
235 |
235 |
|
|
|
... |
... |
function rg_git_type($obj) |
238 |
238 |
} |
} |
239 |
239 |
|
|
240 |
240 |
rg_log_exit(); |
rg_log_exit(); |
241 |
|
rg_prof_end("git_type"); |
|
|
241 |
|
rg_prof_end('git_type'); |
242 |
242 |
return $ret; |
return $ret; |
243 |
243 |
} |
} |
244 |
244 |
|
|
|
... |
... |
function rg_git_type($obj) |
247 |
247 |
*/ |
*/ |
248 |
248 |
function rg_git_content($obj) |
function rg_git_content($obj) |
249 |
249 |
{ |
{ |
250 |
|
rg_prof_start("git_content"); |
|
251 |
|
rg_log_enter("git_content: obj=$obj"); |
|
|
250 |
|
rg_prof_start('git_content'); |
|
251 |
|
rg_log_enter('git_content: obj=' . $obj); |
252 |
252 |
|
|
253 |
253 |
$ret = FALSE; |
$ret = FALSE; |
254 |
254 |
while (1) { |
while (1) { |
255 |
|
$cmd = "git cat-file -p '" . escapeshellarg($obj) . "'"; |
|
256 |
|
$a = rg_exec($cmd, '', FALSE); |
|
|
255 |
|
$cmd = 'git cat-file -p ' . escapeshellarg($obj); |
|
256 |
|
$a = rg_exec($cmd, '', FALSE, FALSE); |
257 |
257 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
258 |
|
rg_git_set_error("error on cat-file (" . $a['errmsg'] . ")"); |
|
|
258 |
|
rg_git_set_error('error on cat-file (' . $a['errmsg'] . ')'); |
259 |
259 |
break; |
break; |
260 |
260 |
} |
} |
261 |
261 |
|
|
|
... |
... |
function rg_git_content($obj) |
264 |
264 |
} |
} |
265 |
265 |
|
|
266 |
266 |
rg_log_exit(); |
rg_log_exit(); |
267 |
|
rg_prof_end("git_content"); |
|
|
267 |
|
rg_prof_end('git_content'); |
268 |
268 |
return $ret; |
return $ret; |
269 |
269 |
} |
} |
270 |
270 |
|
|
|
... |
... |
function rg_git_rev_ok($rev) |
330 |
330 |
$ret = FALSE; |
$ret = FALSE; |
331 |
331 |
while (1) { |
while (1) { |
332 |
332 |
$cmd = 'git rev-parse --verify ' . escapeshellarg($rev); |
$cmd = 'git rev-parse --verify ' . escapeshellarg($rev); |
333 |
|
$a = rg_exec($cmd, '', FALSE); |
|
|
333 |
|
$a = rg_exec($cmd, '', FALSE, FALSE); |
334 |
334 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
335 |
335 |
rg_git_set_error("error on rev-parse (" . $a['errmsg'] . ")"); |
rg_git_set_error("error on rev-parse (" . $a['errmsg'] . ")"); |
336 |
336 |
break; |
break; |
|
... |
... |
function rg_git_whitespace_ok($old, $new) |
365 |
365 |
$cmd = "git diff --check" |
$cmd = "git diff --check" |
366 |
366 |
. " " . escapeshellarg($old) |
. " " . escapeshellarg($old) |
367 |
367 |
. " " . escapeshellarg($new); |
. " " . escapeshellarg($new); |
368 |
|
$a = rg_exec($cmd, '', FALSE); |
|
|
368 |
|
$a = rg_exec($cmd, '', FALSE, FALSE); |
369 |
369 |
rg_log("a:" . rg_array2string($a)); |
rg_log("a:" . rg_array2string($a)); |
370 |
370 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
371 |
371 |
rg_git_set_error("error on diff (" . $a['errmsg'] . ")"); |
rg_git_set_error("error on diff (" . $a['errmsg'] . ")"); |
|
... |
... |
function rg_git_merge_base($repo_path, $a, $b) |
446 |
446 |
. ' merge-base' |
. ' merge-base' |
447 |
447 |
. ' ' . escapeshellarg($a) |
. ' ' . escapeshellarg($a) |
448 |
448 |
. ' ' . escapeshellarg($b); |
. ' ' . escapeshellarg($b); |
449 |
|
$a = rg_exec($cmd, '', FALSE); |
|
|
449 |
|
$a = rg_exec($cmd, '', FALSE, FALSE); |
450 |
450 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
451 |
451 |
rg_git_set_error('error on git merge_base (' |
rg_git_set_error('error on git merge_base (' |
452 |
452 |
. $a['errmsg'] . ')'); |
. $a['errmsg'] . ')'); |
|
... |
... |
function rg_git_update_ref($repo_path, $ref, $old, $new, $reason) |
493 |
493 |
if (!empty($old)) |
if (!empty($old)) |
494 |
494 |
$cmd .= " " . escapeshellarg($old); |
$cmd .= " " . escapeshellarg($old); |
495 |
495 |
|
|
496 |
|
$a = rg_exec($cmd, '', FALSE); |
|
|
496 |
|
$a = rg_exec($cmd, '', FALSE, FALSE); |
497 |
497 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
498 |
498 |
rg_git_set_error("error on update-ref (" . $a['errmsg'] . ")"); |
rg_git_set_error("error on update-ref (" . $a['errmsg'] . ")"); |
499 |
499 |
break; |
break; |
|
... |
... |
function rg_git_shortlog($repo_path, $a, $b) |
522 |
522 |
. ' --git-dir=' . escapeshellarg($repo_path) |
. ' --git-dir=' . escapeshellarg($repo_path) |
523 |
523 |
. ' ' . escapeshellarg($a) |
. ' ' . escapeshellarg($a) |
524 |
524 |
. '..' . escapeshellarg($b); |
. '..' . escapeshellarg($b); |
525 |
|
$r = rg_exec($cmd, '', FALSE); |
|
|
525 |
|
$r = rg_exec($cmd, '', FALSE, FALSE); |
526 |
526 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
527 |
527 |
rg_git_set_error('error on shortlog (' . $r['errmsg'] . ')'); |
rg_git_set_error('error on shortlog (' . $r['errmsg'] . ')'); |
528 |
528 |
break; |
break; |
|
... |
... |
function rg_git_ls_tree($repo_path, $tree, $path) |
559 |
559 |
. escapeshellarg($tree); |
. escapeshellarg($tree); |
560 |
560 |
if (!empty($path)) |
if (!empty($path)) |
561 |
561 |
$cmd .= ' ' . escapeshellarg($path); |
$cmd .= ' ' . escapeshellarg($path); |
562 |
|
$a = rg_exec($cmd, '', FALSE); |
|
|
562 |
|
$a = rg_exec($cmd, '', FALSE, FALSE); |
563 |
563 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
564 |
564 |
rg_git_set_error("error on ls-tree (" . $a['errmsg'] . ")"); |
rg_git_set_error("error on ls-tree (" . $a['errmsg'] . ")"); |
565 |
565 |
break; |
break; |
|
... |
... |
function rg_git_log($path, $max, $from, $to, $also_patch) |
868 |
868 |
. "%x00ROCKETGIT_END_OF_VARS%x00\""; |
. "%x00ROCKETGIT_END_OF_VARS%x00\""; |
869 |
869 |
if (!empty($from_to)) |
if (!empty($from_to)) |
870 |
870 |
$cmd .= ' ' . escapeshellarg($from_to); |
$cmd .= ' ' . escapeshellarg($from_to); |
871 |
|
$a = rg_exec($cmd, '', FALSE); |
|
|
871 |
|
$a = rg_exec($cmd, '', FALSE, FALSE); |
872 |
872 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
873 |
873 |
rg_internal_error("error on log (" . $a['errmsg'] . ")"); |
rg_internal_error("error on log (" . $a['errmsg'] . ")"); |
874 |
874 |
rg_git_set_error("could not generate log; try again later"); |
rg_git_set_error("could not generate log; try again later"); |
|
... |
... |
function rg_git_files($old, $new) |
1044 |
1044 |
|
|
1045 |
1045 |
$cmd = 'git diff --name-only ' . escapeshellarg($old) |
$cmd = 'git diff --name-only ' . escapeshellarg($old) |
1046 |
1046 |
. ' ' . escapeshellarg($new); |
. ' ' . escapeshellarg($new); |
1047 |
|
$a = rg_exec($cmd, '', FALSE); |
|
|
1047 |
|
$a = rg_exec($cmd, '', FALSE, FALSE); |
1048 |
1048 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
1049 |
1049 |
rg_git_set_error("error on git diff (" . $a['errmsg'] . ")"); |
rg_git_set_error("error on git diff (" . $a['errmsg'] . ")"); |
1050 |
1050 |
break; |
break; |
|
... |
... |
function rg_git_diff_tree($tree1, $tree2) |
1645 |
1645 |
while (1) { |
while (1) { |
1646 |
1646 |
$cmd = "git diff-tree -r " . escapeshellarg($tree1) |
$cmd = "git diff-tree -r " . escapeshellarg($tree1) |
1647 |
1647 |
. " " . escapeshellarg($tree2); |
. " " . escapeshellarg($tree2); |
1648 |
|
$a = rg_exec($cmd, '', FALSE); |
|
|
1648 |
|
$a = rg_exec($cmd, '', FALSE, FALSE); |
1649 |
1649 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
1650 |
1650 |
rg_git_set_error("error on diff-tree (" . $a['errmsg'] . ")"); |
rg_git_set_error("error on diff-tree (" . $a['errmsg'] . ")"); |
1651 |
1651 |
break; |
break; |
|
... |
... |
function rg_git_content_by_file($treeish, $file) |
1689 |
1689 |
while (1) { |
while (1) { |
1690 |
1690 |
$cmd = 'git show ' . escapeshellarg($treeish) . ':' |
$cmd = 'git show ' . escapeshellarg($treeish) . ':' |
1691 |
1691 |
. escapeshellarg($file); |
. escapeshellarg($file); |
1692 |
|
$a = rg_exec($cmd, '', FALSE); |
|
|
1692 |
|
$a = rg_exec($cmd, '', FALSE, FALSE); |
1693 |
1693 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
1694 |
1694 |
rg_git_set_error("error on show (" . $a['errmsg'] . ")"); |
rg_git_set_error("error on show (" . $a['errmsg'] . ")"); |
1695 |
1695 |
break; |
break; |
|
... |
... |
function rg_git_archive($repo_path, $treeish, $archive_name, $format) |
1802 |
1802 |
. ' archive --format=' . escapeshellarg($format) |
. ' archive --format=' . escapeshellarg($format) |
1803 |
1803 |
. ' --output=' . escapeshellarg($archive_name) |
. ' --output=' . escapeshellarg($archive_name) |
1804 |
1804 |
. ' ' . escapeshellarg($treeish); |
. ' ' . escapeshellarg($treeish); |
1805 |
|
$a = rg_exec($cmd, '', FALSE); |
|
|
1805 |
|
$a = rg_exec($cmd, '', FALSE, FALSE); |
1806 |
1806 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
1807 |
1807 |
rg_git_set_error('error on git archive' |
rg_git_set_error('error on git archive' |
1808 |
1808 |
. ' (' . $a['errmsg'] . ')'); |
. ' (' . $a['errmsg'] . ')'); |
|
... |
... |
function rg_git_merge_tree($repo_path, $base, $a, $b) |
1871 |
1871 |
. ' ' . escapeshellarg($base) |
. ' ' . escapeshellarg($base) |
1872 |
1872 |
. ' ' . escapeshellarg($a) |
. ' ' . escapeshellarg($a) |
1873 |
1873 |
. ' ' . escapeshellarg($b); |
. ' ' . escapeshellarg($b); |
1874 |
|
$a = rg_exec($cmd, '', FALSE); |
|
|
1874 |
|
$a = rg_exec($cmd, '', FALSE, FALSE); |
1875 |
1875 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
1876 |
1876 |
rg_git_set_error('error on git merge-tree (' |
rg_git_set_error('error on git merge-tree (' |
1877 |
1877 |
. $a['errmsg'] . ')'); |
. $a['errmsg'] . ')'); |
|
... |
... |
function rg_git_merge($repo_path, $a, $b, $ff, $msg) |
1973 |
1973 |
. ' -m ' . escapeshellarg($msg) |
. ' -m ' . escapeshellarg($msg) |
1974 |
1974 |
. ' ' . escapeshellarg($a) |
. ' ' . escapeshellarg($a) |
1975 |
1975 |
. ' ' . escapeshellarg($b); |
. ' ' . escapeshellarg($b); |
1976 |
|
$a = rg_exec($cmd, '', FALSE); |
|
|
1976 |
|
$a = rg_exec($cmd, '', FALSE, FALSE); |
1977 |
1977 |
rg_rmdir($work_tree); |
rg_rmdir($work_tree); |
1978 |
1978 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
1979 |
1979 |
rg_git_set_error('error on git merge (' |
rg_git_set_error('error on git merge (' |
|
... |
... |
function rg_git_request_pull($repo_path, $start, $url, $end, $patch) |
2022 |
2022 |
if ($patch) |
if ($patch) |
2023 |
2023 |
$cmd .= ' --patch'; |
$cmd .= ' --patch'; |
2024 |
2024 |
$cmd .= escapeshellarg($start) . '..' . escapeshellarg($end); |
$cmd .= escapeshellarg($start) . '..' . escapeshellarg($end); |
2025 |
|
$r = rg_exec($cmd, '', FALSE); |
|
|
2025 |
|
$r = rg_exec($cmd, '', FALSE, FALSE); |
2026 |
2026 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
2027 |
2027 |
rg_git_set_error('error on git diff: ' . $a['errmsg']); |
rg_git_set_error('error on git diff: ' . $a['errmsg']); |
2028 |
2028 |
break; |
break; |
File scripts/worker.php changed (mode: 100644) (index 6fe3575..022ccf6) |
... |
... |
function reload_config() |
95 |
95 |
$cmd = 'ssh-keygen -t rsa -b 4096 -N \'\'' |
$cmd = 'ssh-keygen -t rsa -b 4096 -N \'\'' |
96 |
96 |
. ' -C \'Key to connect to builder\'' |
. ' -C \'Key to connect to builder\'' |
97 |
97 |
. ' -f ' . escapeshellarg($conf['state'] . '/key'); |
. ' -f ' . escapeshellarg($conf['state'] . '/key'); |
98 |
|
$r = rg_exec($cmd, '', FALSE); |
|
|
98 |
|
$r = rg_exec($cmd, '', FALSE, FALSE); |
99 |
99 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
100 |
|
rg_log('Cannot create key: ' . $r['data'] . '!'); |
|
|
100 |
|
rg_log('Cannot create key: ' . $r['errmsg'] . '!'); |
101 |
101 |
sleep(60); |
sleep(60); |
102 |
102 |
exit(0); |
exit(0); |
103 |
103 |
} |
} |
|
... |
... |
function start_worker($job) |
135 |
135 |
$do_umount = FALSE; |
$do_umount = FALSE; |
136 |
136 |
$err = TRUE; |
$err = TRUE; |
137 |
137 |
while (1) { |
while (1) { |
138 |
|
rg_exec('virsh destroy ' . $ename, '', FALSE); |
|
139 |
|
rg_exec('virsh undefine ' . $ename, '', FALSE); |
|
|
138 |
|
rg_exec('virsh destroy ' . $ename, '', FALSE, FALSE); |
|
139 |
|
rg_exec('virsh undefine ' . $ename, '', FALSE, FALSE); |
140 |
140 |
|
|
141 |
141 |
$r = rg_del_tree($job['main']); |
$r = rg_del_tree($job['main']); |
142 |
142 |
if ($r === FALSE) { |
if ($r === FALSE) { |
|
... |
... |
function start_worker($job) |
161 |
161 |
} |
} |
162 |
162 |
|
|
163 |
163 |
$r = rg_exec('qemu-img create -b ' . $master |
$r = rg_exec('qemu-img create -b ' . $master |
164 |
|
. ' -f qcow2 ' . $img, '', FALSE); |
|
|
164 |
|
. ' -f qcow2 ' . $img, '', FALSE, FALSE); |
165 |
165 |
if ($r['ok'] !== 1) { |
if ($r['ok'] !== 1) { |
166 |
166 |
$reason = 'cannot create image: ' . $r['errmsg']; |
$reason = 'cannot create image: ' . $r['errmsg']; |
167 |
167 |
break; |
break; |
168 |
168 |
} |
} |
169 |
169 |
|
|
170 |
|
$r = rg_exec('qemu-img create -f raw ' . $img2 . ' 1G', '', FALSE); |
|
|
170 |
|
$r = rg_exec('qemu-img create -f raw ' . $img2 . ' 1G', '', |
|
171 |
|
FALSE, FALSE); |
171 |
172 |
if ($r['ok'] !== 1) { |
if ($r['ok'] !== 1) { |
172 |
173 |
$reason = 'cannot create image2: ' . $r['errmsg']; |
$reason = 'cannot create image2: ' . $r['errmsg']; |
173 |
174 |
break; |
break; |
|
... |
... |
function start_worker($job) |
177 |
178 |
$path = getenv('PATH'); |
$path = getenv('PATH'); |
178 |
179 |
putenv('PATH=' . $path . ':/usr/sbin'); |
putenv('PATH=' . $path . ':/usr/sbin'); |
179 |
180 |
|
|
180 |
|
$r = rg_exec('mkfs.ext4 -L RG ' . $img2, '', FALSE); |
|
|
181 |
|
$r = rg_exec('mkfs.ext4 -L RG ' . $img2, '', FALSE, FALSE); |
181 |
182 |
if ($r['ok'] !== 1) { |
if ($r['ok'] !== 1) { |
182 |
183 |
$reason = 'cannot create fs: ' . $r['errmsg']; |
$reason = 'cannot create fs: ' . $r['errmsg']; |
183 |
184 |
break; |
break; |
184 |
185 |
} |
} |
185 |
186 |
|
|
186 |
|
$r = @mkdir($job['main'] . '/root', 0755); |
|
|
187 |
|
$r = @mkdir($job['main'] . '/root', 0700); |
187 |
188 |
if ($r === FALSE) { |
if ($r === FALSE) { |
188 |
189 |
$reason = 'Cannot create root dir: ' . $php_errormsg . '!'; |
$reason = 'Cannot create root dir: ' . $php_errormsg . '!'; |
189 |
190 |
break; |
break; |
190 |
191 |
} |
} |
191 |
192 |
|
|
192 |
|
$r = rg_exec('mount ' . $img2 . ' ' . $emain . '/root', '', FALSE); |
|
|
193 |
|
$r = rg_exec('mount ' . $img2 . ' ' . $emain . '/root', '', |
|
194 |
|
FALSE, FALSE); |
193 |
195 |
if ($r['ok'] !== 1) { |
if ($r['ok'] !== 1) { |
194 |
196 |
$reason = 'cannot mount fs: ' . $r['errmsg']; |
$reason = 'cannot mount fs: ' . $r['errmsg']; |
195 |
197 |
break; |
break; |
|
... |
... |
function start_worker($job) |
204 |
206 |
$cmd = 'git clone --depth 1' |
$cmd = 'git clone --depth 1' |
205 |
207 |
. ' ' . escapeshellarg($job['url']) |
. ' ' . escapeshellarg($job['url']) |
206 |
208 |
. ' ' . $emain . '/root/git'; |
. ' ' . $emain . '/root/git'; |
207 |
|
$r = rg_exec($cmd, '', FALSE); |
|
|
209 |
|
$r = rg_exec($cmd, '', FALSE, FALSE); |
208 |
210 |
if ($r['ok'] !== 1) { |
if ($r['ok'] !== 1) { |
209 |
211 |
$reason = 'cannot clone: ' . $r['errmsg']; |
$reason = 'cannot clone: ' . $r['errmsg']; |
210 |
212 |
break; |
break; |
|
... |
... |
function start_worker($job) |
300 |
302 |
break; |
break; |
301 |
303 |
} |
} |
302 |
304 |
|
|
303 |
|
$r = rg_exec('umount ' . $emain . '/root', '', FALSE); |
|
|
305 |
|
$r = rg_exec('umount ' . $emain . '/root', '', FALSE, FALSE); |
304 |
306 |
if ($r['ok'] !== 1) { |
if ($r['ok'] !== 1) { |
305 |
307 |
$reason = 'cannot umount fs: ' . $r['errmsg']; |
$reason = 'cannot umount fs: ' . $r['errmsg']; |
306 |
308 |
break; |
break; |
|
... |
... |
function start_worker($job) |
328 |
330 |
. ' --rng /dev/random' |
. ' --rng /dev/random' |
329 |
331 |
. ' --memballoon virtio' |
. ' --memballoon virtio' |
330 |
332 |
. ' --console pty,target_type=virtio' |
. ' --console pty,target_type=virtio' |
331 |
|
. ' ' . $env['paras'], '', FALSE); |
|
|
333 |
|
. ' ' . $env['paras'], '', FALSE, FALSE); |
332 |
334 |
if ($r['ok'] !== 1) { |
if ($r['ok'] !== 1) { |
333 |
|
$reason = 'cannot define and start virtual machine: ' . $r['errmsg']; |
|
|
335 |
|
$reason = 'cannot define and start virtual machine: ' |
|
336 |
|
. $r['errmsg']; |
334 |
337 |
break; |
break; |
335 |
338 |
} |
} |
336 |
339 |
|
|
|
... |
... |
function start_worker($job) |
338 |
341 |
break; |
break; |
339 |
342 |
} |
} |
340 |
343 |
if ($do_umount) |
if ($do_umount) |
341 |
|
rg_exec('umount ' . $emain . '/root', '', FALSE); |
|
|
344 |
|
rg_exec('umount ' . $emain . '/root', '', FALSE, FALSE); |
342 |
345 |
|
|
343 |
346 |
// Seems that any error above must retrigger the build on other worker |
// Seems that any error above must retrigger the build on other worker |
344 |
347 |
if ($err) |
if ($err) |
|
... |
... |
function rg_job_extract_info(&$job) |
447 |
450 |
} |
} |
448 |
451 |
|
|
449 |
452 |
$cmd = 'mount ' . $emain . '/image2.raw ' . $emain . '/root'; |
$cmd = 'mount ' . $emain . '/image2.raw ' . $emain . '/root'; |
450 |
|
$r = rg_exec($cmd, '', FALSE); |
|
|
453 |
|
$r = rg_exec($cmd, '', FALSE, FALSE); |
451 |
454 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
452 |
|
$job['error'] = 'Could not mount image: ' . $r['data']; |
|
|
455 |
|
$job['error'] = 'Could not mount image: ' . $r['errmsg']; |
453 |
456 |
break; |
break; |
454 |
457 |
} |
} |
455 |
458 |
|
|
|
... |
... |
function rg_job_extract_info(&$job) |
489 |
492 |
unset($job['env']); |
unset($job['env']); |
490 |
493 |
|
|
491 |
494 |
$cmd = 'umount ' . $emain . '/root'; |
$cmd = 'umount ' . $emain . '/root'; |
492 |
|
$r = rg_exec($cmd, '', FALSE); |
|
|
495 |
|
$r = rg_exec($cmd, '', FALSE, FALSE); |
493 |
496 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
494 |
|
rg_log('Cannot unmount!'); |
|
|
497 |
|
rg_log('Cannot unmount: ' . $r['errmsg'] . '!'); |
495 |
498 |
break; |
break; |
496 |
499 |
} |
} |
497 |
500 |
|
|
|
... |
... |
while(1) { |
600 |
603 |
|
|
601 |
604 |
// TODO: do we destroy the pool in case of crash? |
// TODO: do we destroy the pool in case of crash? |
602 |
605 |
$cmd = 'virsh pool-destroy rocketgit-j-' . $jid; |
$cmd = 'virsh pool-destroy rocketgit-j-' . $jid; |
603 |
|
$r = rg_exec($cmd, '', FALSE); |
|
|
606 |
|
$r = rg_exec($cmd, '', FALSE, FALSE); |
604 |
607 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
605 |
|
$job['error'] = 'Could not destroy pool: ' . $r['data']; |
|
|
608 |
|
$job['error'] = 'Could not destroy pool: ' . $r['errmsg']; |
606 |
609 |
rg_log('Error: ' . $job['error']); |
rg_log('Error: ' . $job['error']); |
607 |
610 |
//break; TODO: do we need to do this?! |
//break; TODO: do we need to do this?! |
608 |
611 |
} |
} |
609 |
612 |
|
|
610 |
613 |
// TODO: do we clean the pool in case of crash? |
// TODO: do we clean the pool in case of crash? |
611 |
614 |
$cmd = 'virsh pool-undefine rocketgit-j-' . $jid; |
$cmd = 'virsh pool-undefine rocketgit-j-' . $jid; |
612 |
|
$r = rg_exec($cmd, '', FALSE); |
|
|
615 |
|
$r = rg_exec($cmd, '', FALSE, FALSE); |
613 |
616 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
614 |
|
$job['error'] = 'Could not undefine pool: ' . $r['data']; |
|
|
617 |
|
$job['error'] = 'Could not undefine pool: ' . $r['errmsg']; |
615 |
618 |
rg_log('Error: ' . $job['error']); |
rg_log('Error: ' . $job['error']); |
616 |
619 |
//break; TODO: do we need to do this?! |
//break; TODO: do we need to do this?! |
617 |
620 |
} |
} |
618 |
621 |
|
|
619 |
622 |
// TODO: do we clean the machine in case of crash? |
// TODO: do we clean the machine in case of crash? |
620 |
623 |
$cmd = 'virsh undefine rg-worker-' . escapeshellarg($jid); |
$cmd = 'virsh undefine rg-worker-' . escapeshellarg($jid); |
621 |
|
$r = rg_exec($cmd, '', FALSE); |
|
|
624 |
|
$r = rg_exec($cmd, '', FALSE, FALSE); |
622 |
625 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
623 |
|
$job['error'] = 'Could not undefine machine: ' . $r['data']; |
|
|
626 |
|
$job['error'] = 'Could not undefine machine: ' . $r['errmsg']; |
624 |
627 |
rg_log('Error: ' . $job['error']); |
rg_log('Error: ' . $job['error']); |
625 |
628 |
//break; TODO |
//break; TODO |
626 |
629 |
} |
} |
File tests/pr_anon.php changed (mode: 100644) (index 65379b5..382192f) |
... |
... |
rg_log_exit(); |
82 |
82 |
rg_log(''); |
rg_log(''); |
83 |
83 |
rg_log_enter('Preparing repo...'); |
rg_log_enter('Preparing repo...'); |
84 |
84 |
system('rm -rf _pr_anon.git 2>/dev/null'); |
system('rm -rf _pr_anon.git 2>/dev/null'); |
85 |
|
$r = rg_exec('git init _pr_anon.git', '', FALSE); |
|
|
85 |
|
$r = rg_exec('git init _pr_anon.git', '', FALSE, FALSE); |
86 |
86 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
87 |
87 |
rg_log_ml('r: ' . print_r($r, TRUE)); |
rg_log_ml('r: ' . print_r($r, TRUE)); |
88 |
88 |
rg_log('Could not init repo!'); |
rg_log('Could not init repo!'); |
|
... |
... |
if ($r['ok'] != 1) { |
91 |
91 |
$r = rg_exec('cd _pr_anon.git; git remote add origin_ssh ' |
$r = rg_exec('cd _pr_anon.git; git remote add origin_ssh ' |
92 |
92 |
. ' ssh://rocketgit@' . $rg_ssh_host . ':' . $rg_ssh_port |
. ' ssh://rocketgit@' . $rg_ssh_host . ':' . $rg_ssh_port |
93 |
93 |
. '/user/' . escapeshellarg($rg_ui['username']) . '/' |
. '/user/' . escapeshellarg($rg_ui['username']) . '/' |
94 |
|
. escapeshellarg($repo['name']), '', FALSE); |
|
|
94 |
|
. escapeshellarg($repo['name']), '', FALSE, FALSE); |
95 |
95 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
96 |
96 |
rg_log_ml('r: ' . print_r($r, TRUE)); |
rg_log_ml('r: ' . print_r($r, TRUE)); |
97 |
97 |
rg_log('Could not add ssh remote!'); |
rg_log('Could not add ssh remote!'); |
|
... |
... |
if ($r['ok'] != 1) { |
100 |
100 |
$r = rg_exec('cd _pr_anon.git; git remote add origin_git ' |
$r = rg_exec('cd _pr_anon.git; git remote add origin_git ' |
101 |
101 |
. ' git://' . $rg_git_host . ':' . $rg_git_port |
. ' git://' . $rg_git_host . ':' . $rg_git_port |
102 |
102 |
. '/user/' . escapeshellarg($rg_ui['username']) . '/' |
. '/user/' . escapeshellarg($rg_ui['username']) . '/' |
103 |
|
. escapeshellarg($repo['name']), '', FALSE); |
|
|
103 |
|
. escapeshellarg($repo['name']), '', FALSE, FALSE); |
104 |
104 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
105 |
105 |
rg_log_ml('r: ' . print_r($r, TRUE)); |
rg_log_ml('r: ' . print_r($r, TRUE)); |
106 |
106 |
rg_log('Could not add git remote!'); |
rg_log('Could not add git remote!'); |
|
... |
... |
$r = rg_exec('export GIT_SSH_COMMAND="ssh -o IdentityFile=../keys/pr_anon";' |
115 |
115 |
. 'cd _pr_anon.git; echo "change1" > a;' |
. 'cd _pr_anon.git; echo "change1" > a;' |
116 |
116 |
. 'git add a; git commit -m "change1 desc";' |
. 'git add a; git commit -m "change1 desc";' |
117 |
117 |
. 'echo "change2" > a; git commit -a -m "change2 desc";' |
. 'echo "change2" > a; git commit -a -m "change2 desc";' |
118 |
|
. 'git push origin_ssh master', '', FALSE); |
|
|
118 |
|
. 'git push origin_ssh master', '', FALSE, FALSE); |
119 |
119 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
120 |
120 |
rg_log_ml('r: ' . print_r($r, TRUE)); |
rg_log_ml('r: ' . print_r($r, TRUE)); |
121 |
121 |
rg_log('Non-anonymous push was rejected!'); |
rg_log('Non-anonymous push was rejected!'); |
|
... |
... |
rg_log_enter('Do an anonymous push...'); |
129 |
129 |
$r = rg_exec('cd _pr_anon.git; echo "change3" >> a;' |
$r = rg_exec('cd _pr_anon.git; echo "change3" >> a;' |
130 |
130 |
. 'git add a; git commit -m "anon change1 desc";' |
. 'git add a; git commit -m "anon change1 desc";' |
131 |
131 |
. 'echo "change4" >> a; git commit -a -m "anon change2 desc";' |
. 'echo "change4" >> a; git commit -a -m "anon change2 desc";' |
132 |
|
. 'git push origin_git master', '', FALSE); |
|
|
132 |
|
. 'git push origin_git master', '', FALSE, FALSE); |
133 |
133 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
134 |
134 |
rg_log_ml('r: ' . print_r($r, TRUE)); |
rg_log_ml('r: ' . print_r($r, TRUE)); |
135 |
135 |
rg_log('Anonymous push was rejected!'); |
rg_log('Anonymous push was rejected!'); |
|
... |
... |
$r = rg_exec('cd _pr_anon.git;' |
212 |
212 |
. 'git pull origin_git master;' |
. 'git pull origin_git master;' |
213 |
213 |
. 'echo "change2" > a;' |
. 'echo "change2" > a;' |
214 |
214 |
. 'git commit -a -m "conflict1b";' |
. 'git commit -a -m "conflict1b";' |
215 |
|
. 'git push origin_git master', '', FALSE); |
|
|
215 |
|
. 'git push origin_git master', '', FALSE, FALSE); |
216 |
216 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
217 |
217 |
rg_log_ml('r: ' . print_r($r, TRUE)); |
rg_log_ml('r: ' . print_r($r, TRUE)); |
218 |
218 |
rg_log('Could not pull/commit/push by git proto!'); |
rg_log('Could not pull/commit/push by git proto!'); |
|
... |
... |
$r = rg_exec('export GIT_SSH_COMMAND="ssh -o IdentityFile=../keys/pr_anon";' |
223 |
223 |
. 'git reset --hard HEAD^1;' |
. 'git reset --hard HEAD^1;' |
224 |
224 |
. ' echo "change1" > a;' |
. ' echo "change1" > a;' |
225 |
225 |
. 'git commit -a -m "conflict1a";' |
. 'git commit -a -m "conflict1a";' |
226 |
|
. 'git push origin_ssh master', '', FALSE); |
|
|
226 |
|
. 'git push origin_ssh master', '', FALSE, FALSE); |
227 |
227 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
228 |
228 |
rg_log_ml('r: ' . print_r($r, TRUE)); |
rg_log_ml('r: ' . print_r($r, TRUE)); |
229 |
229 |
rg_log('Could not reset/commit/push by ssh proto!'); |
rg_log('Could not reset/commit/push by ssh proto!'); |