diff options
author | jkh <jkh@FreeBSD.org> | 1998-11-15 09:06:20 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1998-11-15 09:06:20 +0000 |
commit | ffd97e5342d926be2f35b764575b61c28801658c (patch) | |
tree | f6d951a8fdaddd587487ae7d5a84ea7702875b0a /usr.sbin/sade | |
parent | c0977927244cf33b27cc7a36fa0db9652260b50f (diff) | |
download | FreeBSD-src-ffd97e5342d926be2f35b764575b61c28801658c.zip FreeBSD-src-ffd97e5342d926be2f35b764575b61c28801658c.tar.gz |
o Break fixups into binary fixups and XFree86 based fixups.
o Move fixups into extraction routine so all consumers don't have to duplicate
the right behavior.
o Make some things more orthogonal (just for asthetics sake)
o Add option to go back and do it again if XF86Setup fails (possibly with
a different setup - this one has always annoyed me).
Diffstat (limited to 'usr.sbin/sade')
-rw-r--r-- | usr.sbin/sade/config.c | 55 | ||||
-rw-r--r-- | usr.sbin/sade/dispatch.c | 5 | ||||
-rw-r--r-- | usr.sbin/sade/install.c | 114 | ||||
-rw-r--r-- | usr.sbin/sade/sade.h | 9 |
4 files changed, 96 insertions, 87 deletions
diff --git a/usr.sbin/sade/config.c b/usr.sbin/sade/config.c index 9c9ca8c..878a232 100644 --- a/usr.sbin/sade/config.c +++ b/usr.sbin/sade/config.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: config.c,v 1.113 1998/09/30 12:33:28 jkh Exp $ + * $Id: config.c,v 1.114 1998/10/14 01:04:44 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -168,7 +168,7 @@ seq_num(Chunk *c1) } int -configFstab(void) +configFstab(dialogMenuItem *self) { Device **devs; Disk *disk; @@ -213,49 +213,42 @@ configFstab(void) } chunk_list[nchunks] = 0; chunk_sort(); - + fstab = fopen("/etc/fstab", "w"); if (!fstab) { msgConfirm("Unable to create a new /etc/fstab file! Manual intervention\n" "will be required."); return DITEM_FAILURE; } - + check_rootdev(chunk_list, nchunks); - + /* Go for the burn */ msgDebug("Generating /etc/fstab file\n"); fprintf(fstab, "# Device\t\tMountpoint\tFStype\tOptions\t\tDump\tPass#\n"); for (i = 0; i < nchunks; i++) fprintf(fstab, "/dev/%s\t\t%s\t\t%s\t%s\t\t%d\t%d\n", name_of(chunk_list[i]), mount_point(chunk_list[i]), fstype(chunk_list[i]), fstype_short(chunk_list[i]), seq_num(chunk_list[i]), seq_num(chunk_list[i])); - Mkdir("/proc"); - fprintf(fstab, "proc\t\t\t/proc\t\tprocfs\trw\t\t0\t0\n"); - + /* Now look for the CDROMs */ devs = deviceFind(NULL, DEVICE_TYPE_CDROM); cnt = deviceCount(devs); - - /* Write the first one out as /cdrom */ - if (cnt) { - if (Mkdir("/cdrom")) { - msgConfirm("Unable to make mount point for: /cdrom"); - } - else - fprintf(fstab, "/dev/%s\t\t/cdrom\t\tcd9660\tro,noauto\t0\t0\n", devs[0]->name); - } - - /* Write the others out as /cdrom<n> */ - for (i = 1; i < cnt; i++) { + + /* Write out the CDROM entries */ + for (i = 0; i < cnt; i++) { char cdname[10]; - - sprintf(cdname, "/cdrom%d", i); - if (Mkdir(cdname)) { + + sprintf(cdname, "/cdrom%s", i ? itoa(i) : ""); + if (Mkdir(cdname)) msgConfirm("Unable to make mount point for: %s", cdname); - } else fprintf(fstab, "/dev/%s\t\t%s\tcd9660\tro,noauto\t0\t0\n", devs[i]->name, cdname); } + + /* And finally, a /proc. */ + fprintf(fstab, "proc\t\t\t/proc\t\tprocfs\trw\t\t0\t0\n"); + Mkdir("/proc"); + fclose(fstab); if (isDebug()) msgDebug("Wrote out /etc/fstab file\n"); @@ -264,7 +257,7 @@ configFstab(void) /* Do the work of sucking in a config file. * config is the filename to read in. - * lines is a fixed (max) sized array of char *. + * lines is a fixed (max) sized array of char* * returns number of lines read. line contents * are malloc'd and must be freed by the caller. */ @@ -506,6 +499,7 @@ configXEnvironment(dialogMenuItem *self) char *config, *execfile; char *moused; +tryagain: dialog_clear_norefresh(); if (!dmenuOpenSimple(&MenuXF86Config, FALSE)) return DITEM_FAILURE | DITEM_RESTORE; @@ -538,6 +532,8 @@ configXEnvironment(dialogMenuItem *self) "utility."); dialog_clear(); systemExecute(execfile); + if (!file_readable("/etc/XF86Config") && !msgYesNo("The XFree86 configuration process seems to have\nfailed. Would you like to try again?")) + goto tryagain; return DITEM_SUCCESS | DITEM_RESTORE; } else { @@ -548,8 +544,8 @@ configXEnvironment(dialogMenuItem *self) } } -void -configResolv(void) +int +configResolv(dialogMenuItem *ditem) { FILE *fp; char *cp, *dp, *hp; @@ -560,7 +556,7 @@ configResolv(void) Mkdir("/etc"); fp = fopen("/etc/resolv.conf", "w"); if (!fp) - return; + return DITEM_FAILURE; if (variable_get(VAR_DOMAINNAME)) fprintf(fp, "domain\t%s\n", variable_get(VAR_DOMAINNAME)); fprintf(fp, "nameserver\t%s\n", cp); @@ -575,7 +571,7 @@ skip: /* Tack ourselves into /etc/hosts */ fp = fopen("/etc/hosts", "w"); if (!fp) - return; + return DITEM_FAILURE; /* Add an entry for localhost */ if (dp) fprintf(fp, "127.0.0.1\t\tlocalhost.%s localhost\n", dp); @@ -597,6 +593,7 @@ skip: fclose(fp); if (isDebug()) msgDebug("Wrote out /etc/hosts\n"); + return DITEM_SUCCESS; } int diff --git a/usr.sbin/sade/dispatch.c b/usr.sbin/sade/dispatch.c index 9bac849..5e1668a 100644 --- a/usr.sbin/sade/dispatch.c +++ b/usr.sbin/sade/dispatch.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: dispatch.c,v 1.24 1997/09/17 16:18:13 pst Exp $ + * $Id: dispatch.c,v 1.25 1998/07/18 09:41:58 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -82,7 +82,8 @@ static struct _word { { "installExpress", installExpress }, { "installNovice", installNovice }, { "installUpgrade", installUpgrade }, - { "installFixup", installFixup }, + { "installFixupBin", installFixupBin }, + { "installFixupXFree", installFixupXFree }, { "installFixitHoloShell", installFixitHoloShell }, { "installFixitCDROM", installFixitCDROM }, { "installFixitFloppy", installFixitFloppy }, diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c index 856b8bc..a9f1f62 100644 --- a/usr.sbin/sade/install.c +++ b/usr.sbin/sade/install.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: install.c,v 1.216 1998/10/13 10:07:43 jkh Exp $ + * $Id: install.c,v 1.217 1998/10/23 10:27:50 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -197,6 +197,7 @@ static int installInitial(void) { static Boolean alreadyDone = FALSE; + int status = DITEM_SUCCESS; if (alreadyDone) return DITEM_SUCCESS; @@ -240,13 +241,18 @@ installInitial(void) chdir("/"); variable_set2(RUNNING_ON_ROOT, "yes"); - configResolv(); + + /* Configure various files in /etc */ + if (DITEM_STATUS(configResolv(NULL)) == DITEM_FAILURE) + status = DITEM_FAILURE; + if (DITEM_STATUS(configFstab(NULL)) == DITEM_FAILURE) + status = DITEM_FAILURE; /* stick a helpful shell over on the 4th VTY */ systemCreateHoloshell(); alreadyDone = TRUE; - return DITEM_SUCCESS; + return status; } int @@ -665,7 +671,6 @@ installCommit(dialogMenuItem *self) { int i; char *str; - Boolean need_bin; if (!Dists) distConfig(NULL); @@ -681,13 +686,9 @@ installCommit(dialogMenuItem *self) if (isDebug()) msgDebug("installCommit: System state is `%s'\n", str); - if (RunningAsInit) { - /* Do things we wouldn't do to a multi-user system */ - if (DITEM_STATUS((i = installInitial())) == DITEM_FAILURE) - return i; - if (DITEM_STATUS((i = configFstab())) == DITEM_FAILURE) - return i; - } + /* Installation stuff we wouldn't do to a running system */ + if (RunningAsInit && DITEM_STATUS((i = installInitial())) == DITEM_FAILURE) + return i; try_media: if (!mediaDevice->init(mediaDevice)) { @@ -703,11 +704,9 @@ try_media: return DITEM_FAILURE | DITEM_RESTORE; } - need_bin = Dists & DIST_BIN; + /* Now go get it all */ i = distExtractAll(self); - /* Only do fixup if bin dist was successfully extracted */ - if (need_bin && !(Dists & DIST_BIN)) - i |= installFixup(self); + /* When running as init, *now* it's safe to grab the rc.foo vars */ installEnvironment(); @@ -733,33 +732,35 @@ installConfigure(void) } int -installFixup(dialogMenuItem *self) +installFixupBin(dialogMenuItem *self) { Device **devs; int i; - if (!file_readable("/kernel")) { - if (file_readable("/kernel.GENERIC")) { - if (vsystem("cp -p /kernel.GENERIC /kernel")) { - msgConfirm("Unable to link /kernel into place!"); - return DITEM_FAILURE; - } + /* All of this is done only as init, just to be safe */ + if (RunningAsInit) { + /* Fix up kernel first */ + if (!file_readable("/kernel")) { + if (file_readable("/kernel.GENERIC")) { + if (vsystem("cp -p /kernel.GENERIC /kernel")) { + msgConfirm("Unable to copy /kernel into place!"); + return DITEM_FAILURE; + } #ifdef SAVE_USERCONFIG - /* Snapshot any boot -c changes back to the new kernel */ - if (!variable_cmp(VAR_RELNAME, RELEASE_NAME)) - save_userconfig_to_kernel("/kernel"); + /* Snapshot any boot -c changes back to the new kernel */ + if (!variable_cmp(VAR_RELNAME, RELEASE_NAME)) + save_userconfig_to_kernel("/kernel"); #endif + } + else { + msgConfirm("Can't find a kernel image to link to on the root file system!\n" + "You're going to have a hard time getting this system to\n" + "boot from the hard disk, I'm afraid!"); + return DITEM_FAILURE; + } } - else { - msgConfirm("Can't find a kernel image to link to on the root file system!\n" - "You're going to have a hard time getting this system to\n" - "boot from the hard disk, I'm afraid!"); - return DITEM_FAILURE; - } - } - - /* Resurrect /dev after bin distribution screws it up */ - if (RunningAsInit) { + + /* BOGON #1: Resurrect /dev after bin distribution screws it up */ msgNotify("Remaking all devices.. Please wait!"); if (vsystem("cd /dev; sh MAKEDEV all")) { msgConfirm("MAKEDEV returned non-zero status"); @@ -775,7 +776,7 @@ installFixup(dialogMenuItem *self) for (i = 0; devs[i]; i++) { Disk *disk = (Disk *)devs[i]->private; Chunk *c1; - + if (!devs[i]->enabled) continue; if (!disk->chunks) @@ -790,30 +791,18 @@ installFixup(dialogMenuItem *self) } } } - - /* Do all the last ugly work-arounds here */ - msgNotify("Fixing permissions.."); - /* BOGON #1: XFree86 requires various specialized fixups */ - if (directory_exists("/usr/X11R6")) { - vsystem("chmod -R a+r /usr/X11R6"); - vsystem("find /usr/X11R6 -type d | xargs chmod a+x"); - - /* Also do bogus minimal package registration so ports don't whine */ - if (file_readable("/usr/X11R6/lib/X11/pkgreg.tar.gz")) - vsystem("tar xpzf /usr/X11R6/lib/X11/pkgreg.tar.gz -C / && rm /usr/X11R6/lib/X11/pkgreg.tar.gz"); - } - + /* BOGON #2: We leave /etc in a bad state */ chmod("/etc", 0755); - + /* BOGON #3: No /var/db/mountdtab complains */ Mkdir("/var/db"); creat("/var/db/mountdtab", 0644); - + /* BOGON #4: /compat created by default in root fs */ Mkdir("/usr/compat"); vsystem("ln -s /usr/compat /compat"); - + /* BOGON #5: aliases database not build for bin */ vsystem("newaliases"); @@ -827,6 +816,27 @@ installFixup(dialogMenuItem *self) vsystem("mtree -deU -f /etc/mtree/BSD.root.dist -p /"); vsystem("mtree -deU -f /etc/mtree/BSD.var.dist -p /var"); vsystem("mtree -deU -f /etc/mtree/BSD.usr.dist -p /usr"); + + /* Do all the last ugly work-arounds here */ + } + return DITEM_SUCCESS; +} + +/* Fix side-effects from the the XFree86 installation */ +int +installFixupXFree(dialogMenuItem *self) +{ + /* BOGON #1: XFree86 requires various specialized fixups */ + if (directory_exists("/usr/X11R6")) { + msgNotify("Fixing permissions in XFree86 tree.."); + vsystem("chmod -R a+r /usr/X11R6"); + vsystem("find /usr/X11R6 -type d | xargs chmod a+x"); + + /* Also do bogus minimal package registration so ports don't whine */ + if (file_readable("/usr/X11R6/lib/X11/pkgreg.tar.gz")) { + msgNotify("Installing package metainfo.."); + vsystem("tar xpzf /usr/X11R6/lib/X11/pkgreg.tar.gz -C / && rm /usr/X11R6/lib/X11/pkgreg.tar.gz"); + } } return DITEM_SUCCESS; } diff --git a/usr.sbin/sade/sade.h b/usr.sbin/sade/sade.h index c74c423..0024b73 100644 --- a/usr.sbin/sade/sade.h +++ b/usr.sbin/sade/sade.h @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: sysinstall.h,v 1.148 1998/09/30 11:49:37 jkh Exp $ + * $Id: sysinstall.h,v 1.149 1998/10/14 11:23:48 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -407,13 +407,13 @@ extern void command_shell_add(char *key, char *fmt, ...); extern void command_func_add(char *key, commandFunc func, void *data); /* config.c */ -extern int configFstab(void); extern void configEnvironmentRC_conf(char *config); extern void configEnvironmentResolv(char *config); extern void configRC_conf(char *config); +extern int configFstab(dialogMenuItem *self); extern int configRC(dialogMenuItem *self); extern int configRegister(dialogMenuItem *self); -extern void configResolv(void); +extern int configResolv(dialogMenuItem *self); extern int configPackages(dialogMenuItem *self); extern int configSaver(dialogMenuItem *self); extern int configSaverTimeout(dialogMenuItem *self); @@ -537,7 +537,8 @@ extern int installNovice(dialogMenuItem *self); extern int installFixitHoloShell(dialogMenuItem *self); extern int installFixitCDROM(dialogMenuItem *self); extern int installFixitFloppy(dialogMenuItem *self); -extern int installFixup(dialogMenuItem *self); +extern int installFixupBin(dialogMenuItem *self); +extern int installFixupXFree(dialogMenuItem *self); extern int installUpgrade(dialogMenuItem *self); extern int installFilesystems(dialogMenuItem *self); extern int installVarDefaults(dialogMenuItem *self); |