install.c revision 8302
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.5 1995/05/04 03:51:16 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	partition_disks(disks);
85
86	if (!write_disks(disks)) {
87	    make_filesystems(disks);
88	    cpio_extract(disks);
89	    extract_dists(disks);
90	    do_final_setup(disks);
91	    SystemWasInstalled = TRUE;
92	    break;
93	}
94	else {
95	    dialog_clear();
96	    if (msgYesNo("Would you like to go back to the Master Partition Editor?")) {
97		for (i = 0; disks[i]; i++)
98		    Free_Disk(disks[i]);
99		break;
100	    }
101	}
102    }
103    return SystemWasInstalled;
104}
105
106int
107installCustom(char *str)
108{
109    int scroll, choice, curr, max;
110    extern DMenu MenuDiskDevices;
111    DMenu *menu;
112    Device *devs;
113
114    variable_set2("install_type", "custom");
115    menu = device_create_disk_menu(&MenuDiskDevices, &devs, installHook);
116    if (!menu)
117	return 0;
118    choice = scroll = curr = max = 0;
119    dmenuOpen(menu, &choice, &scroll, &curr, &max);
120    free(menu);
121    free(devs);
122    return SystemWasInstalled;
123}
124
125int
126installExpress(char *str)
127{
128    int scroll, choice, curr, max;
129    extern DMenu MenuDiskDevices;
130    DMenu *menu;
131    Device *devs;
132
133    variable_set2("install_type", "express");
134    menu = device_create_disk_menu(&MenuDiskDevices, &devs, installHook);
135    if (!menu)
136	return 0;
137    choice = scroll = curr = max = 0;
138    dmenuOpen(menu, &choice, &scroll, &curr, &max);
139    free(menu);
140    free(devs);
141    return SystemWasInstalled;
142}
143
144int
145installMaint(char *str)
146{
147    msgConfirm("Sorry, maintainance mode is not implemented in this version.");
148    return 0;
149}
150