X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=helper%2Fmain.c;h=f194008f324ed582e5d97682d6d777f6c66cfd7a;hb=f6e12eccb65bef3eb57631e54199d8b1610e7c5c;hp=b4359b695240efd5fe6e97d3d4fd2940b180d4f8;hpb=89e336ee166be538e376d288fb2b3fbbffd66d4c;p=febootstrap.git diff --git a/helper/main.c b/helper/main.c index b4359b6..f194008 100644 --- a/helper/main.c +++ b/helper/main.c @@ -51,13 +51,15 @@ static const struct option long_options[] = { }; static void -usage (const char *progname) +usage (FILE *f, const char *progname) { - printf ("%s: build the supermin appliance on the fly\n" + fprintf (f, + "%s: build the supermin appliance on the fly\n" "\n" "Usage:\n" " %s [-options] inputs [...] host_cpu kernel initrd\n" " %s -f ext2 inputs [...] host_cpu kernel initrd appliance\n" + " %s -f checksum inputs [...] host_cpu\n" " %s --help\n" " %s --version\n" "\n" @@ -72,7 +74,7 @@ usage (const char *progname) "Options:\n" " --help\n" " Display this help text and exit.\n" - " -f cpio|ext2 | --format cpio|ext2\n" + " -f cpio|ext2|checksum | --format cpio|ext2|checksum\n" " Specify output format (default: cpio).\n" " -k file | --kmods file\n" " Specify kernel module whitelist.\n" @@ -80,7 +82,7 @@ usage (const char *progname) " Enable verbose messages (give multiple times for more verbosity).\n" " --version | -V\n" " Display version number and exit.\n", - progname, progname, progname, progname, progname); + progname, progname, progname, progname, progname, progname); } int @@ -98,7 +100,7 @@ main (int argc, char *argv[]) switch (c) { case HELP_OPTION: - usage (argv[0]); + usage (stdout, argv[0]); exit (EXIT_SUCCESS); case 'f': @@ -118,7 +120,7 @@ main (int argc, char *argv[]) exit (EXIT_SUCCESS); default: - usage (argv[0]); + usage (stderr, argv[0]); exit (EXIT_FAILURE); } } @@ -135,8 +137,13 @@ main (int argc, char *argv[]) writer = &ext2_writer; nr_outputs = 3; /* kernel, initrd, appliance */ } + else if (strcmp (format, "checksum") == 0) { + writer = &checksum_writer; + nr_outputs = 0; /* (none) */ + } else { - fprintf (stderr, "%s: incorrect output format (-f): must be cpio|ext2\n", + fprintf (stderr, + "%s: incorrect output format (-f): must be cpio|ext2|checksum\n", argv[0]); exit (EXIT_FAILURE); } @@ -160,10 +167,11 @@ main (int argc, char *argv[]) const char *hostcpu = outputs[-1]; /* Output files. */ - const char *kernel = outputs[0]; - const char *initrd; - const char *appliance; - initrd = appliance = outputs[1]; + const char *kernel = NULL, *initrd = NULL, *appliance = NULL; + if (nr_outputs > 0) + kernel = outputs[0]; + if (nr_outputs > 1) + initrd = appliance = outputs[1]; if (nr_outputs > 2) appliance = outputs[2]; @@ -181,20 +189,21 @@ main (int argc, char *argv[]) } /* Remove the output files if they exist. */ - unlink (kernel); - unlink (initrd); - if (initrd != appliance) + if (kernel) + unlink (kernel); + if (initrd) + unlink (initrd); + if (appliance && initrd != appliance) unlink (appliance); /* Create kernel output file. */ - const char *modpath; - modpath = create_kernel (hostcpu, kernel); + const char *modpath = create_kernel (hostcpu, kernel); if (verbose) print_timestamped_message ("finished creating kernel"); /* Create the appliance. */ - create_appliance (inputs, nr_inputs, whitelist, modpath, + create_appliance (hostcpu, inputs, nr_inputs, whitelist, modpath, initrd, appliance, writer); if (verbose)