diff --git a/ChangeLog b/ChangeLog index b27c22d20..435420d82 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-12-07 Vladimir Serbinenko + + Transform -C option to grub-mkstandalone to --core-compress available + in all grub-install flavours. + 2013-12-07 Vladimir Serbinenko Merge GRUBFS and GRUB_FS variables. diff --git a/include/grub/util/install.h b/include/grub/util/install.h index 4ba00f55b..beca2d25d 100644 --- a/include/grub/util/install.h +++ b/include/grub/util/install.h @@ -41,6 +41,9 @@ { "compress", GRUB_INSTALL_OPTIONS_INSTALL_COMPRESS, \ "no,xz,gz,lzo", OPTION_ARG_OPTIONAL, \ N_("compress GRUB files [optional]"), 1 }, \ + {"core-compress", GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS, \ + N_("xz|none|auto"), \ + 0, N_("choose the compression to use for core image"), 2}, \ /* TRANSLATORS: platform here isn't identifier. It can be translated. */ \ { "directory", 'd', N_("DIR"), 0, \ N_("use images and modules under DIR [default=%s/]"), 1 }, \ @@ -111,7 +114,8 @@ enum grub_install_options { GRUB_INSTALL_OPTIONS_DIRECTORY2, GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY, GRUB_INSTALL_OPTIONS_THEMES_DIRECTORY, - GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE + GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE, + GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS }; extern char *grub_install_source_directory; @@ -146,15 +150,13 @@ void grub_install_make_image_wrap (const char *dir, const char *prefix, const char *outname, char *memdisk_path, char *config_path, - const char *format, int note, - grub_compression_t comp); + const char *format, int note); void grub_install_make_image_wrap_file (const char *dir, const char *prefix, FILE *fp, const char *outname, char *memdisk_path, char *config_path, - const char *mkimage_target, int note, - grub_compression_t comp); + const char *mkimage_target, int note); int grub_install_copy_file (const char *src, diff --git a/util/grub-install-common.c b/util/grub-install-common.c index 9d9bae709..ea500cc5a 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c @@ -297,12 +297,30 @@ handle_install_list (struct install_list *il, const char *val, static char **pubkeys; static size_t npubkeys; +static grub_compression_t compression; int grub_install_parse (int key, char *arg) { switch (key) { + case 'C': + if (grub_strcmp (arg, "xz") == 0) + { +#ifdef HAVE_LIBLZMA + compression = GRUB_COMPRESSION_XZ; +#else + grub_util_error ("%s", + _("grub-mkimage is compiled without XZ support")); +#endif + } + else if (grub_strcmp (arg, "none") == 0) + compression = GRUB_COMPRESSION_NONE; + else if (grub_strcmp (arg, "auto") == 0) + compression = GRUB_COMPRESSION_AUTO; + else + grub_util_error (_("Unknown compression format %s"), arg); + return 1; case 'k': pubkeys = xrealloc (pubkeys, sizeof (pubkeys[0]) @@ -401,8 +419,7 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, FILE *fp, const char *outname, char *memdisk_path, char *config_path, - const char *mkimage_target, int note, - grub_compression_t comp) + const char *mkimage_target, int note) { const struct grub_install_image_target_desc *tgt; const char *const compnames[] = @@ -468,7 +485,7 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, "--format '%s' --compression '%s' %s %s\n", dir, prefix, outname, mkimage_target, - compnames[comp], note ? "--note" : "", s); + compnames[compression], note ? "--note" : "", s); tgt = grub_install_get_image_target (mkimage_target); if (!tgt) @@ -477,7 +494,7 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, grub_install_generate_image (dir, prefix, fp, outname, modules.entries, memdisk_path, pubkeys, npubkeys, config_path, tgt, - note, comp); + note, compression); while (dc--) grub_install_pop_module (); } @@ -486,8 +503,7 @@ void grub_install_make_image_wrap (const char *dir, const char *prefix, const char *outname, char *memdisk_path, char *config_path, - const char *mkimage_target, int note, - grub_compression_t comp) + const char *mkimage_target, int note) { FILE *fp; @@ -497,7 +513,7 @@ grub_install_make_image_wrap (const char *dir, const char *prefix, strerror (errno)); grub_install_make_image_wrap_file (dir, prefix, fp, outname, memdisk_path, config_path, - mkimage_target, note, comp); + mkimage_target, note); grub_util_file_sync (fp); fclose (fp); } diff --git a/util/grub-install.c b/util/grub-install.c index 7596ad91e..0aa7f48b4 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -1368,8 +1368,7 @@ main (int argc, char *argv[]) /* output */ imgfile, /* memdisk */ NULL, have_load_cfg ? load_cfg : NULL, - /* image target */ mkimage_target, - 0, GRUB_COMPRESSION_AUTO); + /* image target */ mkimage_target, 0); /* Backward-compatibility kludges. */ switch (platform) { @@ -1399,8 +1398,7 @@ main (int argc, char *argv[]) /* output */ dst, /* memdisk */ NULL, have_load_cfg ? load_cfg : NULL, - /* image target */ mkimage_target, - 0, GRUB_COMPRESSION_AUTO); + /* image target */ mkimage_target, 0); } break; case GRUB_INSTALL_PLATFORM_ARM_EFI: diff --git a/util/grub-mknetdir.c b/util/grub-mknetdir.c index 40ca7248b..26f4c0eb4 100644 --- a/util/grub-mknetdir.c +++ b/util/grub-mknetdir.c @@ -149,8 +149,7 @@ process_input_dir (const char *input_dir, enum grub_install_plat platform) output = grub_util_path_concat_ext (2, grubdir, "core", targets[platform].ext); grub_install_make_image_wrap (input_dir, prefix, output, 0, load_cfg, - targets[platform].mkimage_target, 0, - GRUB_COMPRESSION_AUTO); + targets[platform].mkimage_target, 0); grub_install_pop_module (); /* TRANSLATORS: First %s is replaced by platform name. Second one by filename. */ diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index d212cb645..3e19cb720 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -241,8 +241,7 @@ write_part (FILE *f, const char *srcdir) static void make_image_abs (enum grub_install_plat plat, const char *mkimage_target, - const char *output, - grub_compression_t compress) + const char *output) { char *load_cfg; FILE *load_cfg_f; @@ -266,8 +265,7 @@ make_image_abs (enum grub_install_plat plat, grub_install_push_module ("iso9660"); grub_install_make_image_wrap (source_dirs[plat], "/boot/grub", output, 0, load_cfg, - mkimage_target, 0, - compress); + mkimage_target, 0); grub_install_pop_module (); grub_install_pop_module (); grub_util_unlink (load_cfg); @@ -276,12 +274,10 @@ make_image_abs (enum grub_install_plat plat, static void make_image (enum grub_install_plat plat, const char *mkimage_target, - const char *output_sub, - grub_compression_t compress) + const char *output_sub) { char *out = grub_util_path_concat (2, boot_grub, output_sub); - make_image_abs (plat, mkimage_target, - out, GRUB_COMPRESSION_AUTO); + make_image_abs (plat, mkimage_target, out); free (out); } @@ -307,8 +303,7 @@ make_image_fwdisk_abs (enum grub_install_plat plat, grub_install_push_module ("iso9660"); grub_install_make_image_wrap (source_dirs[plat], "()/boot/grub", output, - 0, load_cfg, mkimage_target, 0, - GRUB_COMPRESSION_AUTO); + 0, load_cfg, mkimage_target, 0); grub_install_pop_module (); } @@ -483,8 +478,7 @@ main (int argc, char *argv[]) grub_install_make_image_wrap (source_dirs[GRUB_INSTALL_PLATFORM_I386_PC], "/boot/grub", output, 0, load_cfg, - "i386-pc-eltorito", 0, - GRUB_COMPRESSION_AUTO); + "i386-pc-eltorito", 0); xorriso_push ("-b"); xorriso_push ("boot/grub/i386-pc/eltorito.img"); @@ -528,8 +522,7 @@ main (int argc, char *argv[]) grub_install_make_image_wrap (source_dirs[GRUB_INSTALL_PLATFORM_I386_PC], "/boot/grub", output, 0, load_cfg, - "i386-pc", 0, - GRUB_COMPRESSION_AUTO); + "i386-pc", 0); sz = ftello (sa); fflush (sa); grub_util_fd_sync (fileno (sa)); @@ -554,7 +547,7 @@ main (int argc, char *argv[]) grub_install_push_module ("pata"); grub_install_push_module ("ahci"); grub_install_push_module ("at_keyboard"); - make_image (GRUB_INSTALL_PLATFORM_I386_MULTIBOOT, "i386-multiboot", "i386-multiboot/core.elf", GRUB_COMPRESSION_AUTO); + make_image (GRUB_INSTALL_PLATFORM_I386_MULTIBOOT, "i386-multiboot", "i386-multiboot/core.elf"); grub_install_pop_module (); grub_install_pop_module (); grub_install_pop_module (); @@ -775,22 +768,22 @@ main (int argc, char *argv[]) make_image_fwdisk (GRUB_INSTALL_PLATFORM_MIPSEL_ARC, "mipsel-arc", "arc.exe"); grub_install_push_module ("pata"); - make_image (GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS, "mipsel-qemu_mips-elf", "roms/mipsel-qemu_mips.elf", GRUB_COMPRESSION_AUTO); + make_image (GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS, "mipsel-qemu_mips-elf", "roms/mipsel-qemu_mips.elf"); - make_image (GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON, "mipsel-loongson-elf", "loongson.elf", GRUB_COMPRESSION_XZ); + make_image (GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON, "mipsel-loongson-elf", "loongson.elf"); - make_image (GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON, "mipsel-yeeloong-flash", "mipsel-yeeloong.bin", GRUB_COMPRESSION_XZ); - make_image (GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON, "mipsel-fuloong2f-flash", "mipsel-fuloong2f.bin", GRUB_COMPRESSION_XZ); + make_image (GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON, "mipsel-yeeloong-flash", "mipsel-yeeloong.bin"); + make_image (GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON, "mipsel-fuloong2f-flash", "mipsel-fuloong2f.bin"); - make_image (GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS, "mips-qemu_mips-elf", "roms/mips-qemu_mips.elf", GRUB_COMPRESSION_AUTO); + make_image (GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS, "mips-qemu_mips-elf", "roms/mips-qemu_mips.elf"); grub_install_push_module ("at_keyboard"); - make_image (GRUB_INSTALL_PLATFORM_I386_QEMU, "i386-qemu", "roms/qemu.img", GRUB_COMPRESSION_AUTO); + make_image (GRUB_INSTALL_PLATFORM_I386_QEMU, "i386-qemu", "roms/qemu.img"); grub_install_push_module ("ahci"); - make_image (GRUB_INSTALL_PLATFORM_I386_COREBOOT, "i386-coreboot", "roms/coreboot.elf", GRUB_COMPRESSION_AUTO); + make_image (GRUB_INSTALL_PLATFORM_I386_COREBOOT, "i386-coreboot", "roms/coreboot.elf"); grub_install_pop_module (); grub_install_pop_module (); grub_install_pop_module (); diff --git a/util/grub-mkstandalone.c b/util/grub-mkstandalone.c index 3097f704d..6ee5e588a 100644 --- a/util/grub-mkstandalone.c +++ b/util/grub-mkstandalone.c @@ -25,7 +25,6 @@ #include #include -static grub_compression_t compression; static char *output_image; static char **files; static int nfiles; @@ -35,8 +34,7 @@ static FILE *memdisk; enum { OPTION_OUTPUT = 'o', - OPTION_FORMAT = 'C', - OPTION_COMPRESION = 'C' + OPTION_FORMAT = 'O' }; static struct argp_option options[] = { @@ -44,8 +42,7 @@ static struct argp_option options[] = { {"output", 'o', N_("FILE"), 0, N_("save output in FILE [required]"), 2}, {"format", 'O', N_("FILE"), 0, 0, 2}, - {"compression", 'C', N_("xz|none|auto"), - 0, N_("choose the compression to use for core image"), 2}, + {"compression", 'C', N_("xz|none|auto"), OPTION_HIDDEN, 0, 2}, {0, 0, 0, 0, 0, 0} }; @@ -70,6 +67,9 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused))) static error_t argp_parser (int key, char *arg, struct argp_state *state) { + if (key == 'C') + key = GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS; + if (grub_install_parse (key, arg)) return 0; @@ -95,23 +95,6 @@ argp_parser (int key, char *arg, struct argp_state *state) break; } - case 'C': - if (grub_strcmp (arg, "xz") == 0) - { -#ifdef HAVE_LIBLZMA - compression = GRUB_COMPRESSION_XZ; -#else - grub_util_error ("%s", - _("grub-mkimage is compiled without XZ support")); -#endif - } - else if (grub_strcmp (arg, "none") == 0) - compression = GRUB_COMPRESSION_NONE; - else if (grub_strcmp (arg, "auto") == 0) - compression = GRUB_COMPRESSION_AUTO; - else - grub_util_error (_("Unknown compression format %s"), arg); - break; case ARGP_KEY_ARG: files[nfiles++] = xstrdup (arg); break; @@ -365,8 +348,7 @@ main (int argc, char *argv[]) grub_install_make_image_wrap (grub_install_source_directory, "(memdisk)/boot/grub", output_image, memdisk_img, NULL, - grub_util_get_target_name (format), 0, - compression); + grub_util_get_target_name (format), 0); grub_util_unlink (memdisk_img); return 0;