List of commits:
Subject Hash Author Date (UTC)
rg_exec accepts a second para: data to be sent as stdin 71d2b273ae592e3c6e6a77e7b19df3f94aa1e9e9 Catalin(ux) M. BOIE 2016-07-31 03:05:23
Simplify event processing by passing full 'ui'; fixed 'confirmed' filed usage cbb6f8877db547d55b7b86e0fe5c41519d6c8b65 Catalin(ux) M. BOIE 2016-07-14 05:08:51
Fixed the unit tests (minor) 0e9cfc3911aba7119bb57140ecfa51ad6e3983bf Catalin(ux) M. BOIE 2016-07-14 05:05:37
Fixed e-mail confirmation logic. dd5b4be2e8e49aa612ddf7557e8ef0b1e0268822 Catalin(ux) M. BOIE 2016-07-11 21:09:19
Do more tests and resync some with the reality db9bb136ff176006cbb8f8848309b8adbf98d630 Catalin(ux) M. BOIE 2016-07-11 04:07:38
Improved user cache to not have null elements in JSON d6b75a2cc4830cfb8dfb92e911f1e5a41c2023bc Catalin(ux) M. BOIE 2016-07-11 04:06:25
Allow rights to have numbers and _ in name 4f5c38389bc98e2dcb60d36359917c33820e5779 Catalin(ux) M. BOIE 2016-07-11 04:05:40
Allow strange chars in cache names 00b05d99d3d3cf0229249718d2482af40f063972 Catalin(ux) M. BOIE 2016-07-11 04:04:08
Small improvements to builder and worker 08f9bc668f7f192af61868bebd644bea64b6aedd Catalin(ux) M. BOIE 2016-07-11 04:01:47
SELinux improvements to support the builder a2b52360b43be53786ee5d68c9fcb2db14f29c0c Catalin(ux) M. BOIE 2016-07-11 04:00:57
Document docker on Download web section 5d4ece50d6b4dc3d4902afd9264a45834ceb3592 Catalin(ux) M. BOIE 2016-07-11 03:54:31
Doc: restore context for rc.local eb5fa1cab84737e3440cfbca147d50859b8f9a53 Catalin(ux) M. BOIE 2016-07-07 04:09:23
Fixed small bug preventing e-mail to show in report 26d884b3a332f3c3b241c194912b9653749a9427 Catalin(ux) M. BOIE 2016-07-07 03:37:23
Do not clobber the cron file 5c68384676d9b8087255dda3b62e3588fc50e6c7 Catalin(ux) M. BOIE 2016-07-06 22:03:58
When using rg_json_encode, no quotes needed. c4b7693a81e593918f8c06408f16b4884a92773b Catalin(ux) M. BOIE 2016-07-06 05:21:00
Remove summary from tables because violates HTML5 specs. :( 11865f18e979f3849dbb265e5c5350f4a638088b Catalin(ux) M. BOIE 2016-07-06 05:00:11
Bump version to 0.55 58652b8250a867c0f4e9e3a9c76737443f242b36 Catalin(ux) M. BOIE 2016-07-06 04:48:24
Big commit of a lot of unrelated changes. Shame on me! e503666df79ef1553d0bb7ffd1d12a6b62748b1c Catalin(ux) M. BOIE 2016-07-06 04:44:43
Do not free resources if query fails. 57baca81e9087a00a8e2e1807c932de2fb9769c4 Catalin(ux) M. BOIE 2016-06-26 11:47:09
Packaging changes: prepared for Debian build c32cb09dc84615f4984ce5f8fac4064accbeeb28 Catalin(ux) M. BOIE 2016-06-12 05:59:14
Commit 71d2b273ae592e3c6e6a77e7b19df3f94aa1e9e9 - rg_exec accepts a second para: data to be sent as stdin
Author: Catalin(ux) M. BOIE
Author date (UTC): 2016-07-31 03:05
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2016-07-31 03:05
Parent(s): cbb6f8877db547d55b7b86e0fe5c41519d6c8b65
Signer:
Signing key:
Signing status: N
Tree: be54885d151d47b39f9a881181691b9f37b446cf
File Lines added Lines deleted
inc/builder.inc.php 1 1
inc/git.inc.php 18 18
inc/totp.inc.php 2 2
inc/util.inc.php 24 5
scripts/worker.php 17 16
tests/export.php 1 1
tests/git2.php 2 2
tests/pr_anon.php 7 7
tests/repo.php 1 1
tests/user.php 1 1
tests/util.php 3 3
tests/wh_cloud.php 1 1
File inc/builder.inc.php changed (mode: 100644) (index 86c445b..b38750f)
... ... function rg_builder_add($db, $repo_id, $d)
84 84 function rg_builder_vm_list() function rg_builder_vm_list()
85 85 { {
86 86 $cmd = 'virsh list --name'; $cmd = 'virsh list --name';
87 $r = rg_exec($cmd);
87 $r = rg_exec($cmd, '');
88 88 if ($r['ok'] != 1) { if ($r['ok'] != 1) {
89 89 rg_log('Cannot find out virtual machines: ' . $r['errmsg']); rg_log('Cannot find out virtual machines: ' . $r['errmsg']);
90 90 return FALSE; return FALSE;
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/totp.inc.php changed (mode: 100644) (index 8971fc8..4d1cd73)
... ... function rg_totp_png($secret)
155 155 $extra = gmdate('Y-m-d H:i'); $extra = gmdate('Y-m-d H:i');
156 156 $issuer = $rg_ssh_host; $issuer = $rg_ssh_host;
157 157 $cmd = "qrencode -o - --level=H --type=PNG 'otpauth://totp/$extra?secret=$secret&issuer=$issuer'"; $cmd = "qrencode -o - --level=H --type=PNG 'otpauth://totp/$extra?secret=$secret&issuer=$issuer'";
158 $a = rg_exec($cmd);
158 $a = rg_exec($cmd, '');
159 159 if ($a['ok'] != 1) if ($a['ok'] != 1)
160 160 return FALSE; return FALSE;
161 161
 
... ... function rg_totp_text($secret)
172 172 $extra = gmdate('Y-m-d H:i'); $extra = gmdate('Y-m-d H:i');
173 173 $issuer = $rg_ssh_host; $issuer = $rg_ssh_host;
174 174 $cmd = "qrencode -o - --level=M --margin=2 --type=UTF8 'otpauth://totp/$extra?secret=$secret&issuer=$issuer'"; $cmd = "qrencode -o - --level=M --margin=2 --type=UTF8 'otpauth://totp/$extra?secret=$secret&issuer=$issuer'";
175 $a = rg_exec($cmd);
175 $a = rg_exec($cmd, '');
176 176 if ($a['ok'] != 1) if ($a['ok'] != 1)
177 177 return FALSE; return FALSE;
178 178
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/export.php changed (mode: 100644) (index c5b707a..429604f)
... ... if ($r === FALSE) {
45 45 } }
46 46
47 47 $cmd = 'cat export.json | json_verify'; $cmd = 'cat export.json | json_verify';
48 $a = rg_exec($cmd);
48 $a = rg_exec($cmd, '');
49 49 if ($a['ok'] !== 1) { if ($a['ok'] !== 1) {
50 50 rg_log_ml(print_r($a, TRUE)); rg_log_ml(print_r($a, TRUE));
51 51 rg_log('Seems the JSON is not valid!'); rg_log('Seems the JSON is not valid!');
File tests/git2.php changed (mode: 100644) (index eee1b63..f1ee122)
... ... $remote = 'ssh://rocketgit@' . $rg_ssh_host . ':' .$rg_ssh_port
66 66 . '/' . escapeshellarg($repo['name']); . '/' . escapeshellarg($repo['name']);
67 67 $r = rg_exec("cd git2 && git remote add origin $remote" $r = rg_exec("cd git2 && git remote add origin $remote"
68 68 . " && export GIT_SSH_COMMAND=\"ssh -v -o IdentityFile=../keys/git2\"" . " && export GIT_SSH_COMMAND=\"ssh -v -o IdentityFile=../keys/git2\""
69 . " && git push origin master");
69 . " && git push origin master", '');
70 70 if ($r['ok'] != 1) { if ($r['ok'] != 1) {
71 71 rg_log_ml('out: ' . $r['errmsg']); rg_log_ml('out: ' . $r['errmsg']);
72 72 rg_log("Seems I cannot push master! err=$err"); rg_log("Seems I cannot push master! err=$err");
 
... ... rg_log('');
79 79 rg_log_enter('Trying to push tags...'); rg_log_enter('Trying to push tags...');
80 80 $r = rg_exec("cd git2" $r = rg_exec("cd git2"
81 81 . " && export GIT_SSH_COMMAND=\"ssh -v -o IdentityFile=../keys/git2\"" . " && export GIT_SSH_COMMAND=\"ssh -v -o IdentityFile=../keys/git2\""
82 . " && git push --tags origin");
82 . " && git push --tags origin", '');
83 83 if ($r['ok'] != 1) { if ($r['ok'] != 1) {
84 84 rg_log_ml('error: ' . $r['errmsg']); rg_log_ml('error: ' . $r['errmsg']);
85 85 rg_log("Seems I cannot push tags!"); rg_log("Seems I cannot push tags!");
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!');
File tests/repo.php changed (mode: 100644) (index 8e8134b..0fdba41)
... ... if ($ri['exists'] != 1) {
192 192
193 193 rg_log(''); rg_log('');
194 194 rg_log_enter('Cleaning repos folder...'); rg_log_enter('Cleaning repos folder...');
195 $r = rg_exec("rm -rf base/*");
195 $r = rg_exec("rm -rf base/*", '');
196 196 if ($r['ok'] != 1) { if ($r['ok'] != 1) {
197 197 rg_log("Failed to clean base folder."); rg_log("Failed to clean base folder.");
198 198 exit(1); exit(1);
File tests/user.php changed (mode: 100644) (index 1c66ec0..cacb722)
... ... $rg_admin_name = "RocketGit Admin";
27 27 $_SERVER['HTTP_HOST'] = "fake.tld"; $_SERVER['HTTP_HOST'] = "fake.tld";
28 28
29 29
30 $r = rg_exec("rm -rf ubase");
30 $r = rg_exec("rm -rf ubase", '');
31 31 if ($r['ok'] != 1) { if ($r['ok'] != 1) {
32 32 rg_log("Cannot remove ubase dir (" . $r['errmsg'] . ")!"); rg_log("Cannot remove ubase dir (" . $r['errmsg'] . ")!");
33 33 exit(1); exit(1);
File tests/util.php changed (mode: 100644) (index 1679820..9b45304)
... ... if ($r !== TRUE) {
264 264 } }
265 265
266 266
267 $r = rg_exec("/xxxx");
267 $r = rg_exec("/xxxx", '');
268 268 if ($r['ok'] == 1) { if ($r['ok'] == 1) {
269 269 rg_log("util.php: running non existing command does not return 0!"); rg_log("util.php: running non existing command does not return 0!");
270 270 print_r($r); print_r($r);
271 271 exit(1); exit(1);
272 272 } }
273 273
274 $r = rg_exec("ls");
274 $r = rg_exec("ls", '');
275 275 if ($r['ok'] != 1) { if ($r['ok'] != 1) {
276 276 rg_log("util.php: cannot run a command!"); rg_log("util.php: cannot run a command!");
277 277 print_r($r); print_r($r);
278 278 exit(1); exit(1);
279 279 } }
280 280
281 $r = rg_exec("./util_exit_code.sh 5");
281 $r = rg_exec("./util_exit_code.sh 5", '');
282 282 if ($r['code'] != 5) { if ($r['code'] != 5) {
283 283 rg_log("util.php: error code seems to not be propageted!"); rg_log("util.php: error code seems to not be propageted!");
284 284 print_r($r); print_r($r);
File tests/wh_cloud.php changed (mode: 100644) (index 568da7a..cf746ea)
... ... rg_test_create_repo($db, $rg_ui, $repo);
103 103 $repo_url = 'ssh://rocketgit@' . $rg_ssh_host . ':' . $rg_ssh_port $repo_url = 'ssh://rocketgit@' . $rg_ssh_host . ':' . $rg_ssh_port
104 104 . '/user/' . $rg_ui['username'] . '/' . $repo['name']; . '/user/' . $rg_ui['username'] . '/' . $repo['name'];
105 105 rg_log('repo_url=' . escapeshellarg($repo_url)); rg_log('repo_url=' . escapeshellarg($repo_url));
106 $r = rg_exec('./wh_cloud.git.sh ' . escapeshellarg($repo_url));
106 $r = rg_exec('./wh_cloud.git.sh ' . escapeshellarg($repo_url), '');
107 107 if ($r['ok'] != 1) { if ($r['ok'] != 1) {
108 108 rg_log('Could not create local git repo: ' . $r['errmsg'] . '!'); rg_log('Could not create local git repo: ' . $r['errmsg'] . '!');
109 109 exit(1); exit(1);
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/rocketgit

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main