diff options
author | jkh <jkh@FreeBSD.org> | 1995-04-27 12:50:35 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1995-04-27 12:50:35 +0000 |
commit | 6f2f81d9e4ac7ca45afd65b27e5567b6f807ed79 (patch) | |
tree | ef685ef365d69340db49a32f4b84a0d6e94b07e5 | |
parent | ceb04bec46fb40aa3c0a8e5705ecafe366728405 (diff) | |
download | FreeBSD-src-6f2f81d9e4ac7ca45afd65b27e5567b6f807ed79.zip FreeBSD-src-6f2f81d9e4ac7ca45afd65b27e5567b6f807ed79.tar.gz |
Here is my first "framework" commit of the new sysinstall. There is a LOT
more to come in the next 24 hours, this is just the first stable result of
8 hours of hacking so far. The specification format for menus is pretty
much hammered out and the beginnings (very humble) of the doc hierarchy
are present for an example. It should be quite easy to add a lot more
menus quickly to this since I did go somewhat out of my way to make the
framework easy to work with. This is NOT the glorious semi-graphical
sysinstall (or whatever its name will be) that the install-geeks are working
on, this is simply the "son of sysinstall" I've been promising to write in
the interim for 2.0.5 and 2.1R (super install doesn't come until 2.2R).
39 files changed, 3547 insertions, 0 deletions
diff --git a/release/sysinstall/Makefile b/release/sysinstall/Makefile new file mode 100644 index 0000000..9be88fe --- /dev/null +++ b/release/sysinstall/Makefile @@ -0,0 +1,50 @@ +PROG= sysinstall +NOMAN= yes +CLEANFILES= makedevs.c rtermcap + +.PATH: ${.CURDIR}/../disklabel + +SRCS = globals.c main.c dmenu.c menus.c \ + misc.c msg.c system.c install.c \ + termcap.c makedevs.c + +CFLAGS += -Wall -g -static +LDADD = -ldialog -lncurses -lmytinfo +DPADD = ${LIBDIALOG} ${LIBNCURSES} ${LIBMYTINFO} + +.if exists(${.CURDIR}/../../sys/i386/boot/biosboot/obj) +BOOTS=${.CURDIR}/../../sys/i386/boot/biosboot/obj +.else +BOOTS=${.CURDIR}/../../sys/i386/boot/biosboot +.endif + +makedevs.c: dev2c.sh Makefile rtermcap + mkdir -p dev + cp ${.CURDIR}/../../etc/etc.i386/MAKEDEV dev + ( cd dev; sh ./MAKEDEV all ) + sh ${.CURDIR}/dev2c.sh dev > makedevs.tmp + rm -rf dev + uudecode < ${.CURDIR}/bteasy17.uu + file2c 'const unsigned char boot0[] = {' '};' \ + < bteasy17 >> makedevs.tmp + rm -rf bteasy17 + file2c 'const unsigned char boot1[] = {' '};' \ + < ${BOOTS}/boot1 >> makedevs.tmp + file2c 'const unsigned char boot2[] = {' '};' \ + < ${BOOTS}/boot2 >> makedevs.tmp + ./rtermcap cons25 | \ + file2c 'const char termcap_cons25[] = {' ',0};' \ + >> makedevs.tmp + ./rtermcap cons25-m | \ + file2c 'const char termcap_cons25_m[] = {' ',0};' \ + >> makedevs.tmp + ./rtermcap vt100 | \ + file2c 'const char termcap_vt100[] = {' ',0};' \ + >> makedevs.tmp + mv makedevs.tmp makedevs.c + +rtermcap: ${.CURDIR}/rtermcap.c + ${CC} -o rtermcap ${.CURDIR}/rtermcap.c -ltermcap + +.include <bsd.prog.mk> + diff --git a/release/sysinstall/bteasy17.uu b/release/sysinstall/bteasy17.uu new file mode 100644 index 0000000..2cc05b2 --- /dev/null +++ b/release/sysinstall/bteasy17.uu @@ -0,0 +1,15 @@ +begin 664 bteasy17 +M,\".P([8CM"\`'S\B_2_``:Y``'RI>I@!@``B]58HD@'/#5T'+00]N0%K@26 +M]D0$_W0^Q@2`Z-H`BG0!BTP"ZPCHSP"Y`0`RT;L`?+@!`LT3<AZ!O_X!5:IU +M%NH`?```@/J!=`*R@(OJ0H#RLX@6.@>_O@>Y!`#&!BT',3+VB"V*100\`'0C +M/`5T'_[&OBH'Z'$`OD@'1D:+'`K_=`4R?01U\XVW<@?H6@"#QQ#^!BT'XLN` +M/G4$`G0+OCL'"O9U"LT8ZZR^*@?H.0#H-@`RY,T:B]J#PV"T`<T6M`!U"\T: +M.]-R\J!(!^L*S1:*Q#P<=/,$]CPQ<M8\-7?24+XH![L;!E/\K%`D?[0.S1!8 +MJ(!T\L-6N`$#NP`&N0$`,O;-$U[&!D@'/\,-B@T*1C`@+B`N("Z@9&ES:R`Q +M#0H*1&5F875L=#H@1C^@``$`!``&`P<'"@IC#F0.912`%($9@AZ3)*4GGRMU +M+U(OVS)`-_(]`&1O\TA01M-/<[)5;FGX3F]V96SL36EN:?A,:6YU^$%M;V5B +MX4)3Q$)31.E00TG80U#-5F5N:?A$;W-S9>,_OP`````````````````````` +M```````````````````````````````````````````````````````````` +1````````````````````5:H` +` +end diff --git a/release/sysinstall/dev2c.sh b/release/sysinstall/dev2c.sh new file mode 100644 index 0000000..cbd2e71 --- /dev/null +++ b/release/sysinstall/dev2c.sh @@ -0,0 +1,80 @@ +: +# +# ---------------------------------------------------------------------------- +# "THE BEER-WARE LICENSE" (Revision 42): +# <phk@login.dknet.dk> wrote this file. As long as you retain this notice you +# can do whatever you want with this stuff. If we meet some day, and you think +# this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp +# ---------------------------------------------------------------------------- +# +# $Id: dev2c.sh,v 1.1 1994/10/26 02:53:08 phk Exp $ +# +# During installation, we suffer badly of we have to run MAKEDEV. MAKEDEV +# need sh, ln, chown, mknod, awk, rm, test and probably emacs too when +# we come down to it. So instead this script will make a C-procedure which +# makes all the B & C nodes of a specified directory. +# +# Poul-Henning + +(cd $1; ls -li ) | sed 's/,//' | awk ' +BEGIN { + while (getline < "/etc/passwd") { + split($0,a,":") + uid[a[1]] = a[3] + } + while (getline < "/etc/group") { + split($0,a,":") + gid[a[1]] = a[3] + } + printf("/*\n"); + printf(" * This file is generated from the contents of /dev\n"); + printf(" */\n"); + printf("#define CHK(foo) {i = foo;}\n"); + printf("#include <unistd.h>\n"); + printf("#include <sys/types.h>\n"); + printf("#include <sys/stat.h>\n"); + printf("int makedevs()\n{\n\tint i=0;\n"); + } + { + printf ("/* %s */\n",$0) + $4 = uid[$4] + $5 = gid[$5] + if (substr($2,1,1) == "b") { + k="S_IFBLK" + } else if (substr($2,1,1) == "c") { + k="S_IFCHR" + } else if (substr($2,1,1) == "d") { + next + } else if (substr($2,1,1) == "-") { + next + } else { + next + } + m = 0; + if (substr($2,2,1) == "r") m += 400; + if (substr($2,3,1) == "w") m += 200; + if (substr($2,4,1) == "x") m += 100; + if (substr($2,5,1) == "r") m += 40; + if (substr($2,6,1) == "w") m += 20; + if (substr($2,7,1) == "x") m += 10; + if (substr($2,8,1) == "r") m += 4; + if (substr($2,9,1) == "w") m += 2; + if (substr($2,10,1) == "x") m += 1; + + if (a[$1] != 0) { + printf ("\tCHK(link(\"%s\",\"%s\"));\n", \ + a[$1],$11) + } else { + printf ("\tCHK(mknod(\"%s\",%s,makedev(%d,%d)));\n", \ + $11, k, $6, $7) + printf ("\tCHK(chmod(\"%s\",0%d));\n", \ + $11, m) + printf ("\tCHK(chown(\"%s\",%d,%d));\n", \ + $11, $4,$5) + a[$1] = $11 + } + } +END { + printf("\treturn i;\n}\n"); + } +' diff --git a/release/sysinstall/dmenu.c b/release/sysinstall/dmenu.c new file mode 100644 index 0000000..cb8508d --- /dev/null +++ b/release/sysinstall/dmenu.c @@ -0,0 +1,191 @@ +/* + * The new sysinstall program. + * + * This is probably the last attempt in the `sysinstall' line, the next + * generation being slated for what's essentially a complete rewrite. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sysinstall.h" +#include <sys/wait.h> + +#define MAX_MENU 15 + +static DMenuItem shellAction = { NULL, NULL, MENU_SHELL_ESCAPE, NULL, 0 }; + +/* Traverse over an internal menu */ +void +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; + + /* 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); + ++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) { + /* 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); + dialog_clear(); + if (!rval) { + for (tmp = menu->items; tmp->title; tmp++) + if (!strcmp(result, tmp->title)) + break; + if (!tmp->title) + msgFatal("Menu item `%s' not found??", result); + } + else if (rval == 255) + tmp = &shellAction; + else { + items_free(nitems, curr, max); + return; + } + switch (tmp->type) { + 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; + break; + + 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(); + } + } + break; + + case MENU_SUBMENU: { + int choice, scroll, curr, max; + + choice = scroll = curr = max = 0; + dmenuOpen((DMenu *)tmp->ptr, &choice, &scroll, &curr, &max); + break; + } + + case MENU_SYSTEM_COMMAND: + (void)systemExecute((char *)tmp->ptr); + break; + + case MENU_CALL: + ((void (*)())tmp->ptr)(); + break; + + case MENU_SET_VARIABLE: { + Variable *newvar; + + if (!index((char *)tmp->ptr, '=')) + msgWarn("Improperly formatted variable: %s", tmp->ptr); + putenv((char *)tmp->ptr); + newvar = (Variable *)malloc(sizeof(Variable)); + if (!newvar) + msgFatal("Out of Memory!"); + strncpy(newvar->value, tmp->ptr, 1024); + newvar->next = VarHead; + VarHead = newvar; + } + break; + + default: + msgFatal("Don't know how to deal with menu type %d", tmp->type); + } + } +} + + diff --git a/release/sysinstall/globals.c b/release/sysinstall/globals.c new file mode 100644 index 0000000..9d52ff3 --- /dev/null +++ b/release/sysinstall/globals.c @@ -0,0 +1,72 @@ +/* + * The new sysinstall program. + * + * This is probably the last program in the `sysinstall' line - the next + * generation being essentially a complete rewrite. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sysinstall.h" + +/* + * Various global variables and an initialization hook to set them to + * whatever values we feel are appropriate. + */ + +int CpioFD; /* The file descriptor for our CPIO floppy */ +int DebugFD; /* Where diagnostic output goes */ +Boolean OnCDROM; /* Are we running off of a CDROM? */ +Boolean OnSerial; /* Are we on a serial console? */ +Boolean DialogActive; +Variable *VarHead; /* The head of the variable chain */ + +/* + * Yes, I know some of these are already automatically initialized as + * globals. I simply find it clearer to set everything explicitly. + */ +void +globalsInit(void) +{ + CpioFD = -1; + DebugFD = -1; + OnCDROM = FALSE; + OnSerial = FALSE; + DialogActive = FALSE; + VarHead = NULL; +} + diff --git a/release/sysinstall/install.c b/release/sysinstall/install.c new file mode 100644 index 0000000..bc6937b --- /dev/null +++ b/release/sysinstall/install.c @@ -0,0 +1,56 @@ +/* + * The new sysinstall program. + * + * This is probably the last program in the `sysinstall' line - the next + * generation being essentially a complete rewrite. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sysinstall.h" + +void +installExpress(void) +{ + msgInfo("Doing an express installation"); +} + +void +installCustom(void) +{ + msgInfo("Doing a custom installation"); +} diff --git a/release/sysinstall/main.c b/release/sysinstall/main.c new file mode 100644 index 0000000..31a7c0f --- /dev/null +++ b/release/sysinstall/main.c @@ -0,0 +1,66 @@ +/* + * The new sysinstall program. + * + * This is probably the last attempt in the `sysinstall' line, the next + * generation being slated for what's essentially a complete rewrite. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sysinstall.h" + +int +main(int argc, char **argv) +{ + int choice, scroll, curr, max; + + /* Set up whatever things need setting up */ + systemInitialize(argc, argv); + + /* Welcome user to FreeBSD */ + systemWelcome(); + + /* Begin user dialog at outer menu */ + choice = scroll = curr = max = 0; + dmenuOpen(&MenuInitial, &choice, &scroll, &curr, &max); + + /* Say goodnight, Gracie */ + systemShutdown(); + + /* If we're running as init, we should never get here */ + return 0; +} diff --git a/release/sysinstall/menus.c b/release/sysinstall/menus.c new file mode 100644 index 0000000..ce19217 --- /dev/null +++ b/release/sysinstall/menus.c @@ -0,0 +1,119 @@ +/* + * The new sysinstall program. + * + * This is probably the last program in the `sysinstall' line - the next + * generation being essentially a complete rewrite. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sysinstall.h" + +/* All the system menus go here. + * + * Hardcoded things like version number strings will disappear from + * these menus just as soon as I add the code for doing inline variable + * expansion. + */ + +DMenuItem documentation_items[] = { +{ "README", "Read this for a general description of FreeBSD", + MENU_DISPLAY_FILE, (void *)"help/readme.hlp", 0 }, +{ "Hardware", "The FreeBSD survival guide for PC hardware.", + MENU_DISPLAY_FILE, (void *)"help/hardware.hlp", 0 }, +{ "Install", "A step-by-step guide to installing FreeBSD.", + MENU_DISPLAY_FILE, (void *)"help/install.hlp", 0 }, +{ "FAQ", "Frequently Asked Questions about FreeBSD.", + MENU_DISPLAY_FILE, (void *)"help/faq.hlp", 0 }, +{ NULL }, +}; + +DMenu MenuDocumentation = { +"Documentation for FreeBSD 2.0.5", /* Title */ +"Blah blah", /* Prompt */ +NULL, /* No help line */ +NULL, /* No help file */ +documentation_items, +}; + +DMenuItem language_items[] = { +{ "English", "The system default.", + MENU_SET_VARIABLE, (void *)"LANG=en", 0 }, +{ "French", "French language and character set (ISO-8859-1)", + MENU_SET_VARIABLE, (void *)"LANG=fr", 0 }, +{ "German", "German language and character set (ISO-8859-1)", + MENU_SET_VARIABLE, (void *)"LANG=de", 0 }, +{ "Japanese", "Japanese language and character set (JIS?)", + MENU_SET_VARIABLE, (void *)"LANG=jp", 0 }, +{ "Russian", "Russian language and character set (cp866-8x14)", + MENU_SET_VARIABLE, (void *)"LANG=ru", 0 }, +{ NULL }, +}; + +DMenu MenuLanguage = { +"Set your preferred language", +"Blah blah", +NULL, +NULL, +language_items, +}; + +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 }, +}; + +/* The first menu */ +DMenu MenuInitial = { +"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\ +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, /* items */ +}; diff --git a/release/sysinstall/misc.c b/release/sysinstall/misc.c new file mode 100644 index 0000000..e9a5642 --- /dev/null +++ b/release/sysinstall/misc.c @@ -0,0 +1,125 @@ +/* + * Miscellaneous support routines.. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sysinstall.h" +#include <ctype.h> + +/* Quick check to see if a file is readable */ +Boolean +file_readable(char *fname) +{ + if (!access(fname, F_OK)) + return TRUE; + return FALSE; +} + +/* Quick check to see if a file is executable */ +Boolean +file_executable(char *fname) +{ + if (!access(fname, X_OK)) + return TRUE; + return FALSE; +} + +/* Concatenate two strings into static storage */ +char * +string_concat(char *one, char *two) +{ + static char tmp[FILENAME_MAX]; + + strcpy(tmp, one); + strcat(tmp, two); + return tmp; +} + +/* Clip the whitespace off the end of a string */ +char * +string_prune(char *str) +{ + int len = str ? strlen(str) : 0; + + while (len && isspace(str[len - 1])) + str[--len] = '\0'; + return str; +} + +/* run the whitespace off the front of a string */ +char * +string_skipwhite(char *str) +{ + while (*str && isspace(*str)) + ++str; + return str; +} + +/* A free guaranteed to take NULL ptrs */ +void +safe_free(void *ptr) +{ + if (ptr) + free(ptr); +} + +/* + * These next two 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) +{ + + if (*curr == *max) { + *max += 20; + list = (char **)realloc(list, sizeof(char *) * *max); + } + list[(*curr)++] = item; + return list; +} + +/* Toss the items out */ +void +items_free(char **list, int *curr, int *max) +{ + safe_free(list); + *curr = *max = 0; +} + diff --git a/release/sysinstall/msg.c b/release/sysinstall/msg.c new file mode 100644 index 0000000..c9fd5ce --- /dev/null +++ b/release/sysinstall/msg.c @@ -0,0 +1,131 @@ +/* + * The new sysinstall program. + * + * This is probably the last program in the `sysinstall' line - the next + * generation being essentially a complete rewrite. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sysinstall.h" +#include <stdarg.h> + +/* Whack up an informational message on the status line */ +void +msgInfo(char *fmt, ...) +{ + va_list args; + char *errstr; + + errstr = (char *)malloc(FILENAME_MAX); + errstr[0] = '\0'; + va_start(args, fmt); + vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); + va_end(args); + move(25, 0); + addstr(errstr); + free(errstr); +} + +/* Whack up a warning on the status line */ +void +msgWarn(char *fmt, ...) +{ + va_list args; + char *errstr; + + errstr = (char *)malloc(FILENAME_MAX); + strcpy(errstr, "Warning: "); + va_start(args, fmt); + vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); + va_end(args); + move(25, 0); + beep(); + standout(); + addstr(errstr); + standend(); + free(errstr); +} + +/* Whack up an error on the status line */ +void +msgError(char *fmt, ...) +{ + va_list args; + char *errstr; + + errstr = (char *)malloc(FILENAME_MAX); + strcpy(errstr, "Error: "); + va_start(args, fmt); + vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); + va_end(args); + move(25, 0); + beep(); + standout(); + addstr(errstr); + standend(); + free(errstr); +} + +/* Whack up a fatal error on the status line */ +void +msgFatal(char *fmt, ...) +{ + va_list args; + char *errstr; + + errstr = (char *)malloc(FILENAME_MAX); + strcpy(errstr, "Fatal Error: "); + va_start(args, fmt); + vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); + va_end(args); + move(25, 0); + beep(); + standout(); + addstr(errstr); + addstr(" - "); + addstr("PRESS ANY KEY TO "); + if (getpid() == 1) + addstr("REBOOT"); + else + addstr("QUIT"); + standend(); + free(errstr); + getch(); + systemShutdown(); +} + diff --git a/release/sysinstall/rtermcap.c b/release/sysinstall/rtermcap.c new file mode 100644 index 0000000..3f18e8b --- /dev/null +++ b/release/sysinstall/rtermcap.c @@ -0,0 +1,14 @@ +#include <stdio.h> +#include <termcap.h> + +int +main(int argc, char **argv) +{ + char buf[4096]; + int i; + + i = tgetent(buf, argv[1]); + + printf("%s",buf); + return 0; +} diff --git a/release/sysinstall/sysinstall.h b/release/sysinstall/sysinstall.h new file mode 100644 index 0000000..c6a2af4 --- /dev/null +++ b/release/sysinstall/sysinstall.h @@ -0,0 +1,131 @@ +/* + * The new sysinstall program. + * + * This is probably the last attempt in the `sysinstall' line, the next + * generation being slated to essentially a complete rewrite. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#ifndef _SYSINSTALL_H_INCLUDE +#define _SYSINSTALL_H_INCLUDE + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <dialog.h> + +/* Types */ +typedef unsigned int Boolean; + +typedef enum { + MENU_SHELL_ESCAPE, + MENU_DISPLAY_FILE, + MENU_SUBMENU, + MENU_SYSTEM_COMMAND, + MENU_SET_VARIABLE, + MENU_CALL +} DMenuItemType; + +typedef struct _dmenuItem { + char *title; + char *prompt; + DMenuItemType type; + void *ptr; + int disabled; +} DMenuItem; + +typedef struct _dmenu { + char *title; + char *prompt; + char *helpline; + char *helpfile; + DMenuItem *items; +} DMenu; + +/* A sysconfig variable */ +typedef struct _variable { + struct _variable *next; + char value[1024]; +} 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 */ + +/* All the menus to which forward references exist */ +extern DMenu MenuDocumenation, MenuInitial, MenuLanguage; + + +/* Prototypes */ +extern void globalsInit(void); + +extern void installExpress(void); +extern void installCustom(void); + +extern void systemInitialize(int argc, char **argv); +extern void systemShutdown(void); +extern void systemWelcome(void); +extern int systemExecute(char *cmd); + +extern void dmenuOpen(DMenu *menu, int *choice, int *scroll, + int *curr, int *max); + +extern Boolean file_readable(char *fname); +extern Boolean file_executable(char *fname); +extern char *string_concat(char *p1, char *p2); +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 void items_free(char **list, int *curr, int *max); + +extern int set_termcap(void); + +extern void msgInfo(char *fmt, ...); +extern void msgWarn(char *fmt, ...); +extern void msgError(char *fmt, ...); +extern void msgFatal(char *fmt, ...); + +#endif +/* _SYSINSTALL_H_INCLUDE */ diff --git a/release/sysinstall/system.c b/release/sysinstall/system.c new file mode 100644 index 0000000..a48c9df --- /dev/null +++ b/release/sysinstall/system.c @@ -0,0 +1,107 @@ +/* + * The new sysinstall program. + * + * This is probably the last program in the `sysinstall' line - the next + * generation being essentially a complete rewrite. + * + * $Id$ + * + * Jordan Hubbard + * + * My contributions are in the public domain. + * + * Parts of this file are also blatently stolen from Poul-Henning Kamp's + * previous version of sysinstall, and as such fall under his "BEERWARE" + * license, so buy him a beer if you like it! Buy him a beer for me, too! + */ + +#include "sysinstall.h" +#include <signal.h> +#include <sys/reboot.h> +#include <sys/fcntl.h> +#include <sys/ioctl.h> + +/* Handle interrupt signals (duh!) */ +static void +handle_intr(int sig) +{ +} + +/* Welcome the user to the system */ +void +systemWelcome(void) +{ +} + +/* Initialize system defaults */ +void +systemInitialize(int argc, char **argv) +{ + signal(SIGINT, SIG_IGN); + globalsInit(); + + /* Are we running as init? */ + if (getpid() == 1) { + setsid(); + if (argc > 1 && strchr(argv[1],'C')) { + /* Kernel told us that we are on a CDROM root */ + close(0); open("/bootcd/dev/console", O_RDWR); + close(1); dup(0); + close(2); dup(0); + CpioFD = open("/floppies/cpio.flp", O_RDONLY); + OnCDROM = TRUE; + chroot("/bootcd"); + } else { + close(0); open("/dev/console", O_RDWR); + close(1); dup(0); + close(2); dup(0); + } + msgInfo("%s running as init", argv[0]); + + ioctl(0, TIOCSCTTY, (char *)NULL); + setlogin("root"); + setbuf(stdin, 0); + setbuf(stdout, 0); + setbuf(stderr, 0); + } + + if (set_termcap() == -1) + msgFatal("Can't find terminal entry"); + + /* XXX - libdialog has particularly bad return value checking */ + init_dialog(); + /* If we haven't crashed I guess dialog is running ! */ + DialogActive = TRUE; + + signal(SIGINT, handle_intr); +} + +/* Close down and prepare to exit */ +void +systemShutdown(void) +{ + if (DialogActive) { + end_dialog(); + DialogActive = FALSE; + } + /* REALLY exit! */ + if (getpid() == 1) + reboot(RB_HALT); +} + +int +systemExecute(char *command) +{ + int status; + + dialog_clear(); + dialog_update(); + end_dialog(); + DialogActive = FALSE; + status = system(command); + DialogActive = TRUE; + dialog_clear(); + dialog_update(); + return status; +} + diff --git a/release/sysinstall/termcap.c b/release/sysinstall/termcap.c new file mode 100644 index 0000000..e05b82d --- /dev/null +++ b/release/sysinstall/termcap.c @@ -0,0 +1,62 @@ +/* + * Copyright (c) 1994, Paul Richards. + * + * All rights reserved. + * + * This software may be used, modified, copied, distributed, and sold, in both + * source and binary form provided that the above copyright and these terms + * are retained, verbatim, as the first lines of this file. Under no + * circumstances is the author responsible for the proper functioning of this + * software, nor does the author assume any responsibility for damages + * incurred with its use. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <stdarg.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include <machine/console.h> + +#include "sysinstall.h" + +int +set_termcap(void) +{ + char *term; + extern const char termcap_vt100[]; + extern const char termcap_cons25[]; + extern const char termcap_cons25_m[]; + + term = getenv("TERM"); + if (term == NULL) { + int color_display; + + if (ioctl(STDERR_FILENO, GIO_COLOR, &color_display) < 0) { + if (setenv("TERM", "vt100", 1) < 0) + return -1; + if (setenv("TERMCAP", termcap_vt100, 1) < 0) + return -1; + DebugFD = dup(1); + OnSerial = TRUE; + } else if (color_display) { + if (setenv("TERM", "cons25", 1) < 0) + return -1; + if (setenv("TERMCAP", termcap_cons25, 1) < 0) + return -1; + DebugFD = open("/dev/ttyv1",O_WRONLY); + } else { + if (setenv("TERM", "cons25-m", 1) < 0) + return -1; + if (setenv("TERMCAP", termcap_cons25_m, 1) < 0) + return -1; + DebugFD = open("/dev/ttyv1",O_WRONLY); + } + } else { + DebugFD = open("sysinstall.debug", + O_WRONLY|O_CREAT|O_TRUNC,0644); + } + return 0; +} diff --git a/usr.sbin/sade/Makefile b/usr.sbin/sade/Makefile new file mode 100644 index 0000000..9be88fe --- /dev/null +++ b/usr.sbin/sade/Makefile @@ -0,0 +1,50 @@ +PROG= sysinstall +NOMAN= yes +CLEANFILES= makedevs.c rtermcap + +.PATH: ${.CURDIR}/../disklabel + +SRCS = globals.c main.c dmenu.c menus.c \ + misc.c msg.c system.c install.c \ + termcap.c makedevs.c + +CFLAGS += -Wall -g -static +LDADD = -ldialog -lncurses -lmytinfo +DPADD = ${LIBDIALOG} ${LIBNCURSES} ${LIBMYTINFO} + +.if exists(${.CURDIR}/../../sys/i386/boot/biosboot/obj) +BOOTS=${.CURDIR}/../../sys/i386/boot/biosboot/obj +.else +BOOTS=${.CURDIR}/../../sys/i386/boot/biosboot +.endif + +makedevs.c: dev2c.sh Makefile rtermcap + mkdir -p dev + cp ${.CURDIR}/../../etc/etc.i386/MAKEDEV dev + ( cd dev; sh ./MAKEDEV all ) + sh ${.CURDIR}/dev2c.sh dev > makedevs.tmp + rm -rf dev + uudecode < ${.CURDIR}/bteasy17.uu + file2c 'const unsigned char boot0[] = {' '};' \ + < bteasy17 >> makedevs.tmp + rm -rf bteasy17 + file2c 'const unsigned char boot1[] = {' '};' \ + < ${BOOTS}/boot1 >> makedevs.tmp + file2c 'const unsigned char boot2[] = {' '};' \ + < ${BOOTS}/boot2 >> makedevs.tmp + ./rtermcap cons25 | \ + file2c 'const char termcap_cons25[] = {' ',0};' \ + >> makedevs.tmp + ./rtermcap cons25-m | \ + file2c 'const char termcap_cons25_m[] = {' ',0};' \ + >> makedevs.tmp + ./rtermcap vt100 | \ + file2c 'const char termcap_vt100[] = {' ',0};' \ + >> makedevs.tmp + mv makedevs.tmp makedevs.c + +rtermcap: ${.CURDIR}/rtermcap.c + ${CC} -o rtermcap ${.CURDIR}/rtermcap.c -ltermcap + +.include <bsd.prog.mk> + diff --git a/usr.sbin/sade/dmenu.c b/usr.sbin/sade/dmenu.c new file mode 100644 index 0000000..cb8508d --- /dev/null +++ b/usr.sbin/sade/dmenu.c @@ -0,0 +1,191 @@ +/* + * The new sysinstall program. + * + * This is probably the last attempt in the `sysinstall' line, the next + * generation being slated for what's essentially a complete rewrite. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sysinstall.h" +#include <sys/wait.h> + +#define MAX_MENU 15 + +static DMenuItem shellAction = { NULL, NULL, MENU_SHELL_ESCAPE, NULL, 0 }; + +/* Traverse over an internal menu */ +void +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; + + /* 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); + ++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) { + /* 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); + dialog_clear(); + if (!rval) { + for (tmp = menu->items; tmp->title; tmp++) + if (!strcmp(result, tmp->title)) + break; + if (!tmp->title) + msgFatal("Menu item `%s' not found??", result); + } + else if (rval == 255) + tmp = &shellAction; + else { + items_free(nitems, curr, max); + return; + } + switch (tmp->type) { + 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; + break; + + 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(); + } + } + break; + + case MENU_SUBMENU: { + int choice, scroll, curr, max; + + choice = scroll = curr = max = 0; + dmenuOpen((DMenu *)tmp->ptr, &choice, &scroll, &curr, &max); + break; + } + + case MENU_SYSTEM_COMMAND: + (void)systemExecute((char *)tmp->ptr); + break; + + case MENU_CALL: + ((void (*)())tmp->ptr)(); + break; + + case MENU_SET_VARIABLE: { + Variable *newvar; + + if (!index((char *)tmp->ptr, '=')) + msgWarn("Improperly formatted variable: %s", tmp->ptr); + putenv((char *)tmp->ptr); + newvar = (Variable *)malloc(sizeof(Variable)); + if (!newvar) + msgFatal("Out of Memory!"); + strncpy(newvar->value, tmp->ptr, 1024); + newvar->next = VarHead; + VarHead = newvar; + } + break; + + default: + msgFatal("Don't know how to deal with menu type %d", tmp->type); + } + } +} + + diff --git a/usr.sbin/sade/globals.c b/usr.sbin/sade/globals.c new file mode 100644 index 0000000..9d52ff3 --- /dev/null +++ b/usr.sbin/sade/globals.c @@ -0,0 +1,72 @@ +/* + * The new sysinstall program. + * + * This is probably the last program in the `sysinstall' line - the next + * generation being essentially a complete rewrite. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sysinstall.h" + +/* + * Various global variables and an initialization hook to set them to + * whatever values we feel are appropriate. + */ + +int CpioFD; /* The file descriptor for our CPIO floppy */ +int DebugFD; /* Where diagnostic output goes */ +Boolean OnCDROM; /* Are we running off of a CDROM? */ +Boolean OnSerial; /* Are we on a serial console? */ +Boolean DialogActive; +Variable *VarHead; /* The head of the variable chain */ + +/* + * Yes, I know some of these are already automatically initialized as + * globals. I simply find it clearer to set everything explicitly. + */ +void +globalsInit(void) +{ + CpioFD = -1; + DebugFD = -1; + OnCDROM = FALSE; + OnSerial = FALSE; + DialogActive = FALSE; + VarHead = NULL; +} + diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c new file mode 100644 index 0000000..bc6937b --- /dev/null +++ b/usr.sbin/sade/install.c @@ -0,0 +1,56 @@ +/* + * The new sysinstall program. + * + * This is probably the last program in the `sysinstall' line - the next + * generation being essentially a complete rewrite. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sysinstall.h" + +void +installExpress(void) +{ + msgInfo("Doing an express installation"); +} + +void +installCustom(void) +{ + msgInfo("Doing a custom installation"); +} diff --git a/usr.sbin/sade/main.c b/usr.sbin/sade/main.c new file mode 100644 index 0000000..31a7c0f --- /dev/null +++ b/usr.sbin/sade/main.c @@ -0,0 +1,66 @@ +/* + * The new sysinstall program. + * + * This is probably the last attempt in the `sysinstall' line, the next + * generation being slated for what's essentially a complete rewrite. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sysinstall.h" + +int +main(int argc, char **argv) +{ + int choice, scroll, curr, max; + + /* Set up whatever things need setting up */ + systemInitialize(argc, argv); + + /* Welcome user to FreeBSD */ + systemWelcome(); + + /* Begin user dialog at outer menu */ + choice = scroll = curr = max = 0; + dmenuOpen(&MenuInitial, &choice, &scroll, &curr, &max); + + /* Say goodnight, Gracie */ + systemShutdown(); + + /* If we're running as init, we should never get here */ + return 0; +} diff --git a/usr.sbin/sade/menus.c b/usr.sbin/sade/menus.c new file mode 100644 index 0000000..ce19217 --- /dev/null +++ b/usr.sbin/sade/menus.c @@ -0,0 +1,119 @@ +/* + * The new sysinstall program. + * + * This is probably the last program in the `sysinstall' line - the next + * generation being essentially a complete rewrite. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sysinstall.h" + +/* All the system menus go here. + * + * Hardcoded things like version number strings will disappear from + * these menus just as soon as I add the code for doing inline variable + * expansion. + */ + +DMenuItem documentation_items[] = { +{ "README", "Read this for a general description of FreeBSD", + MENU_DISPLAY_FILE, (void *)"help/readme.hlp", 0 }, +{ "Hardware", "The FreeBSD survival guide for PC hardware.", + MENU_DISPLAY_FILE, (void *)"help/hardware.hlp", 0 }, +{ "Install", "A step-by-step guide to installing FreeBSD.", + MENU_DISPLAY_FILE, (void *)"help/install.hlp", 0 }, +{ "FAQ", "Frequently Asked Questions about FreeBSD.", + MENU_DISPLAY_FILE, (void *)"help/faq.hlp", 0 }, +{ NULL }, +}; + +DMenu MenuDocumentation = { +"Documentation for FreeBSD 2.0.5", /* Title */ +"Blah blah", /* Prompt */ +NULL, /* No help line */ +NULL, /* No help file */ +documentation_items, +}; + +DMenuItem language_items[] = { +{ "English", "The system default.", + MENU_SET_VARIABLE, (void *)"LANG=en", 0 }, +{ "French", "French language and character set (ISO-8859-1)", + MENU_SET_VARIABLE, (void *)"LANG=fr", 0 }, +{ "German", "German language and character set (ISO-8859-1)", + MENU_SET_VARIABLE, (void *)"LANG=de", 0 }, +{ "Japanese", "Japanese language and character set (JIS?)", + MENU_SET_VARIABLE, (void *)"LANG=jp", 0 }, +{ "Russian", "Russian language and character set (cp866-8x14)", + MENU_SET_VARIABLE, (void *)"LANG=ru", 0 }, +{ NULL }, +}; + +DMenu MenuLanguage = { +"Set your preferred language", +"Blah blah", +NULL, +NULL, +language_items, +}; + +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 }, +}; + +/* The first menu */ +DMenu MenuInitial = { +"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\ +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, /* items */ +}; diff --git a/usr.sbin/sade/misc.c b/usr.sbin/sade/misc.c new file mode 100644 index 0000000..e9a5642 --- /dev/null +++ b/usr.sbin/sade/misc.c @@ -0,0 +1,125 @@ +/* + * Miscellaneous support routines.. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sysinstall.h" +#include <ctype.h> + +/* Quick check to see if a file is readable */ +Boolean +file_readable(char *fname) +{ + if (!access(fname, F_OK)) + return TRUE; + return FALSE; +} + +/* Quick check to see if a file is executable */ +Boolean +file_executable(char *fname) +{ + if (!access(fname, X_OK)) + return TRUE; + return FALSE; +} + +/* Concatenate two strings into static storage */ +char * +string_concat(char *one, char *two) +{ + static char tmp[FILENAME_MAX]; + + strcpy(tmp, one); + strcat(tmp, two); + return tmp; +} + +/* Clip the whitespace off the end of a string */ +char * +string_prune(char *str) +{ + int len = str ? strlen(str) : 0; + + while (len && isspace(str[len - 1])) + str[--len] = '\0'; + return str; +} + +/* run the whitespace off the front of a string */ +char * +string_skipwhite(char *str) +{ + while (*str && isspace(*str)) + ++str; + return str; +} + +/* A free guaranteed to take NULL ptrs */ +void +safe_free(void *ptr) +{ + if (ptr) + free(ptr); +} + +/* + * These next two 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) +{ + + if (*curr == *max) { + *max += 20; + list = (char **)realloc(list, sizeof(char *) * *max); + } + list[(*curr)++] = item; + return list; +} + +/* Toss the items out */ +void +items_free(char **list, int *curr, int *max) +{ + safe_free(list); + *curr = *max = 0; +} + diff --git a/usr.sbin/sade/msg.c b/usr.sbin/sade/msg.c new file mode 100644 index 0000000..c9fd5ce --- /dev/null +++ b/usr.sbin/sade/msg.c @@ -0,0 +1,131 @@ +/* + * The new sysinstall program. + * + * This is probably the last program in the `sysinstall' line - the next + * generation being essentially a complete rewrite. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sysinstall.h" +#include <stdarg.h> + +/* Whack up an informational message on the status line */ +void +msgInfo(char *fmt, ...) +{ + va_list args; + char *errstr; + + errstr = (char *)malloc(FILENAME_MAX); + errstr[0] = '\0'; + va_start(args, fmt); + vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); + va_end(args); + move(25, 0); + addstr(errstr); + free(errstr); +} + +/* Whack up a warning on the status line */ +void +msgWarn(char *fmt, ...) +{ + va_list args; + char *errstr; + + errstr = (char *)malloc(FILENAME_MAX); + strcpy(errstr, "Warning: "); + va_start(args, fmt); + vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); + va_end(args); + move(25, 0); + beep(); + standout(); + addstr(errstr); + standend(); + free(errstr); +} + +/* Whack up an error on the status line */ +void +msgError(char *fmt, ...) +{ + va_list args; + char *errstr; + + errstr = (char *)malloc(FILENAME_MAX); + strcpy(errstr, "Error: "); + va_start(args, fmt); + vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); + va_end(args); + move(25, 0); + beep(); + standout(); + addstr(errstr); + standend(); + free(errstr); +} + +/* Whack up a fatal error on the status line */ +void +msgFatal(char *fmt, ...) +{ + va_list args; + char *errstr; + + errstr = (char *)malloc(FILENAME_MAX); + strcpy(errstr, "Fatal Error: "); + va_start(args, fmt); + vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); + va_end(args); + move(25, 0); + beep(); + standout(); + addstr(errstr); + addstr(" - "); + addstr("PRESS ANY KEY TO "); + if (getpid() == 1) + addstr("REBOOT"); + else + addstr("QUIT"); + standend(); + free(errstr); + getch(); + systemShutdown(); +} + diff --git a/usr.sbin/sade/rtermcap.c b/usr.sbin/sade/rtermcap.c new file mode 100644 index 0000000..3f18e8b --- /dev/null +++ b/usr.sbin/sade/rtermcap.c @@ -0,0 +1,14 @@ +#include <stdio.h> +#include <termcap.h> + +int +main(int argc, char **argv) +{ + char buf[4096]; + int i; + + i = tgetent(buf, argv[1]); + + printf("%s",buf); + return 0; +} diff --git a/usr.sbin/sade/sade.h b/usr.sbin/sade/sade.h new file mode 100644 index 0000000..c6a2af4 --- /dev/null +++ b/usr.sbin/sade/sade.h @@ -0,0 +1,131 @@ +/* + * The new sysinstall program. + * + * This is probably the last attempt in the `sysinstall' line, the next + * generation being slated to essentially a complete rewrite. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#ifndef _SYSINSTALL_H_INCLUDE +#define _SYSINSTALL_H_INCLUDE + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <dialog.h> + +/* Types */ +typedef unsigned int Boolean; + +typedef enum { + MENU_SHELL_ESCAPE, + MENU_DISPLAY_FILE, + MENU_SUBMENU, + MENU_SYSTEM_COMMAND, + MENU_SET_VARIABLE, + MENU_CALL +} DMenuItemType; + +typedef struct _dmenuItem { + char *title; + char *prompt; + DMenuItemType type; + void *ptr; + int disabled; +} DMenuItem; + +typedef struct _dmenu { + char *title; + char *prompt; + char *helpline; + char *helpfile; + DMenuItem *items; +} DMenu; + +/* A sysconfig variable */ +typedef struct _variable { + struct _variable *next; + char value[1024]; +} 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 */ + +/* All the menus to which forward references exist */ +extern DMenu MenuDocumenation, MenuInitial, MenuLanguage; + + +/* Prototypes */ +extern void globalsInit(void); + +extern void installExpress(void); +extern void installCustom(void); + +extern void systemInitialize(int argc, char **argv); +extern void systemShutdown(void); +extern void systemWelcome(void); +extern int systemExecute(char *cmd); + +extern void dmenuOpen(DMenu *menu, int *choice, int *scroll, + int *curr, int *max); + +extern Boolean file_readable(char *fname); +extern Boolean file_executable(char *fname); +extern char *string_concat(char *p1, char *p2); +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 void items_free(char **list, int *curr, int *max); + +extern int set_termcap(void); + +extern void msgInfo(char *fmt, ...); +extern void msgWarn(char *fmt, ...); +extern void msgError(char *fmt, ...); +extern void msgFatal(char *fmt, ...); + +#endif +/* _SYSINSTALL_H_INCLUDE */ diff --git a/usr.sbin/sade/system.c b/usr.sbin/sade/system.c new file mode 100644 index 0000000..a48c9df --- /dev/null +++ b/usr.sbin/sade/system.c @@ -0,0 +1,107 @@ +/* + * The new sysinstall program. + * + * This is probably the last program in the `sysinstall' line - the next + * generation being essentially a complete rewrite. + * + * $Id$ + * + * Jordan Hubbard + * + * My contributions are in the public domain. + * + * Parts of this file are also blatently stolen from Poul-Henning Kamp's + * previous version of sysinstall, and as such fall under his "BEERWARE" + * license, so buy him a beer if you like it! Buy him a beer for me, too! + */ + +#include "sysinstall.h" +#include <signal.h> +#include <sys/reboot.h> +#include <sys/fcntl.h> +#include <sys/ioctl.h> + +/* Handle interrupt signals (duh!) */ +static void +handle_intr(int sig) +{ +} + +/* Welcome the user to the system */ +void +systemWelcome(void) +{ +} + +/* Initialize system defaults */ +void +systemInitialize(int argc, char **argv) +{ + signal(SIGINT, SIG_IGN); + globalsInit(); + + /* Are we running as init? */ + if (getpid() == 1) { + setsid(); + if (argc > 1 && strchr(argv[1],'C')) { + /* Kernel told us that we are on a CDROM root */ + close(0); open("/bootcd/dev/console", O_RDWR); + close(1); dup(0); + close(2); dup(0); + CpioFD = open("/floppies/cpio.flp", O_RDONLY); + OnCDROM = TRUE; + chroot("/bootcd"); + } else { + close(0); open("/dev/console", O_RDWR); + close(1); dup(0); + close(2); dup(0); + } + msgInfo("%s running as init", argv[0]); + + ioctl(0, TIOCSCTTY, (char *)NULL); + setlogin("root"); + setbuf(stdin, 0); + setbuf(stdout, 0); + setbuf(stderr, 0); + } + + if (set_termcap() == -1) + msgFatal("Can't find terminal entry"); + + /* XXX - libdialog has particularly bad return value checking */ + init_dialog(); + /* If we haven't crashed I guess dialog is running ! */ + DialogActive = TRUE; + + signal(SIGINT, handle_intr); +} + +/* Close down and prepare to exit */ +void +systemShutdown(void) +{ + if (DialogActive) { + end_dialog(); + DialogActive = FALSE; + } + /* REALLY exit! */ + if (getpid() == 1) + reboot(RB_HALT); +} + +int +systemExecute(char *command) +{ + int status; + + dialog_clear(); + dialog_update(); + end_dialog(); + DialogActive = FALSE; + status = system(command); + DialogActive = TRUE; + dialog_clear(); + dialog_update(); + return status; +} + diff --git a/usr.sbin/sade/termcap.c b/usr.sbin/sade/termcap.c new file mode 100644 index 0000000..e05b82d --- /dev/null +++ b/usr.sbin/sade/termcap.c @@ -0,0 +1,62 @@ +/* + * Copyright (c) 1994, Paul Richards. + * + * All rights reserved. + * + * This software may be used, modified, copied, distributed, and sold, in both + * source and binary form provided that the above copyright and these terms + * are retained, verbatim, as the first lines of this file. Under no + * circumstances is the author responsible for the proper functioning of this + * software, nor does the author assume any responsibility for damages + * incurred with its use. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <stdarg.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include <machine/console.h> + +#include "sysinstall.h" + +int +set_termcap(void) +{ + char *term; + extern const char termcap_vt100[]; + extern const char termcap_cons25[]; + extern const char termcap_cons25_m[]; + + term = getenv("TERM"); + if (term == NULL) { + int color_display; + + if (ioctl(STDERR_FILENO, GIO_COLOR, &color_display) < 0) { + if (setenv("TERM", "vt100", 1) < 0) + return -1; + if (setenv("TERMCAP", termcap_vt100, 1) < 0) + return -1; + DebugFD = dup(1); + OnSerial = TRUE; + } else if (color_display) { + if (setenv("TERM", "cons25", 1) < 0) + return -1; + if (setenv("TERMCAP", termcap_cons25, 1) < 0) + return -1; + DebugFD = open("/dev/ttyv1",O_WRONLY); + } else { + if (setenv("TERM", "cons25-m", 1) < 0) + return -1; + if (setenv("TERMCAP", termcap_cons25_m, 1) < 0) + return -1; + DebugFD = open("/dev/ttyv1",O_WRONLY); + } + } else { + DebugFD = open("sysinstall.debug", + O_WRONLY|O_CREAT|O_TRUNC,0644); + } + return 0; +} diff --git a/usr.sbin/sysinstall/Makefile b/usr.sbin/sysinstall/Makefile new file mode 100644 index 0000000..9be88fe --- /dev/null +++ b/usr.sbin/sysinstall/Makefile @@ -0,0 +1,50 @@ +PROG= sysinstall +NOMAN= yes +CLEANFILES= makedevs.c rtermcap + +.PATH: ${.CURDIR}/../disklabel + +SRCS = globals.c main.c dmenu.c menus.c \ + misc.c msg.c system.c install.c \ + termcap.c makedevs.c + +CFLAGS += -Wall -g -static +LDADD = -ldialog -lncurses -lmytinfo +DPADD = ${LIBDIALOG} ${LIBNCURSES} ${LIBMYTINFO} + +.if exists(${.CURDIR}/../../sys/i386/boot/biosboot/obj) +BOOTS=${.CURDIR}/../../sys/i386/boot/biosboot/obj +.else +BOOTS=${.CURDIR}/../../sys/i386/boot/biosboot +.endif + +makedevs.c: dev2c.sh Makefile rtermcap + mkdir -p dev + cp ${.CURDIR}/../../etc/etc.i386/MAKEDEV dev + ( cd dev; sh ./MAKEDEV all ) + sh ${.CURDIR}/dev2c.sh dev > makedevs.tmp + rm -rf dev + uudecode < ${.CURDIR}/bteasy17.uu + file2c 'const unsigned char boot0[] = {' '};' \ + < bteasy17 >> makedevs.tmp + rm -rf bteasy17 + file2c 'const unsigned char boot1[] = {' '};' \ + < ${BOOTS}/boot1 >> makedevs.tmp + file2c 'const unsigned char boot2[] = {' '};' \ + < ${BOOTS}/boot2 >> makedevs.tmp + ./rtermcap cons25 | \ + file2c 'const char termcap_cons25[] = {' ',0};' \ + >> makedevs.tmp + ./rtermcap cons25-m | \ + file2c 'const char termcap_cons25_m[] = {' ',0};' \ + >> makedevs.tmp + ./rtermcap vt100 | \ + file2c 'const char termcap_vt100[] = {' ',0};' \ + >> makedevs.tmp + mv makedevs.tmp makedevs.c + +rtermcap: ${.CURDIR}/rtermcap.c + ${CC} -o rtermcap ${.CURDIR}/rtermcap.c -ltermcap + +.include <bsd.prog.mk> + diff --git a/usr.sbin/sysinstall/dev2c.sh b/usr.sbin/sysinstall/dev2c.sh new file mode 100644 index 0000000..cbd2e71 --- /dev/null +++ b/usr.sbin/sysinstall/dev2c.sh @@ -0,0 +1,80 @@ +: +# +# ---------------------------------------------------------------------------- +# "THE BEER-WARE LICENSE" (Revision 42): +# <phk@login.dknet.dk> wrote this file. As long as you retain this notice you +# can do whatever you want with this stuff. If we meet some day, and you think +# this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp +# ---------------------------------------------------------------------------- +# +# $Id: dev2c.sh,v 1.1 1994/10/26 02:53:08 phk Exp $ +# +# During installation, we suffer badly of we have to run MAKEDEV. MAKEDEV +# need sh, ln, chown, mknod, awk, rm, test and probably emacs too when +# we come down to it. So instead this script will make a C-procedure which +# makes all the B & C nodes of a specified directory. +# +# Poul-Henning + +(cd $1; ls -li ) | sed 's/,//' | awk ' +BEGIN { + while (getline < "/etc/passwd") { + split($0,a,":") + uid[a[1]] = a[3] + } + while (getline < "/etc/group") { + split($0,a,":") + gid[a[1]] = a[3] + } + printf("/*\n"); + printf(" * This file is generated from the contents of /dev\n"); + printf(" */\n"); + printf("#define CHK(foo) {i = foo;}\n"); + printf("#include <unistd.h>\n"); + printf("#include <sys/types.h>\n"); + printf("#include <sys/stat.h>\n"); + printf("int makedevs()\n{\n\tint i=0;\n"); + } + { + printf ("/* %s */\n",$0) + $4 = uid[$4] + $5 = gid[$5] + if (substr($2,1,1) == "b") { + k="S_IFBLK" + } else if (substr($2,1,1) == "c") { + k="S_IFCHR" + } else if (substr($2,1,1) == "d") { + next + } else if (substr($2,1,1) == "-") { + next + } else { + next + } + m = 0; + if (substr($2,2,1) == "r") m += 400; + if (substr($2,3,1) == "w") m += 200; + if (substr($2,4,1) == "x") m += 100; + if (substr($2,5,1) == "r") m += 40; + if (substr($2,6,1) == "w") m += 20; + if (substr($2,7,1) == "x") m += 10; + if (substr($2,8,1) == "r") m += 4; + if (substr($2,9,1) == "w") m += 2; + if (substr($2,10,1) == "x") m += 1; + + if (a[$1] != 0) { + printf ("\tCHK(link(\"%s\",\"%s\"));\n", \ + a[$1],$11) + } else { + printf ("\tCHK(mknod(\"%s\",%s,makedev(%d,%d)));\n", \ + $11, k, $6, $7) + printf ("\tCHK(chmod(\"%s\",0%d));\n", \ + $11, m) + printf ("\tCHK(chown(\"%s\",%d,%d));\n", \ + $11, $4,$5) + a[$1] = $11 + } + } +END { + printf("\treturn i;\n}\n"); + } +' diff --git a/usr.sbin/sysinstall/dmenu.c b/usr.sbin/sysinstall/dmenu.c new file mode 100644 index 0000000..cb8508d --- /dev/null +++ b/usr.sbin/sysinstall/dmenu.c @@ -0,0 +1,191 @@ +/* + * The new sysinstall program. + * + * This is probably the last attempt in the `sysinstall' line, the next + * generation being slated for what's essentially a complete rewrite. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sysinstall.h" +#include <sys/wait.h> + +#define MAX_MENU 15 + +static DMenuItem shellAction = { NULL, NULL, MENU_SHELL_ESCAPE, NULL, 0 }; + +/* Traverse over an internal menu */ +void +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; + + /* 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); + ++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) { + /* 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); + dialog_clear(); + if (!rval) { + for (tmp = menu->items; tmp->title; tmp++) + if (!strcmp(result, tmp->title)) + break; + if (!tmp->title) + msgFatal("Menu item `%s' not found??", result); + } + else if (rval == 255) + tmp = &shellAction; + else { + items_free(nitems, curr, max); + return; + } + switch (tmp->type) { + 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; + break; + + 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(); + } + } + break; + + case MENU_SUBMENU: { + int choice, scroll, curr, max; + + choice = scroll = curr = max = 0; + dmenuOpen((DMenu *)tmp->ptr, &choice, &scroll, &curr, &max); + break; + } + + case MENU_SYSTEM_COMMAND: + (void)systemExecute((char *)tmp->ptr); + break; + + case MENU_CALL: + ((void (*)())tmp->ptr)(); + break; + + case MENU_SET_VARIABLE: { + Variable *newvar; + + if (!index((char *)tmp->ptr, '=')) + msgWarn("Improperly formatted variable: %s", tmp->ptr); + putenv((char *)tmp->ptr); + newvar = (Variable *)malloc(sizeof(Variable)); + if (!newvar) + msgFatal("Out of Memory!"); + strncpy(newvar->value, tmp->ptr, 1024); + newvar->next = VarHead; + VarHead = newvar; + } + break; + + default: + msgFatal("Don't know how to deal with menu type %d", tmp->type); + } + } +} + + diff --git a/usr.sbin/sysinstall/globals.c b/usr.sbin/sysinstall/globals.c new file mode 100644 index 0000000..9d52ff3 --- /dev/null +++ b/usr.sbin/sysinstall/globals.c @@ -0,0 +1,72 @@ +/* + * The new sysinstall program. + * + * This is probably the last program in the `sysinstall' line - the next + * generation being essentially a complete rewrite. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sysinstall.h" + +/* + * Various global variables and an initialization hook to set them to + * whatever values we feel are appropriate. + */ + +int CpioFD; /* The file descriptor for our CPIO floppy */ +int DebugFD; /* Where diagnostic output goes */ +Boolean OnCDROM; /* Are we running off of a CDROM? */ +Boolean OnSerial; /* Are we on a serial console? */ +Boolean DialogActive; +Variable *VarHead; /* The head of the variable chain */ + +/* + * Yes, I know some of these are already automatically initialized as + * globals. I simply find it clearer to set everything explicitly. + */ +void +globalsInit(void) +{ + CpioFD = -1; + DebugFD = -1; + OnCDROM = FALSE; + OnSerial = FALSE; + DialogActive = FALSE; + VarHead = NULL; +} + diff --git a/usr.sbin/sysinstall/install.c b/usr.sbin/sysinstall/install.c new file mode 100644 index 0000000..bc6937b --- /dev/null +++ b/usr.sbin/sysinstall/install.c @@ -0,0 +1,56 @@ +/* + * The new sysinstall program. + * + * This is probably the last program in the `sysinstall' line - the next + * generation being essentially a complete rewrite. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sysinstall.h" + +void +installExpress(void) +{ + msgInfo("Doing an express installation"); +} + +void +installCustom(void) +{ + msgInfo("Doing a custom installation"); +} diff --git a/usr.sbin/sysinstall/main.c b/usr.sbin/sysinstall/main.c new file mode 100644 index 0000000..31a7c0f --- /dev/null +++ b/usr.sbin/sysinstall/main.c @@ -0,0 +1,66 @@ +/* + * The new sysinstall program. + * + * This is probably the last attempt in the `sysinstall' line, the next + * generation being slated for what's essentially a complete rewrite. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sysinstall.h" + +int +main(int argc, char **argv) +{ + int choice, scroll, curr, max; + + /* Set up whatever things need setting up */ + systemInitialize(argc, argv); + + /* Welcome user to FreeBSD */ + systemWelcome(); + + /* Begin user dialog at outer menu */ + choice = scroll = curr = max = 0; + dmenuOpen(&MenuInitial, &choice, &scroll, &curr, &max); + + /* Say goodnight, Gracie */ + systemShutdown(); + + /* If we're running as init, we should never get here */ + return 0; +} diff --git a/usr.sbin/sysinstall/menus.c b/usr.sbin/sysinstall/menus.c new file mode 100644 index 0000000..ce19217 --- /dev/null +++ b/usr.sbin/sysinstall/menus.c @@ -0,0 +1,119 @@ +/* + * The new sysinstall program. + * + * This is probably the last program in the `sysinstall' line - the next + * generation being essentially a complete rewrite. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sysinstall.h" + +/* All the system menus go here. + * + * Hardcoded things like version number strings will disappear from + * these menus just as soon as I add the code for doing inline variable + * expansion. + */ + +DMenuItem documentation_items[] = { +{ "README", "Read this for a general description of FreeBSD", + MENU_DISPLAY_FILE, (void *)"help/readme.hlp", 0 }, +{ "Hardware", "The FreeBSD survival guide for PC hardware.", + MENU_DISPLAY_FILE, (void *)"help/hardware.hlp", 0 }, +{ "Install", "A step-by-step guide to installing FreeBSD.", + MENU_DISPLAY_FILE, (void *)"help/install.hlp", 0 }, +{ "FAQ", "Frequently Asked Questions about FreeBSD.", + MENU_DISPLAY_FILE, (void *)"help/faq.hlp", 0 }, +{ NULL }, +}; + +DMenu MenuDocumentation = { +"Documentation for FreeBSD 2.0.5", /* Title */ +"Blah blah", /* Prompt */ +NULL, /* No help line */ +NULL, /* No help file */ +documentation_items, +}; + +DMenuItem language_items[] = { +{ "English", "The system default.", + MENU_SET_VARIABLE, (void *)"LANG=en", 0 }, +{ "French", "French language and character set (ISO-8859-1)", + MENU_SET_VARIABLE, (void *)"LANG=fr", 0 }, +{ "German", "German language and character set (ISO-8859-1)", + MENU_SET_VARIABLE, (void *)"LANG=de", 0 }, +{ "Japanese", "Japanese language and character set (JIS?)", + MENU_SET_VARIABLE, (void *)"LANG=jp", 0 }, +{ "Russian", "Russian language and character set (cp866-8x14)", + MENU_SET_VARIABLE, (void *)"LANG=ru", 0 }, +{ NULL }, +}; + +DMenu MenuLanguage = { +"Set your preferred language", +"Blah blah", +NULL, +NULL, +language_items, +}; + +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 }, +}; + +/* The first menu */ +DMenu MenuInitial = { +"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\ +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, /* items */ +}; diff --git a/usr.sbin/sysinstall/misc.c b/usr.sbin/sysinstall/misc.c new file mode 100644 index 0000000..e9a5642 --- /dev/null +++ b/usr.sbin/sysinstall/misc.c @@ -0,0 +1,125 @@ +/* + * Miscellaneous support routines.. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sysinstall.h" +#include <ctype.h> + +/* Quick check to see if a file is readable */ +Boolean +file_readable(char *fname) +{ + if (!access(fname, F_OK)) + return TRUE; + return FALSE; +} + +/* Quick check to see if a file is executable */ +Boolean +file_executable(char *fname) +{ + if (!access(fname, X_OK)) + return TRUE; + return FALSE; +} + +/* Concatenate two strings into static storage */ +char * +string_concat(char *one, char *two) +{ + static char tmp[FILENAME_MAX]; + + strcpy(tmp, one); + strcat(tmp, two); + return tmp; +} + +/* Clip the whitespace off the end of a string */ +char * +string_prune(char *str) +{ + int len = str ? strlen(str) : 0; + + while (len && isspace(str[len - 1])) + str[--len] = '\0'; + return str; +} + +/* run the whitespace off the front of a string */ +char * +string_skipwhite(char *str) +{ + while (*str && isspace(*str)) + ++str; + return str; +} + +/* A free guaranteed to take NULL ptrs */ +void +safe_free(void *ptr) +{ + if (ptr) + free(ptr); +} + +/* + * These next two 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) +{ + + if (*curr == *max) { + *max += 20; + list = (char **)realloc(list, sizeof(char *) * *max); + } + list[(*curr)++] = item; + return list; +} + +/* Toss the items out */ +void +items_free(char **list, int *curr, int *max) +{ + safe_free(list); + *curr = *max = 0; +} + diff --git a/usr.sbin/sysinstall/msg.c b/usr.sbin/sysinstall/msg.c new file mode 100644 index 0000000..c9fd5ce --- /dev/null +++ b/usr.sbin/sysinstall/msg.c @@ -0,0 +1,131 @@ +/* + * The new sysinstall program. + * + * This is probably the last program in the `sysinstall' line - the next + * generation being essentially a complete rewrite. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "sysinstall.h" +#include <stdarg.h> + +/* Whack up an informational message on the status line */ +void +msgInfo(char *fmt, ...) +{ + va_list args; + char *errstr; + + errstr = (char *)malloc(FILENAME_MAX); + errstr[0] = '\0'; + va_start(args, fmt); + vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); + va_end(args); + move(25, 0); + addstr(errstr); + free(errstr); +} + +/* Whack up a warning on the status line */ +void +msgWarn(char *fmt, ...) +{ + va_list args; + char *errstr; + + errstr = (char *)malloc(FILENAME_MAX); + strcpy(errstr, "Warning: "); + va_start(args, fmt); + vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); + va_end(args); + move(25, 0); + beep(); + standout(); + addstr(errstr); + standend(); + free(errstr); +} + +/* Whack up an error on the status line */ +void +msgError(char *fmt, ...) +{ + va_list args; + char *errstr; + + errstr = (char *)malloc(FILENAME_MAX); + strcpy(errstr, "Error: "); + va_start(args, fmt); + vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); + va_end(args); + move(25, 0); + beep(); + standout(); + addstr(errstr); + standend(); + free(errstr); +} + +/* Whack up a fatal error on the status line */ +void +msgFatal(char *fmt, ...) +{ + va_list args; + char *errstr; + + errstr = (char *)malloc(FILENAME_MAX); + strcpy(errstr, "Fatal Error: "); + va_start(args, fmt); + vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); + va_end(args); + move(25, 0); + beep(); + standout(); + addstr(errstr); + addstr(" - "); + addstr("PRESS ANY KEY TO "); + if (getpid() == 1) + addstr("REBOOT"); + else + addstr("QUIT"); + standend(); + free(errstr); + getch(); + systemShutdown(); +} + diff --git a/usr.sbin/sysinstall/rtermcap.c b/usr.sbin/sysinstall/rtermcap.c new file mode 100644 index 0000000..3f18e8b --- /dev/null +++ b/usr.sbin/sysinstall/rtermcap.c @@ -0,0 +1,14 @@ +#include <stdio.h> +#include <termcap.h> + +int +main(int argc, char **argv) +{ + char buf[4096]; + int i; + + i = tgetent(buf, argv[1]); + + printf("%s",buf); + return 0; +} diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h new file mode 100644 index 0000000..c6a2af4 --- /dev/null +++ b/usr.sbin/sysinstall/sysinstall.h @@ -0,0 +1,131 @@ +/* + * The new sysinstall program. + * + * This is probably the last attempt in the `sysinstall' line, the next + * generation being slated to essentially a complete rewrite. + * + * $Id$ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#ifndef _SYSINSTALL_H_INCLUDE +#define _SYSINSTALL_H_INCLUDE + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <dialog.h> + +/* Types */ +typedef unsigned int Boolean; + +typedef enum { + MENU_SHELL_ESCAPE, + MENU_DISPLAY_FILE, + MENU_SUBMENU, + MENU_SYSTEM_COMMAND, + MENU_SET_VARIABLE, + MENU_CALL +} DMenuItemType; + +typedef struct _dmenuItem { + char *title; + char *prompt; + DMenuItemType type; + void *ptr; + int disabled; +} DMenuItem; + +typedef struct _dmenu { + char *title; + char *prompt; + char *helpline; + char *helpfile; + DMenuItem *items; +} DMenu; + +/* A sysconfig variable */ +typedef struct _variable { + struct _variable *next; + char value[1024]; +} 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 */ + +/* All the menus to which forward references exist */ +extern DMenu MenuDocumenation, MenuInitial, MenuLanguage; + + +/* Prototypes */ +extern void globalsInit(void); + +extern void installExpress(void); +extern void installCustom(void); + +extern void systemInitialize(int argc, char **argv); +extern void systemShutdown(void); +extern void systemWelcome(void); +extern int systemExecute(char *cmd); + +extern void dmenuOpen(DMenu *menu, int *choice, int *scroll, + int *curr, int *max); + +extern Boolean file_readable(char *fname); +extern Boolean file_executable(char *fname); +extern char *string_concat(char *p1, char *p2); +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 void items_free(char **list, int *curr, int *max); + +extern int set_termcap(void); + +extern void msgInfo(char *fmt, ...); +extern void msgWarn(char *fmt, ...); +extern void msgError(char *fmt, ...); +extern void msgFatal(char *fmt, ...); + +#endif +/* _SYSINSTALL_H_INCLUDE */ diff --git a/usr.sbin/sysinstall/system.c b/usr.sbin/sysinstall/system.c new file mode 100644 index 0000000..a48c9df --- /dev/null +++ b/usr.sbin/sysinstall/system.c @@ -0,0 +1,107 @@ +/* + * The new sysinstall program. + * + * This is probably the last program in the `sysinstall' line - the next + * generation being essentially a complete rewrite. + * + * $Id$ + * + * Jordan Hubbard + * + * My contributions are in the public domain. + * + * Parts of this file are also blatently stolen from Poul-Henning Kamp's + * previous version of sysinstall, and as such fall under his "BEERWARE" + * license, so buy him a beer if you like it! Buy him a beer for me, too! + */ + +#include "sysinstall.h" +#include <signal.h> +#include <sys/reboot.h> +#include <sys/fcntl.h> +#include <sys/ioctl.h> + +/* Handle interrupt signals (duh!) */ +static void +handle_intr(int sig) +{ +} + +/* Welcome the user to the system */ +void +systemWelcome(void) +{ +} + +/* Initialize system defaults */ +void +systemInitialize(int argc, char **argv) +{ + signal(SIGINT, SIG_IGN); + globalsInit(); + + /* Are we running as init? */ + if (getpid() == 1) { + setsid(); + if (argc > 1 && strchr(argv[1],'C')) { + /* Kernel told us that we are on a CDROM root */ + close(0); open("/bootcd/dev/console", O_RDWR); + close(1); dup(0); + close(2); dup(0); + CpioFD = open("/floppies/cpio.flp", O_RDONLY); + OnCDROM = TRUE; + chroot("/bootcd"); + } else { + close(0); open("/dev/console", O_RDWR); + close(1); dup(0); + close(2); dup(0); + } + msgInfo("%s running as init", argv[0]); + + ioctl(0, TIOCSCTTY, (char *)NULL); + setlogin("root"); + setbuf(stdin, 0); + setbuf(stdout, 0); + setbuf(stderr, 0); + } + + if (set_termcap() == -1) + msgFatal("Can't find terminal entry"); + + /* XXX - libdialog has particularly bad return value checking */ + init_dialog(); + /* If we haven't crashed I guess dialog is running ! */ + DialogActive = TRUE; + + signal(SIGINT, handle_intr); +} + +/* Close down and prepare to exit */ +void +systemShutdown(void) +{ + if (DialogActive) { + end_dialog(); + DialogActive = FALSE; + } + /* REALLY exit! */ + if (getpid() == 1) + reboot(RB_HALT); +} + +int +systemExecute(char *command) +{ + int status; + + dialog_clear(); + dialog_update(); + end_dialog(); + DialogActive = FALSE; + status = system(command); + DialogActive = TRUE; + dialog_clear(); + dialog_update(); + return status; +} + diff --git a/usr.sbin/sysinstall/termcap.c b/usr.sbin/sysinstall/termcap.c new file mode 100644 index 0000000..e05b82d --- /dev/null +++ b/usr.sbin/sysinstall/termcap.c @@ -0,0 +1,62 @@ +/* + * Copyright (c) 1994, Paul Richards. + * + * All rights reserved. + * + * This software may be used, modified, copied, distributed, and sold, in both + * source and binary form provided that the above copyright and these terms + * are retained, verbatim, as the first lines of this file. Under no + * circumstances is the author responsible for the proper functioning of this + * software, nor does the author assume any responsibility for damages + * incurred with its use. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <stdarg.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include <machine/console.h> + +#include "sysinstall.h" + +int +set_termcap(void) +{ + char *term; + extern const char termcap_vt100[]; + extern const char termcap_cons25[]; + extern const char termcap_cons25_m[]; + + term = getenv("TERM"); + if (term == NULL) { + int color_display; + + if (ioctl(STDERR_FILENO, GIO_COLOR, &color_display) < 0) { + if (setenv("TERM", "vt100", 1) < 0) + return -1; + if (setenv("TERMCAP", termcap_vt100, 1) < 0) + return -1; + DebugFD = dup(1); + OnSerial = TRUE; + } else if (color_display) { + if (setenv("TERM", "cons25", 1) < 0) + return -1; + if (setenv("TERMCAP", termcap_cons25, 1) < 0) + return -1; + DebugFD = open("/dev/ttyv1",O_WRONLY); + } else { + if (setenv("TERM", "cons25-m", 1) < 0) + return -1; + if (setenv("TERMCAP", termcap_cons25_m, 1) < 0) + return -1; + DebugFD = open("/dev/ttyv1",O_WRONLY); + } + } else { + DebugFD = open("sysinstall.debug", + O_WRONLY|O_CREAT|O_TRUNC,0644); + } + return 0; +} |