grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Borzenkov <arvidjaar@gmail.com>
To: grub-devel@gnu.org
Subject: Re: [PATCH] add --boot-directory option to grub-mkstandalone
Date: Sat, 21 Dec 2013 14:29:52 +0400	[thread overview]
Message-ID: <1387621792.918.2.camel@opensuse.site> (raw)
In-Reply-To: <20131220121616.GA25815@riva.ucam.org>

В Пт, 20/12/2013 в 12:16 +0000, Colin Watson пишет:
> On Fri, Dec 13, 2013 at 07:40:54PM +0400, Andrey Borzenkov wrote:
> > > 2) make it possible for grub-mkstandalone to build images with the
> > >    prefix set to something other than (memdisk)/boot/grub
> > 
> > Like below?
> 
> Indeed, I like this general approach, and it's probably better than
> fiddling around with "search".
> 
> > I'm not keen on using --boot-directory; may be using full
> > --grub-directory (without implied ../grub) will actually be more
> > logical.
> 
> I agree - I would prefer to explicitly specify the whole thing.  Could
> you redo the patch that way?
> 

See below

> >  enum
> >    {
> >      OPTION_OUTPUT = 'o',
> > -    OPTION_FORMAT = 'O'
> > +    OPTION_FORMAT = 'O',
> > +    OPTION_BOOT_DIRECTORY = 0x301,
> > +
> >    };
> 
> Stray newline.
> 
Fixed

> > @@ -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);
> 
> I'd probably assign the result of that xasprintf to a variable in order
> to be able to free it, for valgrind-friendliness.
> 

Well, I could do it but as part of separate clean up patch. There are
many non-freed allocations besides it.

From: Andrey Borzenkov <arvidjaar@gmail.com>
Subject: [PATCH] add --boot-directory option to grub-mkstandalone

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 | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/util/grub-mkstandalone.c b/util/grub-mkstandalone.c
index 576ab40..77c1998 100644
--- a/util/grub-mkstandalone.c
+++ b/util/grub-mkstandalone.c
@@ -30,15 +30,19 @@ static char **files;
 static int nfiles;
 const struct grub_install_image_target_desc *format;
 static FILE *memdisk;
+static char *grubdir;
 
 enum
   {
     OPTION_OUTPUT = 'o',
-    OPTION_FORMAT = 'O'
+    OPTION_FORMAT = 'O',
+    OPTION_GRUB_DIRECTORY = 0x301,
   };
 
 static struct argp_option options[] = {
   GRUB_INSTALL_OPTIONS,
+  {"grub-directory", OPTION_GRUB_DIRECTORY, N_("DIR"),
+   0, N_("install GRUB images under the directory DIR 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 +80,11 @@ argp_parser (int key, char *arg, struct argp_state *state)
   switch (key)
     {
 
+    case OPTION_GRUB_DIRECTORY:
+      free (grubdir);
+      grubdir = xstrdup (arg);
+      return 0;
+
     case 'o':
       if (output_image)
 	free (output_image);
@@ -294,6 +303,9 @@ main (int argc, char *argv[])
 
   argp_parse (&argp, argc, argv, 0, 0, 0);
 
+  if (!grubdir)
+    grubdir = xstrdup ("/boot/grub");
+
   pkglibdir = grub_util_get_pkglibdir ();
 
   if (!output_image)
@@ -308,7 +320,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 (2, memdisk_dir, grubdir);
   grub_install_copy_files (grub_install_source_directory,
 			   boot_grub, plat);
 
@@ -346,8 +358,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", bootdir),
+				output_image, memdisk_img, NULL,
 				grub_util_get_target_name (format), 0);
 
   grub_util_unlink (memdisk_img);
-- 
tg: (065adc3..) u/grub-directory (depends on: master)




  reply	other threads:[~2013-12-21 10:30 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-12 15:36 [PATCH 0/4] Turn-key PV-GRUB2 installation Colin Watson
2013-12-12 15:37 ` [PATCH 1/4] Add an option to exclude devices from search results Colin Watson
2013-12-13 12:27   ` [Xen-devel] " Vladimir 'φ-coder/phcoder' Serbinenko
2013-12-13 13:18     ` Colin Watson
2013-12-13 15:40       ` [PATCH] add --boot-directory option to grub-mkstandalone Andrey Borzenkov
2013-12-20 12:16         ` Colin Watson
2013-12-21 10:29           ` Andrey Borzenkov [this message]
2013-12-21 10:37             ` Andrey Borzenkov
2013-12-22 17:20     ` [Xen-devel] [PATCH 1/4] Add an option to exclude devices from search results Jordan Uggla
2013-12-12 15:37 ` [PATCH 2/4] Accept environment variables on the command line for Xen Colin Watson
2013-12-12 15:48   ` Andrey Borzenkov
2013-12-12 16:11     ` Colin Watson
2013-12-12 16:15       ` Vladimir 'phcoder' Serbinenko
2013-12-12 16:13     ` Vladimir 'phcoder' Serbinenko
2013-12-12 17:12       ` Andrey Borzenkov
2013-12-12 17:58         ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-12-12 19:12           ` Colin Watson
2013-12-12 19:50             ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-12-12 15:37 ` [PATCH 3/4] Build grub.xen Colin Watson
2013-12-12 16:24   ` Vladimir 'phcoder' Serbinenko
2013-12-12 16:39     ` Colin Watson
2013-12-12 16:45       ` Vladimir 'phcoder' Serbinenko
2013-12-12 16:49         ` Fwd: " Vladimir 'phcoder' Serbinenko
2013-12-12 17:36         ` Colin Watson
2013-12-12 17:41           ` Andrey Borzenkov
2013-12-12 18:08             ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-12-13 11:56   ` Colin Watson
2013-12-13 12:19     ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-12-12 15:37 ` [PATCH 4/4] Improve installation on Xen Colin Watson
2013-12-12 16:23   ` [Xen-devel] " Vladimir 'phcoder' Serbinenko
2013-12-13 11:58     ` Colin Watson
2013-12-16 11:42 ` [Xen-devel] [PATCH 0/4] Turn-key PV-GRUB2 installation Ian Campbell
2013-12-16 12:05   ` Samuel Thibault

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=1387621792.918.2.camel@opensuse.site \
    --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).