install.c (8452) | install.c (8549) |
---|---|
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 * | 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.15 1995/05/11 06:47:44 jkh Exp $ | 7 * $Id: install.c,v 1.16 1995/05/11 09:01:32 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 --- 27 unchanged lines hidden (view full) --- 43 44#include "sysinstall.h" 45#include <sys/disklabel.h> 46#include <sys/errno.h> 47#include <sys/fcntl.h> 48#include <unistd.h> 49 50Boolean SystemWasInstalled; | 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 --- 27 unchanged lines hidden (view full) --- 43 44#include "sysinstall.h" 45#include <sys/disklabel.h> 46#include <sys/errno.h> 47#include <sys/fcntl.h> 48#include <unistd.h> 49 50Boolean SystemWasInstalled; |
51struct disk *Disks[100]; /* some ridiculously large number */ | |
52 | 51 |
53static int 54installHook(char *str) | 52static void make_filesystems(void); 53static void cpio_extract(void); 54static void install_configuration_files(void); 55static void do_final_setup(void); 56 57int 58installCommit(char *str) |
55{ | 59{ |
60 extern u_char boot1[], boot2[]; 61 extern u_char mbr[], bteasy17[]; 62 u_char *mbrContents; 63 Device **devs; |
|
56 int i; | 64 int i; |
57 extern DMenu MenuInstall; | |
58 | 65 |
59 i = 0; 60 /* Clip garbage off the ends */ 61 string_prune(str); 62 str = string_skipwhite(str); 63 /* Try and open all the disks */ 64 while (str) { 65 char *cp; | 66 if (!getenv(DISK_PARTITIONED)) { 67 msgConfirm("You need to partition your disk before you can proceed with\nthe installation."); |
66 | 68 |
67 cp = index(str, '\n'); 68 if (cp) 69 *cp++ = 0; 70 if (!*str) { 71 beep(); 72 return 0; 73 } 74 Disks[i] = Open_Disk(str); 75 if (!Disks[i]) 76 msgFatal("Unable to open disk %s!", str); 77 ++i; 78 str = cp; | 69 return 0; |
79 } | 70 } |
80 Disks[i] = NULL; 81 if (!i) | 71 if (!getenv(DISK_LABELLED)) { 72 msgConfirm("You need to assign disk labels before you can proceed with\nthe installation."); |
82 return 0; | 73 return 0; |
83 84 while (1) { 85 /* Now go set up all the MBR partition information */ 86 for (i = 0; Disks[i]; i++) 87 Disks[i] = device_slice_disk(Disks[i]); 88 89 /* Whap partitions on all the FreeBSD slices created */ 90 partition_disks(); 91 92 /* Try and write it out */ 93 if (!write_disks()) { 94 int scroll, choice, curr, max; 95 96 make_filesystems(); 97 scroll = choice = curr = max = 0; 98 dmenuOpen(&MenuInstall, &choice, &scroll, &curr, &max); 99 chdir("/mnt"); 100 cpio_extract(); 101 chroot("/mnt"); 102 distExtractAll(); 103 install_configuration_files(); 104 do_final_setup(); 105 SystemWasInstalled = TRUE; 106 break; 107 } 108 else { 109 dialog_clear(); 110 if (msgYesNo("Would you like to go back to the Master Partition Editor?")) { 111 for (i = 0; Disks[i]; i++) 112 Free_Disk(Disks[i]); 113 break; 114 } 115 } | |
116 } | 74 } |
117 return SystemWasInstalled; 118} 119 120int 121installCustom(char *str) 122{ 123 int scroll, choice, curr, max; 124 extern DMenu MenuDiskDevices; 125 DMenu *menu; 126 Device *devs; 127 128 variable_set2("install_type", "custom"); 129 menu = device_create_disk_menu(&MenuDiskDevices, &devs, installHook); 130 if (!menu) | 75 if (!Dists) { 76 msgConfirm("You haven't told me what distributions to load yet!\nPlease select a distribution from the Distributions menu."); |
131 return 0; | 77 return 0; |
132 choice = scroll = curr = max = 0; 133 dmenuOpen(menu, &choice, &scroll, &curr, &max); 134 free(menu); 135 free(devs); 136 return SystemWasInstalled; 137} 138 139int 140installExpress(char *str) 141{ 142 int scroll, choice, curr, max; 143 extern DMenu MenuDiskDevices; 144 DMenu *menu; 145 Device *devs; 146 147 variable_set2("install_type", "express"); 148 menu = device_create_disk_menu(&MenuDiskDevices, &devs, installHook); 149 if (!menu) | 78 } 79 if (mediaVerifyStatus()) { 80 msgConfirm("Please correct installation media problems and try again!"); |
150 return 0; | 81 return 0; |
151 choice = scroll = curr = max = 0; 152 dmenuOpen(menu, &choice, &scroll, &curr, &max); 153 free(menu); 154 free(devs); 155 return SystemWasInstalled; | 82 } 83 if (msgYesNo("Last Chance! Are you SURE you want continue the\ninstallation? If you're running this on an existing system, we STRONGLY\nencourage you to make proper backups before doing this.\nWe take no responsibility for lost disk contents!")) 84 return 0; 85 dialog_clear(); 86 mbrContents = NULL; 87 if (!msgYesNo("Would you like to install a boot manager?\n\nThis will allow you to easily select between other operating systems\non the first disk, or boot from a disk other than the first.")) 88 mbrContents = bteasy17; 89 else { 90 dialog_clear(); 91 if (!msgYesNo("Would you like to remove an existing boot manager?")) 92 mbrContents = mbr; 93 } 94 for (i = 0; Devices[i]; i++) { 95 if (Devices[i]->type != DEVICE_TYPE_DISK) 96 continue; 97 if (mbrContents) { 98 Set_Boot_Mgr((Disk *)Devices[i]->private, mbrContents); 99 mbrContents = NULL; 100 } 101 Set_Boot_Blocks((Disk *)Devices[i]->private, boot1, boot2); 102 msgNotify("Writing partition information to drive %s", 103 Devices[i]->name); 104 Write_Disk((Disk *)Devices[i]->private); 105 } 106 make_filesystems(); 107 cpio_extract(); 108 install_configuration_files(); 109 do_final_setup(); 110 return 1; |
156} 157 | 111} 112 |
158int 159installMaint(char *str) 160{ 161 msgConfirm("Sorry, maintainance mode is not implemented in this version."); 162 return 0; 163} 164 | |
165/* Go newfs and/or mount all the filesystems we've been asked to */ | 113/* Go newfs and/or mount all the filesystems we've been asked to */ |
166void | 114static void |
167make_filesystems(void) 168{ 169 int i; | 115make_filesystems(void) 116{ 117 int i; |
118 Disk *disk; 119 Chunk *c1; |
|
170 171 command_clear(); | 120 121 command_clear(); |
172 for (i = 0; Disks[i]; i++) { 173 struct chunk *c1; | 122 for (i = 0; Devices[i]; i++) { 123 if (Devices[i]->type != DEVICE_TYPE_DISK) 124 continue; |
174 | 125 |
175 if (!Disks[i]->chunks) 176 msgFatal("No chunk list found for %s!", Disks[i]->name); 177 c1 = Disks[i]->chunks->part; | 126 disk = (Disk *)Devices[i]->private; 127 if (!disk->chunks) 128 msgFatal("No chunk list found for %s!", disk->name); 129 c1 = disk->chunks->part; |
178 while (c1) { 179 if (c1->type == freebsd) { | 130 while (c1) { 131 if (c1->type == freebsd) { |
180 struct chunk *c2 = c1->part; | 132 Chunk *c2 = c1->part; |
181 182 while (c2) { 183 if (c2->type == part && c2->subtype != FS_SWAP && 184 c2->private) { 185 PartInfo *tmp = (PartInfo *)c2->private; 186 187 if (tmp->newfs) | 133 134 while (c2) { 135 if (c2->type == part && c2->subtype != FS_SWAP && 136 c2->private) { 137 PartInfo *tmp = (PartInfo *)c2->private; 138 139 if (tmp->newfs) |
188 command_add(tmp->mountpoint, 189 "%s %s", tmp->newfs_cmd, c2->name); 190 if (strcmp(tmp->mountpoint, "/")) { 191 command_add(tmp->mountpoint, 192 "mkdir -p /mnt%s", tmp->mountpoint); 193 command_add(tmp->mountpoint, 194 "mount /mnt/dev/%s /mnt%s", c2->name, 195 tmp->mountpoint); 196 } 197 else 198 command_add(tmp->mountpoint, 199 "mount /mnt/dev/%s /mnt", c2->name); 200 | 140 command_shell_add(tmp->mountpoint, 141 "%s %s", tmp->newfs_cmd, 142 c2->name); 143 if (strcmp(tmp->mountpoint, "/")) 144 command_func_add(tmp->mountpoint, Mkdir, NULL); 145 command_func_add(tmp->mountpoint, Mount, c2->name); |
201 } 202 c2 = c2->next; 203 } 204 } 205 c1 = c1->next; 206 } 207 } 208 command_sort(); 209 command_execute(); 210} 211 | 146 } 147 c2 = c2->next; 148 } 149 } 150 c1 = c1->next; 151 } 152 } 153 command_sort(); 154 command_execute(); 155} 156 |
212void | 157static void |
213cpio_extract(void) 214{ 215 int i, j, zpid, cpid, pfd[2]; 216 extern int wait(int *status); 217 218 while (CpioFD == -1) { 219 msgConfirm("Please Insert CPIO floppy in floppy drive 0"); 220 CpioFD = open("/dev/rfd0", O_RDONLY); --- 27 unchanged lines hidden (view full) --- 248 msgFatal("Pid %d, status %d, cpio=%d, gunzip=%d.\nerror:%s", 249 i, j, cpid, zpid, strerror(errno)); 250 i = wait(&j); 251 if (i < 0 || j) 252 msgFatal("Pid %d, status %d, cpio=%d, gunzip=%d.\nerror:%s", 253 i, j, cpid, zpid, strerror(errno)); 254} 255 | 158cpio_extract(void) 159{ 160 int i, j, zpid, cpid, pfd[2]; 161 extern int wait(int *status); 162 163 while (CpioFD == -1) { 164 msgConfirm("Please Insert CPIO floppy in floppy drive 0"); 165 CpioFD = open("/dev/rfd0", O_RDONLY); --- 27 unchanged lines hidden (view full) --- 193 msgFatal("Pid %d, status %d, cpio=%d, gunzip=%d.\nerror:%s", 194 i, j, cpid, zpid, strerror(errno)); 195 i = wait(&j); 196 if (i < 0 || j) 197 msgFatal("Pid %d, status %d, cpio=%d, gunzip=%d.\nerror:%s", 198 i, j, cpid, zpid, strerror(errno)); 199} 200 |
256void | 201static void |
257install_configuration_files(void) 258{ 259} 260 | 202install_configuration_files(void) 203{ 204} 205 |
261void | 206static void |
262do_final_setup(void) 263{ 264} | 207do_final_setup(void) 208{ 209} |
265 | |