git.annexia.org
/
febootstrap.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Send usage output to stdout or stderr depending on context.
[febootstrap.git]
/
helper
/
main.c
diff --git
a/helper/main.c
b/helper/main.c
index
b4359b6
..
f194008
100644
(file)
--- a/
helper/main.c
+++ b/
helper/main.c
@@
-51,13
+51,15
@@
static const struct option long_options[] = {
};
static void
};
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"
"\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"
" %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"
"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"
" 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",
" 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
}
int
@@
-98,7
+100,7
@@
main (int argc, char *argv[])
switch (c) {
case HELP_OPTION:
switch (c) {
case HELP_OPTION:
- usage (argv[0]);
+ usage (
stdout,
argv[0]);
exit (EXIT_SUCCESS);
case 'f':
exit (EXIT_SUCCESS);
case 'f':
@@
-118,7
+120,7
@@
main (int argc, char *argv[])
exit (EXIT_SUCCESS);
default:
exit (EXIT_SUCCESS);
default:
- usage (argv[0]);
+ usage (
stderr,
argv[0]);
exit (EXIT_FAILURE);
}
}
exit (EXIT_FAILURE);
}
}
@@
-135,8
+137,13
@@
main (int argc, char *argv[])
writer = &ext2_writer;
nr_outputs = 3; /* kernel, initrd, appliance */
}
writer = &ext2_writer;
nr_outputs = 3; /* kernel, initrd, appliance */
}
+ else if (strcmp (format, "checksum") == 0) {
+ writer = &checksum_writer;
+ nr_outputs = 0; /* (none) */
+ }
else {
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);
}
argv[0]);
exit (EXIT_FAILURE);
}
@@
-160,10
+167,11
@@
main (int argc, char *argv[])
const char *hostcpu = outputs[-1];
/* Output files. */
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];
if (nr_outputs > 2)
appliance = outputs[2];
@@
-181,20
+189,21
@@
main (int argc, char *argv[])
}
/* Remove the output files if they exist. */
}
/* 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. */
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. */
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)
initrd, appliance, writer);
if (verbose)