do not set default prefix in grub-mkimage

Default prefix is likely wrong on Unix and completely wrong on Windows.
Let caller set it explicitly to avoid any ambiguity.
This commit is contained in:
Andrey Borzenkov 2014-01-25 19:54:51 +04:00
parent 61c8482b20
commit 1440b7ebae
2 changed files with 15 additions and 5 deletions

View file

@ -1,3 +1,7 @@
2014-01-25 Andrey Borzenkov <arvidjaar@gmail.com>
* util/grub-mkimage.c: Make prefix argument mandatory.
2014-01-24 Vladimir Serbinenko <phcoder@gmail.com> 2014-01-24 Vladimir Serbinenko <phcoder@gmail.com>
Fix several translatable strings. Fix several translatable strings.

View file

@ -64,7 +64,7 @@ static struct argp_option options[] = {
{"directory", 'd', N_("DIR"), 0, {"directory", 'd', N_("DIR"), 0,
/* TRANSLATORS: platform here isn't identifier. It can be translated. */ /* TRANSLATORS: platform here isn't identifier. It can be translated. */
N_("use images and modules under DIR [default=%s/<platform>]"), 0}, N_("use images and modules under DIR [default=%s/<platform>]"), 0},
{"prefix", 'p', N_("DIR"), 0, N_("set prefix directory [default=%s]"), 0}, {"prefix", 'p', N_("DIR"), 0, N_("set prefix directory"), 0},
{"memdisk", 'm', N_("FILE"), 0, {"memdisk", 'm', N_("FILE"), 0,
/* TRANSLATORS: "memdisk" here isn't an identifier, it can be translated. /* TRANSLATORS: "memdisk" here isn't an identifier, it can be translated.
"embed" is a verb (command description). "*/ "embed" is a verb (command description). "*/
@ -93,8 +93,6 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused)))
{ {
case 'd': case 'd':
return xasprintf (text, grub_util_get_pkglibdir ()); return xasprintf (text, grub_util_get_pkglibdir ());
case 'p':
return xasprintf (text, DEFAULT_DIRECTORY);
case 'O': case 'O':
{ {
char *formats = grub_install_get_image_targets_string (), *ret; char *formats = grub_install_get_image_targets_string (), *ret;
@ -268,6 +266,15 @@ main (int argc, char *argv[])
exit(1); exit(1);
} }
if (!arguments.prefix)
{
char *program = xstrdup(program_name);
printf ("%s\n", _("Prefix not specified (use the -p option)."));
argp_help (&argp, stderr, ARGP_HELP_STD_USAGE, program);
free (program);
exit(1);
}
if (arguments.output) if (arguments.output)
{ {
fp = grub_util_fopen (arguments.output, "wb"); fp = grub_util_fopen (arguments.output, "wb");
@ -287,8 +294,7 @@ main (int argc, char *argv[])
strcpy (ptr, dn); strcpy (ptr, dn);
} }
grub_install_generate_image (arguments.dir, grub_install_generate_image (arguments.dir, arguments.prefix, fp,
arguments.prefix ? : DEFAULT_DIRECTORY, fp,
arguments.output, arguments.modules, arguments.output, arguments.modules,
arguments.memdisk, arguments.pubkeys, arguments.memdisk, arguments.pubkeys,
arguments.npubkeys, arguments.config, arguments.npubkeys, arguments.config,