install.c revision 8281
1/*
2 * The new sysinstall program.
3 *
4 * This is probably the last program in the `sysinstall' line - the next
5 * generation being essentially a complete rewrite.
6 *
7 * $Id: install.c,v 1.6 1995/05/04 19:48:11 jkh Exp $
8 *
9 * Copyright (c) 1995
10 *	Jordan Hubbard.  All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 *    notice, this list of conditions and the following disclaimer,
17 *    verbatim and that no modifications are made prior to this
18 *    point in the file.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 *    notice, this list of conditions and the following disclaimer in the
21 *    documentation and/or other materials provided with the distribution.
22 * 3. All advertising materials mentioning features or use of this software
23 *    must display the following acknowledgement:
24 *	This product includes software developed by Jordan Hubbard
25 *	for the FreeBSD Project.
26 * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to
27 *    endorse or promote products derived from this software without specific
28 *    prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
31 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED.  IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * SUCH DAMAGE.
41 *
42 */
43
44#include "sysinstall.h"
45
46Boolean SystemWasInstalled;
47
48static int
49installHook(char *str)
50{
51    int i;
52    struct disk *disks[100];	/* some ridiculously large number */
53
54    i = 0;
55    /* Clip garbage off the ends */
56    string_prune(str);
57    str = string_skipwhite(str);
58    /* Try and open all the disks */
59    while (str) {
60	char *cp;
61
62	cp = index(str, '\n');
63	if (cp)
64	   *cp++ = 0;
65	if (!*str) {
66	    beep();
67	    return 0;
68	}
69	disks[i] = Open_Disk(str);
70	if (!disks[i])
71	    msgFatal("Unable to open disk %s!", str);
72	++i;
73	str = cp;
74    }
75    disks[i] = NULL;
76    if (!i)
77	return 0;
78
79    while (1) {
80	/* Now go set up all the MBR partition information */
81	for (i = 0; disks[i]; i++)
82	    disks[i] = device_slice_disk(disks[i]);
83
84	for (i = 0; disks[i]; i++)
85	    partition_disk(disks[i]);
86
87	if (!write_disks(disks)) {
88	    make_filesystems(disks);
89	    cpio_extract(disks);
90	    extract_dists(disks);
91	    do_final_setup(disks);
92	    SystemWasInstalled = TRUE;
93	    break;
94	}
95	else {
96	    dialog_clear();
97	    if (msgYesNo("Would you like to go back to the master partition menu?")) {
98		for (i = 0; disks[i]; i++)
99		    Free_Disk(disks[i]);
100		break;
101	    }
102	}
103    }
104    return SystemWasInstalled;
105}
106
107int
108installCustom(char *str)
109{
110    int scroll, choice, curr, max;
111    extern DMenu MenuDiskDevices;
112    DMenu *menu;
113    Device *devs;
114
115    variable_set2("install_type", "custom");
116    menu = device_create_disk_menu(&MenuDiskDevices, &devs, installHook);
117    if (!menu)
118	return 0;
119    choice = scroll = curr = max = 0;
120    dmenuOpen(menu, &choice, &scroll, &curr, &max);
121    free(menu);
122    free(devs);
123    return SystemWasInstalled;
124}
125
126int
127installExpress(char *str)
128{
129    int scroll, choice, curr, max;
130    extern DMenu MenuDiskDevices;
131    DMenu *menu;
132    Device *devs;
133
134    variable_set2("install_type", "express");
135    menu = device_create_disk_menu(&MenuDiskDevices, &devs, installHook);
136    if (!menu)
137	return 0;
138    choice = scroll = curr = max = 0;
139    dmenuOpen(menu, &choice, &scroll, &curr, &max);
140    free(menu);
141    free(devs);
142    return SystemWasInstalled;
143}
144
145int
146installMaint(char *str)
147{
148    msgConfirm("Sorry, maintainance mode is not implemented in this version.");
149    return 0;
150}
151