Convert grub-emu to argp.
* grub-core/Makefile.core.def (kernel): Add kern/emu/argp_common.c on emu. * util/argp_common.c: Rename to ... * grub-core/kern/emu/argp_common.c: ... this. All users updated. Add missing includes. * grub-core/kern/emu/main.c: Convert to argp. * po/POTFILES.in: Regenerate. * util/grub-install.in (usage): Make first letter lowcase in messages for uniformity. * util/grub-setup.c (options): Likewise.
This commit is contained in:
parent
1e3f8ae86f
commit
6a656b0ea5
8 changed files with 120 additions and 83 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
||||||
|
2012-02-25 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Convert grub-emu to argp.
|
||||||
|
|
||||||
|
* grub-core/Makefile.core.def (kernel): Add kern/emu/argp_common.c on
|
||||||
|
emu.
|
||||||
|
* util/argp_common.c: Rename to ...
|
||||||
|
* grub-core/kern/emu/argp_common.c: ... this. All users updated.
|
||||||
|
Add missing includes.
|
||||||
|
* grub-core/kern/emu/main.c: Convert to argp.
|
||||||
|
* po/POTFILES.in: Regenerate.
|
||||||
|
* util/grub-install.in (usage): Make first letter lowcase in messages
|
||||||
|
for uniformity.
|
||||||
|
* util/grub-setup.c (options): Likewise.
|
||||||
|
|
||||||
2012-02-24 Vladimir Serbinenko <phcoder@gmail.com>
|
2012-02-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/gfxmenu/gui_progress_bar.c (progress_bar_set_property):
|
* grub-core/gfxmenu/gui_progress_bar.c (progress_bar_set_property):
|
||||||
|
|
|
@ -142,7 +142,7 @@ program = {
|
||||||
|
|
||||||
common = util/grub-mkimage.c;
|
common = util/grub-mkimage.c;
|
||||||
common = util/resolve.c;
|
common = util/resolve.c;
|
||||||
common = util/argp_common.c;
|
common = grub-core/kern/emu/argp_common.c;
|
||||||
|
|
||||||
extra_dist = util/grub-mkimagexx.c;
|
extra_dist = util/grub-mkimagexx.c;
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ program = {
|
||||||
mansection = 1;
|
mansection = 1;
|
||||||
|
|
||||||
common = util/grub-mkrelpath.c;
|
common = util/grub-mkrelpath.c;
|
||||||
common = util/argp_common.c;
|
common = grub-core/kern/emu/argp_common.c;
|
||||||
|
|
||||||
ldadd = libgrubmods.a;
|
ldadd = libgrubmods.a;
|
||||||
ldadd = libgrubgcry.a;
|
ldadd = libgrubgcry.a;
|
||||||
|
@ -174,7 +174,7 @@ program = {
|
||||||
mansection = 1;
|
mansection = 1;
|
||||||
|
|
||||||
common = util/grub-script-check.c;
|
common = util/grub-script-check.c;
|
||||||
common = util/argp_common.c;
|
common = grub-core/kern/emu/argp_common.c;
|
||||||
|
|
||||||
ldadd = libgrubmods.a;
|
ldadd = libgrubmods.a;
|
||||||
ldadd = libgrubgcry.a;
|
ldadd = libgrubgcry.a;
|
||||||
|
@ -201,7 +201,7 @@ program = {
|
||||||
mansection = 1;
|
mansection = 1;
|
||||||
|
|
||||||
common = util/grub-mkpasswd-pbkdf2.c;
|
common = util/grub-mkpasswd-pbkdf2.c;
|
||||||
common = util/argp_common.c;
|
common = grub-core/kern/emu/argp_common.c;
|
||||||
|
|
||||||
ldadd = libgrubmods.a;
|
ldadd = libgrubmods.a;
|
||||||
ldadd = libgrubgcry.a;
|
ldadd = libgrubgcry.a;
|
||||||
|
@ -271,7 +271,7 @@ program = {
|
||||||
mansection = 1;
|
mansection = 1;
|
||||||
common = util/grub-mkfont.c;
|
common = util/grub-mkfont.c;
|
||||||
common = grub-core/unidata.c;
|
common = grub-core/unidata.c;
|
||||||
common = util/argp_common.c;
|
common = grub-core/kern/emu/argp_common.c;
|
||||||
|
|
||||||
cflags = '$(freetype_cflags)';
|
cflags = '$(freetype_cflags)';
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ program = {
|
||||||
mansection = 8;
|
mansection = 8;
|
||||||
common = util/grub-probe.c;
|
common = util/grub-probe.c;
|
||||||
common = util/ieee1275/ofpath.c;
|
common = util/ieee1275/ofpath.c;
|
||||||
common = util/argp_common.c;
|
common = grub-core/kern/emu/argp_common.c;
|
||||||
|
|
||||||
ldadd = libgrubmods.a;
|
ldadd = libgrubmods.a;
|
||||||
ldadd = libgrubgcry.a;
|
ldadd = libgrubgcry.a;
|
||||||
|
@ -305,7 +305,7 @@ program = {
|
||||||
mansection = 8;
|
mansection = 8;
|
||||||
common = util/grub-setup.c;
|
common = util/grub-setup.c;
|
||||||
common = util/lvm.c;
|
common = util/lvm.c;
|
||||||
common = util/argp_common.c;
|
common = grub-core/kern/emu/argp_common.c;
|
||||||
common = grub-core/lib/reed_solomon.c;
|
common = grub-core/lib/reed_solomon.c;
|
||||||
|
|
||||||
sparc64_ieee1275 = util/ieee1275/ofpath.c;
|
sparc64_ieee1275 = util/ieee1275/ofpath.c;
|
||||||
|
@ -341,7 +341,7 @@ program = {
|
||||||
mansection = 1;
|
mansection = 1;
|
||||||
|
|
||||||
common = util/grub-mklayout.c;
|
common = util/grub-mklayout.c;
|
||||||
common = util/argp_common.c;
|
common = grub-core/kern/emu/argp_common.c;
|
||||||
|
|
||||||
ldadd = libgrubmods.a;
|
ldadd = libgrubmods.a;
|
||||||
ldadd = libgrubgcry.a;
|
ldadd = libgrubgcry.a;
|
||||||
|
|
|
@ -210,6 +210,7 @@ kernel = {
|
||||||
emu = kern/emu/hostdisk.c;
|
emu = kern/emu/hostdisk.c;
|
||||||
emu = kern/emu/hostfs.c;
|
emu = kern/emu/hostfs.c;
|
||||||
emu = kern/emu/main.c;
|
emu = kern/emu/main.c;
|
||||||
|
emu = kern/emu/argp_common.c;
|
||||||
emu = kern/emu/misc.c;
|
emu = kern/emu/misc.c;
|
||||||
emu = kern/emu/mm.c;
|
emu = kern/emu/mm.c;
|
||||||
emu = kern/emu/time.c;
|
emu = kern/emu/time.c;
|
||||||
|
|
|
@ -20,7 +20,9 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#define _GNU_SOURCE 1
|
#define _GNU_SOURCE 1
|
||||||
#include "progname.h"
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <progname.h>
|
||||||
#include <argp.h>
|
#include <argp.h>
|
||||||
|
|
||||||
/* Print the version information. */
|
/* Print the version information. */
|
|
@ -42,6 +42,7 @@
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
|
|
||||||
#include "progname.h"
|
#include "progname.h"
|
||||||
|
#include <argp.h>
|
||||||
|
|
||||||
#define ENABLE_RELOCATABLE 0
|
#define ENABLE_RELOCATABLE 0
|
||||||
|
|
||||||
|
@ -81,41 +82,84 @@ grub_machine_fini (void)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static struct option options[] =
|
static struct argp_option options[] = {
|
||||||
{
|
{"root", 'r', N_("DEVICE_NAME"), 0, N_("Set root device."), 2},
|
||||||
{"root-device", required_argument, 0, 'r'},
|
{"device-map", 'm', N_("FILE"), 0,
|
||||||
{"device-map", required_argument, 0, 'm'},
|
N_("use FILE as the device map [default=%s]"), 0},
|
||||||
{"directory", required_argument, 0, 'd'},
|
{"directory", 'd', N_("DIR"), 0,
|
||||||
{"hold", optional_argument, 0, 'H'},
|
N_("use GRUB files in the directory DIR [default=%s]"), 0},
|
||||||
{"help", no_argument, 0, 'h'},
|
{"verbose", 'v', 0, 0, N_("print verbose messages."), 0},
|
||||||
{"version", no_argument, 0, 'V'},
|
{"hold", 'H', N_("SECS"), OPTION_ARG_OPTIONAL, N_("wait until a debugger will attach"), 0},
|
||||||
{"verbose", no_argument, 0, 'v'},
|
{ 0, 0, 0, 0, 0, 0 }
|
||||||
{ 0, 0, 0, 0 }
|
};
|
||||||
};
|
|
||||||
|
|
||||||
static int
|
static char *
|
||||||
usage (int status)
|
help_filter (int key, const char *text, void *input __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
if (status)
|
switch (key)
|
||||||
fprintf (stderr,
|
{
|
||||||
_("Try `%s --help' for more information.\n"), program_name);
|
case 'd':
|
||||||
else
|
return xasprintf (text, DEFAULT_DIRECTORY);
|
||||||
printf (
|
case 'm':
|
||||||
_("Usage: %s [OPTION]...\n"
|
return xasprintf (text, DEFAULT_DEVICE_MAP);
|
||||||
"\n"
|
default:
|
||||||
"GRUB emulator.\n"
|
return (char *) text;
|
||||||
"\n"
|
}
|
||||||
" -r, --root-device=DEV use DEV as the root device [default=host]\n"
|
|
||||||
" -m, --device-map=FILE use FILE as the device map [default=%s]\n"
|
|
||||||
" -d, --directory=DIR use GRUB files in the directory DIR [default=%s]\n"
|
|
||||||
" -v, --verbose print verbose messages\n"
|
|
||||||
" -H, --hold[=SECONDS] wait until a debugger will attach\n"
|
|
||||||
" -h, --help display this message and exit\n"
|
|
||||||
" -V, --version print version information and exit\n"
|
|
||||||
"\n"
|
|
||||||
"Report bugs to <%s>.\n"), program_name, DEFAULT_DEVICE_MAP, DEFAULT_DIRECTORY, PACKAGE_BUGREPORT);
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct arguments
|
||||||
|
{
|
||||||
|
const char *dev_map;
|
||||||
|
int hold;
|
||||||
|
};
|
||||||
|
|
||||||
|
static error_t
|
||||||
|
argp_parser (int key, char *arg, struct argp_state *state)
|
||||||
|
{
|
||||||
|
/* Get the input argument from argp_parse, which we
|
||||||
|
know is a pointer to our arguments structure. */
|
||||||
|
struct arguments *arguments = state->input;
|
||||||
|
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case 'r':
|
||||||
|
free (root_dev);
|
||||||
|
root_dev = xstrdup (arg);
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
free (dir);
|
||||||
|
dir = xstrdup (arg);
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
arguments->dev_map = arg;
|
||||||
|
break;
|
||||||
|
case 'H':
|
||||||
|
arguments->hold = (arg ? atoi (arg) : -1);
|
||||||
|
break;
|
||||||
|
case 'v':
|
||||||
|
verbosity++;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ARGP_KEY_ARG:
|
||||||
|
{
|
||||||
|
/* Too many arguments. */
|
||||||
|
fprintf (stderr, _("Unknown extra argument `%s'.\n"), arg);
|
||||||
|
argp_usage (state);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return ARGP_ERR_UNKNOWN;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct argp argp = {
|
||||||
|
options, argp_parser, NULL,
|
||||||
|
N_("GRUB emulator."),
|
||||||
|
NULL, help_filter, NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void grub_hostfs_init (void);
|
void grub_hostfs_init (void);
|
||||||
|
@ -127,49 +171,24 @@ void grub_emu_init (void);
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
const char *dev_map = DEFAULT_DEVICE_MAP;
|
struct arguments arguments =
|
||||||
|
{
|
||||||
|
.dev_map = DEFAULT_DEVICE_MAP,
|
||||||
|
.hold = 0
|
||||||
|
};
|
||||||
volatile int hold = 0;
|
volatile int hold = 0;
|
||||||
int opt;
|
|
||||||
|
|
||||||
set_program_name (argv[0]);
|
set_program_name (argv[0]);
|
||||||
|
|
||||||
dir = xstrdup (DEFAULT_DIRECTORY);
|
dir = xstrdup (DEFAULT_DIRECTORY);
|
||||||
|
|
||||||
while ((opt = getopt_long (argc, argv, "r:d:m:vH:hV", options, 0)) != -1)
|
if (argp_parse (&argp, argc, argv, 0, 0, &arguments) != 0)
|
||||||
switch (opt)
|
|
||||||
{
|
|
||||||
case 'r':
|
|
||||||
free (root_dev);
|
|
||||||
root_dev = xstrdup (optarg);
|
|
||||||
break;
|
|
||||||
case 'd':
|
|
||||||
free (dir);
|
|
||||||
dir = xstrdup (optarg);
|
|
||||||
break;
|
|
||||||
case 'm':
|
|
||||||
dev_map = optarg;
|
|
||||||
break;
|
|
||||||
case 'v':
|
|
||||||
verbosity++;
|
|
||||||
break;
|
|
||||||
case 'H':
|
|
||||||
hold = (optarg ? atoi (optarg) : -1);
|
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
return usage (0);
|
|
||||||
case 'V':
|
|
||||||
printf ("%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
|
|
||||||
return 0;
|
|
||||||
default:
|
|
||||||
return usage (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (optind < argc)
|
|
||||||
{
|
{
|
||||||
fprintf (stderr, _("Unknown extra argument `%s'.\n"), argv[optind]);
|
fprintf (stderr, "%s", _("Error in parsing command line arguments\n"));
|
||||||
return usage (1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hold = arguments.hold;
|
||||||
/* Wait until the ARGS.HOLD variable is cleared by an attached debugger. */
|
/* Wait until the ARGS.HOLD variable is cleared by an attached debugger. */
|
||||||
if (hold && verbosity > 0)
|
if (hold && verbosity > 0)
|
||||||
printf (_("Run \"gdb %s %d\", and set ARGS.HOLD to zero.\n"),
|
printf (_("Run \"gdb %s %d\", and set ARGS.HOLD to zero.\n"),
|
||||||
|
@ -188,7 +207,7 @@ main (int argc, char *argv[])
|
||||||
grub_host_init ();
|
grub_host_init ();
|
||||||
|
|
||||||
/* XXX: This is a bit unportable. */
|
/* XXX: This is a bit unportable. */
|
||||||
grub_util_biosdisk_init (dev_map);
|
grub_util_biosdisk_init (arguments.dev_map);
|
||||||
|
|
||||||
grub_init_all ();
|
grub_init_all ();
|
||||||
|
|
||||||
|
|
|
@ -252,6 +252,7 @@
|
||||||
./grub-core/kern/efi/init.c
|
./grub-core/kern/efi/init.c
|
||||||
./grub-core/kern/efi/mm.c
|
./grub-core/kern/efi/mm.c
|
||||||
./grub-core/kern/elf.c
|
./grub-core/kern/elf.c
|
||||||
|
./grub-core/kern/emu/argp_common.c
|
||||||
./grub-core/kern/emu/cache.c
|
./grub-core/kern/emu/cache.c
|
||||||
./grub-core/kern/emu/full.c
|
./grub-core/kern/emu/full.c
|
||||||
./grub-core/kern/emu/hostdisk.c
|
./grub-core/kern/emu/hostdisk.c
|
||||||
|
@ -537,7 +538,6 @@
|
||||||
./tests/example_unit_test.c
|
./tests/example_unit_test.c
|
||||||
./tests/lib/unit_test.c
|
./tests/lib/unit_test.c
|
||||||
./tests/printf_unit_test.c
|
./tests/printf_unit_test.c
|
||||||
./util/argp_common.c
|
|
||||||
./util/bin2h.c
|
./util/bin2h.c
|
||||||
./util/devicemap.c
|
./util/devicemap.c
|
||||||
./util/getroot.c
|
./util/getroot.c
|
||||||
|
|
|
@ -103,7 +103,7 @@ usage () {
|
||||||
printf " --grub-mkimage=%-9s%s\n" "$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
|
printf " --grub-mkimage=%-9s%s\n" "$(gettext "FILE")" "$(gettext "use FILE as grub-mkimage")"
|
||||||
printf " --grub-mkrelpath=%-7s%s\n" "$(gettext "FILE")" "$(gettext "use FILE as grub-mkrelpath")"
|
printf " --grub-mkrelpath=%-7s%s\n" "$(gettext "FILE")" "$(gettext "use FILE as grub-mkrelpath")"
|
||||||
printf " --grub-probe=%-11s%s\n" "$(gettext "FILE")" "$(gettext "use FILE as grub-probe")"
|
printf " --grub-probe=%-11s%s\n" "$(gettext "FILE")" "$(gettext "use FILE as grub-probe")"
|
||||||
printf " --allow-floppy %s\n" "$(gettext "Make the drive also bootable as floppy (default for fdX devices). May break on some BIOSes.")"
|
printf " --allow-floppy %s\n" "$(gettext "make the drive also bootable as floppy (default for fdX devices). May break on some BIOSes.")"
|
||||||
printf " --recheck %s\n" "$(gettext "delete device map if it already exists")"
|
printf " --recheck %s\n" "$(gettext "delete device map if it already exists")"
|
||||||
printf " --force %s\n" "$(gettext "install even if problems are detected")"
|
printf " --force %s\n" "$(gettext "install even if problems are detected")"
|
||||||
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
|
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
|
||||||
|
|
|
@ -742,20 +742,20 @@ unable_to_embed:
|
||||||
|
|
||||||
static struct argp_option options[] = {
|
static struct argp_option options[] = {
|
||||||
{"boot-image", 'b', N_("FILE"), 0,
|
{"boot-image", 'b', N_("FILE"), 0,
|
||||||
N_("Use FILE as the boot image [default=%s]"), 0},
|
N_("use FILE as the boot image [default=%s]"), 0},
|
||||||
{"core-image", 'c', N_("FILE"), 0,
|
{"core-image", 'c', N_("FILE"), 0,
|
||||||
N_("Use FILE as the core image [default=%s]"), 0},
|
N_("use FILE as the core image [default=%s]"), 0},
|
||||||
{"directory", 'd', N_("DIR"), 0,
|
{"directory", 'd', N_("DIR"), 0,
|
||||||
N_("Use GRUB files in the directory DIR [default=%s]"), 0},
|
N_("use GRUB files in the directory DIR [default=%s]"), 0},
|
||||||
{"device-map", 'm', N_("FILE"), 0,
|
{"device-map", 'm', N_("FILE"), 0,
|
||||||
N_("use FILE as the device map [default=%s]"), 0},
|
N_("use FILE as the device map [default=%s]"), 0},
|
||||||
{"force", 'f', 0, 0,
|
{"force", 'f', 0, 0,
|
||||||
N_("install even if problems are detected"), 0},
|
N_("install even if problems are detected"), 0},
|
||||||
{"skip-fs-probe",'s',0, 0,
|
{"skip-fs-probe",'s',0, 0,
|
||||||
N_("Do not probe for filesystems in DEVICE"), 0},
|
N_("do not probe for filesystems in DEVICE"), 0},
|
||||||
{"verbose", 'v', 0, 0, N_("print verbose messages."), 0},
|
{"verbose", 'v', 0, 0, N_("print verbose messages."), 0},
|
||||||
{"allow-floppy", 'a', 0, 0,
|
{"allow-floppy", 'a', 0, 0,
|
||||||
N_("Make the drive also bootable as floppy (default for fdX devices). May break on some BIOSes."), 0},
|
N_("make the drive also bootable as floppy (default for fdX devices). May break on some BIOSes."), 0},
|
||||||
|
|
||||||
{ 0, 0, 0, 0, 0, 0 }
|
{ 0, 0, 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue