grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Borzenkov <arvidjaar@gmail.com>
To: grub-devel@gnu.org
Subject: [PATCH] normalize default prefix in grub-mkimage
Date: Fri, 27 Dec 2013 21:41:16 +0400	[thread overview]
Message-ID: <1388166076-10718-1-git-send-email-arvidjaar@gmail.com> (raw)

This fixes bogus "C:\boot\grub" at runtime for Windows build as well as
the case when /boot is on separate mount point for other systems.

---
 util/grub-mkimage.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c
index a2bd4c1..4d54f0a 100644
--- a/util/grub-mkimage.c
+++ b/util/grub-mkimage.c
@@ -84,6 +84,7 @@ static struct argp_option options[] = {
   { 0, 0, 0, 0, 0, 0 }
 };
 
+static char *default_prefix;
 #pragma GCC diagnostic ignored "-Wformat-nonliteral"
 
 static char *
@@ -94,7 +95,7 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused)))
     case 'd':
       return xasprintf (text, grub_util_get_pkglibdir ());
     case 'p':
-      return xasprintf (text, DEFAULT_DIRECTORY);
+      return xasprintf (text, default_prefix);
     case 'O':
       {
 	char *formats = grub_install_get_image_targets_string (), *ret;
@@ -245,6 +246,7 @@ main (int argc, char *argv[])
 
   grub_util_host_init (&argc, &argv);
 
+  default_prefix = grub_make_system_path_relative_to_its_root (DEFAULT_DIRECTORY);
   memset (&arguments, 0, sizeof (struct arguments));
   arguments.comp = GRUB_COMPRESSION_AUTO;
   arguments.modules_max = argc + 1;
@@ -252,6 +254,7 @@ main (int argc, char *argv[])
 			     * sizeof (arguments.modules[0]));
   memset (arguments.modules, 0, (arguments.modules_max + 1)
 	  * sizeof (arguments.modules[0]));
+  arguments.prefix = xstrdup (default_prefix);
 
   if (argp_parse (&argp, argc, argv, 0, 0, &arguments) != 0)
     {
@@ -287,8 +290,7 @@ main (int argc, char *argv[])
       strcpy (ptr, dn);
     }
 
-  grub_install_generate_image (arguments.dir,
-			       arguments.prefix ? : DEFAULT_DIRECTORY, fp,
+  grub_install_generate_image (arguments.dir, arguments.prefix, fp,
 			       arguments.output, arguments.modules,
 			       arguments.memdisk, arguments.pubkeys,
 			       arguments.npubkeys, arguments.config,
@@ -298,6 +300,8 @@ main (int argc, char *argv[])
   grub_util_file_sync  (fp);
   fclose (fp);
 
+  free (default_prefix);
+
   if (arguments.dir)
     free (arguments.dir);
 
-- 
tg: (645ff63..) u/mingw/default-prefix (depends on: master)


             reply	other threads:[~2013-12-27 17:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-27 17:41 Andrey Borzenkov [this message]
2014-01-21  7:19 ` [PATCH] normalize default prefix in grub-mkimage Vladimir 'φ-coder/phcoder' Serbinenko
2014-01-21 16:48   ` Andrey Borzenkov
2014-01-22 15:07     ` Vladimir 'φ-coder/phcoder' Serbinenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1388166076-10718-1-git-send-email-arvidjaar@gmail.com \
    --to=arvidjaar@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).