nrelease/installer: Rename the UP/SMP kernel directories on the LiveCD.
[dragonfly.git] / usr.sbin / installer / dfuibe_installer / fn_install.c
blob34db13a1105378ceb09164e934dcd48f87842dfa
1 /*
2 * Copyright (c)2004 The DragonFly Project. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
16 * Neither the name of the DragonFly Project nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31 * OF THE POSSIBILITY OF SUCH DAMAGE.
35 * fn_install.c
36 * Installer Function : Install OS Files.
37 * $Id: fn_install.c,v 1.74 2006/04/18 19:43:48 joerg Exp $
40 #include <libgen.h>
41 #include <string.h>
43 #define SOURCES_CONF_FILE "usr/share/installer/sources.conf"
45 #ifdef ENABLE_NLS
46 #include <libintl.h>
47 #define _(String) gettext (String)
48 #else
49 #define _(String) (String)
50 #endif
52 #include "libaura/mem.h"
53 #include "libaura/buffer.h"
54 #include "libaura/fspred.h"
56 #include "libdfui/dfui.h"
57 #include "libdfui/system.h"
59 #include "libinstaller/commands.h"
60 #include "libinstaller/confed.h"
61 #include "libinstaller/diskutil.h"
62 #include "libinstaller/functions.h"
63 #include "libinstaller/uiutil.h"
65 #include "flow.h"
66 #include "pathnames.h"
67 #include "fn.h"
69 static const char *pfs_mountpt[8] = {"/var", "/tmp", "/usr", "/home",
70 "/usr/obj", "/var/crash", "/var/tmp", NULL};
72 static const int pfs_nohistory[8] = {0, 1, 0, 0, 1, 1, 1};
74 static void
75 handle_pfs(struct i_fn_args *a, struct commands *cmds)
77 int j;
80 * Create PFS root directory.
82 command_add(cmds, "%s%s -p %smnt/pfs",
83 a->os_root, cmd_name(a, "MKDIR"),
84 a->os_root);
86 for (j = 0; pfs_mountpt[j] != NULL; j++) {
88 * We have a PFS for a subdirectory, e.g. /var/crash, so we
89 * need to create /pfs/var.crash
91 if (rindex(pfs_mountpt[j]+1, '/') != NULL) {
92 command_add(cmds, "%s%s pfs-master %smnt/pfs%s.%s",
93 a->os_root, cmd_name(a, "HAMMER"),
94 a->os_root, dirname(pfs_mountpt[j]),
95 basename(pfs_mountpt[j]));
96 command_add(cmds, "%s%s -p %smnt%s",
97 a->os_root, cmd_name(a, "MKDIR"),
98 a->os_root, pfs_mountpt[j]);
99 command_add(cmds, "%s%s %smnt/pfs%s.%s %smnt%s",
100 a->os_root, cmd_name(a, "MOUNT_NULL"),
101 a->os_root, dirname(pfs_mountpt[j]),
102 basename(pfs_mountpt[j]),
103 a->os_root, pfs_mountpt[j]);
104 } else {
105 command_add(cmds, "%s%s pfs-master %smnt/pfs%s",
106 a->os_root, cmd_name(a, "HAMMER"),
107 a->os_root, pfs_mountpt[j]);
108 command_add(cmds, "%s%s -p %smnt%s",
109 a->os_root, cmd_name(a, "MKDIR"),
110 a->os_root, pfs_mountpt[j]);
111 command_add(cmds, "%s%s %smnt/pfs%s %smnt%s",
112 a->os_root, cmd_name(a, "MOUNT_NULL"),
113 a->os_root, pfs_mountpt[j],
114 a->os_root, pfs_mountpt[j]);
120 * fn_install_os: actually put DragonFly on a disk.
122 void
123 fn_install_os(struct i_fn_args *a)
125 struct subpartition *sp;
126 struct commands *cmds;
127 struct command *cmd;
128 int i, seen_it, prefix, j;
129 FILE *sources_conf;
130 char line[256];
131 char cp_src[64][256];
132 char file_path[256];
133 char *string;
134 int lines = 0;
137 * Read SOURCES_CONF_FILE and populate our copy sources.
139 snprintf(file_path, 256, "%s%s", a->os_root, SOURCES_CONF_FILE);
140 sources_conf = fopen(file_path, "r");
141 i_log(a, "Reading %s", file_path);
142 while(fgets(line, 256, sources_conf) != NULL && lines < 63) {
143 if(strlen(line)>0)
144 line[strlen(line)-1] = '\0';
145 strlcpy(cp_src[lines], line, 256);
146 i_log(a,"Adding %s to copy source table.", cp_src[lines]);
147 lines++;
149 i_log(a,"Added %i total items to copy source table.", lines);
150 strcpy(cp_src[lines], "");
151 fclose(sources_conf);
153 cmds = commands_new();
156 * If swap isn't mounted yet, mount it.
158 if (measure_activated_swap(a) == 0) {
159 for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
160 sp != NULL; sp = subpartition_next(sp)) {
161 if (!subpartition_is_swap(sp))
162 continue;
163 command_add(cmds, "%s%s %sdev/%s",
164 a->os_root,
165 cmd_name(a, "SWAPON"),
166 a->os_root,
167 subpartition_get_device_name(sp));
172 * Unmount anything already mounted on /mnt.
174 unmount_all_under(a, cmds, "%smnt", a->os_root);
176 for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
177 sp != NULL; sp = subpartition_next(sp)) {
178 if (strcmp(subpartition_get_mountpoint(sp), "/") == 0) {
179 if (use_hammer == 1) {
180 command_add(cmds, "%s%s %sdev/%s %smnt%s",
181 a->os_root, cmd_name(a, "MOUNT_HAMMER"),
182 a->os_root,
183 subpartition_get_device_name(sp),
184 a->os_root,
185 subpartition_get_mountpoint(sp));
186 } else {
187 command_add(cmds, "%s%s %sdev/%s %smnt%s",
188 a->os_root, cmd_name(a, "MOUNT"),
189 a->os_root,
190 subpartition_get_device_name(sp),
191 a->os_root,
192 subpartition_get_mountpoint(sp));
198 * Create mount points and mount subpartitions on them.
200 for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
201 sp != NULL; sp = subpartition_next(sp)) {
202 if (subpartition_is_swap(sp)) {
204 * Set this subpartition as the dump device.
206 if (subpartition_get_capacity(sp) < storage_get_memsize(a->s))
207 continue;
209 command_add(cmds, "%s%s -v %sdev/%s",
210 a->os_root, cmd_name(a, "DUMPON"),
211 a->os_root,
212 subpartition_get_device_name(sp));
214 asprintf(&string, "/dev/%s",
215 subpartition_get_device_name(sp));
216 config_var_set(rc_conf, "dumpdev", string);
217 free(string);
218 continue;
221 if (use_hammer == 0) {
222 /* / is already mounted */
223 if (strcmp(subpartition_get_mountpoint(sp), "/") != 0) {
224 command_add(cmds, "%s%s -p %smnt%s",
225 a->os_root, cmd_name(a, "MKDIR"),
226 a->os_root,
227 subpartition_get_mountpoint(sp));
228 /* Don't mount it if it's TMPFS-backed. */
229 if (subpartition_is_tmpfsbacked(sp))
230 continue;
231 command_add(cmds, "%s%s %sdev/%s %smnt%s",
232 a->os_root, cmd_name(a, "MOUNT"),
233 a->os_root,
234 subpartition_get_device_name(sp),
235 a->os_root,
236 subpartition_get_mountpoint(sp));
238 } else if (strcmp(subpartition_get_mountpoint(sp), "/boot") == 0) {
239 command_add(cmds, "%s%s -p %smnt%s",
240 a->os_root, cmd_name(a, "MKDIR"),
241 a->os_root,
242 subpartition_get_mountpoint(sp));
243 command_add(cmds, "%s%s %sdev/%s %smnt%s",
244 a->os_root, cmd_name(a, "MOUNT"),
245 a->os_root,
246 subpartition_get_device_name(sp),
247 a->os_root,
248 subpartition_get_mountpoint(sp));
253 * Take care of HAMMER PFS.
255 if (use_hammer == 1)
256 handle_pfs(a, cmds);
259 * Actually copy files now.
262 for (i = 0; cp_src[i] != NULL && cp_src[i][0] != '\0'; i++) {
263 char *src, *dest, *dn, *tmp_dest;
265 dest = cp_src[i];
268 * If dest would be on an TMPFS-backed
269 * mountpoint, don't bother copying it.
271 sp = subpartition_of(storage_get_selected_slice(a->s),
272 "%s%s", a->os_root, &dest[1]);
273 if (sp != NULL && subpartition_is_tmpfsbacked(sp)) {
274 continue;
278 * Create intermediate directories, if needed.
280 tmp_dest = aura_strdup(dest);
281 dn = dirname(tmp_dest);
282 if (is_dir("%s%s", a->os_root, &dn[1]) &&
283 !is_dir("%smnt%s", a->os_root, dn)) {
284 command_add(cmds, "%s%s -p %smnt%s",
285 a->os_root, cmd_name(a, "MKDIR"),
286 a->os_root, dn);
288 aura_free(tmp_dest, "directory name");
291 * If a directory by the same name but with the suffix
292 * ".hdd" exists on the installation media, cpdup that
293 * instead. This is particularly useful with /etc, which
294 * may have significantly different behaviour on the
295 * live CD compared to a standard HDD boot.
297 if (is_dir("%s%s.hdd", a->os_root, &dest[1]))
298 asprintf(&src, "%s.hdd", &dest[1]);
299 else
300 asprintf(&src, "%s", &dest[1]);
302 if (is_dir("%s%s", a->os_root, src) || is_file("%s%s", a->os_root, src)) {
304 * Cpdup the chosen file or directory onto the HDD.
305 * if it exists on the source.
307 cmd = command_add(cmds, "%s%s %s%s %smnt%s",
308 a->os_root, cmd_name(a, "CPDUP"),
309 a->os_root, src,
310 a->os_root, dest);
311 command_set_log_mode(cmd, COMMAND_LOG_QUIET);
316 * Now, because cpdup does not cross mount points,
317 * we must copy anything that the user might've made a
318 * seperate mount point for (e.g. /usr/libdata/lint.)
320 for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
321 sp != NULL; sp = subpartition_next(sp)) {
323 * If the subpartition is a swap subpartition or an
324 * TMPFS-backed mountpoint, don't try to copy anything
325 * into it.
327 if (subpartition_is_swap(sp) || subpartition_is_tmpfsbacked(sp))
328 continue;
331 * If the mountpoint doesn't even exist on the installation
332 * medium, don't try to copy anything from it! We assume
333 * it's an empty subpartition for the user's needs.
335 if (!is_dir("%s%s", a->os_root, &subpartition_get_mountpoint(sp)[1]))
336 continue;
339 * Don't bother copying the mountpoint IF:
340 * - we've already said to copy it, or something besides it
341 * (it's a prefix of something in cp_src); or
342 * - we haven't said to copy it
343 * (nothing in cp_src is a prefix of it.)
345 seen_it = 0;
346 prefix = 0;
347 for (i = 0; cp_src[i] != NULL && cp_src[i][0] != '\0'; i++) {
348 if (strncmp(subpartition_get_mountpoint(sp), cp_src[i],
349 strlen(subpartition_get_mountpoint(sp))) == 0) {
350 seen_it = 1;
351 break;
353 if (strncmp(cp_src[i], subpartition_get_mountpoint(sp),
354 strlen(cp_src[i])) == 0) {
355 prefix = 1;
358 if (seen_it || !prefix)
359 continue;
362 * Otherwise, cpdup the subpartition.
364 * XXX check for .hdd-extended source dirs here, too,
365 * eventually - but for now, /etc.hdd will never be
366 * the kind of tricky sub-mount-within-a-mount-point
367 * that this part of the code is meant to handle.
369 cmd = command_add(cmds, "%s%s %s%s %smnt%s",
370 a->os_root, cmd_name(a, "CPDUP"),
371 a->os_root, &subpartition_get_mountpoint(sp)[1],
372 a->os_root, subpartition_get_mountpoint(sp));
373 command_set_log_mode(cmd, COMMAND_LOG_QUIET);
377 * Create symlinks.
380 /* Take care of /sys. */
381 command_add(cmds, "%s%s -s usr/src/sys %smnt/sys",
382 a->os_root, cmd_name(a, "LN"), a->os_root);
385 * If the user has both /var and /tmp subpartitions,
386 * symlink /var/tmp to /tmp.
388 if (subpartition_find(storage_get_selected_slice(a->s), "/tmp") != NULL &&
389 subpartition_find(storage_get_selected_slice(a->s), "/var") != NULL) {
390 command_add(cmds, "%s%s 1777 %smnt/tmp",
391 a->os_root, cmd_name(a, "CHMOD"), a->os_root);
392 command_add(cmds, "%s%s -rf %smnt/var/tmp",
393 a->os_root, cmd_name(a, "RM"), a->os_root);
394 command_add(cmds, "%s%s -s /tmp %smnt/var/tmp",
395 a->os_root, cmd_name(a, "LN"), a->os_root);
399 * If the user has /var, but no /tmp,
400 * symlink /tmp to /var/tmp.
402 if (subpartition_find(storage_get_selected_slice(a->s), "/tmp") == NULL &&
403 subpartition_find(storage_get_selected_slice(a->s), "/var") != NULL) {
404 command_add(cmds, "%s%s -rf %smnt/tmp",
405 a->os_root, cmd_name(a, "RM"), a->os_root);
406 command_add(cmds, "%s%s -s /var/tmp %smnt/tmp",
407 a->os_root, cmd_name(a, "LN"), a->os_root);
411 * If the user has /usr, but no /home,
412 * symlink /home to /usr/home.
414 if (subpartition_find(storage_get_selected_slice(a->s), "/home") == NULL &&
415 subpartition_find(storage_get_selected_slice(a->s), "/usr") != NULL) {
416 command_add(cmds, "%s%s -rf %smnt/home",
417 a->os_root, cmd_name(a, "RM"), a->os_root);
418 command_add(cmds, "%s%s %smnt/usr/home",
419 a->os_root, cmd_name(a, "MKDIR"), a->os_root);
420 command_add(cmds, "%s%s -s /usr/home %smnt/home",
421 a->os_root, cmd_name(a, "LN"), a->os_root);
425 * XXX check for other possible combinations too?
429 * Clean up. In case some file didn't make it, use rm -f
431 command_add(cmds, "%s%s -f %smnt/boot/loader.conf",
432 a->os_root, cmd_name(a, "RM"), a->os_root);
433 command_add(cmds, "%s%s -f %smnt/tmp/install.log",
434 a->os_root, cmd_name(a, "RM"), a->os_root);
437 * Copy pristine versions over any files we might have installed.
438 * This allows the resulting file tree to be customized.
440 for (i = 0; cp_src[i] != NULL && cp_src[i][0] != '\0'; i++) {
441 char *src, *dest, *dn, *tmp_dest;
443 src = cp_src[i];
444 dest = cp_src[i];
447 * Get the directory that the desired thing to
448 * copy resides in.
450 tmp_dest = aura_strdup(dest);
451 dn = dirname(tmp_dest);
454 * If this dir doesn't exist in PRISTINE_DIR
455 * on the install media, just skip it.
457 if (!is_dir("%s%s%s", a->os_root, PRISTINE_DIR, dn)) {
458 aura_free(tmp_dest, _("directory name"));
459 continue;
463 * Create intermediate directories, if needed.
465 if (!is_dir("%smnt%s", a->os_root, dn)) {
466 command_add(cmds, "%s%s -p %smnt%s",
467 a->os_root, cmd_name(a, "MKDIR"),
468 a->os_root, dn);
470 aura_free(tmp_dest, "directory name");
473 * Cpdup the chosen file or directory onto the HDD.
475 cmd = command_add(cmds, "%s%s %s%s %smnt%s",
476 a->os_root, cmd_name(a, "CPDUP"),
477 a->os_root, src,
478 a->os_root, dest);
480 cmd = command_add(cmds,
481 "%s%s %s%s%s %smnt%s",
482 a->os_root, cmd_name(a, "CPDUP"),
483 a->os_root, PRISTINE_DIR, src,
484 a->os_root, dest);
485 command_set_log_mode(cmd, COMMAND_LOG_QUIET);
489 * Rebuild the user database, to get rid of any extra users
490 * from the LiveCD that aren't supposed to be installed
491 * (copying a pristine master.passwd isn't enough.)
493 command_add(cmds, "%s%s -p -d %smnt/etc %smnt/etc/master.passwd",
494 a->os_root, cmd_name(a, "PWD_MKDB"), a->os_root, a->os_root);
496 /* Create missing directories. */
497 command_add(cmds, "%s%s %smnt/proc",
498 a->os_root, cmd_name(a, "MKDIR"), a->os_root);
499 command_add(cmds, "%s%s %smnt/mnt",
500 a->os_root, cmd_name(a, "MKDIR"), a->os_root);
502 /* Write new fstab. */
503 command_add(cmds, "%s%s '%s' >%smnt/etc/fstab",
504 a->os_root, cmd_name(a, "ECHO"),
505 "# Device\t\tMountpoint\tFStype\tOptions\t\tDump\tPass#",
506 a->os_root);
508 for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
509 sp != NULL; sp = subpartition_next(sp)) {
510 if (strcmp(subpartition_get_mountpoint(sp), "swap") == 0) {
511 command_add(cmds, "%s%s '/dev/%s\t\tnone\t\tswap\tsw\t\t0\t0' >>%smnt/etc/fstab",
512 a->os_root, cmd_name(a, "ECHO"),
513 subpartition_get_device_name(sp),
514 a->os_root);
515 } else if (use_hammer == 0) {
516 if (strcmp(subpartition_get_mountpoint(sp), "/") == 0) {
517 command_add(cmds, "%s%s '/dev/%s\t\t%s\t\tufs\trw\t\t1\t1' >>%smnt/etc/fstab",
518 a->os_root, cmd_name(a, "ECHO"),
519 subpartition_get_device_name(sp),
520 subpartition_get_mountpoint(sp),
521 a->os_root);
522 command_add(cmds, "%s%s 'kern.emergency_intr_enable=1' >>%smnt/boot/loader.conf",
523 a->os_root, cmd_name(a, "ECHO"), a->os_root);
524 } else if (subpartition_is_tmpfsbacked(sp)) {
525 command_add(cmds, "%s%s 'tmpfs\t\t\t%s\t\ttmpfs\trw,-s%luM\t1\t1' >>%smnt/etc/fstab",
526 a->os_root, cmd_name(a, "ECHO"),
527 subpartition_get_mountpoint(sp),
528 subpartition_get_capacity(sp),
529 a->os_root);
530 } else {
531 command_add(cmds, "%s%s '/dev/%s\t\t%s\t\tufs\trw\t\t2\t2' >>%smnt/etc/fstab",
532 a->os_root, cmd_name(a, "ECHO"),
533 subpartition_get_device_name(sp),
534 subpartition_get_mountpoint(sp),
535 a->os_root);
537 } else {
538 if (strcmp(subpartition_get_mountpoint(sp), "/") == 0) {
539 command_add(cmds, "%s%s '/dev/%s\t\t%s\t\thammer\trw\t\t1\t1' >>%smnt/etc/fstab",
540 a->os_root, cmd_name(a, "ECHO"),
541 subpartition_get_device_name(sp),
542 subpartition_get_mountpoint(sp),
543 a->os_root);
544 command_add(cmds, "%s%s 'vfs.root.mountfrom=\"hammer:%s\"' >>%smnt/boot/loader.conf",
545 a->os_root, cmd_name(a, "ECHO"),
546 subpartition_get_device_name(sp),
547 a->os_root);
548 command_add(cmds, "%s%s 'kern.emergency_intr_enable=1' >>%smnt/boot/loader.conf",
549 a->os_root, cmd_name(a, "ECHO"), a->os_root);
550 } else if (strcmp(subpartition_get_mountpoint(sp), "/boot") == 0) {
551 command_add(cmds, "%s%s '/dev/%s\t\t%s\t\tufs\trw\t\t1\t1' >>%smnt/etc/fstab",
552 a->os_root, cmd_name(a, "ECHO"),
553 subpartition_get_device_name(sp),
554 subpartition_get_mountpoint(sp),
555 a->os_root);
561 * Take care of HAMMER PFS null mounts.
563 if (use_hammer == 1) {
564 for (j = 0; pfs_mountpt[j] != NULL; j++) {
565 if (rindex(pfs_mountpt[j]+1, '/') != NULL)
566 command_add(cmds, "%s%s '/pfs%s.%s\t%s\t\tnull\trw\t\t0\t0' >>%smnt/etc/fstab",
567 a->os_root, cmd_name(a, "ECHO"),
568 dirname(pfs_mountpt[j]),
569 basename(pfs_mountpt[j]),
570 pfs_mountpt[j],
571 a->os_root);
572 else
573 command_add(cmds, "%s%s '/pfs%s\t\t%s\t\tnull\trw\t\t0\t0' >>%smnt/etc/fstab",
574 a->os_root, cmd_name(a, "ECHO"),
575 pfs_mountpt[j],
576 pfs_mountpt[j],
577 a->os_root);
581 command_add(cmds, "%s%s '%s' >>%smnt/etc/fstab",
582 a->os_root, cmd_name(a, "ECHO"),
583 "proc\t\t\t/proc\t\tprocfs\trw\t\t0\t0",
584 a->os_root);
586 /* Backup the disklabel and the log. */
587 command_add(cmds, "%s%s %s > %smnt/etc/disklabel.%s",
588 a->os_root, cmd_name(a, "DISKLABEL64"),
589 slice_get_device_name(storage_get_selected_slice(a->s)),
590 a->os_root,
591 slice_get_device_name(storage_get_selected_slice(a->s)));
593 /* 'chflags nohistory' as needed */
594 for (j = 0; pfs_mountpt[j] != NULL; j++)
595 if (pfs_nohistory[j] == 1)
596 command_add(cmds, "%s%s -R nohistory %smnt%s",
597 a->os_root, cmd_name(a, "CHFLAGS"),
598 a->os_root, pfs_mountpt[j]);
600 command_add(cmds, "%s%s %sinstall.log %smnt/var/log/install.log",
601 a->os_root, cmd_name(a, "CP"),
602 a->tmp, a->os_root);
603 command_add(cmds, "%s%s 600 %smnt/var/log/install.log",
604 a->os_root, cmd_name(a, "CHMOD"), a->os_root);
607 * Move the kernel used for booting (kernel.UP or kernel.SMP) to
608 * /boot/kernel and remove the other kernel
610 command_add(cmds,
611 "%s%s %smnt`%s%s $(%s%s -n kern.bootfile)` %smnt/boot/kernel",
612 a->os_root, cmd_name(a, "MV"),
613 a->os_root,
614 a->os_root, cmd_name(a, "DIRNAME"),
615 a->os_root, cmd_name(a, "SYSCTL"),
616 a->os_root);
617 command_add(cmds,
618 "%s%s -R noschg %smnt/boot/kernel.[SU]M*P; %s%s -rf %smnt/boot/kernel.[SU]M*P",
619 a->os_root, cmd_name(a, "CHFLAGS"),
620 a->os_root,
621 a->os_root, cmd_name(a, "RM"),
622 a->os_root);
624 /* Customize stuff here */
625 if(is_file("%susr/local/bin/after_installation_routines.sh", a->os_root)) {
626 command_add(cmds, "%susr/local/bin/after_installation_routines.sh",
627 a->os_root);
631 * Do it!
633 /* commands_preview(a->c, cmds); */
634 if (!commands_execute(a, cmds)) {
635 inform(a->c, _("%s was not fully installed."), OPERATING_SYSTEM_NAME);
636 a->result = 0;
637 } else {
638 a->result = 1;
640 commands_free(cmds);
641 cmds = commands_new();
643 if (a->result) {
644 config_vars_write(rc_conf, CONFIG_TYPE_SH, "%smnt/etc/rc.conf",
645 a->os_root);
646 config_vars_free(rc_conf);
647 rc_conf = config_vars_new();
651 * Unmount everything we mounted on /mnt. This is done in a seperate
652 * command chain, so that partitions are unmounted, even if an error
653 * occurs in one of the preceding commands, or it is cancelled.
655 unmount_all_under(a, cmds, "%smnt", a->os_root);
658 * Once everything is unmounted, if the install went successfully,
659 * make sure once and for all that the disklabel is bootable.
661 if (a->result)
662 command_add(cmds, "%s%s -B %s",
663 a->os_root, cmd_name(a, "DISKLABEL64"),
664 slice_get_device_name(storage_get_selected_slice(a->s)));
666 if (!commands_execute(a, cmds))
667 inform(a->c, _("Warning: subpartitions were not correctly unmounted."));
669 commands_free(cmds);
672 * Finally, remove all swap.
674 if (swapoff_all(a) == NULL)
675 inform(a->c, _("Warning: swap could not be turned off."));