summaryrefslogtreecommitdiffstats
path: root/helper
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2010-08-19 14:58:03 +0100
committerRichard Jones <rjones@redhat.com>2010-08-24 13:17:41 +0100
commit5b45043e8cc72285f5f7077ae65e0ac98f40ec58 (patch)
tree8f6a8aba00f9dd0501cf70f173b3af0d2f09c8fb /helper
parent15c230a50d78435716b701a68709b3576118f27b (diff)
downloadfebootstrap-5b45043e8cc72285f5f7077ae65e0ac98f40ec58.tar.gz
febootstrap-5b45043e8cc72285f5f7077ae65e0ac98f40ec58.tar.xz
febootstrap-5b45043e8cc72285f5f7077ae65e0ac98f40ec58.zip
Add -f option for selecting the output format.
Only -f cpio is permitted by this commit.
Diffstat (limited to 'helper')
-rw-r--r--helper/febootstrap-supermin-helper.pod5
-rw-r--r--helper/main.c25
2 files changed, 27 insertions, 3 deletions
diff --git a/helper/febootstrap-supermin-helper.pod b/helper/febootstrap-supermin-helper.pod
index 29f4b95..6a2551b 100644
--- a/helper/febootstrap-supermin-helper.pod
+++ b/helper/febootstrap-supermin-helper.pod
@@ -33,6 +33,11 @@ booting the appliance, and should be deleted straight afterwards.
=over 4
+=item B<-f cpio> | B<--format cpio>
+
+Select the output format. The default, and only possible output
+format, is C<cpio> (ie. a Linux initramfs).
+
=item B<-k file> | B<--kmods file>
If this option is specified, then C<file> should be a list of
diff --git a/helper/main.c b/helper/main.c
index a448b9e..f5a06cc 100644
--- a/helper/main.c
+++ b/helper/main.c
@@ -36,11 +36,14 @@
struct timeval start_t;
int verbose = 0;
+static const char *format = "cpio";
+
enum { HELP_OPTION = CHAR_MAX + 1 };
-static const char *options = "k:vV";
+static const char *options = "f:k:vV";
static const struct option long_options[] = {
{ "help", 0, 0, HELP_OPTION },
+ { "format", required_argument, 0, 'f' },
{ "kmods", required_argument, 0, 'k' },
{ "verbose", 0, 0, 'v' },
{ "version", 0, 0, 'V' },
@@ -68,6 +71,8 @@ usage (const char *progname)
"Options:\n"
" --help\n"
" Display this help text and exit.\n"
+ " -f cpio | --format cpio\n"
+ " Specify output format (default: cpio).\n"
" -k file | --kmods file\n"
" Specify kernel module whitelist.\n"
" --verbose | -v\n"
@@ -95,6 +100,10 @@ main (int argc, char *argv[])
usage (argv[0]);
exit (EXIT_SUCCESS);
+ case 'f':
+ format = optarg;
+ break;
+
case 'k':
whitelist = optarg;
break;
@@ -113,6 +122,17 @@ main (int argc, char *argv[])
}
}
+ /* Select the correct writer module. */
+ struct writer *writer;
+
+ if (strcmp (format, "cpio") == 0)
+ writer = &cpio_writer;
+ else {
+ fprintf (stderr, "%s: incorrect output format (-f): must be cpio\n",
+ argv[0]);
+ exit (EXIT_FAILURE);
+ }
+
char **inputs = &argv[optind];
int nr_inputs = argc - optind - 3;
@@ -152,8 +172,7 @@ main (int argc, char *argv[])
print_timestamped_message ("finished creating kernel");
/* Create the appliance. */
- create_appliance (inputs, nr_inputs, whitelist, modpath, appliance,
- &cpio_writer);
+ create_appliance (inputs, nr_inputs, whitelist, modpath, appliance, writer);
if (verbose)
print_timestamped_message ("finished creating appliance");