]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Transform -C option to grub-mkstandalone to --core-compress available
authorVladimir Serbinenko <phcoder@gmail.com>
Sat, 7 Dec 2013 15:18:22 +0000 (16:18 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Sat, 7 Dec 2013 15:18:22 +0000 (16:18 +0100)
in all grub-install flavours.

ChangeLog
include/grub/util/install.h
util/grub-install-common.c
util/grub-install.c
util/grub-mknetdir.c
util/grub-mkrescue.c
util/grub-mkstandalone.c

index b27c22d2079c160dfdb05948ad356a6a0a57c062..435420d8221e48215134d6b84e415d7c57f07ac5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-12-07  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Transform -C option to grub-mkstandalone to --core-compress available
+       in all grub-install flavours.
+
 2013-12-07  Vladimir Serbinenko  <phcoder@gmail.com>
 
        Merge GRUBFS and GRUB_FS variables.
index 4ba00f55b5f2b2518d1386192664d234e574c2cb..beca2d25d1c4c7a0f77df63b6f5e42f95a8ddfdb 100644 (file)
@@ -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/<platform>]"), 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,
index 9d9bae709257bb366a37325b1c0a7f485470be70..ea500cc5ada70621d1748940ab41a3a2eaaa20f6 100644 (file)
@@ -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);
 }
index 7596ad91e1246cf24a1b553ffee990e2a315a89c..0aa7f48b44f61d2c97cc7ff1b9fcebc5d11ffbc8 100644 (file)
@@ -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:
index 40ca7248b0d16570b0fcb3eb354d4332e445d6ab..26f4c0eb49643f6e1528731e04c0b45fa69e1140 100644 (file)
@@ -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.  */
index d212cb645088eef52e0ddfab377e23d09da73bd6..3e19cb7203006addb6183b4216ebdd4b1cacbadf 100644 (file)
@@ -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 ();
index 3097f704d8e4d28fb30d1d113d16c2c560549423..6ee5e588a966879b34f65f6e65f771b4f7c566f2 100644 (file)
@@ -25,7 +25,6 @@
 #include <argp.h>
 #include <string.h>
 
-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;