diff options
author | jkh <jkh@FreeBSD.org> | 1995-04-29 19:33:06 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1995-04-29 19:33:06 +0000 |
commit | fe13bd0b5e978f8a7c822e5dd4d039a5981f7204 (patch) | |
tree | ab80745bc8d6737d2054b314ccdba01ec7273564 | |
parent | 3710598186a6d9cf7b16aac1100f0197134ef8a9 (diff) | |
download | FreeBSD-src-fe13bd0b5e978f8a7c822e5dd4d039a5981f7204.zip FreeBSD-src-fe13bd0b5e978f8a7c822e5dd4d039a5981f7204.tar.gz |
o Add extra menu types (radio implemented, multiple choice shortly).
o Make the framework generally more robust.
o Figured out how to nest the menu descriptions - no more grotty initialization
of menus.
o Fix bug with helpline and helpfile not being reset.
o Add stubs for the media selection code.
Coming next: Fdisk and disklabel screens using Phk's new libdisk stuff.
-rw-r--r-- | release/sysinstall/dmenu.c | 143 | ||||
-rw-r--r-- | release/sysinstall/install.c | 7 | ||||
-rw-r--r-- | release/sysinstall/media.c | 52 | ||||
-rw-r--r-- | release/sysinstall/menus.c | 177 | ||||
-rw-r--r-- | release/sysinstall/misc.c | 14 | ||||
-rw-r--r-- | release/sysinstall/sysinstall.h | 65 | ||||
-rw-r--r-- | release/sysinstall/system.c | 70 | ||||
-rw-r--r-- | usr.sbin/sade/dmenu.c | 143 | ||||
-rw-r--r-- | usr.sbin/sade/install.c | 7 | ||||
-rw-r--r-- | usr.sbin/sade/menus.c | 177 | ||||
-rw-r--r-- | usr.sbin/sade/misc.c | 14 | ||||
-rw-r--r-- | usr.sbin/sade/sade.h | 65 | ||||
-rw-r--r-- | usr.sbin/sade/system.c | 70 | ||||
-rw-r--r-- | usr.sbin/sysinstall/dmenu.c | 143 | ||||
-rw-r--r-- | usr.sbin/sysinstall/install.c | 7 | ||||
-rw-r--r-- | usr.sbin/sysinstall/media.c | 52 | ||||
-rw-r--r-- | usr.sbin/sysinstall/menus.c | 177 | ||||
-rw-r--r-- | usr.sbin/sysinstall/misc.c | 14 | ||||
-rw-r--r-- | usr.sbin/sysinstall/sysinstall.h | 65 | ||||
-rw-r--r-- | usr.sbin/sysinstall/system.c | 70 |
20 files changed, 936 insertions, 596 deletions
diff --git a/release/sysinstall/dmenu.c b/release/sysinstall/dmenu.c index b792f49..f49e4cd 100644 --- a/release/sysinstall/dmenu.c +++ b/release/sysinstall/dmenu.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated for what's essentially a complete rewrite. * - * $Id: dmenu.c,v 1.1.1.1 1995/04/27 12:50:34 jkh Exp $ + * $Id: dmenu.c,v 1.2 1995/04/27 18:03:52 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -42,11 +42,10 @@ */ #include "sysinstall.h" -#include <sys/wait.h> -#define MAX_MENU 15 +#define MAX_MENU 15 -static DMenuItem shellAction = { NULL, NULL, MENU_SHELL_ESCAPE, NULL, 0 }; +static DMenuItem shellAction = { NULL, NULL, DMENU_SHELL_ESCAPE, NULL, 0 }; /* Traverse over an internal menu */ void @@ -55,36 +54,64 @@ dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max) char result[FILENAME_MAX]; char **nitems = NULL; DMenuItem *tmp; - int rval, n = 0; - char *sh = NULL; + int rval = 0, n = 0; /* First, construct the menu */ for (tmp = menu->items; tmp->title; tmp++) { if (!tmp->disabled) { - nitems = item_add(nitems, tmp->title, curr, max); - nitems = item_add(nitems, tmp->prompt, curr, max); + char *addme = NULL; + char *title = tmp->title; + char *prompt = tmp->prompt; + + if (menu->options & DMENU_RADIO_TYPE) { + if (*title == '*') { + addme = "ON"; + ++title; + } + else + addme = "OFF"; + } + nitems = item_add_pair(nitems, title, prompt, curr, max); + if (addme) + nitems = item_add(nitems, addme, curr, max); ++n; } } nitems = item_add(nitems, NULL, curr, max); /* Terminate it */ - /* Any helpful hints, put 'em up! */ - if (menu->helpline) - use_helpline(menu->helpline); - if (menu->helpfile) - use_helpfile(menu->helpfile); - while (1) { + /* Any helpful hints, put 'em up! */ + if (menu->helpline) + use_helpline(menu->helpline); + if (menu->helpfile) + use_helpfile(menu->helpfile); + /* Pop up that dialog! */ - rval = dialog_menu((unsigned char *)menu->title, - (unsigned char *)menu->prompt, - -1, -1, n > MAX_MENU ? MAX_MENU : n, n, - (unsigned char **)nitems, (unsigned char *)result, - choice, scroll); + if (menu->options & DMENU_NORMAL_TYPE) { + rval = dialog_menu((unsigned char *)menu->title, + (unsigned char *)menu->prompt, + -1, -1, + n > MAX_MENU ? MAX_MENU : n, + n, + (unsigned char **)nitems, + (unsigned char *)result, + choice, scroll); + } + else if (menu->options & DMENU_RADIO_TYPE) { + rval = dialog_radiolist((unsigned char *)menu->title, + (unsigned char *)menu->prompt, + -1, -1, + n > MAX_MENU ? MAX_MENU : n, + n, + (unsigned char **)nitems, + (unsigned char *)result); + } dialog_clear(); if (!rval) { for (tmp = menu->items; tmp->title; tmp++) - if (!strcmp(result, tmp->title)) + if (!strcmp(result, + (*tmp->title == '*') ? tmp->title + 1 : + tmp->title)) break; if (!tmp->title) msgFatal("Menu item `%s' not found??", result); @@ -96,66 +123,18 @@ dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max) return; } switch (tmp->type) { - /* User whapped ESC twice and wants a sub-shell */ - case MENU_SHELL_ESCAPE: - if (file_executable("/bin/sh")) - sh = "/bin/sh"; - else if (file_executable("/stand/sh")) - sh = "/stand/sh"; - else { - msgWarn("No shell available, sorry!"); - break; - } - setenv("PS1", "freebsd% ", 1); - dialog_clear(); - dialog_update(); - move(0, 0); - standout(); - addstr("Type `exit' to leave this shell and continue install."); - standend(); - refresh(); - end_dialog(); - DialogActive = FALSE; - if (fork() == 0) - execlp(sh, "-sh", 0); - else - wait(NULL); - dialog_clear(); - DialogActive = TRUE; + case DMENU_SHELL_ESCAPE: + systemShellEscape(); break; /* We want to simply display a file */ - case MENU_DISPLAY_FILE: { - char buf[FILENAME_MAX], *cp, *fname = NULL; - - if (file_readable((char *)tmp->ptr)) - fname = (char *)tmp->ptr; - else if ((cp = getenv("LANG")) != NULL) { - snprintf(buf, FILENAME_MAX, "%s/%s", cp, tmp->ptr); - if (file_readable(buf)) - fname = buf; - } - else { - snprintf(buf, FILENAME_MAX, "english/%s", tmp->ptr); - if (file_readable(buf)) - fname = buf; - } - if (!fname) { - snprintf(buf, FILENAME_MAX, "The %s file is not provided on the 1.2MB floppy image.", (char *)tmp->ptr); - dialog_msgbox("Sorry!", buf, -1, -1, 1); - dialog_clear_norefresh(); - } - else { - dialog_clear_norefresh(); - dialog_textbox(tmp->title, fname, LINES, COLS); - dialog_clear_norefresh(); - } - } + case DMENU_DISPLAY_FILE: + systemDisplayFile((char *)tmp->ptr); break; /* It's a sub-menu; recurse on it */ - case MENU_SUBMENU: { + case DMENU_SUBMENU: { int choice, scroll, curr, max; choice = scroll = curr = max = 0; @@ -164,27 +143,27 @@ dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max) } /* Execute it as a system command */ - case MENU_SYSTEM_COMMAND: + case DMENU_SYSTEM_COMMAND: (void)systemExecute((char *)tmp->ptr); break; /* Same as above, but execute it in a prgbox */ - case MENU_SYSTEM_COMMAND_BOX: + case DMENU_SYSTEM_COMMAND_BOX: dialog_prgbox(tmp->title, (char *)tmp->ptr, 22, 76, 1, 1); break; - case MENU_CALL: + case DMENU_CALL: if (((int (*)())tmp->ptr)()) { items_free(nitems, curr, max); return; } break; - case MENU_CANCEL: + case DMENU_CANCEL: items_free(nitems, curr, max); return; - case MENU_SET_VARIABLE: { + case DMENU_SET_VARIABLE: { Variable *newvar; if (!index((char *)tmp->ptr, '=')) @@ -196,13 +175,19 @@ dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max) strncpy(newvar->value, tmp->ptr, 1024); newvar->next = VarHead; VarHead = newvar; - msgInfo("Set variable %s", newvar->value); + msgInfo("Setting option %s", newvar->value); } break; default: msgFatal("Don't know how to deal with menu type %d", tmp->type); } + + /* Did the user want to make this a single-selection menu? */ + if (menu->options & DMENU_SELECTION_RETURNS) { + items_free(nitems, curr, max); + return; + } } } diff --git a/release/sysinstall/install.c b/release/sysinstall/install.c index dcb5eb5..ee1efa0 100644 --- a/release/sysinstall/install.c +++ b/release/sysinstall/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.1.1.1 1995/04/27 12:50:35 jkh Exp $ + * $Id: install.c,v 1.2 1995/04/27 18:03:53 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -57,3 +57,8 @@ installExpress(void) return 0; } +int +installMaint(void) +{ + return 0; +} diff --git a/release/sysinstall/media.c b/release/sysinstall/media.c index 16fec45..b6febca 100644 --- a/release/sysinstall/media.c +++ b/release/sysinstall/media.c @@ -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$ + * $Id: media.c,v 1.1 1995/04/27 18:05:10 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -50,3 +50,53 @@ mediaSetCDROM(void) { return 0; } + +/* + * Return 0 if we successfully found and set the installation type to + * be a floppy + */ +int +mediaSetFloppy(void) +{ + return 0; +} + +/* + * Return 0 if we successfully found and set the installation type to + * be a DOS partition. + */ +int +mediaSetDOS(void) +{ + return 0; +} + +/* + * Return 0 if we successfully found and set the installation type to + * be a tape drive. + */ +int +mediaSetTape(void) +{ + return 0; +} + +/* + * Return 0 if we successfully found and set the installation type to + * be an ftp server + */ +int +mediaSetFTP(void) +{ + return 0; +} + +/* + * Return 0 if we successfully found and set the installation type to + * be some sort of mounted filesystem (it's also mounted at this point) + */ +int +mediaSetFS(void) +{ + return 0; +} diff --git a/release/sysinstall/menus.c b/release/sysinstall/menus.c index 3450a3e..c4afad5 100644 --- a/release/sysinstall/menus.c +++ b/release/sysinstall/menus.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: menus.c,v 1.1.1.1 1995/04/27 12:50:34 jkh Exp $ + * $Id: menus.c,v 1.2 1995/04/27 18:03:54 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -55,83 +55,9 @@ extern DMenu MenuMedia; extern DMenu MenuInstallType; extern DMenu MenuInstallOptions; -/* - * Bloody C won't let me nest these initializers properly - do the - * items and the menus containing them as two seperate initializers - * done in two groups. - */ - -/* First, the lists of items */ - -/* Documentation menu */ -DMenuItem _doc_items[] = { - { "README", "Read this for a general description of FreeBSD", /* R */ - MENU_DISPLAY_FILE, (void *)"help/readme.hlp", 0 }, - { "Hardware", "The FreeBSD survival guide for PC hardware.", /* H */ - MENU_DISPLAY_FILE, (void *)"help/hardware.hlp", 0 }, - { "Install", "A step-by-step guide to installing FreeBSD.", /* I */ - MENU_DISPLAY_FILE, (void *)"help/install.hlp", 0 }, - { "FAQ", "Frequently Asked Questions about FreeBSD.", /* F */ - MENU_DISPLAY_FILE, (void *)"help/faq.hlp", 0 }, - { NULL } -}; - -/* Language menu */ -DMenuItem _lang_items[] = { - { "English", "The system default language", /* E */ - MENU_SET_VARIABLE, (void *)"LANG=en", 0 }, - { "French", "French language and character set (ISO-8859-1)", /* F */ - MENU_SET_VARIABLE, (void *)"LANG=fr", 0 }, - { "German", "German language and character set (ISO-8859-1)", /* G */ - MENU_SET_VARIABLE, (void *)"LANG=de", 0 }, - { "Japanese", "Japanese language and character set (JIS?)", /* J */ - MENU_SET_VARIABLE, (void *)"LANG=jp", 0 }, - { "Russian", "Russian language and character set (cp866-8x14)", /* R */ - MENU_SET_VARIABLE, (void *)"LANG=ru", 0 }, - { NULL }, -}; - -/* The first menu */ -DMenuItem _initial_items[] = { - { "Usage", "Quick start - How to use this menu system.", /* U */ - MENU_DISPLAY_FILE, (void *)"help/initial.hlp", 0 }, - { "Doc", "More detailed documentation on FreeBSD.", /* D */ - MENU_SUBMENU, (void *)&MenuDocumentation, 0 }, - { "Lang", "Select natural language options.", /* L */ - MENU_SUBMENU, (void *)&MenuLanguage, 0 }, - { "Express", "Express installation (don't ask)", /* E */ - MENU_CALL, (void *)installExpress, 0 }, - { "Custom", "Custom installation (please ask)", /* C */ - MENU_CALL, (void *)installCustom, 0 }, - { NULL }, -}; - -/* Installation media menu */ -DMenuItem _media_items[] = { - { "CDROM", "Install from a FreeBSD CDROM", - MENU_CALL, (void *)mediaSetCDROM, 0 }, - { NULL }, -}; - -/* Installation main menu */ -DMenuItem _install_items[] = { - { "Media", "Choose Installation media type", /* M */ - MENU_SUBMENU, (void *)&MenuMedia, 0 }, - { "Type", "Choose the type of installation you want", /* T */ - MENU_SUBMENU, (void *)&MenuInstallType, 0 }, - { "Options", "Specify installation options", /* O */ - MENU_SUBMENU, (void *)&MenuInstallOptions, 0 }, - { "Proceed", "Proceed with installation", /* P */ - MENU_CANCEL, (void *)NULL, 0 }, - { NULL }, -}; - -DMenuItem _null_items[] = { - { NULL }, -}; - -/* Start the menu outer bodies */ +/* The initial installation menu */ DMenu MenuInitial = { + DMENU_NORMAL_TYPE, "Welcome to FreeBSD 2.0.5!", /* title */ "This is the main menu of the FreeBSD installation system. Please\n\ select one of the options below by using the arrow keys or typing the\n\ @@ -139,12 +65,26 @@ first character of the option name you're interested in. Invoke an\n\ option by pressing enter.", /* prompt */ "Press F1 for further help", /* help line */ "help/initial.hlp", /* help file */ - _initial_items, + { { "Usage", "Quick start - How to use this menu system.", /* U */ + DMENU_DISPLAY_FILE, (void *)"help/initial.hlp", 0 }, + { "Doc", "More detailed documentation on FreeBSD.", /* D */ + DMENU_SUBMENU, (void *)&MenuDocumentation, 0 }, + { "Lang", "Select natural language options.", /* L */ + DMENU_SUBMENU, (void *)&MenuLanguage, 0 }, + { "Express", "Express installation (don't ask)", /* E */ + DMENU_CALL, (void *)installExpress, 0 }, + { "Custom", "Custom installation (please ask)", /* C */ + DMENU_CALL, (void *)installCustom, 0 }, + { "Maint", "Go into maintainance mode (`fix it').", /* M */ + DMENU_CALL, (void *)installMaint, 0 }, + { NULL } }, }; +/* The main documentation menu */ DMenu MenuDocumentation = { + DMENU_NORMAL_TYPE, "Documentation for FreeBSD 2.0.5", /* Title */ - "If you are at all unsure about the configuration of your hardware\n + "If you are at all unsure about the configuration of your hardware\n\ or are looking to build a system specifically for FreeBSD, read the\n\ Hardware guide! New users should also read the Install document for\n\ a step-by-step tutorial on installing FreeBSD. For general information,\n\ @@ -152,50 +92,97 @@ consult the README file. If you're having other problems, you may find\n\ answers in the FAQ.", "Having trouble? Press F1 for help!", /* help line */ "help/usage.hlp", /* help file */ - _doc_items, + { { "README", "Read this for a general description of FreeBSD", /* R */ + DMENU_DISPLAY_FILE, (void *)"help/readme.hlp", 0 }, + { "Hardware", "The FreeBSD survival guide for PC hardware.", /* H */ + DMENU_DISPLAY_FILE, (void *)"help/hardware.hlp", 0 }, + { "Install", "A step-by-step guide to installing FreeBSD.", /* I */ + DMENU_DISPLAY_FILE, (void *)"help/install.hlp", 0 }, + { "FAQ", "Frequently Asked Questions about FreeBSD.", /* F */ + DMENU_DISPLAY_FILE, (void *)"help/faq.hlp", 0 }, + { NULL } }, }; +/* The language selection menu */ +/* + * Note: The RADIO menus use a slightly different syntax. If an item + * name starts with `*', it's considered to be "ON" by default, + * otherwise off. + */ DMenu MenuLanguage = { + DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS, "Natural language selection", /* title */ - "Please specify the language you'd like to use by default.\n\ -While a large amount of the system's documentation is still\n\ -written in english (and may never be translated), there are some\n\ -guides and system documentation that may be written in your\n\ + "Please specify the language you'd like to use by default.\n\n\ +While almost all of the system's documentation is still\n\ +written in english (and may never be translated), there are a few\n\ +guides and types of system documentation that may be written in your\n\ preferred language. When such are found, they will be used instead\n\ of the english versions.", /* prompt */ "Press F1 for more information", /* help line */ "help/language.hlp", /* help file */ - _lang_items, + { { "Danish", "Danish language and character set (ISO-8859-1)", /* D */ + DMENU_SET_VARIABLE, (void *)"LANG=en", 0 }, + { "*English", "English language (system default)", /* E */ + DMENU_SET_VARIABLE, (void *)"LANG=en", 0 }, + { "French", "French language and character set (ISO-8859-1)", /* F */ + DMENU_SET_VARIABLE, (void *)"LANG=fr", 0 }, + { "German", "German language and character set (ISO-8859-1)", /* G */ + DMENU_SET_VARIABLE, (void *)"LANG=de", 0 }, + { "Japanese", "Japanese language and character set (JIS?)", /* J */ + DMENU_SET_VARIABLE, (void *)"LANG=jp", 0 }, + { "Russian", "Russian language and character set (cp866-8x14)", /* R */ + DMENU_SET_VARIABLE, (void *)"LANG=ru", 0 }, + { NULL } }, }; +/* The media selection menu */ DMenu MenuMedia = { + DMENU_NORMAL_TYPE, "Choose Installation Media", "FreeBSD can be installed from a variety of different installation\n\ media, from floppies to the Internet. If you're installing FreeBSD from\n\ a supported CDROM drive then this is generally the best method to\n\ use unless you have some overriding reason for using another method.", - NULL, - NULL, - _media_items, + "Press F1 for more information on the various media types", + "help/media.hlp", + { { "CDROM", "Install from a FreeBSD CDROM", + DMENU_CALL, (void *)mediaSetCDROM, 0 }, + { "FLOPPY", "Install from a floppy disk set", + DMENU_CALL, (void *)mediaSetFloppy, 0 }, + { "DOS", "Install from a DOS partition", + DMENU_CALL, (void *)mediaSetDOS, 0 }, + { "TAPE", "Install from SCSI or QIC tape", + DMENU_CALL, (void *)mediaSetTape, 0 }, + { "FTP", "Install from an Internet FTP server", + DMENU_CALL, (void *)mediaSetFTP, 0 }, + { "FILESYSTEM", "Install from a UFS or NFS mounted distribution", + DMENU_CALL, (void *)mediaSetFS, 0 }, + { NULL } }, }; +/* The installation type menu */ DMenu MenuInstallType = { + DMENU_NORMAL_TYPE, "Choose Installation Type", "blah blah", NULL, NULL, - _null_items, + { { NULL } }, }; +/* The installation options menu */ DMenu MenuInstallOptions = { + DMENU_NORMAL_TYPE, "Choose Installation Options", "blah blah", NULL, NULL, - _null_items, + { { NULL } }, }; +/* The main installation menu */ DMenu MenuInstall = { + DMENU_NORMAL_TYPE, "Choose Installation Options", /* title */ "Before installation can continue, you need to specify a few items\n\ of information regarding the location of the distribution and the kind\n\ @@ -204,6 +191,14 @@ of options you can specify in the Options menu. If you do not wish to\n\ install FreeBSD at this time, you may select Cancel to leave this menu", "You may wish to read the install guide - press F1 to do so", "help/install.hlp", - _install_items, + { { "Media", "Choose Installation media type", /* M */ + DMENU_SUBMENU, (void *)&MenuMedia, 0 }, + { "Type", "Choose the type of installation you want", /* T */ + DMENU_SUBMENU, (void *)&MenuInstallType, 0 }, + { "Options", "Specify installation options", /* O */ + DMENU_SUBMENU, (void *)&MenuInstallOptions, 0 }, + { "Proceed", "Proceed with installation", /* P */ + DMENU_CANCEL, (void *)NULL, 0 }, + { NULL } }, }; diff --git a/release/sysinstall/misc.c b/release/sysinstall/misc.c index e9a5642..4f789e2 100644 --- a/release/sysinstall/misc.c +++ b/release/sysinstall/misc.c @@ -1,7 +1,7 @@ /* * Miscellaneous support routines.. * - * $Id$ + * $Id: misc.c,v 1.1.1.1 1995/04/27 12:50:35 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -99,9 +99,10 @@ safe_free(void *ptr) } /* - * These next two are kind of specialized just for building string lists + * These next routines are kind of specialized just for building string lists * for dialog_menu(). */ + /* Add a string to an item list */ char ** item_add(char **list, char *item, int *curr, int *max) @@ -115,6 +116,15 @@ item_add(char **list, char *item, int *curr, int *max) return list; } +/* Add a pair of items to an item list (more the usual case) */ +char ** +item_add_pair(char **list, char *item1, char *item2, int *curr, int *max) +{ + list = item_add(list, item1, curr, max); + list = item_add(list, item2, curr, max); + return list; +} + /* Toss the items out */ void items_free(char **list, int *curr, int *max) diff --git a/release/sysinstall/sysinstall.h b/release/sysinstall/sysinstall.h index aa75faa..1b318f4 100644 --- a/release/sysinstall/sysinstall.h +++ b/release/sysinstall/sysinstall.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.1.1.1 1995/04/27 12:50:34 jkh Exp $ + * $Id: sysinstall.h,v 1.2 1995/04/27 18:03:55 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -50,34 +50,41 @@ #include <unistd.h> #include <dialog.h> +/* Bitfields for menu options */ +#define DMENU_NORMAL_TYPE 0x1 /* Normal dialog menu */ +#define DMENU_RADIO_TYPE 0x2 /* Radio dialog menu */ +#define DMENU_MULTIPLE_TYPE 0x4 /* Multiple choice menu */ +#define DMENU_SELECTION_RETURNS 0x8 /* Select item then exit */ + /* Types */ typedef unsigned int Boolean; typedef enum { - MENU_SHELL_ESCAPE, /* Fork a shell */ - MENU_DISPLAY_FILE, /* Display a file's contents */ - MENU_SUBMENU, /* Recurse into another menu */ - MENU_SYSTEM_COMMAND, /* Run shell commmand */ - MENU_SYSTEM_COMMAND_BOX, /* Same as above, but in prgbox */ - MENU_SET_VARIABLE, /* Set an environment/system var */ - MENU_CALL, /* Call back a C function */ - MENU_CANCEL, /* Cancel out of this menu */ + DMENU_SHELL_ESCAPE, /* Fork a shell */ + DMENU_DISPLAY_FILE, /* Display a file's contents */ + DMENU_SUBMENU, /* Recurse into another menu */ + DMENU_SYSTEM_COMMAND, /* Run shell commmand */ + DMENU_SYSTEM_COMMAND_BOX, /* Same as above, but in prgbox */ + DMENU_SET_VARIABLE, /* Set an environment/system var */ + DMENU_CALL, /* Call back a C function */ + DMENU_CANCEL, /* Cancel out of this menu */ } DMenuItemType; typedef struct _dmenuItem { - char *title; /* Our title */ - char *prompt; /* Our prompt */ - DMenuItemType type; /* What type of item we are */ - void *ptr; /* Generic data ptr */ - int disabled; /* Are we temporarily disabled? */ + char *title; /* Our title */ + char *prompt; /* Our prompt */ + DMenuItemType type; /* What type of item we are */ + void *ptr; /* Generic data ptr */ + int disabled; /* Are we temporarily disabled? */ } DMenuItem; typedef struct _dmenu { - char *title; /* Our title */ - char *prompt; /* Our prompt */ - char *helpline; /* Line of help at bottom */ - char *helpfile; /* Help file for "F1" */ - DMenuItem *items; /* Array of menu items */ + unsigned int options; /* What sort of menu we are */ + char *title; /* Our title */ + char *prompt; /* Our prompt */ + char *helpline; /* Line of help at bottom */ + char *helpfile; /* Help file for "F1" */ + DMenuItem items[0]; /* Array of menu items */ } DMenu; /* A sysconfig variable */ @@ -89,11 +96,11 @@ typedef struct _variable { /* Externs */ extern int CpioFD; /* The file descriptor for our CPIO floppy */ -extern int DebugFD; /* Where diagnostic output goes */ -extern Boolean OnCDROM; /* Are we running off of a CDROM? */ -extern Boolean OnSerial; /* Are we on a serial console? */ -extern Boolean DialogActive; /* Is the dialog() stuff up? */ -extern Variable *VarHead; /* The head of the variable chain */ +extern int DebugFD; /* Where diagnostic output goes */ +extern Boolean OnCDROM; /* Are we running off of a CDROM? */ +extern Boolean OnSerial; /* Are we on a serial console? */ +extern Boolean DialogActive; /* Is the dialog() stuff up? */ +extern Variable *VarHead; /* The head of the variable chain */ /* All the menus to which forward references exist */ extern DMenu MenuDocumenation, MenuInitial, MenuLanguage; @@ -107,12 +114,15 @@ extern void globalsInit(void); /* install.c */ extern int installCustom(void); extern int installExpress(void); +extern int installMaint(void); /* system.c */ extern void systemInitialize(int argc, char **argv); extern void systemShutdown(void); extern void systemWelcome(void); extern int systemExecute(char *cmd); +extern int systemShellEscape(void); +extern int systemDisplayFile(char *file); /* dmenu.c */ extern void dmenuOpen(DMenu *menu, int *choice, int *scroll, @@ -126,6 +136,8 @@ extern char *string_prune(char *str); extern char *string_skipwhite(char *str); extern void safe_free(void *ptr); extern char **item_add(char **list, char *item, int *curr, int *max); +extern char **item_add_pair(char **list, char *item1, char *item2, + int *curr, int *max); extern void items_free(char **list, int *curr, int *max); /* termcap.c */ @@ -139,6 +151,11 @@ extern void msgFatal(char *fmt, ...); /* media.c */ extern int mediaSetCDROM(void); +extern int mediaSetFloppy(void); +extern int mediaSetDOS(void); +extern int mediaSetTape(void); +extern int mediaSetFTP(void); +extern int mediaSetFS(void); #endif /* _SYSINSTALL_H_INCLUDE */ diff --git a/release/sysinstall/system.c b/release/sysinstall/system.c index a48c9df..cbf7549 100644 --- a/release/sysinstall/system.c +++ b/release/sysinstall/system.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id$ + * $Id: system.c,v 1.1.1.1 1995/04/27 12:50:34 jkh Exp $ * * Jordan Hubbard * @@ -20,6 +20,7 @@ #include <sys/reboot.h> #include <sys/fcntl.h> #include <sys/ioctl.h> +#include <sys/wait.h> /* Handle interrupt signals (duh!) */ static void @@ -87,8 +88,11 @@ systemShutdown(void) /* REALLY exit! */ if (getpid() == 1) reboot(RB_HALT); + else + exit(1); } +/* Run some general command */ int systemExecute(char *command) { @@ -105,3 +109,67 @@ systemExecute(char *command) return status; } +/* Find and execute a shell */ +int +systemShellEscape(void) +{ + char *sh = NULL; + + if (file_executable("/bin/sh")) + sh = "/bin/sh"; + else if (file_executable("/stand/sh")) + sh = "/stand/sh"; + else { + msgWarn("No shell available, sorry!"); + return 1; + } + setenv("PS1", "freebsd% ", 1); + dialog_clear(); + dialog_update(); + move(0, 0); + standout(); + addstr("Type `exit' to leave this shell and continue installallation"); + standend(); + refresh(); + end_dialog(); + DialogActive = FALSE; + if (fork() == 0) + execlp(sh, "-sh", 0); + else + wait(NULL); + dialog_clear(); + DialogActive = TRUE; + return 0; +} + +/* Display a file in a filebox */ +int +systemDisplayFile(char *file) +{ + char buf[FILENAME_MAX], *cp, *fname = NULL; + + if (file_readable(file)) + fname = file; + else if ((cp = getenv("LANG")) != NULL) { + snprintf(buf, FILENAME_MAX, "%s/%s", cp, file); + if (file_readable(buf)) + fname = buf; + } + else { + snprintf(buf, FILENAME_MAX, "english/%s", file); + if (file_readable(buf)) + fname = buf; + } + if (!fname) { + snprintf(buf, FILENAME_MAX, "The %s file is not provided on this particular floppy image.", file); + dialog_msgbox("Sorry!", buf, -1, -1, 1); + dialog_clear_norefresh(); + return 1; + } + else { + dialog_clear_norefresh(); + dialog_textbox(file, fname, LINES, COLS); + dialog_clear_norefresh(); + } + return 0; +} diff --git a/usr.sbin/sade/dmenu.c b/usr.sbin/sade/dmenu.c index b792f49..f49e4cd 100644 --- a/usr.sbin/sade/dmenu.c +++ b/usr.sbin/sade/dmenu.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated for what's essentially a complete rewrite. * - * $Id: dmenu.c,v 1.1.1.1 1995/04/27 12:50:34 jkh Exp $ + * $Id: dmenu.c,v 1.2 1995/04/27 18:03:52 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -42,11 +42,10 @@ */ #include "sysinstall.h" -#include <sys/wait.h> -#define MAX_MENU 15 +#define MAX_MENU 15 -static DMenuItem shellAction = { NULL, NULL, MENU_SHELL_ESCAPE, NULL, 0 }; +static DMenuItem shellAction = { NULL, NULL, DMENU_SHELL_ESCAPE, NULL, 0 }; /* Traverse over an internal menu */ void @@ -55,36 +54,64 @@ dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max) char result[FILENAME_MAX]; char **nitems = NULL; DMenuItem *tmp; - int rval, n = 0; - char *sh = NULL; + int rval = 0, n = 0; /* First, construct the menu */ for (tmp = menu->items; tmp->title; tmp++) { if (!tmp->disabled) { - nitems = item_add(nitems, tmp->title, curr, max); - nitems = item_add(nitems, tmp->prompt, curr, max); + char *addme = NULL; + char *title = tmp->title; + char *prompt = tmp->prompt; + + if (menu->options & DMENU_RADIO_TYPE) { + if (*title == '*') { + addme = "ON"; + ++title; + } + else + addme = "OFF"; + } + nitems = item_add_pair(nitems, title, prompt, curr, max); + if (addme) + nitems = item_add(nitems, addme, curr, max); ++n; } } nitems = item_add(nitems, NULL, curr, max); /* Terminate it */ - /* Any helpful hints, put 'em up! */ - if (menu->helpline) - use_helpline(menu->helpline); - if (menu->helpfile) - use_helpfile(menu->helpfile); - while (1) { + /* Any helpful hints, put 'em up! */ + if (menu->helpline) + use_helpline(menu->helpline); + if (menu->helpfile) + use_helpfile(menu->helpfile); + /* Pop up that dialog! */ - rval = dialog_menu((unsigned char *)menu->title, - (unsigned char *)menu->prompt, - -1, -1, n > MAX_MENU ? MAX_MENU : n, n, - (unsigned char **)nitems, (unsigned char *)result, - choice, scroll); + if (menu->options & DMENU_NORMAL_TYPE) { + rval = dialog_menu((unsigned char *)menu->title, + (unsigned char *)menu->prompt, + -1, -1, + n > MAX_MENU ? MAX_MENU : n, + n, + (unsigned char **)nitems, + (unsigned char *)result, + choice, scroll); + } + else if (menu->options & DMENU_RADIO_TYPE) { + rval = dialog_radiolist((unsigned char *)menu->title, + (unsigned char *)menu->prompt, + -1, -1, + n > MAX_MENU ? MAX_MENU : n, + n, + (unsigned char **)nitems, + (unsigned char *)result); + } dialog_clear(); if (!rval) { for (tmp = menu->items; tmp->title; tmp++) - if (!strcmp(result, tmp->title)) + if (!strcmp(result, + (*tmp->title == '*') ? tmp->title + 1 : + tmp->title)) break; if (!tmp->title) msgFatal("Menu item `%s' not found??", result); @@ -96,66 +123,18 @@ dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max) return; } switch (tmp->type) { - /* User whapped ESC twice and wants a sub-shell */ - case MENU_SHELL_ESCAPE: - if (file_executable("/bin/sh")) - sh = "/bin/sh"; - else if (file_executable("/stand/sh")) - sh = "/stand/sh"; - else { - msgWarn("No shell available, sorry!"); - break; - } - setenv("PS1", "freebsd% ", 1); - dialog_clear(); - dialog_update(); - move(0, 0); - standout(); - addstr("Type `exit' to leave this shell and continue install."); - standend(); - refresh(); - end_dialog(); - DialogActive = FALSE; - if (fork() == 0) - execlp(sh, "-sh", 0); - else - wait(NULL); - dialog_clear(); - DialogActive = TRUE; + case DMENU_SHELL_ESCAPE: + systemShellEscape(); break; /* We want to simply display a file */ - case MENU_DISPLAY_FILE: { - char buf[FILENAME_MAX], *cp, *fname = NULL; - - if (file_readable((char *)tmp->ptr)) - fname = (char *)tmp->ptr; - else if ((cp = getenv("LANG")) != NULL) { - snprintf(buf, FILENAME_MAX, "%s/%s", cp, tmp->ptr); - if (file_readable(buf)) - fname = buf; - } - else { - snprintf(buf, FILENAME_MAX, "english/%s", tmp->ptr); - if (file_readable(buf)) - fname = buf; - } - if (!fname) { - snprintf(buf, FILENAME_MAX, "The %s file is not provided on the 1.2MB floppy image.", (char *)tmp->ptr); - dialog_msgbox("Sorry!", buf, -1, -1, 1); - dialog_clear_norefresh(); - } - else { - dialog_clear_norefresh(); - dialog_textbox(tmp->title, fname, LINES, COLS); - dialog_clear_norefresh(); - } - } + case DMENU_DISPLAY_FILE: + systemDisplayFile((char *)tmp->ptr); break; /* It's a sub-menu; recurse on it */ - case MENU_SUBMENU: { + case DMENU_SUBMENU: { int choice, scroll, curr, max; choice = scroll = curr = max = 0; @@ -164,27 +143,27 @@ dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max) } /* Execute it as a system command */ - case MENU_SYSTEM_COMMAND: + case DMENU_SYSTEM_COMMAND: (void)systemExecute((char *)tmp->ptr); break; /* Same as above, but execute it in a prgbox */ - case MENU_SYSTEM_COMMAND_BOX: + case DMENU_SYSTEM_COMMAND_BOX: dialog_prgbox(tmp->title, (char *)tmp->ptr, 22, 76, 1, 1); break; - case MENU_CALL: + case DMENU_CALL: if (((int (*)())tmp->ptr)()) { items_free(nitems, curr, max); return; } break; - case MENU_CANCEL: + case DMENU_CANCEL: items_free(nitems, curr, max); return; - case MENU_SET_VARIABLE: { + case DMENU_SET_VARIABLE: { Variable *newvar; if (!index((char *)tmp->ptr, '=')) @@ -196,13 +175,19 @@ dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max) strncpy(newvar->value, tmp->ptr, 1024); newvar->next = VarHead; VarHead = newvar; - msgInfo("Set variable %s", newvar->value); + msgInfo("Setting option %s", newvar->value); } break; default: msgFatal("Don't know how to deal with menu type %d", tmp->type); } + + /* Did the user want to make this a single-selection menu? */ + if (menu->options & DMENU_SELECTION_RETURNS) { + items_free(nitems, curr, max); + return; + } } } diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c index dcb5eb5..ee1efa0 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.1.1.1 1995/04/27 12:50:35 jkh Exp $ + * $Id: install.c,v 1.2 1995/04/27 18:03:53 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -57,3 +57,8 @@ installExpress(void) return 0; } +int +installMaint(void) +{ + return 0; +} diff --git a/usr.sbin/sade/menus.c b/usr.sbin/sade/menus.c index 3450a3e..c4afad5 100644 --- a/usr.sbin/sade/menus.c +++ b/usr.sbin/sade/menus.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: menus.c,v 1.1.1.1 1995/04/27 12:50:34 jkh Exp $ + * $Id: menus.c,v 1.2 1995/04/27 18:03:54 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -55,83 +55,9 @@ extern DMenu MenuMedia; extern DMenu MenuInstallType; extern DMenu MenuInstallOptions; -/* - * Bloody C won't let me nest these initializers properly - do the - * items and the menus containing them as two seperate initializers - * done in two groups. - */ - -/* First, the lists of items */ - -/* Documentation menu */ -DMenuItem _doc_items[] = { - { "README", "Read this for a general description of FreeBSD", /* R */ - MENU_DISPLAY_FILE, (void *)"help/readme.hlp", 0 }, - { "Hardware", "The FreeBSD survival guide for PC hardware.", /* H */ - MENU_DISPLAY_FILE, (void *)"help/hardware.hlp", 0 }, - { "Install", "A step-by-step guide to installing FreeBSD.", /* I */ - MENU_DISPLAY_FILE, (void *)"help/install.hlp", 0 }, - { "FAQ", "Frequently Asked Questions about FreeBSD.", /* F */ - MENU_DISPLAY_FILE, (void *)"help/faq.hlp", 0 }, - { NULL } -}; - -/* Language menu */ -DMenuItem _lang_items[] = { - { "English", "The system default language", /* E */ - MENU_SET_VARIABLE, (void *)"LANG=en", 0 }, - { "French", "French language and character set (ISO-8859-1)", /* F */ - MENU_SET_VARIABLE, (void *)"LANG=fr", 0 }, - { "German", "German language and character set (ISO-8859-1)", /* G */ - MENU_SET_VARIABLE, (void *)"LANG=de", 0 }, - { "Japanese", "Japanese language and character set (JIS?)", /* J */ - MENU_SET_VARIABLE, (void *)"LANG=jp", 0 }, - { "Russian", "Russian language and character set (cp866-8x14)", /* R */ - MENU_SET_VARIABLE, (void *)"LANG=ru", 0 }, - { NULL }, -}; - -/* The first menu */ -DMenuItem _initial_items[] = { - { "Usage", "Quick start - How to use this menu system.", /* U */ - MENU_DISPLAY_FILE, (void *)"help/initial.hlp", 0 }, - { "Doc", "More detailed documentation on FreeBSD.", /* D */ - MENU_SUBMENU, (void *)&MenuDocumentation, 0 }, - { "Lang", "Select natural language options.", /* L */ - MENU_SUBMENU, (void *)&MenuLanguage, 0 }, - { "Express", "Express installation (don't ask)", /* E */ - MENU_CALL, (void *)installExpress, 0 }, - { "Custom", "Custom installation (please ask)", /* C */ - MENU_CALL, (void *)installCustom, 0 }, - { NULL }, -}; - -/* Installation media menu */ -DMenuItem _media_items[] = { - { "CDROM", "Install from a FreeBSD CDROM", - MENU_CALL, (void *)mediaSetCDROM, 0 }, - { NULL }, -}; - -/* Installation main menu */ -DMenuItem _install_items[] = { - { "Media", "Choose Installation media type", /* M */ - MENU_SUBMENU, (void *)&MenuMedia, 0 }, - { "Type", "Choose the type of installation you want", /* T */ - MENU_SUBMENU, (void *)&MenuInstallType, 0 }, - { "Options", "Specify installation options", /* O */ - MENU_SUBMENU, (void *)&MenuInstallOptions, 0 }, - { "Proceed", "Proceed with installation", /* P */ - MENU_CANCEL, (void *)NULL, 0 }, - { NULL }, -}; - -DMenuItem _null_items[] = { - { NULL }, -}; - -/* Start the menu outer bodies */ +/* The initial installation menu */ DMenu MenuInitial = { + DMENU_NORMAL_TYPE, "Welcome to FreeBSD 2.0.5!", /* title */ "This is the main menu of the FreeBSD installation system. Please\n\ select one of the options below by using the arrow keys or typing the\n\ @@ -139,12 +65,26 @@ first character of the option name you're interested in. Invoke an\n\ option by pressing enter.", /* prompt */ "Press F1 for further help", /* help line */ "help/initial.hlp", /* help file */ - _initial_items, + { { "Usage", "Quick start - How to use this menu system.", /* U */ + DMENU_DISPLAY_FILE, (void *)"help/initial.hlp", 0 }, + { "Doc", "More detailed documentation on FreeBSD.", /* D */ + DMENU_SUBMENU, (void *)&MenuDocumentation, 0 }, + { "Lang", "Select natural language options.", /* L */ + DMENU_SUBMENU, (void *)&MenuLanguage, 0 }, + { "Express", "Express installation (don't ask)", /* E */ + DMENU_CALL, (void *)installExpress, 0 }, + { "Custom", "Custom installation (please ask)", /* C */ + DMENU_CALL, (void *)installCustom, 0 }, + { "Maint", "Go into maintainance mode (`fix it').", /* M */ + DMENU_CALL, (void *)installMaint, 0 }, + { NULL } }, }; +/* The main documentation menu */ DMenu MenuDocumentation = { + DMENU_NORMAL_TYPE, "Documentation for FreeBSD 2.0.5", /* Title */ - "If you are at all unsure about the configuration of your hardware\n + "If you are at all unsure about the configuration of your hardware\n\ or are looking to build a system specifically for FreeBSD, read the\n\ Hardware guide! New users should also read the Install document for\n\ a step-by-step tutorial on installing FreeBSD. For general information,\n\ @@ -152,50 +92,97 @@ consult the README file. If you're having other problems, you may find\n\ answers in the FAQ.", "Having trouble? Press F1 for help!", /* help line */ "help/usage.hlp", /* help file */ - _doc_items, + { { "README", "Read this for a general description of FreeBSD", /* R */ + DMENU_DISPLAY_FILE, (void *)"help/readme.hlp", 0 }, + { "Hardware", "The FreeBSD survival guide for PC hardware.", /* H */ + DMENU_DISPLAY_FILE, (void *)"help/hardware.hlp", 0 }, + { "Install", "A step-by-step guide to installing FreeBSD.", /* I */ + DMENU_DISPLAY_FILE, (void *)"help/install.hlp", 0 }, + { "FAQ", "Frequently Asked Questions about FreeBSD.", /* F */ + DMENU_DISPLAY_FILE, (void *)"help/faq.hlp", 0 }, + { NULL } }, }; +/* The language selection menu */ +/* + * Note: The RADIO menus use a slightly different syntax. If an item + * name starts with `*', it's considered to be "ON" by default, + * otherwise off. + */ DMenu MenuLanguage = { + DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS, "Natural language selection", /* title */ - "Please specify the language you'd like to use by default.\n\ -While a large amount of the system's documentation is still\n\ -written in english (and may never be translated), there are some\n\ -guides and system documentation that may be written in your\n\ + "Please specify the language you'd like to use by default.\n\n\ +While almost all of the system's documentation is still\n\ +written in english (and may never be translated), there are a few\n\ +guides and types of system documentation that may be written in your\n\ preferred language. When such are found, they will be used instead\n\ of the english versions.", /* prompt */ "Press F1 for more information", /* help line */ "help/language.hlp", /* help file */ - _lang_items, + { { "Danish", "Danish language and character set (ISO-8859-1)", /* D */ + DMENU_SET_VARIABLE, (void *)"LANG=en", 0 }, + { "*English", "English language (system default)", /* E */ + DMENU_SET_VARIABLE, (void *)"LANG=en", 0 }, + { "French", "French language and character set (ISO-8859-1)", /* F */ + DMENU_SET_VARIABLE, (void *)"LANG=fr", 0 }, + { "German", "German language and character set (ISO-8859-1)", /* G */ + DMENU_SET_VARIABLE, (void *)"LANG=de", 0 }, + { "Japanese", "Japanese language and character set (JIS?)", /* J */ + DMENU_SET_VARIABLE, (void *)"LANG=jp", 0 }, + { "Russian", "Russian language and character set (cp866-8x14)", /* R */ + DMENU_SET_VARIABLE, (void *)"LANG=ru", 0 }, + { NULL } }, }; +/* The media selection menu */ DMenu MenuMedia = { + DMENU_NORMAL_TYPE, "Choose Installation Media", "FreeBSD can be installed from a variety of different installation\n\ media, from floppies to the Internet. If you're installing FreeBSD from\n\ a supported CDROM drive then this is generally the best method to\n\ use unless you have some overriding reason for using another method.", - NULL, - NULL, - _media_items, + "Press F1 for more information on the various media types", + "help/media.hlp", + { { "CDROM", "Install from a FreeBSD CDROM", + DMENU_CALL, (void *)mediaSetCDROM, 0 }, + { "FLOPPY", "Install from a floppy disk set", + DMENU_CALL, (void *)mediaSetFloppy, 0 }, + { "DOS", "Install from a DOS partition", + DMENU_CALL, (void *)mediaSetDOS, 0 }, + { "TAPE", "Install from SCSI or QIC tape", + DMENU_CALL, (void *)mediaSetTape, 0 }, + { "FTP", "Install from an Internet FTP server", + DMENU_CALL, (void *)mediaSetFTP, 0 }, + { "FILESYSTEM", "Install from a UFS or NFS mounted distribution", + DMENU_CALL, (void *)mediaSetFS, 0 }, + { NULL } }, }; +/* The installation type menu */ DMenu MenuInstallType = { + DMENU_NORMAL_TYPE, "Choose Installation Type", "blah blah", NULL, NULL, - _null_items, + { { NULL } }, }; +/* The installation options menu */ DMenu MenuInstallOptions = { + DMENU_NORMAL_TYPE, "Choose Installation Options", "blah blah", NULL, NULL, - _null_items, + { { NULL } }, }; +/* The main installation menu */ DMenu MenuInstall = { + DMENU_NORMAL_TYPE, "Choose Installation Options", /* title */ "Before installation can continue, you need to specify a few items\n\ of information regarding the location of the distribution and the kind\n\ @@ -204,6 +191,14 @@ of options you can specify in the Options menu. If you do not wish to\n\ install FreeBSD at this time, you may select Cancel to leave this menu", "You may wish to read the install guide - press F1 to do so", "help/install.hlp", - _install_items, + { { "Media", "Choose Installation media type", /* M */ + DMENU_SUBMENU, (void *)&MenuMedia, 0 }, + { "Type", "Choose the type of installation you want", /* T */ + DMENU_SUBMENU, (void *)&MenuInstallType, 0 }, + { "Options", "Specify installation options", /* O */ + DMENU_SUBMENU, (void *)&MenuInstallOptions, 0 }, + { "Proceed", "Proceed with installation", /* P */ + DMENU_CANCEL, (void *)NULL, 0 }, + { NULL } }, }; diff --git a/usr.sbin/sade/misc.c b/usr.sbin/sade/misc.c index e9a5642..4f789e2 100644 --- a/usr.sbin/sade/misc.c +++ b/usr.sbin/sade/misc.c @@ -1,7 +1,7 @@ /* * Miscellaneous support routines.. * - * $Id$ + * $Id: misc.c,v 1.1.1.1 1995/04/27 12:50:35 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -99,9 +99,10 @@ safe_free(void *ptr) } /* - * These next two are kind of specialized just for building string lists + * These next routines are kind of specialized just for building string lists * for dialog_menu(). */ + /* Add a string to an item list */ char ** item_add(char **list, char *item, int *curr, int *max) @@ -115,6 +116,15 @@ item_add(char **list, char *item, int *curr, int *max) return list; } +/* Add a pair of items to an item list (more the usual case) */ +char ** +item_add_pair(char **list, char *item1, char *item2, int *curr, int *max) +{ + list = item_add(list, item1, curr, max); + list = item_add(list, item2, curr, max); + return list; +} + /* Toss the items out */ void items_free(char **list, int *curr, int *max) diff --git a/usr.sbin/sade/sade.h b/usr.sbin/sade/sade.h index aa75faa..1b318f4 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.1.1.1 1995/04/27 12:50:34 jkh Exp $ + * $Id: sysinstall.h,v 1.2 1995/04/27 18:03:55 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -50,34 +50,41 @@ #include <unistd.h> #include <dialog.h> +/* Bitfields for menu options */ +#define DMENU_NORMAL_TYPE 0x1 /* Normal dialog menu */ +#define DMENU_RADIO_TYPE 0x2 /* Radio dialog menu */ +#define DMENU_MULTIPLE_TYPE 0x4 /* Multiple choice menu */ +#define DMENU_SELECTION_RETURNS 0x8 /* Select item then exit */ + /* Types */ typedef unsigned int Boolean; typedef enum { - MENU_SHELL_ESCAPE, /* Fork a shell */ - MENU_DISPLAY_FILE, /* Display a file's contents */ - MENU_SUBMENU, /* Recurse into another menu */ - MENU_SYSTEM_COMMAND, /* Run shell commmand */ - MENU_SYSTEM_COMMAND_BOX, /* Same as above, but in prgbox */ - MENU_SET_VARIABLE, /* Set an environment/system var */ - MENU_CALL, /* Call back a C function */ - MENU_CANCEL, /* Cancel out of this menu */ + DMENU_SHELL_ESCAPE, /* Fork a shell */ + DMENU_DISPLAY_FILE, /* Display a file's contents */ + DMENU_SUBMENU, /* Recurse into another menu */ + DMENU_SYSTEM_COMMAND, /* Run shell commmand */ + DMENU_SYSTEM_COMMAND_BOX, /* Same as above, but in prgbox */ + DMENU_SET_VARIABLE, /* Set an environment/system var */ + DMENU_CALL, /* Call back a C function */ + DMENU_CANCEL, /* Cancel out of this menu */ } DMenuItemType; typedef struct _dmenuItem { - char *title; /* Our title */ - char *prompt; /* Our prompt */ - DMenuItemType type; /* What type of item we are */ - void *ptr; /* Generic data ptr */ - int disabled; /* Are we temporarily disabled? */ + char *title; /* Our title */ + char *prompt; /* Our prompt */ + DMenuItemType type; /* What type of item we are */ + void *ptr; /* Generic data ptr */ + int disabled; /* Are we temporarily disabled? */ } DMenuItem; typedef struct _dmenu { - char *title; /* Our title */ - char *prompt; /* Our prompt */ - char *helpline; /* Line of help at bottom */ - char *helpfile; /* Help file for "F1" */ - DMenuItem *items; /* Array of menu items */ + unsigned int options; /* What sort of menu we are */ + char *title; /* Our title */ + char *prompt; /* Our prompt */ + char *helpline; /* Line of help at bottom */ + char *helpfile; /* Help file for "F1" */ + DMenuItem items[0]; /* Array of menu items */ } DMenu; /* A sysconfig variable */ @@ -89,11 +96,11 @@ typedef struct _variable { /* Externs */ extern int CpioFD; /* The file descriptor for our CPIO floppy */ -extern int DebugFD; /* Where diagnostic output goes */ -extern Boolean OnCDROM; /* Are we running off of a CDROM? */ -extern Boolean OnSerial; /* Are we on a serial console? */ -extern Boolean DialogActive; /* Is the dialog() stuff up? */ -extern Variable *VarHead; /* The head of the variable chain */ +extern int DebugFD; /* Where diagnostic output goes */ +extern Boolean OnCDROM; /* Are we running off of a CDROM? */ +extern Boolean OnSerial; /* Are we on a serial console? */ +extern Boolean DialogActive; /* Is the dialog() stuff up? */ +extern Variable *VarHead; /* The head of the variable chain */ /* All the menus to which forward references exist */ extern DMenu MenuDocumenation, MenuInitial, MenuLanguage; @@ -107,12 +114,15 @@ extern void globalsInit(void); /* install.c */ extern int installCustom(void); extern int installExpress(void); +extern int installMaint(void); /* system.c */ extern void systemInitialize(int argc, char **argv); extern void systemShutdown(void); extern void systemWelcome(void); extern int systemExecute(char *cmd); +extern int systemShellEscape(void); +extern int systemDisplayFile(char *file); /* dmenu.c */ extern void dmenuOpen(DMenu *menu, int *choice, int *scroll, @@ -126,6 +136,8 @@ extern char *string_prune(char *str); extern char *string_skipwhite(char *str); extern void safe_free(void *ptr); extern char **item_add(char **list, char *item, int *curr, int *max); +extern char **item_add_pair(char **list, char *item1, char *item2, + int *curr, int *max); extern void items_free(char **list, int *curr, int *max); /* termcap.c */ @@ -139,6 +151,11 @@ extern void msgFatal(char *fmt, ...); /* media.c */ extern int mediaSetCDROM(void); +extern int mediaSetFloppy(void); +extern int mediaSetDOS(void); +extern int mediaSetTape(void); +extern int mediaSetFTP(void); +extern int mediaSetFS(void); #endif /* _SYSINSTALL_H_INCLUDE */ diff --git a/usr.sbin/sade/system.c b/usr.sbin/sade/system.c index a48c9df..cbf7549 100644 --- a/usr.sbin/sade/system.c +++ b/usr.sbin/sade/system.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id$ + * $Id: system.c,v 1.1.1.1 1995/04/27 12:50:34 jkh Exp $ * * Jordan Hubbard * @@ -20,6 +20,7 @@ #include <sys/reboot.h> #include <sys/fcntl.h> #include <sys/ioctl.h> +#include <sys/wait.h> /* Handle interrupt signals (duh!) */ static void @@ -87,8 +88,11 @@ systemShutdown(void) /* REALLY exit! */ if (getpid() == 1) reboot(RB_HALT); + else + exit(1); } +/* Run some general command */ int systemExecute(char *command) { @@ -105,3 +109,67 @@ systemExecute(char *command) return status; } +/* Find and execute a shell */ +int +systemShellEscape(void) +{ + char *sh = NULL; + + if (file_executable("/bin/sh")) + sh = "/bin/sh"; + else if (file_executable("/stand/sh")) + sh = "/stand/sh"; + else { + msgWarn("No shell available, sorry!"); + return 1; + } + setenv("PS1", "freebsd% ", 1); + dialog_clear(); + dialog_update(); + move(0, 0); + standout(); + addstr("Type `exit' to leave this shell and continue installallation"); + standend(); + refresh(); + end_dialog(); + DialogActive = FALSE; + if (fork() == 0) + execlp(sh, "-sh", 0); + else + wait(NULL); + dialog_clear(); + DialogActive = TRUE; + return 0; +} + +/* Display a file in a filebox */ +int +systemDisplayFile(char *file) +{ + char buf[FILENAME_MAX], *cp, *fname = NULL; + + if (file_readable(file)) + fname = file; + else if ((cp = getenv("LANG")) != NULL) { + snprintf(buf, FILENAME_MAX, "%s/%s", cp, file); + if (file_readable(buf)) + fname = buf; + } + else { + snprintf(buf, FILENAME_MAX, "english/%s", file); + if (file_readable(buf)) + fname = buf; + } + if (!fname) { + snprintf(buf, FILENAME_MAX, "The %s file is not provided on this particular floppy image.", file); + dialog_msgbox("Sorry!", buf, -1, -1, 1); + dialog_clear_norefresh(); + return 1; + } + else { + dialog_clear_norefresh(); + dialog_textbox(file, fname, LINES, COLS); + dialog_clear_norefresh(); + } + return 0; +} diff --git a/usr.sbin/sysinstall/dmenu.c b/usr.sbin/sysinstall/dmenu.c index b792f49..f49e4cd 100644 --- a/usr.sbin/sysinstall/dmenu.c +++ b/usr.sbin/sysinstall/dmenu.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated for what's essentially a complete rewrite. * - * $Id: dmenu.c,v 1.1.1.1 1995/04/27 12:50:34 jkh Exp $ + * $Id: dmenu.c,v 1.2 1995/04/27 18:03:52 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -42,11 +42,10 @@ */ #include "sysinstall.h" -#include <sys/wait.h> -#define MAX_MENU 15 +#define MAX_MENU 15 -static DMenuItem shellAction = { NULL, NULL, MENU_SHELL_ESCAPE, NULL, 0 }; +static DMenuItem shellAction = { NULL, NULL, DMENU_SHELL_ESCAPE, NULL, 0 }; /* Traverse over an internal menu */ void @@ -55,36 +54,64 @@ dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max) char result[FILENAME_MAX]; char **nitems = NULL; DMenuItem *tmp; - int rval, n = 0; - char *sh = NULL; + int rval = 0, n = 0; /* First, construct the menu */ for (tmp = menu->items; tmp->title; tmp++) { if (!tmp->disabled) { - nitems = item_add(nitems, tmp->title, curr, max); - nitems = item_add(nitems, tmp->prompt, curr, max); + char *addme = NULL; + char *title = tmp->title; + char *prompt = tmp->prompt; + + if (menu->options & DMENU_RADIO_TYPE) { + if (*title == '*') { + addme = "ON"; + ++title; + } + else + addme = "OFF"; + } + nitems = item_add_pair(nitems, title, prompt, curr, max); + if (addme) + nitems = item_add(nitems, addme, curr, max); ++n; } } nitems = item_add(nitems, NULL, curr, max); /* Terminate it */ - /* Any helpful hints, put 'em up! */ - if (menu->helpline) - use_helpline(menu->helpline); - if (menu->helpfile) - use_helpfile(menu->helpfile); - while (1) { + /* Any helpful hints, put 'em up! */ + if (menu->helpline) + use_helpline(menu->helpline); + if (menu->helpfile) + use_helpfile(menu->helpfile); + /* Pop up that dialog! */ - rval = dialog_menu((unsigned char *)menu->title, - (unsigned char *)menu->prompt, - -1, -1, n > MAX_MENU ? MAX_MENU : n, n, - (unsigned char **)nitems, (unsigned char *)result, - choice, scroll); + if (menu->options & DMENU_NORMAL_TYPE) { + rval = dialog_menu((unsigned char *)menu->title, + (unsigned char *)menu->prompt, + -1, -1, + n > MAX_MENU ? MAX_MENU : n, + n, + (unsigned char **)nitems, + (unsigned char *)result, + choice, scroll); + } + else if (menu->options & DMENU_RADIO_TYPE) { + rval = dialog_radiolist((unsigned char *)menu->title, + (unsigned char *)menu->prompt, + -1, -1, + n > MAX_MENU ? MAX_MENU : n, + n, + (unsigned char **)nitems, + (unsigned char *)result); + } dialog_clear(); if (!rval) { for (tmp = menu->items; tmp->title; tmp++) - if (!strcmp(result, tmp->title)) + if (!strcmp(result, + (*tmp->title == '*') ? tmp->title + 1 : + tmp->title)) break; if (!tmp->title) msgFatal("Menu item `%s' not found??", result); @@ -96,66 +123,18 @@ dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max) return; } switch (tmp->type) { - /* User whapped ESC twice and wants a sub-shell */ - case MENU_SHELL_ESCAPE: - if (file_executable("/bin/sh")) - sh = "/bin/sh"; - else if (file_executable("/stand/sh")) - sh = "/stand/sh"; - else { - msgWarn("No shell available, sorry!"); - break; - } - setenv("PS1", "freebsd% ", 1); - dialog_clear(); - dialog_update(); - move(0, 0); - standout(); - addstr("Type `exit' to leave this shell and continue install."); - standend(); - refresh(); - end_dialog(); - DialogActive = FALSE; - if (fork() == 0) - execlp(sh, "-sh", 0); - else - wait(NULL); - dialog_clear(); - DialogActive = TRUE; + case DMENU_SHELL_ESCAPE: + systemShellEscape(); break; /* We want to simply display a file */ - case MENU_DISPLAY_FILE: { - char buf[FILENAME_MAX], *cp, *fname = NULL; - - if (file_readable((char *)tmp->ptr)) - fname = (char *)tmp->ptr; - else if ((cp = getenv("LANG")) != NULL) { - snprintf(buf, FILENAME_MAX, "%s/%s", cp, tmp->ptr); - if (file_readable(buf)) - fname = buf; - } - else { - snprintf(buf, FILENAME_MAX, "english/%s", tmp->ptr); - if (file_readable(buf)) - fname = buf; - } - if (!fname) { - snprintf(buf, FILENAME_MAX, "The %s file is not provided on the 1.2MB floppy image.", (char *)tmp->ptr); - dialog_msgbox("Sorry!", buf, -1, -1, 1); - dialog_clear_norefresh(); - } - else { - dialog_clear_norefresh(); - dialog_textbox(tmp->title, fname, LINES, COLS); - dialog_clear_norefresh(); - } - } + case DMENU_DISPLAY_FILE: + systemDisplayFile((char *)tmp->ptr); break; /* It's a sub-menu; recurse on it */ - case MENU_SUBMENU: { + case DMENU_SUBMENU: { int choice, scroll, curr, max; choice = scroll = curr = max = 0; @@ -164,27 +143,27 @@ dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max) } /* Execute it as a system command */ - case MENU_SYSTEM_COMMAND: + case DMENU_SYSTEM_COMMAND: (void)systemExecute((char *)tmp->ptr); break; /* Same as above, but execute it in a prgbox */ - case MENU_SYSTEM_COMMAND_BOX: + case DMENU_SYSTEM_COMMAND_BOX: dialog_prgbox(tmp->title, (char *)tmp->ptr, 22, 76, 1, 1); break; - case MENU_CALL: + case DMENU_CALL: if (((int (*)())tmp->ptr)()) { items_free(nitems, curr, max); return; } break; - case MENU_CANCEL: + case DMENU_CANCEL: items_free(nitems, curr, max); return; - case MENU_SET_VARIABLE: { + case DMENU_SET_VARIABLE: { Variable *newvar; if (!index((char *)tmp->ptr, '=')) @@ -196,13 +175,19 @@ dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max) strncpy(newvar->value, tmp->ptr, 1024); newvar->next = VarHead; VarHead = newvar; - msgInfo("Set variable %s", newvar->value); + msgInfo("Setting option %s", newvar->value); } break; default: msgFatal("Don't know how to deal with menu type %d", tmp->type); } + + /* Did the user want to make this a single-selection menu? */ + if (menu->options & DMENU_SELECTION_RETURNS) { + items_free(nitems, curr, max); + return; + } } } diff --git a/usr.sbin/sysinstall/install.c b/usr.sbin/sysinstall/install.c index dcb5eb5..ee1efa0 100644 --- a/usr.sbin/sysinstall/install.c +++ b/usr.sbin/sysinstall/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.1.1.1 1995/04/27 12:50:35 jkh Exp $ + * $Id: install.c,v 1.2 1995/04/27 18:03:53 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -57,3 +57,8 @@ installExpress(void) return 0; } +int +installMaint(void) +{ + return 0; +} diff --git a/usr.sbin/sysinstall/media.c b/usr.sbin/sysinstall/media.c index 16fec45..b6febca 100644 --- a/usr.sbin/sysinstall/media.c +++ b/usr.sbin/sysinstall/media.c @@ -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$ + * $Id: media.c,v 1.1 1995/04/27 18:05:10 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -50,3 +50,53 @@ mediaSetCDROM(void) { return 0; } + +/* + * Return 0 if we successfully found and set the installation type to + * be a floppy + */ +int +mediaSetFloppy(void) +{ + return 0; +} + +/* + * Return 0 if we successfully found and set the installation type to + * be a DOS partition. + */ +int +mediaSetDOS(void) +{ + return 0; +} + +/* + * Return 0 if we successfully found and set the installation type to + * be a tape drive. + */ +int +mediaSetTape(void) +{ + return 0; +} + +/* + * Return 0 if we successfully found and set the installation type to + * be an ftp server + */ +int +mediaSetFTP(void) +{ + return 0; +} + +/* + * Return 0 if we successfully found and set the installation type to + * be some sort of mounted filesystem (it's also mounted at this point) + */ +int +mediaSetFS(void) +{ + return 0; +} diff --git a/usr.sbin/sysinstall/menus.c b/usr.sbin/sysinstall/menus.c index 3450a3e..c4afad5 100644 --- a/usr.sbin/sysinstall/menus.c +++ b/usr.sbin/sysinstall/menus.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: menus.c,v 1.1.1.1 1995/04/27 12:50:34 jkh Exp $ + * $Id: menus.c,v 1.2 1995/04/27 18:03:54 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -55,83 +55,9 @@ extern DMenu MenuMedia; extern DMenu MenuInstallType; extern DMenu MenuInstallOptions; -/* - * Bloody C won't let me nest these initializers properly - do the - * items and the menus containing them as two seperate initializers - * done in two groups. - */ - -/* First, the lists of items */ - -/* Documentation menu */ -DMenuItem _doc_items[] = { - { "README", "Read this for a general description of FreeBSD", /* R */ - MENU_DISPLAY_FILE, (void *)"help/readme.hlp", 0 }, - { "Hardware", "The FreeBSD survival guide for PC hardware.", /* H */ - MENU_DISPLAY_FILE, (void *)"help/hardware.hlp", 0 }, - { "Install", "A step-by-step guide to installing FreeBSD.", /* I */ - MENU_DISPLAY_FILE, (void *)"help/install.hlp", 0 }, - { "FAQ", "Frequently Asked Questions about FreeBSD.", /* F */ - MENU_DISPLAY_FILE, (void *)"help/faq.hlp", 0 }, - { NULL } -}; - -/* Language menu */ -DMenuItem _lang_items[] = { - { "English", "The system default language", /* E */ - MENU_SET_VARIABLE, (void *)"LANG=en", 0 }, - { "French", "French language and character set (ISO-8859-1)", /* F */ - MENU_SET_VARIABLE, (void *)"LANG=fr", 0 }, - { "German", "German language and character set (ISO-8859-1)", /* G */ - MENU_SET_VARIABLE, (void *)"LANG=de", 0 }, - { "Japanese", "Japanese language and character set (JIS?)", /* J */ - MENU_SET_VARIABLE, (void *)"LANG=jp", 0 }, - { "Russian", "Russian language and character set (cp866-8x14)", /* R */ - MENU_SET_VARIABLE, (void *)"LANG=ru", 0 }, - { NULL }, -}; - -/* The first menu */ -DMenuItem _initial_items[] = { - { "Usage", "Quick start - How to use this menu system.", /* U */ - MENU_DISPLAY_FILE, (void *)"help/initial.hlp", 0 }, - { "Doc", "More detailed documentation on FreeBSD.", /* D */ - MENU_SUBMENU, (void *)&MenuDocumentation, 0 }, - { "Lang", "Select natural language options.", /* L */ - MENU_SUBMENU, (void *)&MenuLanguage, 0 }, - { "Express", "Express installation (don't ask)", /* E */ - MENU_CALL, (void *)installExpress, 0 }, - { "Custom", "Custom installation (please ask)", /* C */ - MENU_CALL, (void *)installCustom, 0 }, - { NULL }, -}; - -/* Installation media menu */ -DMenuItem _media_items[] = { - { "CDROM", "Install from a FreeBSD CDROM", - MENU_CALL, (void *)mediaSetCDROM, 0 }, - { NULL }, -}; - -/* Installation main menu */ -DMenuItem _install_items[] = { - { "Media", "Choose Installation media type", /* M */ - MENU_SUBMENU, (void *)&MenuMedia, 0 }, - { "Type", "Choose the type of installation you want", /* T */ - MENU_SUBMENU, (void *)&MenuInstallType, 0 }, - { "Options", "Specify installation options", /* O */ - MENU_SUBMENU, (void *)&MenuInstallOptions, 0 }, - { "Proceed", "Proceed with installation", /* P */ - MENU_CANCEL, (void *)NULL, 0 }, - { NULL }, -}; - -DMenuItem _null_items[] = { - { NULL }, -}; - -/* Start the menu outer bodies */ +/* The initial installation menu */ DMenu MenuInitial = { + DMENU_NORMAL_TYPE, "Welcome to FreeBSD 2.0.5!", /* title */ "This is the main menu of the FreeBSD installation system. Please\n\ select one of the options below by using the arrow keys or typing the\n\ @@ -139,12 +65,26 @@ first character of the option name you're interested in. Invoke an\n\ option by pressing enter.", /* prompt */ "Press F1 for further help", /* help line */ "help/initial.hlp", /* help file */ - _initial_items, + { { "Usage", "Quick start - How to use this menu system.", /* U */ + DMENU_DISPLAY_FILE, (void *)"help/initial.hlp", 0 }, + { "Doc", "More detailed documentation on FreeBSD.", /* D */ + DMENU_SUBMENU, (void *)&MenuDocumentation, 0 }, + { "Lang", "Select natural language options.", /* L */ + DMENU_SUBMENU, (void *)&MenuLanguage, 0 }, + { "Express", "Express installation (don't ask)", /* E */ + DMENU_CALL, (void *)installExpress, 0 }, + { "Custom", "Custom installation (please ask)", /* C */ + DMENU_CALL, (void *)installCustom, 0 }, + { "Maint", "Go into maintainance mode (`fix it').", /* M */ + DMENU_CALL, (void *)installMaint, 0 }, + { NULL } }, }; +/* The main documentation menu */ DMenu MenuDocumentation = { + DMENU_NORMAL_TYPE, "Documentation for FreeBSD 2.0.5", /* Title */ - "If you are at all unsure about the configuration of your hardware\n + "If you are at all unsure about the configuration of your hardware\n\ or are looking to build a system specifically for FreeBSD, read the\n\ Hardware guide! New users should also read the Install document for\n\ a step-by-step tutorial on installing FreeBSD. For general information,\n\ @@ -152,50 +92,97 @@ consult the README file. If you're having other problems, you may find\n\ answers in the FAQ.", "Having trouble? Press F1 for help!", /* help line */ "help/usage.hlp", /* help file */ - _doc_items, + { { "README", "Read this for a general description of FreeBSD", /* R */ + DMENU_DISPLAY_FILE, (void *)"help/readme.hlp", 0 }, + { "Hardware", "The FreeBSD survival guide for PC hardware.", /* H */ + DMENU_DISPLAY_FILE, (void *)"help/hardware.hlp", 0 }, + { "Install", "A step-by-step guide to installing FreeBSD.", /* I */ + DMENU_DISPLAY_FILE, (void *)"help/install.hlp", 0 }, + { "FAQ", "Frequently Asked Questions about FreeBSD.", /* F */ + DMENU_DISPLAY_FILE, (void *)"help/faq.hlp", 0 }, + { NULL } }, }; +/* The language selection menu */ +/* + * Note: The RADIO menus use a slightly different syntax. If an item + * name starts with `*', it's considered to be "ON" by default, + * otherwise off. + */ DMenu MenuLanguage = { + DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS, "Natural language selection", /* title */ - "Please specify the language you'd like to use by default.\n\ -While a large amount of the system's documentation is still\n\ -written in english (and may never be translated), there are some\n\ -guides and system documentation that may be written in your\n\ + "Please specify the language you'd like to use by default.\n\n\ +While almost all of the system's documentation is still\n\ +written in english (and may never be translated), there are a few\n\ +guides and types of system documentation that may be written in your\n\ preferred language. When such are found, they will be used instead\n\ of the english versions.", /* prompt */ "Press F1 for more information", /* help line */ "help/language.hlp", /* help file */ - _lang_items, + { { "Danish", "Danish language and character set (ISO-8859-1)", /* D */ + DMENU_SET_VARIABLE, (void *)"LANG=en", 0 }, + { "*English", "English language (system default)", /* E */ + DMENU_SET_VARIABLE, (void *)"LANG=en", 0 }, + { "French", "French language and character set (ISO-8859-1)", /* F */ + DMENU_SET_VARIABLE, (void *)"LANG=fr", 0 }, + { "German", "German language and character set (ISO-8859-1)", /* G */ + DMENU_SET_VARIABLE, (void *)"LANG=de", 0 }, + { "Japanese", "Japanese language and character set (JIS?)", /* J */ + DMENU_SET_VARIABLE, (void *)"LANG=jp", 0 }, + { "Russian", "Russian language and character set (cp866-8x14)", /* R */ + DMENU_SET_VARIABLE, (void *)"LANG=ru", 0 }, + { NULL } }, }; +/* The media selection menu */ DMenu MenuMedia = { + DMENU_NORMAL_TYPE, "Choose Installation Media", "FreeBSD can be installed from a variety of different installation\n\ media, from floppies to the Internet. If you're installing FreeBSD from\n\ a supported CDROM drive then this is generally the best method to\n\ use unless you have some overriding reason for using another method.", - NULL, - NULL, - _media_items, + "Press F1 for more information on the various media types", + "help/media.hlp", + { { "CDROM", "Install from a FreeBSD CDROM", + DMENU_CALL, (void *)mediaSetCDROM, 0 }, + { "FLOPPY", "Install from a floppy disk set", + DMENU_CALL, (void *)mediaSetFloppy, 0 }, + { "DOS", "Install from a DOS partition", + DMENU_CALL, (void *)mediaSetDOS, 0 }, + { "TAPE", "Install from SCSI or QIC tape", + DMENU_CALL, (void *)mediaSetTape, 0 }, + { "FTP", "Install from an Internet FTP server", + DMENU_CALL, (void *)mediaSetFTP, 0 }, + { "FILESYSTEM", "Install from a UFS or NFS mounted distribution", + DMENU_CALL, (void *)mediaSetFS, 0 }, + { NULL } }, }; +/* The installation type menu */ DMenu MenuInstallType = { + DMENU_NORMAL_TYPE, "Choose Installation Type", "blah blah", NULL, NULL, - _null_items, + { { NULL } }, }; +/* The installation options menu */ DMenu MenuInstallOptions = { + DMENU_NORMAL_TYPE, "Choose Installation Options", "blah blah", NULL, NULL, - _null_items, + { { NULL } }, }; +/* The main installation menu */ DMenu MenuInstall = { + DMENU_NORMAL_TYPE, "Choose Installation Options", /* title */ "Before installation can continue, you need to specify a few items\n\ of information regarding the location of the distribution and the kind\n\ @@ -204,6 +191,14 @@ of options you can specify in the Options menu. If you do not wish to\n\ install FreeBSD at this time, you may select Cancel to leave this menu", "You may wish to read the install guide - press F1 to do so", "help/install.hlp", - _install_items, + { { "Media", "Choose Installation media type", /* M */ + DMENU_SUBMENU, (void *)&MenuMedia, 0 }, + { "Type", "Choose the type of installation you want", /* T */ + DMENU_SUBMENU, (void *)&MenuInstallType, 0 }, + { "Options", "Specify installation options", /* O */ + DMENU_SUBMENU, (void *)&MenuInstallOptions, 0 }, + { "Proceed", "Proceed with installation", /* P */ + DMENU_CANCEL, (void *)NULL, 0 }, + { NULL } }, }; diff --git a/usr.sbin/sysinstall/misc.c b/usr.sbin/sysinstall/misc.c index e9a5642..4f789e2 100644 --- a/usr.sbin/sysinstall/misc.c +++ b/usr.sbin/sysinstall/misc.c @@ -1,7 +1,7 @@ /* * Miscellaneous support routines.. * - * $Id$ + * $Id: misc.c,v 1.1.1.1 1995/04/27 12:50:35 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -99,9 +99,10 @@ safe_free(void *ptr) } /* - * These next two are kind of specialized just for building string lists + * These next routines are kind of specialized just for building string lists * for dialog_menu(). */ + /* Add a string to an item list */ char ** item_add(char **list, char *item, int *curr, int *max) @@ -115,6 +116,15 @@ item_add(char **list, char *item, int *curr, int *max) return list; } +/* Add a pair of items to an item list (more the usual case) */ +char ** +item_add_pair(char **list, char *item1, char *item2, int *curr, int *max) +{ + list = item_add(list, item1, curr, max); + list = item_add(list, item2, curr, max); + return list; +} + /* Toss the items out */ void items_free(char **list, int *curr, int *max) diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h index aa75faa..1b318f4 100644 --- a/usr.sbin/sysinstall/sysinstall.h +++ b/usr.sbin/sysinstall/sysinstall.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.1.1.1 1995/04/27 12:50:34 jkh Exp $ + * $Id: sysinstall.h,v 1.2 1995/04/27 18:03:55 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -50,34 +50,41 @@ #include <unistd.h> #include <dialog.h> +/* Bitfields for menu options */ +#define DMENU_NORMAL_TYPE 0x1 /* Normal dialog menu */ +#define DMENU_RADIO_TYPE 0x2 /* Radio dialog menu */ +#define DMENU_MULTIPLE_TYPE 0x4 /* Multiple choice menu */ +#define DMENU_SELECTION_RETURNS 0x8 /* Select item then exit */ + /* Types */ typedef unsigned int Boolean; typedef enum { - MENU_SHELL_ESCAPE, /* Fork a shell */ - MENU_DISPLAY_FILE, /* Display a file's contents */ - MENU_SUBMENU, /* Recurse into another menu */ - MENU_SYSTEM_COMMAND, /* Run shell commmand */ - MENU_SYSTEM_COMMAND_BOX, /* Same as above, but in prgbox */ - MENU_SET_VARIABLE, /* Set an environment/system var */ - MENU_CALL, /* Call back a C function */ - MENU_CANCEL, /* Cancel out of this menu */ + DMENU_SHELL_ESCAPE, /* Fork a shell */ + DMENU_DISPLAY_FILE, /* Display a file's contents */ + DMENU_SUBMENU, /* Recurse into another menu */ + DMENU_SYSTEM_COMMAND, /* Run shell commmand */ + DMENU_SYSTEM_COMMAND_BOX, /* Same as above, but in prgbox */ + DMENU_SET_VARIABLE, /* Set an environment/system var */ + DMENU_CALL, /* Call back a C function */ + DMENU_CANCEL, /* Cancel out of this menu */ } DMenuItemType; typedef struct _dmenuItem { - char *title; /* Our title */ - char *prompt; /* Our prompt */ - DMenuItemType type; /* What type of item we are */ - void *ptr; /* Generic data ptr */ - int disabled; /* Are we temporarily disabled? */ + char *title; /* Our title */ + char *prompt; /* Our prompt */ + DMenuItemType type; /* What type of item we are */ + void *ptr; /* Generic data ptr */ + int disabled; /* Are we temporarily disabled? */ } DMenuItem; typedef struct _dmenu { - char *title; /* Our title */ - char *prompt; /* Our prompt */ - char *helpline; /* Line of help at bottom */ - char *helpfile; /* Help file for "F1" */ - DMenuItem *items; /* Array of menu items */ + unsigned int options; /* What sort of menu we are */ + char *title; /* Our title */ + char *prompt; /* Our prompt */ + char *helpline; /* Line of help at bottom */ + char *helpfile; /* Help file for "F1" */ + DMenuItem items[0]; /* Array of menu items */ } DMenu; /* A sysconfig variable */ @@ -89,11 +96,11 @@ typedef struct _variable { /* Externs */ extern int CpioFD; /* The file descriptor for our CPIO floppy */ -extern int DebugFD; /* Where diagnostic output goes */ -extern Boolean OnCDROM; /* Are we running off of a CDROM? */ -extern Boolean OnSerial; /* Are we on a serial console? */ -extern Boolean DialogActive; /* Is the dialog() stuff up? */ -extern Variable *VarHead; /* The head of the variable chain */ +extern int DebugFD; /* Where diagnostic output goes */ +extern Boolean OnCDROM; /* Are we running off of a CDROM? */ +extern Boolean OnSerial; /* Are we on a serial console? */ +extern Boolean DialogActive; /* Is the dialog() stuff up? */ +extern Variable *VarHead; /* The head of the variable chain */ /* All the menus to which forward references exist */ extern DMenu MenuDocumenation, MenuInitial, MenuLanguage; @@ -107,12 +114,15 @@ extern void globalsInit(void); /* install.c */ extern int installCustom(void); extern int installExpress(void); +extern int installMaint(void); /* system.c */ extern void systemInitialize(int argc, char **argv); extern void systemShutdown(void); extern void systemWelcome(void); extern int systemExecute(char *cmd); +extern int systemShellEscape(void); +extern int systemDisplayFile(char *file); /* dmenu.c */ extern void dmenuOpen(DMenu *menu, int *choice, int *scroll, @@ -126,6 +136,8 @@ extern char *string_prune(char *str); extern char *string_skipwhite(char *str); extern void safe_free(void *ptr); extern char **item_add(char **list, char *item, int *curr, int *max); +extern char **item_add_pair(char **list, char *item1, char *item2, + int *curr, int *max); extern void items_free(char **list, int *curr, int *max); /* termcap.c */ @@ -139,6 +151,11 @@ extern void msgFatal(char *fmt, ...); /* media.c */ extern int mediaSetCDROM(void); +extern int mediaSetFloppy(void); +extern int mediaSetDOS(void); +extern int mediaSetTape(void); +extern int mediaSetFTP(void); +extern int mediaSetFS(void); #endif /* _SYSINSTALL_H_INCLUDE */ diff --git a/usr.sbin/sysinstall/system.c b/usr.sbin/sysinstall/system.c index a48c9df..cbf7549 100644 --- a/usr.sbin/sysinstall/system.c +++ b/usr.sbin/sysinstall/system.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id$ + * $Id: system.c,v 1.1.1.1 1995/04/27 12:50:34 jkh Exp $ * * Jordan Hubbard * @@ -20,6 +20,7 @@ #include <sys/reboot.h> #include <sys/fcntl.h> #include <sys/ioctl.h> +#include <sys/wait.h> /* Handle interrupt signals (duh!) */ static void @@ -87,8 +88,11 @@ systemShutdown(void) /* REALLY exit! */ if (getpid() == 1) reboot(RB_HALT); + else + exit(1); } +/* Run some general command */ int systemExecute(char *command) { @@ -105,3 +109,67 @@ systemExecute(char *command) return status; } +/* Find and execute a shell */ +int +systemShellEscape(void) +{ + char *sh = NULL; + + if (file_executable("/bin/sh")) + sh = "/bin/sh"; + else if (file_executable("/stand/sh")) + sh = "/stand/sh"; + else { + msgWarn("No shell available, sorry!"); + return 1; + } + setenv("PS1", "freebsd% ", 1); + dialog_clear(); + dialog_update(); + move(0, 0); + standout(); + addstr("Type `exit' to leave this shell and continue installallation"); + standend(); + refresh(); + end_dialog(); + DialogActive = FALSE; + if (fork() == 0) + execlp(sh, "-sh", 0); + else + wait(NULL); + dialog_clear(); + DialogActive = TRUE; + return 0; +} + +/* Display a file in a filebox */ +int +systemDisplayFile(char *file) +{ + char buf[FILENAME_MAX], *cp, *fname = NULL; + + if (file_readable(file)) + fname = file; + else if ((cp = getenv("LANG")) != NULL) { + snprintf(buf, FILENAME_MAX, "%s/%s", cp, file); + if (file_readable(buf)) + fname = buf; + } + else { + snprintf(buf, FILENAME_MAX, "english/%s", file); + if (file_readable(buf)) + fname = buf; + } + if (!fname) { + snprintf(buf, FILENAME_MAX, "The %s file is not provided on this particular floppy image.", file); + dialog_msgbox("Sorry!", buf, -1, -1, 1); + dialog_clear_norefresh(); + return 1; + } + else { + dialog_clear_norefresh(); + dialog_textbox(file, fname, LINES, COLS); + dialog_clear_norefresh(); + } + return 0; +} |