All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] Add emdedded-config hidden option to grub-install.
@ 2014-05-19  7:03 Glenn Washburn
  2014-05-22  7:33 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 1 reply; 4+ messages in thread
From: Glenn Washburn @ 2014-05-19  7:03 UTC (permalink / raw)
  To: grub-devel

One thing to note with this patch is that the supplied embedded config 
file is appended to the normally generated one.  I did this to allow 
the default root and prefix to be generated and subsequently overridden 
if desired.

---
 util/grub-install.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/util/grub-install.c b/util/grub-install.c
index d66030f..85dd3a1 100644
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -74,6 +74,7 @@ static char *memdisk = NULL;
 static int have_load_cfg = 0;
 static FILE * load_cfg_f = NULL;
 static char *load_cfg;
+static char *embed_cfg = NULL;
 static int install_bootsector = 1;
 static char *label_font;
 static char *label_color;
@@ -100,6 +101,7 @@ enum
     OPTION_BOOTLOADER_ID, 
     OPTION_EFI_DIRECTORY,
     OPTION_MEMDISK,
+    OPTION_EMBED_CFG,
     OPTION_FONT,
     OPTION_DEBUG,
     OPTION_DEBUG_IMAGE,
@@ -188,6 +190,11 @@ argp_parser (int key, char *arg, struct argp_state *state)
       memdisk = xstrdup (arg);
       return 0;
 
+    case OPTION_EMBED_CFG:
+      free (embed_cfg);
+      embed_cfg = xstrdup (arg);
+      return 0;
+
     case OPTION_DISK_MODULE:
       free (disk_module);
       disk_module = xstrdup (arg);
@@ -264,6 +271,7 @@ static struct argp_option options[] = {
    /* TRANSLATORS: "TARGET" as in "target platform".  */
    0, N_("install GRUB for TARGET platform [default=%s]; available targets: %s"), 2},
   {"memdisk", OPTION_MEMDISK, N_("FILE"), OPTION_HIDDEN, 0, 2},
+  {"embedded-config", OPTION_EMBED_CFG, N_("FILE"), OPTION_HIDDEN, 0, 2},
   {"grub-setup", OPTION_SETUP, "FILE", OPTION_HIDDEN, 0, 2},
   {"grub-mkrelpath", OPTION_MKRELPATH, "FILE", OPTION_HIDDEN, 0, 2},
   {"grub-mkdevicemap", OPTION_MKDEVICEMAP, "FILE", OPTION_HIDDEN, 0, 2},
@@ -1586,7 +1594,17 @@ main (int argc, char *argv[])
     grub_util_error ("%s", _("You've found a bug"));
 
   if (load_cfg_f)
-    fclose (load_cfg_f);
+    {
+      if (embed_cfg)
+        {
+          size_t size = grub_util_get_image_size(embed_cfg);
+          char *embed_cfg_data = grub_util_read_image(embed_cfg);
+          grub_util_write_image(embed_cfg_data, size, load_cfg_f, load_cfg);
+          free(embed_cfg_data);
+        }
+      
+      fclose (load_cfg_f);
+    }
 
   char *imgfile = grub_util_path_concat (2, platdir,
 				       core_name);
-- 
1.8.3.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] Add emdedded-config hidden option to grub-install.
  2014-05-19  7:03 [PATCH 2/2] Add emdedded-config hidden option to grub-install Glenn Washburn
@ 2014-05-22  7:33 ` Vladimir 'φ-coder/phcoder' Serbinenko
  2014-05-27  6:32   ` Glenn Washburn
  0 siblings, 1 reply; 4+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2014-05-22  7:33 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 2801 bytes --]

On 19.05.2014 09:03, Glenn Washburn wrote:
> One thing to note with this patch is that the supplied embedded config 
> file is appended to the normally generated one.  I did this to allow 
> the default root and prefix to be generated and subsequently overridden 
> if desired.
> 
embed config isn't meant to hold user-supplied command. Normal config is
for this. If you want to change root/prefix, why not just install to the
location where the desired prefix is?
> ---
>  util/grub-install.c | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/util/grub-install.c b/util/grub-install.c
> index d66030f..85dd3a1 100644
> --- a/util/grub-install.c
> +++ b/util/grub-install.c
> @@ -74,6 +74,7 @@ static char *memdisk = NULL;
>  static int have_load_cfg = 0;
>  static FILE * load_cfg_f = NULL;
>  static char *load_cfg;
> +static char *embed_cfg = NULL;
>  static int install_bootsector = 1;
>  static char *label_font;
>  static char *label_color;
> @@ -100,6 +101,7 @@ enum
>      OPTION_BOOTLOADER_ID, 
>      OPTION_EFI_DIRECTORY,
>      OPTION_MEMDISK,
> +    OPTION_EMBED_CFG,
>      OPTION_FONT,
>      OPTION_DEBUG,
>      OPTION_DEBUG_IMAGE,
> @@ -188,6 +190,11 @@ argp_parser (int key, char *arg, struct argp_state *state)
>        memdisk = xstrdup (arg);
>        return 0;
>  
> +    case OPTION_EMBED_CFG:
> +      free (embed_cfg);
> +      embed_cfg = xstrdup (arg);
> +      return 0;
> +
>      case OPTION_DISK_MODULE:
>        free (disk_module);
>        disk_module = xstrdup (arg);
> @@ -264,6 +271,7 @@ static struct argp_option options[] = {
>     /* TRANSLATORS: "TARGET" as in "target platform".  */
>     0, N_("install GRUB for TARGET platform [default=%s]; available targets: %s"), 2},
>    {"memdisk", OPTION_MEMDISK, N_("FILE"), OPTION_HIDDEN, 0, 2},
> +  {"embedded-config", OPTION_EMBED_CFG, N_("FILE"), OPTION_HIDDEN, 0, 2},
>    {"grub-setup", OPTION_SETUP, "FILE", OPTION_HIDDEN, 0, 2},
>    {"grub-mkrelpath", OPTION_MKRELPATH, "FILE", OPTION_HIDDEN, 0, 2},
>    {"grub-mkdevicemap", OPTION_MKDEVICEMAP, "FILE", OPTION_HIDDEN, 0, 2},
> @@ -1586,7 +1594,17 @@ main (int argc, char *argv[])
>      grub_util_error ("%s", _("You've found a bug"));
>  
>    if (load_cfg_f)
> -    fclose (load_cfg_f);
> +    {
> +      if (embed_cfg)
> +        {
> +          size_t size = grub_util_get_image_size(embed_cfg);
> +          char *embed_cfg_data = grub_util_read_image(embed_cfg);
> +          grub_util_write_image(embed_cfg_data, size, load_cfg_f, load_cfg);
> +          free(embed_cfg_data);
> +        }
> +      
> +      fclose (load_cfg_f);
> +    }
>  
>    char *imgfile = grub_util_path_concat (2, platdir,
>  				       core_name);
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 274 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] Add emdedded-config hidden option to grub-install.
  2014-05-22  7:33 ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2014-05-27  6:32   ` Glenn Washburn
  2014-06-02 15:53     ` Andrey Borzenkov
  0 siblings, 1 reply; 4+ messages in thread
From: Glenn Washburn @ 2014-05-27  6:32 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 3409 bytes --]

On Thu, 22 May 2014 09:33:05 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <phcoder@gmail.com> wrote:

> On 19.05.2014 09:03, Glenn Washburn wrote:
> > One thing to note with this patch is that the supplied embedded
> > config file is appended to the normally generated one.  I did this
> > to allow the default root and prefix to be generated and
> > subsequently overridden if desired.
> > 
> embed config isn't meant to hold user-supplied command. Normal config
> is for this. If you want to change root/prefix, why not just install
> to the location where the desired prefix is?

This is currently needed to set the root to (memdisk) when supplying a
memdisk.  But I generally like the flexibility it offers.  I've made
this a hidden command, so that the average user isn't confused by it,
but available if the user really wants to use it.  It also give
grub-install a capability that it previously had, when it was a shell
script.

> > ---
> >  util/grub-install.c | 20 +++++++++++++++++++-
> >  1 file changed, 19 insertions(+), 1 deletion(-)
> > 
> > diff --git a/util/grub-install.c b/util/grub-install.c
> > index d66030f..85dd3a1 100644
> > --- a/util/grub-install.c
> > +++ b/util/grub-install.c
> > @@ -74,6 +74,7 @@ static char *memdisk = NULL;
> >  static int have_load_cfg = 0;
> >  static FILE * load_cfg_f = NULL;
> >  static char *load_cfg;
> > +static char *embed_cfg = NULL;
> >  static int install_bootsector = 1;
> >  static char *label_font;
> >  static char *label_color;
> > @@ -100,6 +101,7 @@ enum
> >      OPTION_BOOTLOADER_ID, 
> >      OPTION_EFI_DIRECTORY,
> >      OPTION_MEMDISK,
> > +    OPTION_EMBED_CFG,
> >      OPTION_FONT,
> >      OPTION_DEBUG,
> >      OPTION_DEBUG_IMAGE,
> > @@ -188,6 +190,11 @@ argp_parser (int key, char *arg, struct
> > argp_state *state) memdisk = xstrdup (arg);
> >        return 0;
> >  
> > +    case OPTION_EMBED_CFG:
> > +      free (embed_cfg);
> > +      embed_cfg = xstrdup (arg);
> > +      return 0;
> > +
> >      case OPTION_DISK_MODULE:
> >        free (disk_module);
> >        disk_module = xstrdup (arg);
> > @@ -264,6 +271,7 @@ static struct argp_option options[] = {
> >     /* TRANSLATORS: "TARGET" as in "target platform".  */
> >     0, N_("install GRUB for TARGET platform [default=%s]; available
> > targets: %s"), 2}, {"memdisk", OPTION_MEMDISK, N_("FILE"),
> > OPTION_HIDDEN, 0, 2},
> > +  {"embedded-config", OPTION_EMBED_CFG, N_("FILE"), OPTION_HIDDEN,
> > 0, 2}, {"grub-setup", OPTION_SETUP, "FILE", OPTION_HIDDEN, 0, 2},
> >    {"grub-mkrelpath", OPTION_MKRELPATH, "FILE", OPTION_HIDDEN, 0,
> > 2}, {"grub-mkdevicemap", OPTION_MKDEVICEMAP, "FILE", OPTION_HIDDEN,
> > 0, 2}, @@ -1586,7 +1594,17 @@ main (int argc, char *argv[])
> >      grub_util_error ("%s", _("You've found a bug"));
> >  
> >    if (load_cfg_f)
> > -    fclose (load_cfg_f);
> > +    {
> > +      if (embed_cfg)
> > +        {
> > +          size_t size = grub_util_get_image_size(embed_cfg);
> > +          char *embed_cfg_data = grub_util_read_image(embed_cfg);
> > +          grub_util_write_image(embed_cfg_data, size, load_cfg_f,
> > load_cfg);
> > +          free(embed_cfg_data);
> > +        }
> > +      
> > +      fclose (load_cfg_f);
> > +    }
> >  
> >    char *imgfile = grub_util_path_concat (2, platdir,
> >  				       core_name);
> > 
> 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] Add emdedded-config hidden option to grub-install.
  2014-05-27  6:32   ` Glenn Washburn
@ 2014-06-02 15:53     ` Andrey Borzenkov
  0 siblings, 0 replies; 4+ messages in thread
From: Andrey Borzenkov @ 2014-06-02 15:53 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: development

[-- Attachment #1: Type: text/plain, Size: 1021 bytes --]

В Tue, 27 May 2014 01:32:22 -0500
Glenn Washburn <development@efficientek.com> пишет:

> On Thu, 22 May 2014 09:33:05 +0200
> Vladimir 'φ-coder/phcoder' Serbinenko <phcoder@gmail.com> wrote:
> 
> > On 19.05.2014 09:03, Glenn Washburn wrote:
> > > One thing to note with this patch is that the supplied embedded
> > > config file is appended to the normally generated one.  I did this
> > > to allow the default root and prefix to be generated and
> > > subsequently overridden if desired.
> > > 
> > embed config isn't meant to hold user-supplied command. Normal config
> > is for this. If you want to change root/prefix, why not just install
> > to the location where the desired prefix is?
> 
> This is currently needed to set the root to (memdisk) when supplying a
> memdisk.  But I generally like the flexibility it offers. 

Embedded config runs before normal is loaded, basically in rescue
environment. There is very little you can do in it, so it hardly
offers any more flexibility.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-06-02 15:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-19  7:03 [PATCH 2/2] Add emdedded-config hidden option to grub-install Glenn Washburn
2014-05-22  7:33 ` Vladimir 'φ-coder/phcoder' Serbinenko
2014-05-27  6:32   ` Glenn Washburn
2014-06-02 15:53     ` Andrey Borzenkov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.