Remove /lib from the copy sources and sync internal table.
[dragonfly.git] / contrib / bsdinstaller-1.1.6 / src / backend / installer / main.c
blob53790875895a0043e5be649f19a0dad83c96481f
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 * main.c
36 * Main program for installer backend.
37 * $Id: main.c,v 1.18 2005/03/11 19:57:27 cpressey Exp $
40 #include <err.h>
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <string.h>
44 #include <unistd.h>
46 #ifdef ENABLE_NLS
47 #include <libintl.h>
48 #define _(String) gettext (String)
49 #else
50 #define _(String) (String)
51 #endif
53 #include "libaura/mem.h"
55 #include "libdfui/dfui.h"
56 #include "libdfui/dump.h"
57 #include "libdfui/system.h"
59 #include "flow.h"
60 #include "pathnames.h"
62 static void usage(char **);
64 int
65 main(int argc, char **argv)
67 char os_root[256];
68 char *rendezvous = NULL;
69 int do_reboot = 0;
70 int opt;
71 int transport = 0;
72 int booted_from_livecd = 0;
73 int upgrade_menu_toggle = 0;
75 #ifdef ENABLE_NLS
76 setlocale (LC_ALL, "");
77 bindtextdomain (PACKAGE, LOCALEDIR);
78 textdomain (PACKAGE);
79 #endif
82 * XXX TODO: set transport and rendezvous from
83 * corresponding environment variables, if set.
86 strlcpy(os_root, DEFAULT_OS_ROOT, sizeof(os_root));
88 #ifdef DEBUG
89 dfui_debug_file = fopen("/tmp/dfuibe_installer_debug.log", "w");
90 #endif
93 * Get command-line arguments.
95 while ((opt = getopt(argc, argv, "o:r:t:")) != -1) {
96 switch (opt) {
97 case 'o':
98 strlcpy(os_root, optarg, sizeof(os_root));
99 break;
100 case 'r':
101 rendezvous = aura_strdup(optarg);
102 break;
103 case 't':
104 transport = user_get_transport(optarg);
105 break;
106 case '?':
107 default:
108 usage(argv);
111 argc -= optind;
112 argv += optind;
114 if (transport == 0)
115 transport = user_get_transport("tcp");
117 if (rendezvous == NULL) {
118 if (transport == DFUI_TRANSPORT_TCP)
119 rendezvous = aura_strdup("9999");
120 else
121 rendezvous = aura_strdup("test");
124 do_reboot = flow(transport, rendezvous, os_root,
125 booted_from_livecd, upgrade_menu_toggle);
126 free(rendezvous);
128 if (do_reboot)
129 exit(5);
130 else
131 exit(0);
134 static void
135 usage(char **argv)
137 fprintf(stderr, _("Usage: %s [-o rootdir] [-r rendezvous] "
138 "[-t caps|npipe|tcp]\n"), argv[0]);
139 exit(1);