remove URBIT_HOME

New piers are structured as so:

cpu/.urb/{urbit.pill,chk,sis,get,put,code.~dansut-docfyn}
cpu/dansut-docfyn-dozzod-dozzod--dozzod-dozzod-dozzod-dozzod/{try,main,arvo}
This commit is contained in:
~hatteb-mitlyd 2014-05-13 12:22:07 -07:00
parent 43c3988995
commit 4daa9a6ed9
8 changed files with 52 additions and 129 deletions

View File

@ -28,7 +28,7 @@ ENDIAN=little
#
BIN=bin
LIB=$(PWD)/lib
LIB=$(PWD)/urb
RM=rm -f
CC=gcc

View File

@ -113,10 +113,13 @@ _wr_open(c3_c* cpu_c, c3_c* fil_c, c3_c* suf_c, c3_w len_w)
snprintf(ful_c, 8193, "%s", cpu_c);
mkdir(ful_c, 0700);
snprintf(ful_c, 8193, "%s/chk", cpu_c);
snprintf(ful_c, 8193, "%s/.urb", cpu_c);
mkdir(ful_c, 0700);
snprintf(ful_c, 8193, "%s/chk/%s.%s", cpu_c, fil_c, suf_c);
snprintf(ful_c, 8193, "%s/.urb/chk", cpu_c);
mkdir(ful_c, 0700);
snprintf(ful_c, 8193, "%s/.urb/chk/%s.%s", cpu_c, fil_c, suf_c);
fid_i = open(ful_c, O_RDWR | O_CREAT, 0666);
if ( -1 == fid_i ) {
perror(ful_c); exit(1);

View File

@ -494,9 +494,7 @@
/* u2_opts: command line configuration.
*/
typedef struct _u2_opts {
c3_c* cpu_c; // pier name
c3_c* imp_c; // -I, czar name
c3_c* hom_c; // -h, urbit home
c3_c* nam_c; // -n, unix hostname
c3_c* raf_c; // -r, raft flotilla
c3_w kno_w; // -k, kernel version

View File

@ -72,7 +72,7 @@ _main_getopt(c3_i argc, c3_c** argv)
u2_Host.ops_u.vno = u2_no;
u2_Host.ops_u.kno_w = DefaultKernel;
while ( (ch_i = getopt(argc, argv, "I:X:f:h:k:l:n:p:r:Labcdgqv")) != -1 ) {
while ( (ch_i = getopt(argc, argv, "I:X:f:k:l:n:p:r:Labcdgqv")) != -1 ) {
switch ( ch_i ) {
case 'I': {
u2_Host.ops_u.imp_c = strdup(optarg);
@ -90,10 +90,6 @@ _main_getopt(c3_i argc, c3_c** argv)
}
break;
}
case 'h': {
u2_Host.ops_u.hom_c = strdup(optarg);
break;
}
case 'k': {
if ( u2_no == _main_readw(optarg, 256, &u2_Host.ops_u.kno_w) ) {
return u2_no;
@ -145,35 +141,6 @@ _main_getopt(c3_i argc, c3_c** argv)
u2_Host.ops_u.nuu = u2_yes;
}
if ( u2_Host.ops_u.hom_c == 0 ) {
u2_Host.ops_u.hom_c = getenv("URBIT_HOME");
if ( u2_Host.ops_u.hom_c == 0 ) {
fprintf(stderr, "$URBIT_HOME not set, falling back to $HOME/urbit\n");
c3_c* hom_c = getenv("HOME");
c3_w hom_w = strlen(hom_c) + 6;
if ( !hom_c ) {
fprintf(stderr, "$URBIT_HOME or $HOME must be set\n");
exit(1);
} else {
u2_Host.ops_u.hom_c = c3_malloc(hom_w + 1);
snprintf(u2_Host.ops_u.hom_c, hom_w + 1, "%s/urbit", hom_c);
}
}
{
DIR* rid_u;
if ( 0 == (rid_u = opendir(u2_Host.ops_u.hom_c)) ) {
if ( 0 != mkdir(u2_Host.ops_u.hom_c, 0755) ) {
perror(u2_Host.ops_u.hom_c);
exit(1);
}
}
else closedir(rid_u);
}
}
printf("vere: urbit home is %s\n", u2_Host.ops_u.hom_c);
if ( u2_Host.ops_u.nam_c == 0 ) {
u2_Host.ops_u.nam_c = getenv("HOSTNAME");
@ -188,10 +155,6 @@ _main_getopt(c3_i argc, c3_c** argv)
}
}
printf("\n");
printf("welcome.\n");
printf("vere: hostname is %s\n", u2_Host.ops_u.nam_c);
if ( argc != (optind + 1) ) {
return u2_no;
} else {
@ -203,7 +166,7 @@ _main_getopt(c3_i argc, c3_c** argv)
}
}
u2_Host.ops_u.cpu_c = strdup(argv[optind]);
u2_Host.cpu_c = strdup(argv[optind]);
return u2_yes;
}
}
@ -232,11 +195,8 @@ u2_ve_panic(c3_i argc, c3_c** argv)
static void
u2_ve_sysopt()
{
{
u2_Local = strdup(u2_Host.ops_u.cpu_c);
}
u2_Local = strdup(u2_Host.cpu_c);
u2_System = U2_LIB;
u2_Flag_Abort = u2_Host.ops_u.abo;
u2_Flag_Garbage = u2_Host.ops_u.gab;
u2_Flag_Profile = u2_Host.ops_u.pro;
@ -290,8 +250,14 @@ main(c3_i argc,
u2_ve_usage(argc, argv);
return 1;
}
u2_ve_sysopt();
printf("\n");
printf("welcome.\n");
printf("vere: urbit home is %s\n", u2_Host.cpu_c);
printf("vere: hostname is %s\n", u2_Host.ops_u.nam_c);
if ( u2_yes == u2_Host.ops_u.dem && u2_no == u2_Host.ops_u.bat ) {
printf("Starting daemon\n");
}
@ -302,7 +268,7 @@ main(c3_i argc,
// Instantiate process globals.
{
u2_wr_check_init(u2_Host.ops_u.cpu_c);
u2_wr_check_init(u2_Host.cpu_c);
u2_Host.xit_i = 0;
if ( (u2_no == u2_Host.ops_u.nuu) &&
(u2_yes == u2_loom_load()) )
@ -310,7 +276,6 @@ main(c3_i argc,
u2_Host.wir_r = u2_ray_of(0, 0);
u2_Wire = u2_Host.wir_r;
u2_Host.cpu_c = u2_Host.ops_u.cpu_c;
u2_Host.arv_u = u2_Arv;
u2_Arv->ova.egg_u = u2_Arv->ova.geg_u = 0;
@ -329,7 +294,6 @@ main(c3_i argc,
u2_Host.wir_r = u2_wr_init(c3__rock, u2_ray_of(0, 0), u2_ray_of(1, 0));
u2_Wire = u2_Host.wir_r;
u2_Host.cpu_c = u2_Host.ops_u.cpu_c;
u2_Host.arv_u = u2_Arv;
}
}

View File

@ -393,9 +393,9 @@ u2_reck_cold(u2_reck* rec_u, c3_w kno_w)
c3_c ful_c[2048];
if ( u2_yes == u2_Host.ops_u.nuu ) {
snprintf(ful_c, 2048, "%s/urbit.pill", u2_Host.ops_u.hom_c);
snprintf(ful_c, 2048, "%s/urbit.pill", U2_LIB);
} else {
snprintf(ful_c, 2048, "%s/urbit.pill", u2_Host.ops_u.cpu_c);
snprintf(ful_c, 2048, "%s/urbit.pill", u2_Host.cpu_c);
}
printf("loading %s\n", ful_c);
@ -432,30 +432,6 @@ u2_reck_cold(u2_reck* rec_u, c3_w kno_w)
u2z(u2_reck_gate("mook"));
}
#if 0
rec_u->toy.rain = u2_reck_wish(rec_u, "rain");
rec_u->toy.ream = u2_reck_wish(rec_u, "ream");
rec_u->toy.slay = u2_reck_wish(rec_u, "slay");
rec_u->toy.slaw = u2_reck_wish(rec_u, "slaw");
rec_u->toy.slam = u2_reck_wish(rec_u, "slam");
rec_u->toy.slap = u2_reck_wish(rec_u, "slap");
rec_u->toy.slop = u2_reck_wish(rec_u, "slop");
rec_u->toy.scot = u2_reck_wish(rec_u, "scot");
rec_u->toy.spat = u2_reck_wish(rec_u, "spat");
rec_u->toy.stab = u2_reck_wish(rec_u, "stab");
rec_u->toy.turf = u2_reck_wish(rec_u, "turf");
rec_u->toy.tuft = u2_reck_wish(rec_u, "tuft");
rec_u->toy.wash = u2_reck_wish(rec_u, "wash");
rec_u->toy.hoof = u2_reck_wish(rec_u, "hoof");
rec_u->toy.mook = u2_reck_wish(rec_u, "mook");
rec_u->toy.sham = u2_reck_wish(rec_u, "sham");
rec_u->toy.shen = u2_reck_wish(rec_u, "en:crua");
rec_u->toy.shed = u2_reck_wish(rec_u, "de:crua");
rec_u->toy.cyst = u2_reck_wish(rec_u, "cyst");
rec_u->toy.lump = u2_reck_wish(rec_u, "lump");
#endif
u2_reck_time(rec_u);
u2_reck_numb(rec_u);
@ -490,23 +466,6 @@ u2_reck_init(u2_reck* rec_u, c3_w kno_w, u2_noun ken)
else {
rec_u->ken = ken;
rec_u->roc = u2_cn_nock(0, u2k(ken));
#if 0
rec_u->toy.rain = u2_reck_wish(rec_u, "rain");
rec_u->toy.ream = u2_reck_wish(rec_u, "ream");
rec_u->toy.slay = u2_reck_wish(rec_u, "slay");
rec_u->toy.slaw = u2_reck_wish(rec_u, "slaw");
rec_u->toy.slam = u2_reck_wish(rec_u, "slam");
rec_u->toy.slap = u2_reck_wish(rec_u, "slap");
rec_u->toy.slop = u2_reck_wish(rec_u, "slop");
rec_u->toy.scot = u2_reck_wish(rec_u, "scot");
rec_u->toy.spat = u2_reck_wish(rec_u, "spat");
rec_u->toy.stab = u2_reck_wish(rec_u, "stab");
rec_u->toy.turf = u2_reck_wish(rec_u, "turf");
rec_u->toy.tuft = u2_reck_wish(rec_u, "tuft");
rec_u->toy.wash = u2_reck_wish(rec_u, "wash");
rec_u->toy.hoof = u2_reck_wish(rec_u, "hoof");
rec_u->toy.mook = u2_reck_wish(rec_u, "mook");
#endif
// Direct poke to install tang/vanes. Shd be in egz but isnt.
//
{

View File

@ -91,7 +91,7 @@ u2_sist_put(const c3_c* key_c, const c3_y* val_y, size_t siz_i)
c3_i ret_i;
c3_i fid_i;
ret_i = snprintf(ful_c, 2048, "%s/sis/_%s", u2_Host.cpu_c, key_c);
ret_i = snprintf(ful_c, 2048, "%s/.urb/sis/_%s", u2_Host.cpu_c, key_c);
c3_assert(ret_i < 2048);
if ( (fid_i = open(ful_c, O_CREAT | O_TRUNC | O_WRONLY, 0600)) < 0 ) {
@ -123,7 +123,7 @@ u2_sist_has(const c3_c* key_c)
c3_i ret_i;
struct stat sat_u;
ret_i = snprintf(ful_c, 2048, "%s/sis/_%s", u2_Host.cpu_c, key_c);
ret_i = snprintf(ful_c, 2048, "%s/.urb/sis/_%s", u2_Host.cpu_c, key_c);
c3_assert(ret_i < 2048);
if ( (ret_i = stat(ful_c, &sat_u)) < 0 ) {
@ -152,7 +152,7 @@ u2_sist_get(const c3_c* key_c, c3_y* val_y)
c3_i fid_i;
struct stat sat_u;
ret_i = snprintf(ful_c, 2048, "%s/sis/_%s", u2_Host.cpu_c, key_c);
ret_i = snprintf(ful_c, 2048, "%s/.urb/sis/_%s", u2_Host.cpu_c, key_c);
c3_assert(ret_i < 2048);
if ( (fid_i = open(ful_c, O_RDONLY)) < 0 ) {
@ -184,7 +184,7 @@ u2_sist_nil(const c3_c* key_c)
c3_c ful_c[2048];
c3_i ret_i;
ret_i = snprintf(ful_c, 2048, "%s/sis/_%s", u2_Host.cpu_c, key_c);
ret_i = snprintf(ful_c, 2048, "%s/.urb/sis/_%s", u2_Host.cpu_c, key_c);
c3_assert(ret_i < 2048);
if ( (ret_i = unlink(ful_c)) < 0 ) {
@ -274,19 +274,22 @@ _sist_home(u2_reck* rec_u)
{
mkdir(u2_Host.cpu_c, 0700);
snprintf(ful_c, 2048, "%s/get", u2_Host.cpu_c);
snprintf(ful_c, 2048, "%s/.urb", u2_Host.cpu_c);
mkdir(ful_c, 0700);
snprintf(ful_c, 2048, "%s/.urb/get", u2_Host.cpu_c);
if ( 0 != mkdir(ful_c, 0700) ) {
perror(ful_c);
u2_lo_bail(rec_u);
}
snprintf(ful_c, 2048, "%s/put", u2_Host.cpu_c);
snprintf(ful_c, 2048, "%s/.urb/put", u2_Host.cpu_c);
if ( 0 != mkdir(ful_c, 0700) ) {
perror(ful_c);
u2_lo_bail(rec_u);
}
snprintf(ful_c, 2048, "%s/sis", u2_Host.cpu_c);
snprintf(ful_c, 2048, "%s/.urb/sis", u2_Host.cpu_c);
if ( 0 != mkdir(ful_c, 0700) ) {
perror(ful_c);
u2_lo_bail(rec_u);
@ -296,8 +299,19 @@ _sist_home(u2_reck* rec_u)
// Copy urbit.pill.
//
{
snprintf(ful_c, 2048, "cp %s/urbit.pill %s",
u2_Host.ops_u.hom_c, u2_Host.cpu_c);
snprintf(ful_c, 2048, "cp %s/urbit.pill %s/.urb",
U2_LIB, u2_Host.cpu_c);
if ( 0 != system(ful_c) ) {
uL(fprintf(uH, "could not %s\n", ful_c));
u2_lo_bail(rec_u);
}
}
// Copy zod files, if we're generating zod.
//
if ( u2_Host.ops_u.imp_c && 0 == strcmp(u2_Host.ops_u.imp_c, "~zod") ) {
snprintf(ful_c, 2048, "cp -r %s/zod %s/",
U2_LIB, u2_Host.cpu_c);
if ( 0 != system(ful_c) ) {
uL(fprintf(uH, "could not %s\n", ful_c));
u2_lo_bail(rec_u);
@ -437,21 +451,18 @@ static void
_sist_fast(u2_reck* rec_u, u2_noun pas, c3_l key_l)
{
c3_c ful_c[2048];
c3_c* hom_c = getenv("HOME");
c3_c* hom_c = u2_Host.cpu_c;
u2_noun gum = u2_dc("scot", 'p', key_l);
c3_c* gum_c = u2_cr_string(gum);
u2_noun yek = u2_dc("scot", 'p', pas);
c3_c* yek_c = u2_cr_string(yek);
printf("saving passcode in %s/.urbit/%s.txt\r\n", hom_c, gum_c);
printf("saving passcode in %s/.urb/code.%s\r\n", hom_c, gum_c);
printf("(for real security, write it down and delete the file...)\r\n");
{
c3_i fid_i;
snprintf(ful_c, 2048, "%s/.urbit", hom_c);
mkdir(ful_c, 0700);
snprintf(ful_c, 2048, "%s/.urbit/%s.txt", hom_c, gum_c);
snprintf(ful_c, 2048, "%s/.urb/code.%s", hom_c, gum_c);
if ( (fid_i = open(ful_c, O_CREAT | O_TRUNC | O_WRONLY, 0600)) < 0 ) {
uL(fprintf(uH, "fast: could not save %s\n", ful_c));
u2_lo_bail(rec_u);
@ -472,12 +483,12 @@ static u2_noun
_sist_staf(u2_reck* rec_u, c3_l key_l)
{
c3_c ful_c[2048];
c3_c* hom_c = getenv("HOME");
c3_c* hom_c = u2_Host.cpu_c;
u2_noun gum = u2_dc("scot", 'p', key_l);
c3_c* gum_c = u2_cr_string(gum);
u2_noun txt;
snprintf(ful_c, 2048, "%s/.urbit/%s.txt", hom_c, gum_c);
snprintf(ful_c, 2048, "%s/.urb/code.%s", hom_c, gum_c);
free(gum_c);
u2z(gum);
txt = u2_walk_safe(ful_c);
@ -540,7 +551,7 @@ _sist_zest(u2_reck* rec_u)
// Create the record file.
{
snprintf(ful_c, 2048, "%s/egz.hope", u2_Host.cpu_c);
snprintf(ful_c, 2048, "%s/.urb/egz.hope", u2_Host.cpu_c);
if ( ((fid_i = open(ful_c, O_CREAT | O_WRONLY | O_EXCL, 0600)) < 0) ||
(fstat(fid_i, &buf_b) < 0) )
@ -694,7 +705,7 @@ _sist_rest_nuu(u2_ulog* lug_u, u2_uled led_u, c3_c* old_c)
u2_lo_bail(u2A);
}
ret_i = snprintf(nuu_c, 2048, "%s/ham.hope", u2_Host.cpu_c);
ret_i = snprintf(nuu_c, 2048, "%s/.urb/ham.hope", u2_Host.cpu_c);
c3_assert(ret_i < 2048);
if ( (fud_i = open(nuu_c, O_CREAT | O_TRUNC | O_RDWR, 0600)) < 0 ) {
@ -779,18 +790,6 @@ _sist_rest(u2_reck* rec_u)
u2_noun sev_l, tno_l, key_l, sal_l;
u2_bean ohh = u2_no;
// XX delete me -- needed for piers created on old code.
{
snprintf(ful_c, 2048, "%s/sis", u2_Host.cpu_c);
if ( 0 != mkdir(ful_c, 0700) ) {
if ( errno != EEXIST ) {
perror(ful_c);
u2_lo_bail(rec_u);
}
}
}
if ( 0 != rec_u->ent_d ) {
u2_noun ent;
c3_c* ent_c;
@ -805,7 +804,7 @@ _sist_rest(u2_reck* rec_u)
// Open the fscking file. Does it even exist?
{
snprintf(ful_c, 2048, "%s/egz.hope", u2_Host.cpu_c);
snprintf(ful_c, 2048, "%s/.urb/egz.hope", u2_Host.cpu_c);
if ( ((fid_i = open(ful_c, O_RDWR)) < 0) ||
(fstat(fid_i, &buf_b) < 0) )
@ -1182,7 +1181,7 @@ u2_sist_boot(void)
if ( 0 == u2_Host.ops_u.imp_c ) {
c3_c get_c[2049];
snprintf(get_c, 2048, "%s/get", u2_Host.cpu_c);
snprintf(get_c, 2048, "%s/.urb/get", u2_Host.cpu_c);
if ( 0 == access(get_c, 0) ) {
uL(fprintf(uH, "pier: already built\n"));
u2_lo_bail(u2A);

View File

@ -507,7 +507,7 @@ _term_it_save(u2_noun pax, u2_noun pad)
{
c3_c* pax_c;
pax = u2nc(c3_s3('p','u','t'), pax);
pax = u2nt(c3_s4('.','u','r','b'), c3_s3('p','u','t'), pax);
pax_c = _term_it_path(u2_yes, pax);
u2_walk_save(pax_c, 0, pad);

View File

@ -820,7 +820,7 @@ _unix_hot_gain(u2_noun who, u2_bean mek)
{
u2_noun hox = u2_dc("scot", 'p', u2k(who));
c3_c* hox_c = u2_cr_string(hox);
c3_c* pax_c = _unix_down(u2_Host.ops_u.hom_c, hox_c + 1);
c3_c* pax_c = _unix_down(u2_Host.cpu_c, hox_c + 1);
DIR* rid_u = opendir(pax_c);
if ( !rid_u ) {