1 /* febootstrap-supermin-helper reimplementation in C.
2 * Copyright (C) 2009-2010 Red Hat Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include <sys/types.h>
36 struct timeval start_t;
39 enum { HELP_OPTION = CHAR_MAX + 1 };
41 static const char *options = "k:vV";
42 static const struct option long_options[] = {
43 { "help", 0, 0, HELP_OPTION },
44 { "kmods", required_argument, 0, 'k' },
45 { "verbose", 0, 0, 'v' },
46 { "version", 0, 0, 'V' },
51 usage (const char *progname)
53 printf ("%s: build the supermin appliance on the fly\n"
56 " %s [-options] inputs [...] whitelist host_cpu kernel initrd\n"
60 "This script is used by febootstrap to build the supermin appliance\n"
61 "(kernel and initrd output files). You should NOT need to run this\n"
62 "program directly except if you are debugging tricky supermin\n"
63 "appliance problems.\n"
65 "NB: The kernel and initrd parameters are OUTPUT parameters. If\n"
66 "those files exist, they are overwritten by the output.\n"
70 " Display this help text and exit.\n"
71 " -k file | --kmods file\n"
72 " Specify kernel module whitelist.\n"
74 " Enable verbose messages (give multiple times for more verbosity).\n"
76 " Display version number and exit.\n",
77 progname, progname, progname, progname);
81 main (int argc, char *argv[])
83 /* First thing: start the clock. */
84 gettimeofday (&start_t, NULL);
86 const char *whitelist = NULL;
88 /* Command line arguments. */
90 int c = getopt_long (argc, argv, options, long_options, NULL);
107 printf (PACKAGE_NAME " " PACKAGE_VERSION "\n");
116 char **inputs = &argv[optind];
117 int nr_inputs = argc - optind - 3;
124 /* See: https://bugzilla.redhat.com/show_bug.cgi?id=558593 */
125 const char *hostcpu = argv[argc-3];
128 const char *kernel = argv[argc-2];
129 const char *appliance = argv[argc-1];
132 print_timestamped_message ("whitelist = %s, "
136 whitelist ? : "(not specified)",
137 hostcpu, kernel, appliance);
139 for (i = 0; i < nr_inputs; ++i)
140 print_timestamped_message ("inputs[%d] = %s", i, inputs[i]);
143 /* Remove the output files if they exist. */
147 /* Create kernel output file. */
149 modpath = create_kernel (hostcpu, kernel);
152 print_timestamped_message ("finished creating kernel");
154 /* Create the appliance. */
155 create_appliance (inputs, nr_inputs, whitelist, modpath, appliance,
159 print_timestamped_message ("finished creating appliance");