Remove /lib from the copy sources and sync internal table.
[dragonfly.git] / contrib / bsdinstaller-1.1.6 / src / backend / installer / fn_install.c
blob47d1c5eb5ff6b4b1f247c93685b921c6c139f609
1 /*
2 * Copyright (c)2004 The DragonFly Project. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
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, 0, 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 if (pfs_nohistory[j] == 1)
105 command_add(cmds, "%s%s nohistory %smnt%s",
106 a->os_root, cmd_name(a, "CHFLAGS"),
107 a->os_root, pfs_mountpt[j]);
109 else {
110 command_add(cmds, "%s%s pfs-master %smnt/pfs%s",
111 a->os_root, cmd_name(a, "HAMMER"),
112 a->os_root, pfs_mountpt[j]);
113 command_add(cmds, "%s%s -p %smnt%s",
114 a->os_root, cmd_name(a, "MKDIR"),
115 a->os_root, pfs_mountpt[j]);
116 command_add(cmds, "%s%s %smnt/pfs%s %smnt%s",
117 a->os_root, cmd_name(a, "MOUNT_NULL"),
118 a->os_root, pfs_mountpt[j],
119 a->os_root, pfs_mountpt[j]);
125 * fn_install_os: actually put DragonFly on a disk.
127 void
128 fn_install_os(struct i_fn_args *a)
130 struct subpartition *sp;
131 struct commands *cmds;
132 struct command *cmd;
133 int i, seen_it, prefix, j;
134 FILE *sources_conf;
135 char line[256];
136 char cp_src[64][256];
137 char file_path[256];
138 int lines = 0;
139 long mfsbacked_size;
142 * If SOURCES_CONF_FILE exists, lets read in and
143 * populate our copy sources. If it does not exist
144 * simply set the list by hand.
146 if (!is_file("%s%s", a->os_root, SOURCES_CONF_FILE)) {
147 i_log(a, "Using internal copy sources table.");
148 strcpy(cp_src[0],"/COPYRIGHT");
149 strcpy(cp_src[1],"/bin");
150 strcpy(cp_src[2],"/boot");
151 strcpy(cp_src[3],"/cdrom");
152 strcpy(cp_src[4],"/dev");
153 strcpy(cp_src[5],"/etc");
154 strcpy(cp_src[6],"/root");
155 strcpy(cp_src[7],"/sbin");
156 strcpy(cp_src[8],"/sys");
157 strcpy(cp_src[9],"/tmp");
158 strcpy(cp_src[10],"/usr/Makefile");
159 strcpy(cp_src[11],"/usr/bin");
160 strcpy(cp_src[12],"/usr/games");
161 strcpy(cp_src[13],"/usr/include");
162 strcpy(cp_src[14],"/usr/lib");
163 strcpy(cp_src[15],"/usr/libdata");
164 strcpy(cp_src[16],"/usr/libexec");
165 strcpy(cp_src[17],"/usr/local");
166 strcpy(cp_src[18],"/usr/obj");
167 strcpy(cp_src[19],"/usr/pkg");
168 strcpy(cp_src[20],"/usr/sbin");
169 strcpy(cp_src[21],"/usr/share");
170 strcpy(cp_src[22],"/usr/src");
171 strcpy(cp_src[23],"/var");
172 strcpy(cp_src[24],"");
173 } else {
174 snprintf(file_path, 256, "%s%s", a->os_root, SOURCES_CONF_FILE);
175 sources_conf = fopen(file_path, "r");
176 i_log(a, "Reading %s%s", a->os_root, SOURCES_CONF_FILE);
177 while(fgets(line, 256, sources_conf) != NULL && lines < 63) {
178 if(strlen(line)>0)
179 line[strlen(line)-1] = '\0';
180 strlcpy(cp_src[lines], line, 256);
181 i_log(a,"Adding %s to copy source table.", cp_src[lines]);
182 lines++;
184 i_log(a,"Added %i total items to copy source table.", lines);
185 strcpy(cp_src[lines], "");
186 fclose(sources_conf);
189 cmds = commands_new();
192 * If swap isn't mounted yet, mount it.
194 if (measure_activated_swap(a) == 0) {
195 for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
196 sp != NULL; sp = subpartition_next(sp)) {
197 if (!subpartition_is_swap(sp))
198 continue;
199 command_add(cmds, "%s%s %sdev/%s",
200 a->os_root,
201 cmd_name(a, "SWAPON"),
202 a->os_root,
203 subpartition_get_device_name(sp));
208 * Unmount anything already mounted on /mnt.
210 unmount_all_under(a, cmds, "%smnt", a->os_root);
212 for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
213 sp != NULL; sp = subpartition_next(sp)) {
214 if (strcmp(subpartition_get_mountpoint(sp), "/") == 0) {
215 command_add(cmds, "%s%s -p %smnt%s",
216 a->os_root, cmd_name(a, "MKDIR"),
217 a->os_root, subpartition_get_mountpoint(sp));
218 if (use_hammer == 1) {
219 command_add(cmds, "%s%s %sdev/%s %smnt%s",
220 a->os_root, cmd_name(a, "MOUNT_HAMMER"),
221 a->os_root,
222 subpartition_get_device_name(sp),
223 a->os_root,
224 subpartition_get_mountpoint(sp));
225 } else {
226 command_add(cmds, "%s%s %sdev/%s %smnt%s",
227 a->os_root, cmd_name(a, "MOUNT"),
228 a->os_root,
229 subpartition_get_device_name(sp),
230 a->os_root,
231 subpartition_get_mountpoint(sp));
237 * Create mount points and mount subpartitions on them.
239 for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
240 sp != NULL; sp = subpartition_next(sp)) {
241 if (subpartition_is_swap(sp)) {
243 * Set this subpartition as the dump device.
245 #ifdef AUTOMATICALLY_ENABLE_CRASH_DUMPS
246 if (subpartition_get_capacity(sp) < storage_get_memsize(a->s))
247 continue;
249 command_add(cmds, "%s%s -v %sdev/%s",
250 a->os_root, cmd_name(a, "DUMPON"),
251 a->os_root,
252 subpartition_get_device_name(sp));
254 asprintf(&string, "/dev/%s",
255 subpartition_get_device_name(sp));
256 config_var_set(rc_conf, "dumpdev", string);
257 free(string);
258 config_var_set(rc_conf, "dumpdir", "/var/crash");
259 #endif
260 continue;
265 * Don't mount it if it's MFS-backed.
268 if (subpartition_is_mfsbacked(sp)) {
269 continue;
271 if (use_hammer == 0) {
272 /* / is already mounted */
273 if (strcmp(subpartition_get_mountpoint(sp), "/") != 0) {
274 command_add(cmds, "%s%s -p %smnt%s",
275 a->os_root, cmd_name(a, "MKDIR"),
276 a->os_root,
277 subpartition_get_mountpoint(sp));
278 command_add(cmds, "%s%s %sdev/%s %smnt%s",
279 a->os_root, cmd_name(a, "MOUNT"),
280 a->os_root,
281 subpartition_get_device_name(sp),
282 a->os_root,
283 subpartition_get_mountpoint(sp));
289 * Take care of HAMMER PFS.
291 if (use_hammer == 1)
292 handle_pfs(a, cmds);
295 * Actually copy files now.
298 for (i = 0; cp_src[i] != NULL && cp_src[i][0] != '\0'; i++) {
299 char *src, *dest, *dn, *tmp_dest;
301 dest = cp_src[i];
304 * If dest would be on an MFS-backed
305 * mountpoint, don't bother copying it.
307 sp = subpartition_of(storage_get_selected_slice(a->s),
308 "%s%s", a->os_root, &dest[1]);
309 if (sp != NULL && subpartition_is_mfsbacked(sp)) {
310 continue;
314 * Create intermediate directories, if needed.
316 tmp_dest = aura_strdup(dest);
317 dn = dirname(tmp_dest);
318 if (is_dir("%s%s", a->os_root, &dn[1]) &&
319 !is_dir("%smnt%s", a->os_root, dn)) {
320 command_add(cmds, "%s%s -p %smnt%s",
321 a->os_root, cmd_name(a, "MKDIR"),
322 a->os_root, dn);
324 aura_free(tmp_dest, "directory name");
327 * If a directory by the same name but with the suffix
328 * ".hdd" exists on the installation media, cpdup that
329 * instead. This is particularly useful with /etc, which
330 * may have significantly different behaviour on the
331 * live CD compared to a standard HDD boot.
333 if (is_dir("%s%s.hdd", a->os_root, &dest[1]))
334 asprintf(&src, "%s.hdd", &dest[1]);
335 else
336 asprintf(&src, "%s", &dest[1]);
338 if (is_dir("%s%s", a->os_root, src) || is_file("%s%s", a->os_root, src)) {
340 * Cpdup the chosen file or directory onto the HDD.
341 * if it exists on the source.
343 cmd = command_add(cmds, "%s%s %s%s %smnt%s",
344 a->os_root, cmd_name(a, "CPDUP"),
345 a->os_root, src,
346 a->os_root, dest);
347 command_set_log_mode(cmd, COMMAND_LOG_QUIET);
352 * Now, because cpdup does not cross mount points,
353 * we must copy anything that the user might've made a
354 * seperate mount point for (e.g. /usr/libdata/lint.)
356 for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
357 sp != NULL; sp = subpartition_next(sp)) {
359 * If the subpartition is a swap subpartition or an
360 * MFS-backed mountpoint, don't try to copy anything
361 * into it.
363 if (subpartition_is_swap(sp) || subpartition_is_mfsbacked(sp))
364 continue;
367 * If the mountpoint doesn't even exist on the installation
368 * medium, don't try to copy anything from it! We assume
369 * it's an empty subpartition for the user's needs.
371 if (!is_dir("%s%s", a->os_root, &subpartition_get_mountpoint(sp)[1]))
372 continue;
375 * Don't bother copying the mountpoint IF:
376 * - we've already said to copy it, or something besides it
377 * (it's a prefix of something in cp_src); or
378 * - we haven't said to copy it
379 * (nothing in cp_src is a prefix of it.)
381 seen_it = 0;
382 prefix = 0;
383 for (i = 0; cp_src[i] != NULL && cp_src[i][0] != '\0'; i++) {
384 if (strncmp(subpartition_get_mountpoint(sp), cp_src[i],
385 strlen(subpartition_get_mountpoint(sp))) == 0) {
386 seen_it = 1;
387 break;
389 if (strncmp(cp_src[i], subpartition_get_mountpoint(sp),
390 strlen(cp_src[i])) == 0) {
391 prefix = 1;
394 if (seen_it || !prefix)
395 continue;
398 * Otherwise, cpdup the subpartition.
400 * XXX check for .hdd-extended source dirs here, too,
401 * eventually - but for now, /etc.hdd will never be
402 * the kind of tricky sub-mount-within-a-mount-point
403 * that this part of the code is meant to handle.
405 cmd = command_add(cmds, "%s%s %s%s %smnt%s",
406 a->os_root, cmd_name(a, "CPDUP"),
407 a->os_root, &subpartition_get_mountpoint(sp)[1],
408 a->os_root, subpartition_get_mountpoint(sp));
409 command_set_log_mode(cmd, COMMAND_LOG_QUIET);
413 * Create symlinks.
417 * If the user has both /var and /tmp subparitions,
418 * symlink /var/tmp to /tmp.
420 if (subpartition_find(storage_get_selected_slice(a->s), "/tmp") != NULL &&
421 subpartition_find(storage_get_selected_slice(a->s), "/var") != NULL) {
422 command_add(cmds, "%s%s 1777 %smnt/tmp",
423 a->os_root, cmd_name(a, "CHMOD"), a->os_root);
424 command_add(cmds, "%s%s -rf %smnt/var/tmp",
425 a->os_root, cmd_name(a, "RM"), a->os_root);
426 command_add(cmds, "%s%s -s /tmp %smnt/var/tmp",
427 a->os_root, cmd_name(a, "LN"), a->os_root);
431 * If the user has /var, but no /tmp,
432 * symlink /tmp to /var/tmp.
434 if (subpartition_find(storage_get_selected_slice(a->s), "/tmp") == NULL &&
435 subpartition_find(storage_get_selected_slice(a->s), "/var") != NULL) {
436 command_add(cmds, "%s%s -rf %smnt/tmp",
437 a->os_root, cmd_name(a, "RM"), a->os_root);
438 command_add(cmds, "%s%s -s /var/tmp %smnt/tmp",
439 a->os_root, cmd_name(a, "LN"), a->os_root);
443 * If the user has /usr, but no /home,
444 * symlink /home to /usr/home.
446 if (subpartition_find(storage_get_selected_slice(a->s), "/home") == NULL &&
447 subpartition_find(storage_get_selected_slice(a->s), "/usr") != NULL) {
448 command_add(cmds, "%s%s -rf %smnt/home",
449 a->os_root, cmd_name(a, "RM"), a->os_root);
450 command_add(cmds, "%s%s %smnt/usr/home",
451 a->os_root, cmd_name(a, "MKDIR"), a->os_root);
452 command_add(cmds, "%s%s -s /usr/home %smnt/home",
453 a->os_root, cmd_name(a, "LN"), a->os_root);
457 * XXX check for other possible combinations too?
461 * Clean up. In case some file didn't make it, use rm -f
463 #ifdef __DragonFly__
464 command_add(cmds, "%s%s -f %smnt/boot/loader.conf",
465 a->os_root, cmd_name(a, "RM"), a->os_root);
466 #endif
467 command_add(cmds, "%s%s -f %smnt/tmp/install.log",
468 a->os_root, cmd_name(a, "RM"), a->os_root);
471 * Copy pristine versions over any files we might have installed.
472 * This allows the resulting file tree to be customized.
474 for (i = 0; cp_src[i] != NULL && cp_src[i][0] != '\0'; i++) {
475 char *src, *dest, *dn, *tmp_dest;
477 src = cp_src[i];
478 dest = cp_src[i];
481 * Get the directory that the desired thing to
482 * copy resides in.
484 tmp_dest = aura_strdup(dest);
485 dn = dirname(tmp_dest);
488 * If this dir doesn't exist in PRISTINE_DIR
489 * on the install media, just skip it.
491 if (!is_dir("%s%s%s", a->os_root, PRISTINE_DIR, dn)) {
492 aura_free(tmp_dest, _("directory name"));
493 continue;
497 * Create intermediate directories, if needed.
499 if (!is_dir("%smnt%s", a->os_root, dn)) {
500 command_add(cmds, "%s%s -p %smnt%s",
501 a->os_root, cmd_name(a, "MKDIR"),
502 a->os_root, dn);
504 aura_free(tmp_dest, "directory name");
507 * Cpdup the chosen file or directory onto the HDD.
509 cmd = command_add(cmds, "%s%s %s%s %smnt%s",
510 a->os_root, cmd_name(a, "CPDUP"),
511 a->os_root, src,
512 a->os_root, dest);
514 cmd = command_add(cmds,
515 "%s%s %s%s%s %smnt%s",
516 a->os_root, cmd_name(a, "CPDUP"),
517 a->os_root, PRISTINE_DIR, src,
518 a->os_root, dest);
519 command_set_log_mode(cmd, COMMAND_LOG_QUIET);
523 * Rebuild the user database, to get rid of any extra users
524 * from the LiveCD that aren't supposed to be installed
525 * (copying a pristine master.passwd isn't enough.)
527 command_add(cmds, "%s%s -p -d %smnt/etc %smnt/etc/master.passwd",
528 a->os_root, cmd_name(a, "PWD_MKDB"), a->os_root, a->os_root);
530 /* Create missing directories. */
531 command_add(cmds, "%s%s %smnt/proc",
532 a->os_root, cmd_name(a, "MKDIR"), a->os_root);
533 command_add(cmds, "%s%s %smnt/mnt",
534 a->os_root, cmd_name(a, "MKDIR"), a->os_root);
536 /* Write new fstab. */
538 command_add(cmds, "%s%s '%s' >%smnt/etc/fstab",
539 a->os_root, cmd_name(a, "ECHO"),
540 "# Device\t\tMountpoint\tFStype\tOptions\t\tDump\tPass#",
541 a->os_root);
543 for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
544 sp != NULL; sp = subpartition_next(sp)) {
545 if (strcmp(subpartition_get_mountpoint(sp), "swap") == 0) {
546 command_add(cmds, "%s%s '/dev/%s\t\tnone\t\tswap\tsw\t\t0\t0' >>%smnt/etc/fstab",
547 a->os_root, cmd_name(a, "ECHO"),
548 subpartition_get_device_name(sp),
549 a->os_root);
550 } else if (use_hammer == 0) {
551 if (strcmp(subpartition_get_mountpoint(sp), "/") == 0) {
552 command_add(cmds, "%s%s '/dev/%s\t\t%s\t\tufs\trw\t\t1\t1' >>%smnt/etc/fstab",
553 a->os_root, cmd_name(a, "ECHO"),
554 subpartition_get_device_name(sp),
555 subpartition_get_mountpoint(sp),
556 a->os_root);
557 } else if (subpartition_is_mfsbacked(sp)) {
558 mfsbacked_size = slice_get_capacity(storage_get_selected_slice(a->s)) * 2048;
559 command_add(cmds, "%s%s 'swap\t\t%s\t\t\tmfs\trw,-s%ld\t\t1\t1' >>%smnt/etc/fstab",
560 a->os_root, cmd_name(a, "ECHO"),
561 subpartition_get_mountpoint(sp),
562 mfsbacked_size,
563 a->os_root);
564 } else {
565 command_add(cmds, "%s%s '/dev/%s\t\t%s\t\tufs\trw\t\t2\t2' >>%smnt/etc/fstab",
566 a->os_root, cmd_name(a, "ECHO"),
567 subpartition_get_device_name(sp),
568 subpartition_get_mountpoint(sp),
569 a->os_root);
571 } else {
572 if (strcmp(subpartition_get_mountpoint(sp), "/") == 0) {
573 command_add(cmds, "%s%s '/dev/%s\t\t%s\t\thammer\trw\t\t1\t1' >>%smnt/etc/fstab",
574 a->os_root, cmd_name(a, "ECHO"),
575 subpartition_get_device_name(sp),
576 subpartition_get_mountpoint(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 command_add(cmds, "%s%s %sinstall.log %smnt/var/log/install.log",
630 a->os_root, cmd_name(a, "CP"),
631 a->tmp, a->os_root);
632 command_add(cmds, "%s%s 600 %smnt/var/log/install.log",
633 a->os_root, cmd_name(a, "CHMOD"), a->os_root);
635 /* Customize stuff here */
636 if(is_file("%susr/local/bin/after_installation_routines.sh")) {
637 command_add(cmds, "%susr/local/bin/after_installation_routines.sh",
638 a->os_root, _("Running after installation custom routines..."));
642 * Do it!
644 /* commands_preview(cmds); */
645 if (!commands_execute(a, cmds)) {
646 inform(a->c, _("%s was not fully installed."), OPERATING_SYSTEM_NAME);
647 a->result = 0;
648 } else {
649 a->result = 1;
651 commands_free(cmds);
654 * Unmount everything we mounted on /mnt. This is done in a seperate
655 * command chain, so that partitions are unmounted, even if an error
656 * occurs in one of the preceding commands, or it is cancelled.
658 cmds = commands_new();
659 unmount_all_under(a, cmds, "%smnt", a->os_root);
662 * Once everything is unmounted, if the install went successfully,
663 * make sure once and for all that the disklabel is bootable.
665 if (a->result) {
666 if (use_hammer == 0) {
667 command_add(cmds, "%s%s -B %s",
668 a->os_root, cmd_name(a, "DISKLABEL"),
669 slice_get_device_name(storage_get_selected_slice(a->s)));
670 } else {
671 command_add(cmds, "%s%s -B %s",
672 a->os_root, cmd_name(a, "DISKLABEL64"),
673 slice_get_device_name(storage_get_selected_slice(a->s)));
677 if (!commands_execute(a, cmds))
678 inform(a->c, _("Warning: subpartitions were not correctly unmounted."));
680 commands_free(cmds);