Skip to contentSkip to conversation

Allow to install in non-default prefixes

PATCH In review phcoder 1 participant 4 messages Feb 1, 2009 – Feb 12, 2009

lore
Share & tools
lore

phcoder

author
#0 lore raw

PATCH 1/1 Allow to install in non-default prefixes

This patch adds -p option for grub-setup on i386-pc. Without it install to any prefix different from /boot/grub failed Thank
Vladimir 'phcoder' Serbinenko

i386/pc/grub-setup.c +17 -3
Index: util/i386/pc/grub-setup.c
===================================================================
@@ -94,6 +94,7 @@
 
 static void
 setup (const char *dir,
+       const char *prefix,
        const char *boot_file, const char *core_file,
        const char *root, const char *dest, int must_embed)
 {
@@ -373,7 +374,7 @@
   
   /* Make sure that GRUB reads the identical image as the OS.  */
   tmp_img = xmalloc (core_size);
-  core_path_dev = grub_util_get_path (DEFAULT_DIRECTORY, core_file);
+  core_path_dev = grub_util_get_path (prefix, core_file);
   
   /* It is a Good Thing to sync two times.  */
   sync ();
@@ -540,6 +541,7 @@
   -b, --boot-image=FILE   use FILE as the boot image [default=%s]\n\
   -c, --core-image=FILE   use FILE as the core image [default=%s]\n\
   -d, --directory=DIR     use GRUB files in the directory DIR [default=%s]\n\
+  -p, --prefix=DIR        specify the name of GRUB directory relative to partition root [default=%s]\n \
   -m, --device-map=FILE   use FILE as the device map [default=%s]\n\
   -r, --root-device=DEV   use DEV as the root device [default=guessed]\n\
   -h, --help              display this message and exit\n\
@@ -548,7 +550,8 @@
 \n\
 Report bugs to <%s>.\n\
 ",
-	    DEFAULT_BOOT_FILE, DEFAULT_CORE_FILE, DEFAULT_DIRECTORY,
+	    DEFAULT_BOOT_FILE, DEFAULT_CORE_FILE, DEFAULT_DIRECTORY, 
+	    DEFAULT_DIRECTORY,
 	    DEFAULT_DEVICE_MAP, PACKAGE_BUGREPORT);
 
   exit (status);
@@ -575,6 +578,7 @@
   char *dev_map = 0;
   char *root_dev = 0;
   char *dest_dev;
+  char *prefix = 0;
   int must_embed = 0;
   
   progname = "grub-setup";
@@ -582,7 +586,7 @@
   /* Check for options.  */
   while (1)
     {
-      int c = getopt_long (argc, argv, "b:c:d:m:r:hVv", options, 0);
+      int c = getopt_long (argc, argv, "p:b:c:d:m:r:hVv", options, 0);
 
       if (c == -1)
 	break;
@@ -603,6 +607,14 @@
 	    core_file = xstrdup (optarg);
 	    break;
 
+	  case 'p':
+	    if (prefix)
+	      free (prefix);
+
+	    prefix = xstrdup (optarg);
+	    break;
+
+
 	  case 'd':
 	    if (dir)
 	      free (dir);
@@ -723,6 +735,7 @@
       for (i = 0; devicelist[i]; i++)
 	{
 	  setup (dir ? : DEFAULT_DIRECTORY,
+		 prefix ? : DEFAULT_DIRECTORY,
 		 boot_file ? : DEFAULT_BOOT_FILE,
 		 core_file ? : DEFAULT_CORE_FILE,
 		 root_dev, grub_util_get_grub_dev (devicelist[i]), 1);
@@ -732,6 +745,7 @@
 #endif
   /* Do the real work.  */
     setup (dir ? : DEFAULT_DIRECTORY,
+	   prefix ? : DEFAULT_DIRECTORY,
 	   boot_file ? : DEFAULT_BOOT_FILE,
 	   core_file ? : DEFAULT_CORE_FILE,
 	   root_dev, dest_dev, must_embed);
author
#1 lore raw

After speaking with daChaac on IRC some problems with patch were identified. Fixed now Thanks daChaac.
phcoder

Quoted 4 lines · phcoder

This patch adds -p option for grub-setup on i386-pc. Without it install to any prefix different from /boot/grub failed Thank
Vladimir 'phcoder' Serbinenko

ChangeLog +6 -0
Index: ChangeLog
===================================================================
@@ -1,3 +1,9 @@
+2009-02-01  Vladimir Serbinenko  <[email protected]>
+
+	Add prefix option for grub-setup
+
+	* util/i386/pc/grub-setup.c (grub_video_vbe_scroll): Add -p option.
+
 2009-02-01  Vesa Jääskeläinen  <[email protected]>
 
 	Base on patch on bug #24154 created by Tomas Tintera
i386/pc/grub-setup.c +17 -3
Index: util/i386/pc/grub-setup.c
===================================================================
@@ -94,6 +94,7 @@
 
 static void
 setup (const char *dir,
+       const char *prefix_dir,
        const char *boot_file, const char *core_file,
        const char *root, const char *dest, int must_embed)
 {
@@ -373,7 +374,7 @@
   
   /* Make sure that GRUB reads the identical image as the OS.  */
   tmp_img = xmalloc (core_size);
-  core_path_dev = grub_util_get_path (DEFAULT_DIRECTORY, core_file);
+  core_path_dev = grub_util_get_path (prefix_dir, core_file);
   
   /* It is a Good Thing to sync two times.  */
   sync ();
@@ -540,6 +541,7 @@
   -b, --boot-image=FILE   use FILE as the boot image [default=%s]\n\
   -c, --core-image=FILE   use FILE as the core image [default=%s]\n\
   -d, --directory=DIR     use GRUB files in the directory DIR [default=%s]\n\
+  -p, --prefix=DIR        specify the name of GRUB directory relative to partition root [default=%s]\n \
   -m, --device-map=FILE   use FILE as the device map [default=%s]\n\
   -r, --root-device=DEV   use DEV as the root device [default=guessed]\n\
   -h, --help              display this message and exit\n\
@@ -548,7 +550,8 @@
 \n\
 Report bugs to <%s>.\n\
 ",
-	    DEFAULT_BOOT_FILE, DEFAULT_CORE_FILE, DEFAULT_DIRECTORY,
+	    DEFAULT_BOOT_FILE, DEFAULT_CORE_FILE, DEFAULT_DIRECTORY, 
+	    DEFAULT_DIRECTORY,
 	    DEFAULT_DEVICE_MAP, PACKAGE_BUGREPORT);
 
   exit (status);
@@ -575,6 +578,7 @@
   char *dev_map = 0;
   char *root_dev = 0;
   char *dest_dev;
+  char *prefix_dir = 0;
   int must_embed = 0;
   
   progname = "grub-setup";
@@ -582,7 +586,7 @@
   /* Check for options.  */
   while (1)
     {
-      int c = getopt_long (argc, argv, "b:c:d:m:r:hVv", options, 0);
+      int c = getopt_long (argc, argv, "p:b:c:d:m:r:hVv", options, 0);
 
       if (c == -1)
 	break;
@@ -603,6 +607,13 @@
 	    core_file = xstrdup (optarg);
 	    break;
 
+	  case 'p':
+	    if (prefix_dir)
+	      free (prefix_dir);
+
+	    prefix_dir = xstrdup (optarg);
+	    break;
+
 	  case 'd':
 	    if (dir)
 	      free (dir);
@@ -723,6 +734,7 @@
       for (i = 0; devicelist[i]; i++)
 	{
 	  setup (dir ? : DEFAULT_DIRECTORY,
+		 prefix_dir ? : DEFAULT_DIRECTORY,
 		 boot_file ? : DEFAULT_BOOT_FILE,
 		 core_file ? : DEFAULT_CORE_FILE,
 		 root_dev, grub_util_get_grub_dev (devicelist[i]), 1);
@@ -732,6 +744,7 @@
 #endif
   /* Do the real work.  */
     setup (dir ? : DEFAULT_DIRECTORY,
+	   prefix_dir ? : DEFAULT_DIRECTORY,
 	   boot_file ? : DEFAULT_BOOT_FILE,
 	   core_file ? : DEFAULT_CORE_FILE,
 	   root_dev, dest_dev, must_embed);
@@ -743,6 +756,7 @@
   free (boot_file);
   free (core_file);
   free (dir);
+  free (prefix_dir);
   free (dev_map);
   free (root_dev);
   free (dest_dev);
author
#2 lore raw

Sorry, Changelog entry was wrong:
+2009-02-04 Vladimir Serbinenko <[email protected]> +
+ Add prefix option for grub-setup
+
+ * util/i386/pc/grub-setup.c (main): Add -p option.
+ (setup): additional argument prefix_dir

Thanks
Vladimir 'phcoder' Serbinenko

Quoted 10 lines · phcoder

After speaking with daChaac on IRC some problems with patch were identified. Fixed now Thanks daChaac.
phcoder

Quoted 4 lines · phcoder

This patch adds -p option for grub-setup on i386-pc. Without it install to any prefix different from /boot/grub failed Thank
Vladimir 'phcoder' Serbinenko

author
#3 lore raw

Here I attach updated version
Regards
Vladimir 'phcoder' Serbinenko

Quoted 8 lines · phcoder

Sorry, Changelog entry was wrong:
+2009-02-04 Vladimir Serbinenko <[email protected]>

(quoted diff) +5 -0
+
+    Add prefix option for grub-setup
+
+    * util/i386/pc/grub-setup.c (main): Add -p option.
+    (setup): additional argument prefix_dir
Quoted 15 lines

Thanks
Vladimir 'phcoder' Serbinenko

Quoted 10 lines · phcoder

After speaking with daChaac on IRC some problems with patch were identified. Fixed now Thanks daChaac.
phcoder

Quoted 4 lines · phcoder

This patch adds -p option for grub-setup on i386-pc. Without it install to any prefix different from /boot/grub failed Thank
Vladimir 'phcoder' Serbinenko

i386/pc/grub-install.in +1 -1
Index: util/i386/pc/grub-install.in
===================================================================
@@ -295,7 +295,7 @@
     $grub_mkimage --output=${grubdir}/core.img --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1
 
     # Now perform the installation.
-    $grub_setup ${setup_verbose} --directory=${grubdir} --device-map=${device_map} \
+    $grub_setup ${setup_verbose} --directory=${grubdir} --prefix=${relative_grubdir} --device-map=${device_map} \
         ${install_device} || exit 1
 else
     $grub_mkimage -d ${pkglibdir} --output=/boot/multiboot.img --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1
i386/pc/grub-setup.c +18 -3
Index: util/i386/pc/grub-setup.c
===================================================================
@@ -94,6 +94,7 @@
 
 static void
 setup (const char *dir,
+       const char *prefix_dir,
        const char *boot_file, const char *core_file,
        const char *root, const char *dest, int must_embed)
 {
@@ -373,7 +374,7 @@
   
   /* Make sure that GRUB reads the identical image as the OS.  */
   tmp_img = xmalloc (core_size);
-  core_path_dev = grub_util_get_path (DEFAULT_DIRECTORY, core_file);
+  core_path_dev = grub_util_get_path (prefix_dir, core_file);
   
   /* It is a Good Thing to sync two times.  */
   sync ();
@@ -518,6 +519,7 @@
     {"core-image", required_argument, 0, 'c'},
     {"directory", required_argument, 0, 'd'},
     {"device-map", required_argument, 0, 'm'},
+    {"prefix", required_argument, 0, 'p'},
     {"root-device", required_argument, 0, 'r'},
     {"help", no_argument, 0, 'h'},
     {"version", no_argument, 0, 'V'},
@@ -540,6 +542,7 @@
   -b, --boot-image=FILE   use FILE as the boot image [default=%s]\n\
   -c, --core-image=FILE   use FILE as the core image [default=%s]\n\
   -d, --directory=DIR     use GRUB files in the directory DIR [default=%s]\n\
+  -p, --prefix=DIR        specify the name of GRUB directory relative to partition root [default=%s]\n \
   -m, --device-map=FILE   use FILE as the device map [default=%s]\n\
   -r, --root-device=DEV   use DEV as the root device [default=guessed]\n\
   -h, --help              display this message and exit\n\
@@ -548,7 +551,8 @@
 \n\
 Report bugs to <%s>.\n\
 ",
-	    DEFAULT_BOOT_FILE, DEFAULT_CORE_FILE, DEFAULT_DIRECTORY,
+	    DEFAULT_BOOT_FILE, DEFAULT_CORE_FILE, DEFAULT_DIRECTORY, 
+	    DEFAULT_DIRECTORY,
 	    DEFAULT_DEVICE_MAP, PACKAGE_BUGREPORT);
 
   exit (status);
@@ -575,6 +579,7 @@
   char *dev_map = 0;
   char *root_dev = 0;
   char *dest_dev;
+  char *prefix_dir = 0;
   int must_embed = 0;
   
   progname = "grub-setup";
@@ -582,7 +587,7 @@
   /* Check for options.  */
   while (1)
     {
-      int c = getopt_long (argc, argv, "b:c:d:m:r:hVv", options, 0);
+      int c = getopt_long (argc, argv, "p:b:c:d:m:r:hVv", options, 0);
 
       if (c == -1)
 	break;
@@ -603,6 +608,13 @@
 	    core_file = xstrdup (optarg);
 	    break;
 
+	  case 'p':
+	    if (prefix_dir)
+	      free (prefix_dir);
+
+	    prefix_dir = xstrdup (optarg);
+	    break;
+
 	  case 'd':
 	    if (dir)
 	      free (dir);
@@ -723,6 +735,7 @@
       for (i = 0; devicelist[i]; i++)
 	{
 	  setup (dir ? : DEFAULT_DIRECTORY,
+		 prefix_dir ? : DEFAULT_DIRECTORY,
 		 boot_file ? : DEFAULT_BOOT_FILE,
 		 core_file ? : DEFAULT_CORE_FILE,
 		 root_dev, grub_util_get_grub_dev (devicelist[i]), 1);
@@ -732,6 +745,7 @@
 #endif
   /* Do the real work.  */
     setup (dir ? : DEFAULT_DIRECTORY,
+	   prefix_dir ? : DEFAULT_DIRECTORY,
 	   boot_file ? : DEFAULT_BOOT_FILE,
 	   core_file ? : DEFAULT_CORE_FILE,
 	   root_dev, dest_dev, must_embed);
@@ -743,6 +757,7 @@
   free (boot_file);
   free (core_file);
   free (dir);
+  free (prefix_dir);
   free (dev_map);
   free (root_dev);
   free (dest_dev);
ChangeLog +8 -0
Index: ChangeLog
===================================================================
@@ -1,3 +1,104 @@
+2009-02-12  Vladimir Serbinenko  <[email protected]>
+
+	Add prefix option for grub-setup
+
+	* util/i386/pc/grub-setup.c (main): Add -p option.
+	(setup): additional argument prefix_dir
+	* util/i386/pc/grub-install.in: pass prefix option to grub-setup
+
 2009-02-11  Robert Millan  <[email protected]>
 
 	* util/grub.d/00_header.in: Update old reference to `font' command.