grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] add --boot-directory option to grub-mkstandalone


From: Andrey Borzenkov
Subject: [PATCH] add --boot-directory option to grub-mkstandalone
Date: Fri, 13 Dec 2013 19:40:54 +0400

> 2) make it possible for grub-mkstandalone to build images with the
>    prefix set to something other than (memdisk)/boot/grub

Like below? I'm not keen on using --boot-directory; may be using full
--grub-directory (without implied ../grub) will actually be more logical.

---

This allows changing of hardcoded /boot/grub path on memory disk so it does
not conflict with on-disk /boot directories.

Suggested by Colin Watson

---
 util/grub-mkstandalone.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/util/grub-mkstandalone.c b/util/grub-mkstandalone.c
index 6ee5e58..3cb5d7c 100644
--- a/util/grub-mkstandalone.c
+++ b/util/grub-mkstandalone.c
@@ -30,15 +30,20 @@ static char **files;
 static int nfiles;
 const struct grub_install_image_target_desc *format;
 static FILE *memdisk;
+static char *bootdir;
 
 enum
   {
     OPTION_OUTPUT = 'o',
-    OPTION_FORMAT = 'O'
+    OPTION_FORMAT = 'O',
+    OPTION_BOOT_DIRECTORY = 0x301,
+
   };
 
 static struct argp_option options[] = {
   GRUB_INSTALL_OPTIONS,
+  {"boot-directory", OPTION_BOOT_DIRECTORY, N_("DIR"),
+   0, N_("install GRUB images under the directory DIR/grub instead of the 
/boot/grub directory"), 2},
   {"output", 'o', N_("FILE"),
    0, N_("save output in FILE [required]"), 2},
   {"format", 'O', N_("FILE"), 0, 0, 2},
@@ -76,6 +81,11 @@ argp_parser (int key, char *arg, struct argp_state *state)
   switch (key)
     {
 
+    case OPTION_BOOT_DIRECTORY:
+      free (bootdir);
+      bootdir = xstrdup (arg);
+      return 0;
+
     case 'o':
       if (output_image)
        free (output_image);
@@ -294,6 +304,9 @@ main (int argc, char *argv[])
 
   argp_parse (&argp, argc, argv, 0, 0, 0);
 
+  if (!bootdir)
+    bootdir = xstrdup ("/boot");
+
   pkglibdir = grub_util_get_pkglibdir ();
 
   if (!output_image)
@@ -308,7 +321,7 @@ main (int argc, char *argv[])
   enum grub_install_plat plat = grub_install_get_target 
(grub_install_source_directory);
 
   char *memdisk_dir = grub_util_make_temporary_dir ();
-  char *boot_grub = grub_util_path_concat (3, memdisk_dir, "boot", "grub");
+  char *boot_grub = grub_util_path_concat (3, memdisk_dir, bootdir, "grub");
   grub_install_copy_files (grub_install_source_directory,
                           boot_grub, plat);
 
@@ -346,8 +359,8 @@ main (int argc, char *argv[])
   grub_install_push_module ("tar");
 
   grub_install_make_image_wrap (grub_install_source_directory,
-                               "(memdisk)/boot/grub", output_image,
-                               memdisk_img, NULL,
+                               xasprintf ("(memdisk)%s/%s", bootdir, "grub"),
+                               output_image, memdisk_img, NULL,
                                grub_util_get_target_name (format), 0);
 
   grub_util_unlink (memdisk_img);
-- 
tg: (0df77d7..) u/grub-directory (depends on: master)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]