installer: Move the 'chflags nohistory ...' commands behind the cpdups.
[dragonfly.git] / usr.sbin / installer / dfuibe_installer / fn_install.c
bloba7525492007cc63c623cf18d7adcc86088e71a32
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/local/share/dfuibe_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 int lines = 0;
136 * If SOURCES_CONF_FILE exists, lets read in and
137 * populate our copy sources. If it does not exist
138 * simply set the list by hand.
140 if (!is_file("%s%s", a->os_root, SOURCES_CONF_FILE)) {
141 i_log(a, "Using internal copy sources table.");
142 strcpy(cp_src[0],"/COPYRIGHT");
143 strcpy(cp_src[1],"/bin");
144 strcpy(cp_src[2],"/boot");
145 strcpy(cp_src[3],"/cdrom");
146 strcpy(cp_src[4],"/dev");
147 strcpy(cp_src[5],"/etc");
148 strcpy(cp_src[6],"/root");
149 strcpy(cp_src[7],"/sbin");
150 strcpy(cp_src[8],"/sys");
151 strcpy(cp_src[9],"/tmp");
152 strcpy(cp_src[10],"/usr/Makefile");
153 strcpy(cp_src[11],"/usr/bin");
154 strcpy(cp_src[12],"/usr/games");
155 strcpy(cp_src[13],"/usr/include");
156 strcpy(cp_src[14],"/usr/lib");
157 strcpy(cp_src[15],"/usr/libdata");
158 strcpy(cp_src[16],"/usr/libexec");
159 strcpy(cp_src[17],"/usr/local");
160 strcpy(cp_src[18],"/usr/obj");
161 strcpy(cp_src[19],"/usr/pkg");
162 strcpy(cp_src[20],"/usr/sbin");
163 strcpy(cp_src[21],"/usr/share");
164 strcpy(cp_src[22],"/usr/src");
165 strcpy(cp_src[23],"/var");
166 strcpy(cp_src[24],"");
167 } else {
168 snprintf(file_path, 256, "%s%s", a->os_root, SOURCES_CONF_FILE);
169 sources_conf = fopen(file_path, "r");
170 i_log(a, "Reading %s%s", a->os_root, SOURCES_CONF_FILE);
171 while(fgets(line, 256, sources_conf) != NULL && lines < 63) {
172 if(strlen(line)>0)
173 line[strlen(line)-1] = '\0';
174 strlcpy(cp_src[lines], line, 256);
175 i_log(a,"Adding %s to copy source table.", cp_src[lines]);
176 lines++;
178 i_log(a,"Added %i total items to copy source table.", lines);
179 strcpy(cp_src[lines], "");
180 fclose(sources_conf);
183 cmds = commands_new();
186 * If swap isn't mounted yet, mount it.
188 if (measure_activated_swap(a) == 0) {
189 for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
190 sp != NULL; sp = subpartition_next(sp)) {
191 if (!subpartition_is_swap(sp))
192 continue;
193 command_add(cmds, "%s%s %sdev/%s",
194 a->os_root,
195 cmd_name(a, "SWAPON"),
196 a->os_root,
197 subpartition_get_device_name(sp));
202 * Unmount anything already mounted on /mnt.
204 unmount_all_under(a, cmds, "%smnt", a->os_root);
206 for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
207 sp != NULL; sp = subpartition_next(sp)) {
208 if (strcmp(subpartition_get_mountpoint(sp), "/") == 0) {
209 if (use_hammer == 1) {
210 command_add(cmds, "%s%s %sdev/%s %smnt%s",
211 a->os_root, cmd_name(a, "MOUNT_HAMMER"),
212 a->os_root,
213 subpartition_get_device_name(sp),
214 a->os_root,
215 subpartition_get_mountpoint(sp));
216 } else {
217 command_add(cmds, "%s%s %sdev/%s %smnt%s",
218 a->os_root, cmd_name(a, "MOUNT"),
219 a->os_root,
220 subpartition_get_device_name(sp),
221 a->os_root,
222 subpartition_get_mountpoint(sp));
228 * Create mount points and mount subpartitions on them.
230 for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
231 sp != NULL; sp = subpartition_next(sp)) {
232 if (subpartition_is_swap(sp)) {
233 #ifdef AUTOMATICALLY_ENABLE_CRASH_DUMPS
235 * Set this subpartition as the dump device.
237 if (subpartition_get_capacity(sp) < storage_get_memsize(a->s))
238 continue;
240 command_add(cmds, "%s%s -v %sdev/%s",
241 a->os_root, cmd_name(a, "DUMPON"),
242 a->os_root,
243 subpartition_get_device_name(sp));
245 asprintf(&string, "/dev/%s",
246 subpartition_get_device_name(sp));
247 config_var_set(rc_conf, "dumpdev", string);
248 free(string);
249 config_var_set(rc_conf, "dumpdir", "/var/crash");
250 #endif
251 continue;
254 if (use_hammer == 0) {
255 /* / is already mounted */
256 if (strcmp(subpartition_get_mountpoint(sp), "/") != 0) {
257 command_add(cmds, "%s%s -p %smnt%s",
258 a->os_root, cmd_name(a, "MKDIR"),
259 a->os_root,
260 subpartition_get_mountpoint(sp));
261 /* Don't mount it if it's MFS-backed. */
262 if (subpartition_is_mfsbacked(sp))
263 continue;
264 command_add(cmds, "%s%s %sdev/%s %smnt%s",
265 a->os_root, cmd_name(a, "MOUNT"),
266 a->os_root,
267 subpartition_get_device_name(sp),
268 a->os_root,
269 subpartition_get_mountpoint(sp));
271 } else if (strcmp(subpartition_get_mountpoint(sp), "/boot") == 0) {
272 command_add(cmds, "%s%s -p %smnt%s",
273 a->os_root, cmd_name(a, "MKDIR"),
274 a->os_root,
275 subpartition_get_mountpoint(sp));
276 command_add(cmds, "%s%s %sdev/%s %smnt%s",
277 a->os_root, cmd_name(a, "MOUNT"),
278 a->os_root,
279 subpartition_get_device_name(sp),
280 a->os_root,
281 subpartition_get_mountpoint(sp));
286 * Take care of HAMMER PFS.
288 if (use_hammer == 1)
289 handle_pfs(a, cmds);
292 * Actually copy files now.
295 for (i = 0; cp_src[i] != NULL && cp_src[i][0] != '\0'; i++) {
296 char *src, *dest, *dn, *tmp_dest;
298 dest = cp_src[i];
301 * If dest would be on an MFS-backed
302 * mountpoint, don't bother copying it.
304 sp = subpartition_of(storage_get_selected_slice(a->s),
305 "%s%s", a->os_root, &dest[1]);
306 if (sp != NULL && subpartition_is_mfsbacked(sp)) {
307 continue;
311 * Create intermediate directories, if needed.
313 tmp_dest = aura_strdup(dest);
314 dn = dirname(tmp_dest);
315 if (is_dir("%s%s", a->os_root, &dn[1]) &&
316 !is_dir("%smnt%s", a->os_root, dn)) {
317 command_add(cmds, "%s%s -p %smnt%s",
318 a->os_root, cmd_name(a, "MKDIR"),
319 a->os_root, dn);
321 aura_free(tmp_dest, "directory name");
324 * If a directory by the same name but with the suffix
325 * ".hdd" exists on the installation media, cpdup that
326 * instead. This is particularly useful with /etc, which
327 * may have significantly different behaviour on the
328 * live CD compared to a standard HDD boot.
330 if (is_dir("%s%s.hdd", a->os_root, &dest[1]))
331 asprintf(&src, "%s.hdd", &dest[1]);
332 else
333 asprintf(&src, "%s", &dest[1]);
335 if (is_dir("%s%s", a->os_root, src) || is_file("%s%s", a->os_root, src)) {
337 * Cpdup the chosen file or directory onto the HDD.
338 * if it exists on the source.
340 cmd = command_add(cmds, "%s%s %s%s %smnt%s",
341 a->os_root, cmd_name(a, "CPDUP"),
342 a->os_root, src,
343 a->os_root, dest);
344 command_set_log_mode(cmd, COMMAND_LOG_QUIET);
349 * Now, because cpdup does not cross mount points,
350 * we must copy anything that the user might've made a
351 * seperate mount point for (e.g. /usr/libdata/lint.)
353 for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
354 sp != NULL; sp = subpartition_next(sp)) {
356 * If the subpartition is a swap subpartition or an
357 * MFS-backed mountpoint, don't try to copy anything
358 * into it.
360 if (subpartition_is_swap(sp) || subpartition_is_mfsbacked(sp))
361 continue;
364 * If the mountpoint doesn't even exist on the installation
365 * medium, don't try to copy anything from it! We assume
366 * it's an empty subpartition for the user's needs.
368 if (!is_dir("%s%s", a->os_root, &subpartition_get_mountpoint(sp)[1]))
369 continue;
372 * Don't bother copying the mountpoint IF:
373 * - we've already said to copy it, or something besides it
374 * (it's a prefix of something in cp_src); or
375 * - we haven't said to copy it
376 * (nothing in cp_src is a prefix of it.)
378 seen_it = 0;
379 prefix = 0;
380 for (i = 0; cp_src[i] != NULL && cp_src[i][0] != '\0'; i++) {
381 if (strncmp(subpartition_get_mountpoint(sp), cp_src[i],
382 strlen(subpartition_get_mountpoint(sp))) == 0) {
383 seen_it = 1;
384 break;
386 if (strncmp(cp_src[i], subpartition_get_mountpoint(sp),
387 strlen(cp_src[i])) == 0) {
388 prefix = 1;
391 if (seen_it || !prefix)
392 continue;
395 * Otherwise, cpdup the subpartition.
397 * XXX check for .hdd-extended source dirs here, too,
398 * eventually - but for now, /etc.hdd will never be
399 * the kind of tricky sub-mount-within-a-mount-point
400 * that this part of the code is meant to handle.
402 cmd = command_add(cmds, "%s%s %s%s %smnt%s",
403 a->os_root, cmd_name(a, "CPDUP"),
404 a->os_root, &subpartition_get_mountpoint(sp)[1],
405 a->os_root, subpartition_get_mountpoint(sp));
406 command_set_log_mode(cmd, COMMAND_LOG_QUIET);
410 * Create symlinks.
414 * If the user has both /var and /tmp subpartitions,
415 * symlink /var/tmp to /tmp.
417 if (subpartition_find(storage_get_selected_slice(a->s), "/tmp") != NULL &&
418 subpartition_find(storage_get_selected_slice(a->s), "/var") != NULL) {
419 command_add(cmds, "%s%s 1777 %smnt/tmp",
420 a->os_root, cmd_name(a, "CHMOD"), a->os_root);
421 command_add(cmds, "%s%s -rf %smnt/var/tmp",
422 a->os_root, cmd_name(a, "RM"), a->os_root);
423 command_add(cmds, "%s%s -s /tmp %smnt/var/tmp",
424 a->os_root, cmd_name(a, "LN"), a->os_root);
428 * If the user has /var, but no /tmp,
429 * symlink /tmp to /var/tmp.
431 if (subpartition_find(storage_get_selected_slice(a->s), "/tmp") == NULL &&
432 subpartition_find(storage_get_selected_slice(a->s), "/var") != NULL) {
433 command_add(cmds, "%s%s -rf %smnt/tmp",
434 a->os_root, cmd_name(a, "RM"), a->os_root);
435 command_add(cmds, "%s%s -s /var/tmp %smnt/tmp",
436 a->os_root, cmd_name(a, "LN"), a->os_root);
440 * If the user has /usr, but no /home,
441 * symlink /home to /usr/home.
443 if (subpartition_find(storage_get_selected_slice(a->s), "/home") == NULL &&
444 subpartition_find(storage_get_selected_slice(a->s), "/usr") != NULL) {
445 command_add(cmds, "%s%s -rf %smnt/home",
446 a->os_root, cmd_name(a, "RM"), a->os_root);
447 command_add(cmds, "%s%s %smnt/usr/home",
448 a->os_root, cmd_name(a, "MKDIR"), a->os_root);
449 command_add(cmds, "%s%s -s /usr/home %smnt/home",
450 a->os_root, cmd_name(a, "LN"), a->os_root);
454 * XXX check for other possible combinations too?
458 * Clean up. In case some file didn't make it, use rm -f
460 command_add(cmds, "%s%s -f %smnt/boot/loader.conf",
461 a->os_root, cmd_name(a, "RM"), a->os_root);
462 command_add(cmds, "%s%s -f %smnt/tmp/install.log",
463 a->os_root, cmd_name(a, "RM"), a->os_root);
466 * Copy pristine versions over any files we might have installed.
467 * This allows the resulting file tree to be customized.
469 for (i = 0; cp_src[i] != NULL && cp_src[i][0] != '\0'; i++) {
470 char *src, *dest, *dn, *tmp_dest;
472 src = cp_src[i];
473 dest = cp_src[i];
476 * Get the directory that the desired thing to
477 * copy resides in.
479 tmp_dest = aura_strdup(dest);
480 dn = dirname(tmp_dest);
483 * If this dir doesn't exist in PRISTINE_DIR
484 * on the install media, just skip it.
486 if (!is_dir("%s%s%s", a->os_root, PRISTINE_DIR, dn)) {
487 aura_free(tmp_dest, _("directory name"));
488 continue;
492 * Create intermediate directories, if needed.
494 if (!is_dir("%smnt%s", a->os_root, dn)) {
495 command_add(cmds, "%s%s -p %smnt%s",
496 a->os_root, cmd_name(a, "MKDIR"),
497 a->os_root, dn);
499 aura_free(tmp_dest, "directory name");
502 * Cpdup the chosen file or directory onto the HDD.
504 cmd = command_add(cmds, "%s%s %s%s %smnt%s",
505 a->os_root, cmd_name(a, "CPDUP"),
506 a->os_root, src,
507 a->os_root, dest);
509 cmd = command_add(cmds,
510 "%s%s %s%s%s %smnt%s",
511 a->os_root, cmd_name(a, "CPDUP"),
512 a->os_root, PRISTINE_DIR, src,
513 a->os_root, dest);
514 command_set_log_mode(cmd, COMMAND_LOG_QUIET);
518 * Rebuild the user database, to get rid of any extra users
519 * from the LiveCD that aren't supposed to be installed
520 * (copying a pristine master.passwd isn't enough.)
522 command_add(cmds, "%s%s -p -d %smnt/etc %smnt/etc/master.passwd",
523 a->os_root, cmd_name(a, "PWD_MKDB"), a->os_root, a->os_root);
525 /* Create missing directories. */
526 command_add(cmds, "%s%s %smnt/proc",
527 a->os_root, cmd_name(a, "MKDIR"), a->os_root);
528 command_add(cmds, "%s%s %smnt/mnt",
529 a->os_root, cmd_name(a, "MKDIR"), a->os_root);
531 /* Write new fstab. */
533 command_add(cmds, "%s%s '%s' >%smnt/etc/fstab",
534 a->os_root, cmd_name(a, "ECHO"),
535 "# Device\t\tMountpoint\tFStype\tOptions\t\tDump\tPass#",
536 a->os_root);
538 for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
539 sp != NULL; sp = subpartition_next(sp)) {
540 if (strcmp(subpartition_get_mountpoint(sp), "swap") == 0) {
541 command_add(cmds, "%s%s '/dev/%s\t\tnone\t\tswap\tsw\t\t0\t0' >>%smnt/etc/fstab",
542 a->os_root, cmd_name(a, "ECHO"),
543 subpartition_get_device_name(sp),
544 a->os_root);
545 } else if (use_hammer == 0) {
546 if (strcmp(subpartition_get_mountpoint(sp), "/") == 0) {
547 command_add(cmds, "%s%s '/dev/%s\t\t%s\t\tufs\trw\t\t1\t1' >>%smnt/etc/fstab",
548 a->os_root, cmd_name(a, "ECHO"),
549 subpartition_get_device_name(sp),
550 subpartition_get_mountpoint(sp),
551 a->os_root);
552 } else if (subpartition_is_mfsbacked(sp)) {
553 command_add(cmds, "%s%s 'swap\t\t%s\t\t\tmfs\trw,-s%lu,-b%lu,-f%lu\t\t1\t1' >>%smnt/etc/fstab",
554 a->os_root, cmd_name(a, "ECHO"),
555 subpartition_get_mountpoint(sp),
556 subpartition_get_capacity(sp) * 2048,
557 subpartition_get_bsize(sp),
558 subpartition_get_fsize(sp),
559 a->os_root);
560 } else {
561 command_add(cmds, "%s%s '/dev/%s\t\t%s\t\tufs\trw\t\t2\t2' >>%smnt/etc/fstab",
562 a->os_root, cmd_name(a, "ECHO"),
563 subpartition_get_device_name(sp),
564 subpartition_get_mountpoint(sp),
565 a->os_root);
567 } else {
568 if (strcmp(subpartition_get_mountpoint(sp), "/") == 0) {
569 command_add(cmds, "%s%s '/dev/%s\t\t%s\t\thammer\trw\t\t1\t1' >>%smnt/etc/fstab",
570 a->os_root, cmd_name(a, "ECHO"),
571 subpartition_get_device_name(sp),
572 subpartition_get_mountpoint(sp),
573 a->os_root);
574 command_add(cmds, "%s%s 'vfs.root.mountfrom=\"hammer:%s\"' >>%smnt/boot/loader.conf",
575 a->os_root, cmd_name(a, "ECHO"),
576 subpartition_get_device_name(sp),
577 a->os_root);
578 } else if (strcmp(subpartition_get_mountpoint(sp), "/boot") == 0) {
579 command_add(cmds, "%s%s '/dev/%s\t\t%s\t\tufs\trw\t\t1\t1' >>%smnt/etc/fstab",
580 a->os_root, cmd_name(a, "ECHO"),
581 subpartition_get_device_name(sp),
582 subpartition_get_mountpoint(sp),
583 a->os_root);
589 * Take care of HAMMER PFS null mounts.
591 if (use_hammer == 1) {
592 for (j = 0; pfs_mountpt[j] != NULL; j++) {
593 if (rindex(pfs_mountpt[j]+1, '/') != NULL)
594 command_add(cmds, "%s%s '/pfs%s.%s\t%s\t\tnull\trw\t\t0\t0' >>%smnt/etc/fstab",
595 a->os_root, cmd_name(a, "ECHO"),
596 dirname(pfs_mountpt[j]),
597 basename(pfs_mountpt[j]),
598 pfs_mountpt[j],
599 a->os_root);
600 else
601 command_add(cmds, "%s%s '/pfs%s\t\t%s\t\tnull\trw\t\t0\t0' >>%smnt/etc/fstab",
602 a->os_root, cmd_name(a, "ECHO"),
603 pfs_mountpt[j],
604 pfs_mountpt[j],
605 a->os_root);
609 command_add(cmds, "%s%s '%s' >>%smnt/etc/fstab",
610 a->os_root, cmd_name(a, "ECHO"),
611 "proc\t\t\t/proc\t\tprocfs\trw\t\t0\t0",
612 a->os_root);
614 /* Backup the disklabel and the log. */
615 if (use_hammer == 0) {
616 command_add(cmds, "%s%s %s > %smnt/etc/disklabel.%s",
617 a->os_root, cmd_name(a, "DISKLABEL"),
618 slice_get_device_name(storage_get_selected_slice(a->s)),
619 a->os_root,
620 slice_get_device_name(storage_get_selected_slice(a->s)));
621 } else {
622 command_add(cmds, "%s%s %s > %smnt/etc/disklabel.%s",
623 a->os_root, cmd_name(a, "DISKLABEL64"),
624 slice_get_device_name(storage_get_selected_slice(a->s)),
625 a->os_root,
626 slice_get_device_name(storage_get_selected_slice(a->s)));
629 /* 'chflags nohistory' as needed */
630 for (j = 0; pfs_mountpt[j] != NULL; j++)
631 if (pfs_nohistory[j] == 1)
632 command_add(cmds, "%s%s -R nohistory %smnt%s",
633 a->os_root, cmd_name(a, "CHFLAGS"),
634 a->os_root, pfs_mountpt[j]);
636 command_add(cmds, "%s%s %sinstall.log %smnt/var/log/install.log",
637 a->os_root, cmd_name(a, "CP"),
638 a->tmp, a->os_root);
639 command_add(cmds, "%s%s 600 %smnt/var/log/install.log",
640 a->os_root, cmd_name(a, "CHMOD"), a->os_root);
642 /* Customize stuff here */
643 if(is_file("%susr/local/bin/after_installation_routines.sh")) {
644 command_add(cmds, "%susr/local/bin/after_installation_routines.sh",
645 a->os_root, _("Running after installation custom routines..."));
649 * Do it!
651 /* commands_preview(a->c, cmds); */
652 if (!commands_execute(a, cmds)) {
653 inform(a->c, _("%s was not fully installed."), OPERATING_SYSTEM_NAME);
654 a->result = 0;
655 } else {
656 a->result = 1;
658 commands_free(cmds);
661 * Unmount everything we mounted on /mnt. This is done in a seperate
662 * command chain, so that partitions are unmounted, even if an error
663 * occurs in one of the preceding commands, or it is cancelled.
665 cmds = commands_new();
666 unmount_all_under(a, cmds, "%smnt", a->os_root);
669 * Once everything is unmounted, if the install went successfully,
670 * make sure once and for all that the disklabel is bootable.
672 if (a->result) {
673 if (use_hammer == 0) {
674 command_add(cmds, "%s%s -B %s",
675 a->os_root, cmd_name(a, "DISKLABEL"),
676 slice_get_device_name(storage_get_selected_slice(a->s)));
677 } else {
678 command_add(cmds, "%s%s -B %s",
679 a->os_root, cmd_name(a, "DISKLABEL64"),
680 slice_get_device_name(storage_get_selected_slice(a->s)));
684 if (!commands_execute(a, cmds))
685 inform(a->c, _("Warning: subpartitions were not correctly unmounted."));
687 commands_free(cmds);