File inc/git.inc.php changed (mode: 100644) (index a27905a..af45be2) |
... |
... |
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); |
|
|
137 |
|
$a = rg_exec($cmd, ''); |
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); |
|
|
188 |
|
$a = rg_exec($cmd, ''); |
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) |
227 |
227 |
} |
} |
228 |
228 |
|
|
229 |
229 |
$cmd = "git cat-file -t '" . escapeshellarg($obj) . "'"; |
$cmd = "git cat-file -t '" . escapeshellarg($obj) . "'"; |
230 |
|
$a = rg_exec($cmd); |
|
|
230 |
|
$a = rg_exec($cmd, ''); |
231 |
231 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
232 |
232 |
rg_git_set_error("error on cat-file (" . $a['errmsg'] . ")"); |
rg_git_set_error("error on cat-file (" . $a['errmsg'] . ")"); |
233 |
233 |
break; |
break; |
|
... |
... |
function rg_git_content($obj) |
253 |
253 |
$ret = FALSE; |
$ret = FALSE; |
254 |
254 |
while (1) { |
while (1) { |
255 |
255 |
$cmd = "git cat-file -p '" . escapeshellarg($obj) . "'"; |
$cmd = "git cat-file -p '" . escapeshellarg($obj) . "'"; |
256 |
|
$a = rg_exec($cmd); |
|
|
256 |
|
$a = rg_exec($cmd, ''); |
257 |
257 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
258 |
258 |
rg_git_set_error("error on cat-file (" . $a['errmsg'] . ")"); |
rg_git_set_error("error on cat-file (" . $a['errmsg'] . ")"); |
259 |
259 |
break; |
break; |
|
... |
... |
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); |
|
|
333 |
|
$a = rg_exec($cmd, ''); |
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); |
|
|
368 |
|
$a = rg_exec($cmd, ''); |
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); |
|
|
449 |
|
$a = rg_exec($cmd, ''); |
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); |
|
|
496 |
|
$a = rg_exec($cmd, ''); |
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); |
|
|
525 |
|
$r = rg_exec($cmd, ''); |
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); |
|
|
562 |
|
$a = rg_exec($cmd, ''); |
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); |
|
|
871 |
|
$a = rg_exec($cmd, ''); |
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); |
|
|
1047 |
|
$a = rg_exec($cmd, ''); |
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); |
|
|
1648 |
|
$a = rg_exec($cmd, ''); |
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); |
|
|
1692 |
|
$a = rg_exec($cmd, ''); |
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); |
|
|
1805 |
|
$a = rg_exec($cmd, ''); |
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); |
|
|
1874 |
|
$a = rg_exec($cmd, ''); |
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); |
|
|
1976 |
|
$a = rg_exec($cmd, ''); |
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); |
|
|
2025 |
|
$r = rg_exec($cmd, ''); |
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 inc/util.inc.php changed (mode: 100644) (index 805b3f0..ec32a85) |
... |
... |
function rg_ok($msg) |
958 |
958 |
|
|
959 |
959 |
/* |
/* |
960 |
960 |
* Execute $cmd and returns the output as a string, binary safe |
* Execute $cmd and returns the output as a string, binary safe |
|
961 |
|
* @input: some data to be sent to the process and received as stdin |
961 |
962 |
*/ |
*/ |
962 |
|
function rg_exec($cmd) |
|
|
963 |
|
function rg_exec($cmd, $input) |
963 |
964 |
{ |
{ |
964 |
965 |
rg_prof_start("exec"); |
rg_prof_start("exec"); |
965 |
966 |
rg_log_enter("Executing [$cmd]..."); |
rg_log_enter("Executing [$cmd]..."); |
|
... |
... |
function rg_exec($cmd) |
983 |
984 |
$stderr = ""; |
$stderr = ""; |
984 |
985 |
$ret['data'] = ""; |
$ret['data'] = ""; |
985 |
986 |
$rx = array($pipes[1], $pipes[2]); |
$rx = array($pipes[1], $pipes[2]); |
|
987 |
|
$wx = array(); |
|
988 |
|
if (!empty($input)) |
|
989 |
|
$wx[] = $pipes[0]; |
986 |
990 |
while (!empty($rx)) { |
while (!empty($rx)) { |
987 |
991 |
$revents = $rx; |
$revents = $rx; |
988 |
|
$wevents = NULL; |
|
|
992 |
|
$wevents = $wx; |
989 |
993 |
$ex = NULL; |
$ex = NULL; |
990 |
994 |
$r = stream_select($revents, $wevents, $ex, 10, 0); |
$r = stream_select($revents, $wevents, $ex, 10, 0); |
991 |
995 |
if ($r === FALSE) { |
if ($r === FALSE) { |
992 |
996 |
$ret['errmsg'] = "cannot select"; |
$ret['errmsg'] = "cannot select"; |
993 |
997 |
break; |
break; |
994 |
998 |
} |
} |
995 |
|
//rg_log("DEBUG: stream_select returned $r" |
|
996 |
|
// . ", revents: " . rg_array2string($revents)); |
|
|
999 |
|
rg_log('DEBUG: stream_select returned ' . $r |
|
1000 |
|
. ', revents: ' . rg_array2string($revents) |
|
1001 |
|
. ', wevents: ' . rg_array2string($wevents)); |
997 |
1002 |
|
|
998 |
1003 |
foreach ($revents as $fd) { |
foreach ($revents as $fd) { |
999 |
1004 |
if (!empty($ret['errmsg'])) |
if (!empty($ret['errmsg'])) |
1000 |
1005 |
break; |
break; |
1001 |
1006 |
|
|
1002 |
|
//rg_log("Event on fd $fd!"); |
|
|
1007 |
|
rg_log('DEBUG: Event on fd ' . $fd . '!'); |
|
1008 |
|
if ($fd === $pipes[0]) { |
|
1009 |
|
rg_log('We can write!'); |
|
1010 |
|
$r = @fwrite($fd, $input); |
|
1011 |
|
if ($r === FALSE) { |
|
1012 |
|
$ret['ermsg'] = 'cannot write'; |
|
1013 |
|
break; |
|
1014 |
|
} |
|
1015 |
|
rg_log('fwrite returned ' . $r . '.'); |
|
1016 |
|
$input = substr($input, $r); |
|
1017 |
|
if (empty($input)) |
|
1018 |
|
unset($wx[$fd]); |
|
1019 |
|
continue; |
|
1020 |
|
} |
|
1021 |
|
|
1003 |
1022 |
if (feof($fd)) { |
if (feof($fd)) { |
1004 |
1023 |
//rg_log("eof on fd $fd!"); |
//rg_log("eof on fd $fd!"); |
1005 |
1024 |
foreach ($rx as $_key => $_fd) |
foreach ($rx as $_key => $_fd) |
File scripts/worker.php changed (mode: 100644) (index 92b7ab7..d78b2a7) |
... |
... |
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); |
|
|
98 |
|
$r = rg_exec($cmd, ''); |
99 |
99 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
100 |
100 |
rg_log('Cannot create key: ' . $r['data'] . '!'); |
rg_log('Cannot create key: ' . $r['data'] . '!'); |
101 |
101 |
sleep(60); |
sleep(60); |
|
... |
... |
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); |
|
139 |
|
rg_exec('virsh undefine ' . $ename); |
|
|
138 |
|
rg_exec('virsh destroy ' . $ename, ''); |
|
139 |
|
rg_exec('virsh undefine ' . $ename, ''); |
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); |
|
|
164 |
|
. ' -f qcow2 ' . $img, ''); |
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'); |
|
|
170 |
|
$r = rg_exec('qemu-img create -f raw ' . $img2 . ' 1G', ''); |
171 |
171 |
if ($r['ok'] !== 1) { |
if ($r['ok'] !== 1) { |
172 |
172 |
$reason = 'cannot create image2: ' . $r['errmsg']; |
$reason = 'cannot create image2: ' . $r['errmsg']; |
173 |
173 |
break; |
break; |
|
... |
... |
function start_worker($job) |
177 |
177 |
$path = getenv('PATH'); |
$path = getenv('PATH'); |
178 |
178 |
putenv('PATH=' . $path . ':/usr/sbin'); |
putenv('PATH=' . $path . ':/usr/sbin'); |
179 |
179 |
|
|
180 |
|
$r = rg_exec('mkfs.ext4 -L RG ' . $img2); |
|
|
180 |
|
$r = rg_exec('mkfs.ext4 -L RG ' . $img2, ''); |
181 |
181 |
if ($r['ok'] !== 1) { |
if ($r['ok'] !== 1) { |
182 |
182 |
$reason = 'cannot create fs: ' . $r['errmsg']; |
$reason = 'cannot create fs: ' . $r['errmsg']; |
183 |
183 |
break; |
break; |
|
... |
... |
function start_worker($job) |
189 |
189 |
break; |
break; |
190 |
190 |
} |
} |
191 |
191 |
|
|
192 |
|
$r = rg_exec('mount ' . $img2 . ' ' . $emain . '/root'); |
|
|
192 |
|
$r = rg_exec('mount ' . $img2 . ' ' . $emain . '/root', ''); |
193 |
193 |
if ($r['ok'] !== 1) { |
if ($r['ok'] !== 1) { |
194 |
194 |
$reason = 'cannot mount fs: ' . $r['errmsg']; |
$reason = 'cannot mount fs: ' . $r['errmsg']; |
195 |
195 |
break; |
break; |
|
... |
... |
function start_worker($job) |
204 |
204 |
$cmd = 'git clone --depth 1' |
$cmd = 'git clone --depth 1' |
205 |
205 |
. ' ' . escapeshellarg($job['url']) |
. ' ' . escapeshellarg($job['url']) |
206 |
206 |
. ' ' . $emain . '/root/git'; |
. ' ' . $emain . '/root/git'; |
207 |
|
$r = rg_exec($cmd); |
|
|
207 |
|
$r = rg_exec($cmd, ''); |
208 |
208 |
if ($r['ok'] !== 1) { |
if ($r['ok'] !== 1) { |
209 |
209 |
$reason = 'cannot clone: ' . $r['errmsg']; |
$reason = 'cannot clone: ' . $r['errmsg']; |
210 |
210 |
break; |
break; |
|
... |
... |
function start_worker($job) |
300 |
300 |
break; |
break; |
301 |
301 |
} |
} |
302 |
302 |
|
|
303 |
|
$r = rg_exec('umount ' . $emain . '/root'); |
|
|
303 |
|
$r = rg_exec('umount ' . $emain . '/root', ''); |
304 |
304 |
if ($r['ok'] !== 1) { |
if ($r['ok'] !== 1) { |
305 |
305 |
$reason = 'cannot umount fs: ' . $r['errmsg']; |
$reason = 'cannot umount fs: ' . $r['errmsg']; |
306 |
306 |
break; |
break; |
|
... |
... |
function start_worker($job) |
327 |
327 |
. ' --disk path=' . $img2 . ',discard=unmap' |
. ' --disk path=' . $img2 . ',discard=unmap' |
328 |
328 |
. ' --rng /dev/random' |
. ' --rng /dev/random' |
329 |
329 |
. ' --memballoon virtio' |
. ' --memballoon virtio' |
330 |
|
. ' ' . $env['paras']); |
|
|
330 |
|
. ' --console pty,target_type=virtio' |
|
331 |
|
. ' ' . $env['paras'], ''); |
331 |
332 |
if ($r['ok'] !== 1) { |
if ($r['ok'] !== 1) { |
332 |
333 |
$reason = 'cannot define and start virtual machine: ' . $r['errmsg']; |
$reason = 'cannot define and start virtual machine: ' . $r['errmsg']; |
333 |
334 |
break; |
break; |
|
... |
... |
function start_worker($job) |
337 |
338 |
break; |
break; |
338 |
339 |
} |
} |
339 |
340 |
if ($do_umount) |
if ($do_umount) |
340 |
|
rg_exec('umount ' . $emain . '/root'); |
|
|
341 |
|
rg_exec('umount ' . $emain . '/root', ''); |
341 |
342 |
|
|
342 |
343 |
// Seems that any error above must retrigger the build on other worker |
// Seems that any error above must retrigger the build on other worker |
343 |
344 |
if ($err) |
if ($err) |
|
... |
... |
function rg_job_extract_info(&$job) |
446 |
447 |
} |
} |
447 |
448 |
|
|
448 |
449 |
$cmd = 'mount ' . $emain . '/image2.raw ' . $emain . '/root'; |
$cmd = 'mount ' . $emain . '/image2.raw ' . $emain . '/root'; |
449 |
|
$r = rg_exec($cmd); |
|
|
450 |
|
$r = rg_exec($cmd, ''); |
450 |
451 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
451 |
452 |
$job['error'] = 'Could not mount image: ' . $r['data']; |
$job['error'] = 'Could not mount image: ' . $r['data']; |
452 |
453 |
break; |
break; |
|
... |
... |
function rg_job_extract_info(&$job) |
488 |
489 |
unset($job['env']); |
unset($job['env']); |
489 |
490 |
|
|
490 |
491 |
$cmd = 'umount ' . $emain . '/root'; |
$cmd = 'umount ' . $emain . '/root'; |
491 |
|
$r = rg_exec($cmd); |
|
|
492 |
|
$r = rg_exec($cmd, ''); |
492 |
493 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
493 |
494 |
rg_log('Cannot unmount!'); |
rg_log('Cannot unmount!'); |
494 |
495 |
break; |
break; |
|
... |
... |
while(1) { |
599 |
600 |
|
|
600 |
601 |
// TODO: do we destroy the pool in case of crash? |
// TODO: do we destroy the pool in case of crash? |
601 |
602 |
$cmd = 'virsh pool-destroy rocketgit-j-' . $jid; |
$cmd = 'virsh pool-destroy rocketgit-j-' . $jid; |
602 |
|
$r = rg_exec($cmd); |
|
|
603 |
|
$r = rg_exec($cmd, ''); |
603 |
604 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
604 |
605 |
$job['error'] = 'Could not destroy pool: ' . $r['data']; |
$job['error'] = 'Could not destroy pool: ' . $r['data']; |
605 |
606 |
rg_log('Error: ' . $job['error']); |
rg_log('Error: ' . $job['error']); |
|
... |
... |
while(1) { |
608 |
609 |
|
|
609 |
610 |
// TODO: do we clean the pool in case of crash? |
// TODO: do we clean the pool in case of crash? |
610 |
611 |
$cmd = 'virsh pool-undefine rocketgit-j-' . $jid; |
$cmd = 'virsh pool-undefine rocketgit-j-' . $jid; |
611 |
|
$r = rg_exec($cmd); |
|
|
612 |
|
$r = rg_exec($cmd, ''); |
612 |
613 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
613 |
614 |
$job['error'] = 'Could not undefine pool: ' . $r['data']; |
$job['error'] = 'Could not undefine pool: ' . $r['data']; |
614 |
615 |
rg_log('Error: ' . $job['error']); |
rg_log('Error: ' . $job['error']); |
|
... |
... |
while(1) { |
617 |
618 |
|
|
618 |
619 |
// TODO: do we clean the machine in case of crash? |
// TODO: do we clean the machine in case of crash? |
619 |
620 |
$cmd = 'virsh undefine rg-worker-' . escapeshellarg($jid); |
$cmd = 'virsh undefine rg-worker-' . escapeshellarg($jid); |
620 |
|
$r = rg_exec($cmd); |
|
|
621 |
|
$r = rg_exec($cmd, ''); |
621 |
622 |
if ($r['ok'] != 1) { |
if ($r['ok'] != 1) { |
622 |
623 |
$job['error'] = 'Could not undefine machine: ' . $r['data']; |
$job['error'] = 'Could not undefine machine: ' . $r['data']; |
623 |
624 |
rg_log('Error: ' . $job['error']); |
rg_log('Error: ' . $job['error']); |
File tests/pr_anon.php changed (mode: 100644) (index cd0af1e..0cd7e2d) |
... |
... |
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'); |
|
|
85 |
|
$r = rg_exec('git init _pr_anon.git', ''); |
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'])); |
|
|
94 |
|
. escapeshellarg($repo['name']), ''); |
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'])); |
|
|
103 |
|
. escapeshellarg($repo['name']), ''); |
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'); |
|
|
118 |
|
. 'git push origin_ssh master', ''); |
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'); |
|
|
132 |
|
. 'git push origin_git master', ''); |
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'); |
|
|
215 |
|
. 'git push origin_git master', ''); |
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'); |
|
|
226 |
|
. 'git push origin_ssh master', ''); |
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!'); |