mirror of
https://github.com/urbit/shrub.git
synced 2025-01-01 17:16:47 +03:00
removes obsolete u3m_boot, renames new boot functions
This commit is contained in:
parent
1604313207
commit
1565eede94
@ -4,21 +4,15 @@
|
||||
*/
|
||||
/** System management.
|
||||
**/
|
||||
/* 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, c3_c *url_c, c3_c *arv_c);
|
||||
|
||||
/* u3m_boot_new(): start the u3 system (new). return next event,
|
||||
** starting from 1.
|
||||
/* u3m_boot(): start the u3 system. return next event, starting from 1.
|
||||
*/
|
||||
c3_d
|
||||
u3m_boot_new(c3_c* dir_c);
|
||||
u3m_boot(c3_c* dir_c);
|
||||
|
||||
/* u3m_boot_pier(): start without checkpointing.
|
||||
/* u3m_boot_lite(): start without checkpointing.
|
||||
*/
|
||||
c3_d
|
||||
u3m_boot_pier(void);
|
||||
u3m_boot_lite(void);
|
||||
|
||||
/* u3m_bail(): bail out. Does not return.
|
||||
**
|
||||
|
@ -1603,239 +1603,10 @@ u3m_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
// XX orphaned, find a way to restore
|
||||
#if 0
|
||||
/* _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 len_c characters.
|
||||
*/
|
||||
static void
|
||||
_get_cmd_output(c3_c *cmd_c, c3_c *out_c, c3_w len_c)
|
||||
{
|
||||
FILE *fp = popen(cmd_c, "r");
|
||||
if ( NULL == fp ) {
|
||||
u3l_log("'%s' failed\n", cmd_c);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ( NULL == fgets(out_c, len_c, fp) ) {
|
||||
u3l_log("'%s' produced no output\n", cmd_c);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pclose(fp);
|
||||
}
|
||||
|
||||
/* _arvo_hash(): get a shortened hash of the last git commit
|
||||
that modified the sys/ directory in arvo.
|
||||
hax_c must be an array with length >= 11.
|
||||
*/
|
||||
static void
|
||||
_arvo_hash(c3_c *out_c, c3_c *arv_c)
|
||||
{
|
||||
c3_c cmd_c[2048];
|
||||
|
||||
sprintf(cmd_c, "git -C %s log -1 HEAD --format=%%H -- sys/", arv_c);
|
||||
_get_cmd_output(cmd_c, out_c, 11);
|
||||
|
||||
out_c[10] = 0; // end with null-byte
|
||||
}
|
||||
|
||||
/* _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)
|
||||
{
|
||||
c3_c hax_c[11];
|
||||
|
||||
assert(NULL != arv_c);
|
||||
|
||||
if ( 0 != system("which git >> /dev/null") ) {
|
||||
u3l_log("Could not find git executable\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
_arvo_hash(hax_c, arv_c);
|
||||
sprintf(out_c, "https://bootstrap.urbit.org/git-%s.pill", hax_c);
|
||||
}
|
||||
#endif
|
||||
|
||||
// XX deprecated, remove
|
||||
#if 0
|
||||
/* _boot_home(): create ship directory.
|
||||
*/
|
||||
static void
|
||||
_boot_home(c3_c *dir_c, c3_c *pil_c, c3_c *url_c, c3_c *arv_c)
|
||||
{
|
||||
c3_c* nam_c = "urbit.pill";
|
||||
c3_c ful_c[2048];
|
||||
|
||||
/* Create subdirectories. */
|
||||
{
|
||||
mkdir(dir_c, 0700);
|
||||
|
||||
snprintf(ful_c, 2048, "%s/.urb", dir_c);
|
||||
mkdir(ful_c, 0700);
|
||||
|
||||
snprintf(ful_c, 2048, "%s/.urb/get", dir_c);
|
||||
mkdir(ful_c, 0700);
|
||||
|
||||
snprintf(ful_c, 2048, "%s/.urb/put", dir_c);
|
||||
mkdir(ful_c, 0700);
|
||||
|
||||
snprintf(ful_c, 2048, "%s/.urb/sis", dir_c);
|
||||
mkdir(ful_c, 0700);
|
||||
}
|
||||
/* Copy urbit.pill. */
|
||||
{
|
||||
{
|
||||
struct stat s;
|
||||
snprintf(ful_c, 2048, "%s/.urb/%s", dir_c, nam_c);
|
||||
if ( stat(ful_c, &s) == 0 ) {
|
||||
/* we're in a "logical boot". awful hack, but bail here */
|
||||
u3l_log("%s confirmed to exist\r\n", ful_c);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy local pill file. */
|
||||
if ( pil_c != 0 ) {
|
||||
snprintf(ful_c, 2048, "cp %s %s/.urb/%s",
|
||||
pil_c, dir_c, nam_c);
|
||||
u3l_log("%s\r\n", ful_c);
|
||||
if ( 0 != system(ful_c) ) {
|
||||
u3l_log("could not %s\n", ful_c);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
/* Fetch remote pill over HTTP. */
|
||||
else {
|
||||
CURL *curl;
|
||||
CURLcode result;
|
||||
FILE *file;
|
||||
c3_c pil_c[2048];
|
||||
long cod_l;
|
||||
|
||||
/* 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);
|
||||
u3l_log("fetching %s to %s\r\n", url_c, ful_c);
|
||||
if ( !(curl = curl_easy_init()) ) {
|
||||
u3l_log("failed to initialize libcurl\n");
|
||||
exit(1);
|
||||
}
|
||||
if ( !(file = fopen(ful_c, "w")) ) {
|
||||
u3l_log("failed to open %s\n", ful_c);
|
||||
exit(1);
|
||||
}
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url_c);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
|
||||
result = curl_easy_perform(curl);
|
||||
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &cod_l);
|
||||
fclose(file);
|
||||
if ( CURLE_OK != result ) {
|
||||
u3l_log("failed to fetch %s: %s\n",
|
||||
url_c, curl_easy_strerror(result));
|
||||
u3l_log("please fetch it manually and specify the location with -B\n");
|
||||
exit(1);
|
||||
}
|
||||
if ( 300 <= cod_l ) {
|
||||
u3l_log("error fetching %s: HTTP %ld\n", url_c, cod_l);
|
||||
u3l_log("please fetch it manually and specify the location with -B\n");
|
||||
exit(1);
|
||||
}
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// XX deprecated, remove
|
||||
#if 0
|
||||
/* u3m_boot(): start the u3 system (old).
|
||||
*/
|
||||
void
|
||||
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.
|
||||
*/
|
||||
u3m_init();
|
||||
|
||||
/* Activate the storage system.
|
||||
*/
|
||||
nuu_o = u3e_live(nuu_o, dir_c);
|
||||
|
||||
/* Activate tracing.
|
||||
*/
|
||||
u3t_init();
|
||||
|
||||
/* Construct or activate the allocator.
|
||||
*/
|
||||
u3m_pave(nuu_o, bug_o);
|
||||
|
||||
/* Initialize the jet system.
|
||||
*/
|
||||
u3j_boot(nuu_o);
|
||||
|
||||
/* Install or reactivate the kernel.
|
||||
*/
|
||||
if ( _(nuu_o) ) {
|
||||
c3_c ful_c[2048];
|
||||
|
||||
_boot_home(dir_c, pil_c, url_c, arv_c);
|
||||
|
||||
snprintf(ful_c, 2048, "%s/.urb/urbit.pill", dir_c);
|
||||
u3l_log("boot: loading %s\r\n", ful_c);
|
||||
|
||||
{
|
||||
u3_noun pil = u3m_file(ful_c);
|
||||
u3_noun sys, bot;
|
||||
|
||||
{
|
||||
u3_noun pro = u3m_soft(0, u3ke_cue, u3k(pil));
|
||||
|
||||
if ( 0 != u3h(pro) ) {
|
||||
u3l_log("boot: failed: unable to parse pill\r\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sys = u3k(u3t(pro));
|
||||
u3z(pro);
|
||||
}
|
||||
|
||||
// XX confirm trel of lists?
|
||||
//
|
||||
if ( c3n == u3r_trel(sys, &bot, 0, 0) ) {
|
||||
u3l_log("boot: failed: obsolete pill structure\r\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
u3v_boot(u3k(bot));
|
||||
|
||||
u3z(sys);
|
||||
u3z(pil);
|
||||
}
|
||||
}
|
||||
else {
|
||||
u3v_hose();
|
||||
u3j_ream();
|
||||
u3n_ream();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* u3m_boot_new(): start the u3 system (new). return next event,
|
||||
** starting from 1.
|
||||
/* u3m_boot(): start the u3 system. return next event, starting from 1.
|
||||
*/
|
||||
c3_d
|
||||
u3m_boot_new(c3_c* dir_c)
|
||||
u3m_boot(c3_c* dir_c)
|
||||
{
|
||||
c3_o nuu_o;
|
||||
|
||||
@ -1883,10 +1654,10 @@ u3m_boot_new(c3_c* dir_c)
|
||||
}
|
||||
}
|
||||
|
||||
/* u3m_boot_pier(): start without checkpointing.
|
||||
/* u3m_boot_lite(): start without checkpointing.
|
||||
*/
|
||||
c3_d
|
||||
u3m_boot_pier(void)
|
||||
u3m_boot_lite(void)
|
||||
{
|
||||
/* Activate the loom.
|
||||
*/
|
||||
|
@ -840,7 +840,7 @@ u3_daemon_commence()
|
||||
sag_w = u3C.wag_w;
|
||||
u3C.wag_w |= u3o_hashless;
|
||||
|
||||
u3m_boot_pier();
|
||||
u3m_boot_lite();
|
||||
|
||||
// wire up signal controls
|
||||
//
|
||||
|
@ -928,7 +928,7 @@ main(c3_i argc, c3_c* argv[])
|
||||
/* boot image
|
||||
*/
|
||||
{
|
||||
u3V.sen_d = u3V.dun_d = u3m_boot_new(dir_c);
|
||||
u3V.sen_d = u3V.dun_d = u3m_boot(dir_c);
|
||||
u3C.stderr_log_f = _worker_send_stdr;
|
||||
u3C.slog_f = _worker_send_slog;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user