mirror of
https://github.com/urbit/shrub.git
synced 2025-01-03 18:16:30 +03:00
Merge remote-tracking branch 'origin/retrofit' into retrofit
This commit is contained in:
commit
ed09e7e079
@ -7,7 +7,7 @@
|
||||
/* u3m_boot(): start the u3 system.
|
||||
*/
|
||||
void
|
||||
u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c, c3_c *pil_c);
|
||||
u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c, c3_c *pil_c, c3_c *url_c, c3_c *arv_c);
|
||||
|
||||
/* u3m_bail(): bail out. Does not return.
|
||||
**
|
||||
|
@ -530,34 +530,36 @@
|
||||
/* u3_opts: command line configuration.
|
||||
*/
|
||||
typedef struct _u3_opts {
|
||||
c3_c* imp_c; // -I, czar name
|
||||
c3_c* nam_c; // -n, unix hostname
|
||||
c3_c* raf_c; // -r, raft flotilla
|
||||
c3_c* who_c; // -w, begin with ticket
|
||||
c3_c* tic_c; // -t, ticket value
|
||||
c3_c* pil_c; // -B, bootstrap from
|
||||
c3_c* arv_c; // -A, initial sync from
|
||||
c3_c* gen_c; // -G, czar generator
|
||||
c3_w kno_w; // -k, kernel version
|
||||
c3_w fuz_w; // -f, fuzz testing
|
||||
c3_s por_s; // -p, ames port
|
||||
c3_s rop_s; // -l, raft port
|
||||
c3_c* imp_c; // -I, czar name
|
||||
c3_c* nam_c; // -n, unix hostname
|
||||
c3_c* pil_c; // -B, bootstrap from
|
||||
c3_c* raf_c; // -r, raft flotilla
|
||||
c3_c* tic_c; // -t, ticket value
|
||||
c3_c* url_c; // -u, pill url
|
||||
c3_c* who_c; // -w, begin with ticket
|
||||
c3_o abo; // -a
|
||||
c3_o bat; // -b, batch create
|
||||
c3_o gab; // -g
|
||||
c3_o dem; // -d, daemon
|
||||
c3_o dry; // -D, dry compute
|
||||
c3_o tex; // -x, exit after loading
|
||||
c3_o fog; // -X, skip last event
|
||||
c3_o fak; // -F, fake carrier
|
||||
c3_o loh; // -L, local-only networking
|
||||
c3_o pro; // -P, profile
|
||||
c3_o veb; // -v, verbose (inverse of -q)
|
||||
c3_o nuu; // -c, new pier
|
||||
c3_o qui; // -q, quiet
|
||||
c3_o vno; // -V, replay without reboots
|
||||
c3_o fog; // -X, skip last event
|
||||
c3_o gab; // -g, run with garbage collector
|
||||
c3_o git; // -s, pill url from arvo git hash
|
||||
c3_o mem; // -M, memory madness
|
||||
c3_o net; // -N, remote networking in -F mode
|
||||
c3_o nuu; // -c, new pier
|
||||
c3_o pro; // -P, profile
|
||||
c3_o qui; // -q, quiet
|
||||
c3_o rep; // -R, report build info
|
||||
c3_o tex; // -x, exit after loading
|
||||
c3_o veb; // -v, verbose (inverse of -q)
|
||||
c3_o vno; // -V, replay without reboots
|
||||
c3_s por_s; // -p, ames port
|
||||
c3_s rop_s; // -l, raft port
|
||||
c3_w fuz_w; // -f, fuzz testing
|
||||
c3_w kno_w; // -k, kernel version
|
||||
} u3_opts;
|
||||
|
||||
/* u3_host: entire host.
|
||||
|
100
noun/manage.c
100
noun/manage.c
@ -1500,9 +1500,81 @@ _cm_init(c3_o chk_o)
|
||||
}
|
||||
}
|
||||
|
||||
/* _get_cmd_output(): Run a shell command and capture its output.
|
||||
Exits with an error if the command fails or produces no output.
|
||||
The 'out_c' parameter should be an array of sufficient length to hold
|
||||
the command's output, up to a max of 2048 characters.
|
||||
*/
|
||||
static void
|
||||
_get_cmd_output(c3_c *cmd_c, c3_c *out_c)
|
||||
{
|
||||
FILE *fp = popen(cmd_c, "r");
|
||||
if ( NULL == fp ) {
|
||||
fprintf(stderr, "'%s' failed\n", cmd_c);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ( NULL == fgets(out_c, 2048, fp) ) {
|
||||
fprintf(stderr, "'%s' produced no output\n", cmd_c);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pclose(fp);
|
||||
}
|
||||
|
||||
/* _arvo_hash(): retrieve git hash of arvo directory.
|
||||
hax_c must be an array with length >= 41.
|
||||
*/
|
||||
static void
|
||||
_arvo_hash(c3_c *out_c, c3_c *arv_c)
|
||||
{
|
||||
c3_c cmd_c[2048];
|
||||
|
||||
sprintf(cmd_c, "git -C %s rev-parse HEAD", arv_c);
|
||||
_get_cmd_output(cmd_c, out_c);
|
||||
|
||||
out_c[strcspn(out_c, "\r\n")] = 0; /* strip newline */
|
||||
}
|
||||
|
||||
/* _git_branch(): retrieve the current git branch */
|
||||
static void
|
||||
_git_branch(c3_c *out_c, c3_c *arv_c)
|
||||
{
|
||||
c3_c cmd_c[2048];
|
||||
|
||||
sprintf(cmd_c, "git -C %s rev-parse --abbrev-ref HEAD", arv_c);
|
||||
_get_cmd_output(cmd_c, out_c);
|
||||
|
||||
out_c[strcspn(out_c, "\r\n")] = 0; /* strip newline */
|
||||
}
|
||||
|
||||
/* _git_pill_url(): produce a URL from which to download a pill
|
||||
based on the location of an arvo git repository.
|
||||
*/
|
||||
static void
|
||||
_git_pill_url(c3_c *out_c, c3_c *arv_c)
|
||||
{
|
||||
assert(NULL != arv_c);
|
||||
|
||||
if ( 0 != system("which git >> /dev/null") ) {
|
||||
fprintf(stderr, "Could not find git executable\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
{
|
||||
c3_c hax_c[2048];
|
||||
c3_c bra_c[2048];
|
||||
|
||||
_git_branch(bra_c, arv_c);
|
||||
_arvo_hash(hax_c, arv_c);
|
||||
|
||||
sprintf(out_c, "https://bootstrap.urbit.org/%s-%s.pill", hax_c, bra_c);
|
||||
}
|
||||
}
|
||||
|
||||
/* _boot_home(): create ship directory. */
|
||||
static void
|
||||
_boot_home(c3_c *dir_c, c3_c *pil_c)
|
||||
_boot_home(c3_c *dir_c, c3_c *pil_c, c3_c *url_c, c3_c *arv_c)
|
||||
{
|
||||
c3_c ful_c[2048];
|
||||
|
||||
@ -1522,7 +1594,6 @@ _boot_home(c3_c *dir_c, c3_c *pil_c)
|
||||
snprintf(ful_c, 2048, "%s/.urb/sis", dir_c);
|
||||
mkdir(ful_c, 0700);
|
||||
}
|
||||
|
||||
/* Copy urbit.pill. */
|
||||
{
|
||||
{
|
||||
@ -1534,6 +1605,8 @@ _boot_home(c3_c *dir_c, c3_c *pil_c)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy local pill file. */
|
||||
if ( pil_c != 0 ) {
|
||||
snprintf(ful_c, 2048, "cp %s %s/.urb/urbit.pill",
|
||||
pil_c, dir_c);
|
||||
@ -1542,11 +1615,19 @@ _boot_home(c3_c *dir_c, c3_c *pil_c)
|
||||
fprintf(stderr, "could not %s\n", ful_c);
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
c3_c *url_c = "https://bootstrap.urbit.org/latest.pill";
|
||||
}
|
||||
/* Fetch remote pill over HTTP. */
|
||||
else {
|
||||
CURL *curl;
|
||||
CURLcode result;
|
||||
FILE *file;
|
||||
c3_c pil_c[2048];
|
||||
|
||||
/* use arvo git hash and branch for pill url unless overridden */
|
||||
if ( NULL == url_c ) {
|
||||
url_c = pil_c;
|
||||
_git_pill_url(url_c, arv_c);
|
||||
}
|
||||
|
||||
snprintf(ful_c, 2048, "%s/.urb/urbit.pill", dir_c);
|
||||
printf("fetching %s to %s\r\n", url_c, ful_c);
|
||||
@ -1563,8 +1644,10 @@ _boot_home(c3_c *dir_c, c3_c *pil_c)
|
||||
result = curl_easy_perform(curl);
|
||||
fclose(file);
|
||||
if ( result != CURLE_OK ) {
|
||||
fprintf(stderr, "failed to fetch %s: %s\n", url_c, curl_easy_strerror(result));
|
||||
fprintf(stderr, "please fetch it manually and specify the location with -B\n");
|
||||
fprintf(stderr, "failed to fetch %s: %s\n",
|
||||
url_c, curl_easy_strerror(result));
|
||||
fprintf(stderr,
|
||||
"please fetch it manually and specify the location with -B\n");
|
||||
exit(1);
|
||||
}
|
||||
curl_easy_cleanup(curl);
|
||||
@ -1575,7 +1658,8 @@ _boot_home(c3_c *dir_c, c3_c *pil_c)
|
||||
/* u3m_boot(): start the u3 system.
|
||||
*/
|
||||
void
|
||||
u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c, c3_c *pil_c)
|
||||
u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c,
|
||||
c3_c *pil_c, c3_c *url_c, c3_c *arv_c)
|
||||
{
|
||||
/* Activate the loom.
|
||||
*/
|
||||
@ -1602,7 +1686,7 @@ u3m_boot(c3_o nuu_o, c3_o bug_o, c3_c* dir_c, c3_c *pil_c)
|
||||
if ( _(nuu_o) ) {
|
||||
c3_c ful_c[2048];
|
||||
|
||||
_boot_home(dir_c, pil_c);
|
||||
_boot_home(dir_c, pil_c, url_c, arv_c);
|
||||
|
||||
snprintf(ful_c, 2048, "%s/.urb/urbit.pill", dir_c);
|
||||
|
||||
|
@ -50,8 +50,9 @@ _ames_czar(c3_y imp_y, c3_s* por_s)
|
||||
{
|
||||
u3_ames* sam_u = &u3_Host.sam_u;
|
||||
|
||||
if ( c3y == u3_Host.ops_u.loh ) {
|
||||
if ( c3n == u3_Host.ops_u.net ) {
|
||||
*por_s = 31337 + imp_y;
|
||||
uL(fprintf(uH, "ames: czar: localhost-only mode\n"));
|
||||
return 0x7f000001;
|
||||
}
|
||||
else {
|
||||
|
137
vere/main.c
137
vere/main.c
@ -67,22 +67,23 @@ _main_getopt(c3_i argc, c3_c** argv)
|
||||
|
||||
u3_Host.ops_u.abo = c3n;
|
||||
u3_Host.ops_u.bat = c3n;
|
||||
u3_Host.ops_u.gab = c3n;
|
||||
u3_Host.ops_u.loh = c3n;
|
||||
u3_Host.ops_u.dem = c3n;
|
||||
u3_Host.ops_u.fog = c3n;
|
||||
u3_Host.ops_u.fak = c3n;
|
||||
u3_Host.ops_u.tex = c3n;
|
||||
u3_Host.ops_u.pro = c3n;
|
||||
u3_Host.ops_u.dry = c3n;
|
||||
u3_Host.ops_u.veb = c3n;
|
||||
u3_Host.ops_u.qui = c3n;
|
||||
u3_Host.ops_u.nuu = c3n;
|
||||
u3_Host.ops_u.fak = c3n;
|
||||
u3_Host.ops_u.fog = c3n;
|
||||
u3_Host.ops_u.gab = c3n;
|
||||
u3_Host.ops_u.git = c3n;
|
||||
u3_Host.ops_u.net = c3n;
|
||||
u3_Host.ops_u.mem = c3n;
|
||||
u3_Host.ops_u.nuu = c3n;
|
||||
u3_Host.ops_u.pro = c3n;
|
||||
u3_Host.ops_u.qui = c3n;
|
||||
u3_Host.ops_u.rep = c3n;
|
||||
u3_Host.ops_u.tex = c3n;
|
||||
u3_Host.ops_u.veb = c3n;
|
||||
u3_Host.ops_u.kno_w = DefaultKernel;
|
||||
|
||||
while ( (ch_i=getopt(argc, argv,"G:B:A:I:w:t:f:k:l:n:p:r:LabcdgqvxFMPDXR")) != -1 ) {
|
||||
while ( (ch_i=getopt(argc, argv,"G:B:A:I:w:u:t:f:k:l:n:p:r:NabcdgqsvxFMPDXR")) != -1 ) {
|
||||
switch ( ch_i ) {
|
||||
case 'M': {
|
||||
u3_Host.ops_u.mem = c3y;
|
||||
@ -109,6 +110,10 @@ _main_getopt(c3_i argc, c3_c** argv)
|
||||
u3_Host.ops_u.nuu = c3y;
|
||||
break;
|
||||
}
|
||||
case 'u': {
|
||||
u3_Host.ops_u.url_c = strdup(optarg);
|
||||
break;
|
||||
}
|
||||
case 't': {
|
||||
u3_Host.ops_u.tic_c = _main_presig(optarg);
|
||||
break;
|
||||
@ -157,12 +162,8 @@ _main_getopt(c3_i argc, c3_c** argv)
|
||||
u3_Host.ops_u.rep = c3y;
|
||||
return c3y;
|
||||
}
|
||||
case 'L': { u3_Host.ops_u.loh = c3y; break; }
|
||||
case 'F': {
|
||||
u3_Host.ops_u.loh = c3y;
|
||||
u3_Host.ops_u.fak = c3y;
|
||||
break;
|
||||
}
|
||||
case 'N': { u3_Host.ops_u.net = c3y; break; }
|
||||
case 'F': { u3_Host.ops_u.fak = c3y; break; }
|
||||
case 'a': { u3_Host.ops_u.abo = c3y; break; }
|
||||
case 'b': { u3_Host.ops_u.bat = c3y; break; }
|
||||
case 'c': { u3_Host.ops_u.nuu = c3y; break; }
|
||||
@ -172,12 +173,20 @@ _main_getopt(c3_i argc, c3_c** argv)
|
||||
case 'D': { u3_Host.ops_u.dry = c3y; break; }
|
||||
case 'q': { u3_Host.ops_u.qui = c3y; break; }
|
||||
case 'v': { u3_Host.ops_u.veb = c3y; break; }
|
||||
case 's': { u3_Host.ops_u.git = c3y; break; }
|
||||
case '?': default: {
|
||||
return c3n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( u3_Host.ops_u.fak == c3n && u3_Host.ops_u.net == c3y ) {
|
||||
fprintf(stderr, "-N only makes sense with -F\n");
|
||||
return c3n;
|
||||
} else if ( u3_Host.ops_u.fak == c3n && u3_Host.ops_u.net == c3n ) {
|
||||
u3_Host.ops_u.net = c3y; /* remote networking is always on in real mode. */
|
||||
}
|
||||
|
||||
if ( u3_Host.ops_u.arv_c != 0 && ( u3_Host.ops_u.imp_c == 0 ||
|
||||
u3_Host.ops_u.nuu == c3n ) ) {
|
||||
fprintf(stderr, "-A only makes sense when creating a new galaxy\n");
|
||||
@ -191,13 +200,13 @@ _main_getopt(c3_i argc, c3_c** argv)
|
||||
"the initial sync path with -A\n");
|
||||
return c3n;
|
||||
}
|
||||
|
||||
|
||||
if ( u3_Host.ops_u.gen_c != 0 && ( u3_Host.ops_u.imp_c == 0 ||
|
||||
u3_Host.ops_u.nuu == c3n ) ) {
|
||||
fprintf(stderr, "-G only makes sense when creating a new galaxy\n");
|
||||
return c3n;
|
||||
}
|
||||
|
||||
|
||||
if ( u3_Host.ops_u.tic_c != 0 && ( u3_Host.ops_u.imp_c != 0 ||
|
||||
u3_Host.ops_u.nuu == c3n ) ) {
|
||||
fprintf(stderr, "-t only makes sense when creating a new non-galaxy\n");
|
||||
@ -210,10 +219,10 @@ _main_getopt(c3_i argc, c3_c** argv)
|
||||
}
|
||||
|
||||
if ( u3_Host.ops_u.tic_c == 0 && u3_Host.ops_u.who_c != 0 ) {
|
||||
c3_c tic_c[29];
|
||||
printf("your ticket: ~");
|
||||
scanf("%28s",tic_c);
|
||||
u3_Host.ops_u.tic_c = _main_presig(tic_c);
|
||||
c3_c tic_c[29];
|
||||
printf("your ticket: ~");
|
||||
scanf("%28s",tic_c);
|
||||
u3_Host.ops_u.tic_c = _main_presig(tic_c);
|
||||
}
|
||||
|
||||
if ( c3y == u3_Host.ops_u.bat ) {
|
||||
@ -226,6 +235,24 @@ _main_getopt(c3_i argc, c3_c** argv)
|
||||
return c3n;
|
||||
}
|
||||
|
||||
if ( u3_Host.ops_u.nuu != c3y && u3_Host.ops_u.url_c != 0 ) {
|
||||
fprintf(stderr, "-u only makes sense when bootstrapping a new instance\n");
|
||||
return c3n;
|
||||
|
||||
} else if ( u3_Host.ops_u.nuu == c3y
|
||||
&& u3_Host.ops_u.url_c == 0
|
||||
&& u3_Host.ops_u.git == c3n ) {
|
||||
|
||||
u3_Host.ops_u.url_c = "https://bootstrap.urbit.org/latest.pill";
|
||||
|
||||
} else if ( u3_Host.ops_u.nuu == c3y
|
||||
&& u3_Host.ops_u.url_c == 0
|
||||
&& u3_Host.ops_u.arv_c == 0 ) {
|
||||
|
||||
fprintf(stderr, "-s only makes sense with -A\n");
|
||||
return c3n;
|
||||
}
|
||||
|
||||
if ( u3_Host.ops_u.pil_c != 0 ) {
|
||||
struct stat s;
|
||||
if ( stat(u3_Host.ops_u.pil_c, &s) != 0 ) {
|
||||
@ -272,42 +299,56 @@ _main_getopt(c3_i argc, c3_c** argv)
|
||||
static void
|
||||
u3_ve_usage(c3_i argc, c3_c** argv)
|
||||
{
|
||||
#if 0
|
||||
c3_c *use_c[] = {"Usage: %s [options...] computer\n",
|
||||
"-c pier Create a new urbit in pier/\n",
|
||||
"-w name Immediately upgrade to ~name\n",
|
||||
"-t ticket Use ~ticket automatically\n",
|
||||
"-I galaxy Start as ~galaxy\n",
|
||||
c3_c *use_c[] = {
|
||||
"Urbit: a personal server operating function\n",
|
||||
"https://urbit.org\n",
|
||||
"Version " URBIT_VERSION "\n",
|
||||
"\n",
|
||||
"Usage: %s [options...] ship_name\n",
|
||||
"where ship_name is a @p phonetic representation of an urbit address\n",
|
||||
"without the leading '~', and options is some subset of the following:\n",
|
||||
"\n",
|
||||
"-A dir Use dir for initial galaxy sync\n",
|
||||
"-F Fake keys\n",
|
||||
"-L Local-only network\n",
|
||||
"-B pill Bootstrap from this pill\n",
|
||||
"-n host Set unix hostname\n",
|
||||
"-p ames_port Set the HTTP port to bind to\n",
|
||||
"-v Verbose\n",
|
||||
"-q Quiet\n",
|
||||
"-D Recompute from events\n",
|
||||
"-P Profiling\n",
|
||||
"-b Batch create\n",
|
||||
"-B pill Bootstrap from this pill\n",
|
||||
"-c pier Create a new urbit in pier/\n",
|
||||
"-d Daemon mode\n",
|
||||
"-D Recompute from events\n",
|
||||
"-F Fake keys\n",
|
||||
"-f Fuzz testing\n",
|
||||
"-g Set GC flag\n",
|
||||
"-x Exit immediately\n",
|
||||
"-r host Initial peer address\n",
|
||||
"-I galaxy Start as ~galaxy\n",
|
||||
"-k stage Start at Hoon kernel version stage\n",
|
||||
"-L Local-only network\n",
|
||||
"-l port Initial peer port\n",
|
||||
"-M Memory madness\n",
|
||||
"-f Fuzz testing\n",
|
||||
"-k stage Start at Hoon kernel version stage\n",
|
||||
"-n host Set unix hostname\n",
|
||||
"-p ames_port Set the HTTP port to bind to\n",
|
||||
"-P Profiling\n",
|
||||
"-q Quiet\n",
|
||||
"-r host Initial peer address\n",
|
||||
"-R Report urbit build info\n",
|
||||
"-Xwtf Skip last event\n"};
|
||||
#else
|
||||
c3_c *use_c[] = {
|
||||
"simple usage: \n",
|
||||
"-s Pill URL from arvo git hash\n",
|
||||
"-t ticket Use ~ticket automatically\n",
|
||||
"-u url URL from which to download pill\n",
|
||||
"-v Verbose\n",
|
||||
"-w name Immediately upgrade to ~name\n",
|
||||
"-x Exit immediately\n",
|
||||
"-Xwtf Skip last event\n",
|
||||
"\n",
|
||||
"Development Usage:\n",
|
||||
" To create a development ship, use a fakezod:\n",
|
||||
" %s -FI zod -A /path/to/arvo/folder -B /path/to/pill -c zod\n",
|
||||
"\n",
|
||||
" For more information about developing on urbit, see:\n",
|
||||
" https://github.com/urbit/urbit/blob/master/CONTRIBUTING.md\n",
|
||||
"\n",
|
||||
"Simple Usage: \n",
|
||||
" %s -c <mycomet> to create a comet (anonymous urbit)\n",
|
||||
" %s -w <myplanet> -t <myticket> if you have a ticket\n",
|
||||
" %s <myplanet or mycomet> to restart an existing urbit\n",
|
||||
0
|
||||
};
|
||||
#endif
|
||||
|
||||
c3_i i;
|
||||
for ( i=0; use_c[i]; i++ ) {
|
||||
@ -541,7 +582,9 @@ main(c3_i argc,
|
||||
u3m_boot(u3_Host.ops_u.nuu,
|
||||
u3_Host.ops_u.gab,
|
||||
u3_Host.dir_c,
|
||||
u3_Host.ops_u.pil_c);
|
||||
u3_Host.ops_u.pil_c,
|
||||
u3_Host.ops_u.url_c,
|
||||
u3_Host.ops_u.arv_c);
|
||||
|
||||
/* Start Arvo.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user