Update blscfg bits

Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
Peter Jones 2016-10-28 11:03:35 -04:00
parent f50976357c
commit ad67a3cbbf
5 changed files with 93 additions and 121 deletions

View file

@ -1,86 +0,0 @@
From 3f2d8bc3a052c7ab6f89a7684ac93b0f8401a6b5 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 28 Oct 2016 10:55:56 -0400
Subject: [PATCH] Make blscfg include some IDs and indices
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grub-core/commands/blscfg.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
index af838d2..2a16858 100644
--- a/grub-core/commands/blscfg.c
+++ b/grub-core/commands/blscfg.c
@@ -56,6 +56,9 @@ static int parse_entry (
grub_file_t f = NULL;
grub_off_t sz;
char *title = NULL, *options = NULL, *clinux = NULL, *initrd = NULL, *src = NULL;
+ char *id = NULL;
+ char *class[] = { NULL, NULL };
+ char **classes = class[0];
const char *args[2] = { NULL, NULL };
const char *dirname = (const char *)data;
const char *devid = grub_env_get ("boot");
@@ -120,6 +123,20 @@ static int parse_entry (
if (!initrd)
goto finish;
}
+ else if (grub_strncmp (buf, "id ", 3) == 0)
+ {
+ grub_free (id);
+ id = grub_strdup (buf + 3);
+ if (!id)
+ goto finish;
+ }
+ else if (grub_strncmp (buf, "index ", 6) == 0)
+ {
+ grub_free (class[0]);
+ class[0] = grub_strdup (buf + 6);
+ if (!class[0])
+ goto finish;
+ }
grub_free(buf);
}
@@ -141,7 +158,7 @@ static int parse_entry (
GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "",
initrd ? GRUB_INITRD_CMD " " : "", initrd ? GRUB_BOOT_DEVICE : "", initrd ? initrd : "", initrd ? "\n" : "");
- grub_normal_add_menu_entry (1, args, NULL, NULL, "bls", NULL, NULL, src, 0);
+ grub_normal_add_menu_entry (1, args, classes, id, "bls", NULL, NULL, src, 0);
finish:
grub_free (p);
@@ -150,6 +167,8 @@ finish:
grub_free (clinux);
grub_free (initrd);
grub_free (src);
+ grub_free (id);
+ grub_free (class[0]);
if (f)
grub_file_close (f);
@@ -333,7 +352,7 @@ finish:
#endif
static grub_err_t
-grub_cmd_bls_import (grub_extcmd_context_t ctxt __attribute__ ((unused)),
+grub_cmd_blscfg (grub_extcmd_context_t ctxt __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
@@ -384,8 +403,8 @@ static grub_extcmd_t cmd;
GRUB_MOD_INIT(bls)
{
- cmd = grub_register_extcmd ("bls_import",
- grub_cmd_bls_import,
+ cmd = grub_register_extcmd ("blscfg",
+ grub_cmd_blscfg,
0,
NULL,
N_("Import Boot Loader Specification snippets."),
--
2.9.3

View file

@ -1,7 +1,7 @@
From 00857b7fb451f2abf9e97229aef537dab3d56f6e Mon Sep 17 00:00:00 2001
From 986d3e15ed15b19abde41f65a610325573f4db7d Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 24 Oct 2016 14:51:06 -0400
Subject: [PATCH 1/2] blscfg: make the bls_import command know to search env
Subject: [PATCH 88/89] blscfg: make the bls_import command know to search env
files for blsdir
This makes it so when you do "bls_import" on EFI systems, it searches
@ -12,18 +12,18 @@ Once that is done, if there's a variable named "blsdir", it looks there
for BLS config files. If that is absent, it tries to load them from
/EFI/$DIR/loader/entries/
---
grub-core/commands/blscfg.c | 219 ++++++++++++++++++++++++++++++++++++++++---
grub-core/commands/loadenv.c | 77 +--------------
grub-core/commands/loadenv.h | 93 ++++++++++++++++++
grub-core/commands/blscfg.c | 246 ++++++++++++++++++++++++++++++++++++++++---
grub-core/commands/loadenv.c | 77 +-------------
grub-core/commands/loadenv.h | 93 ++++++++++++++++
include/grub/compiler.h | 2 +
4 files changed, 305 insertions(+), 86 deletions(-)
4 files changed, 328 insertions(+), 90 deletions(-)
create mode 100644 grub-core/commands/loadenv.h
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
index 4274aca..af838d2 100644
index 4274aca..2a16858 100644
--- a/grub-core/commands/blscfg.c
+++ b/grub-core/commands/blscfg.c
@@ -30,25 +30,26 @@
@@ -30,32 +30,40 @@
#include <grub/env.h>
#include <grub/file.h>
#include <grub/normal.h>
@ -56,9 +56,12 @@ index 4274aca..af838d2 100644
{
grub_size_t n;
char *p;
@@ -56,6 +57,10 @@ static int parse_entry (
grub_file_t f = NULL;
grub_off_t sz;
char *title = NULL, *options = NULL, *clinux = NULL, *initrd = NULL, *src = NULL;
+ char *id = NULL;
+ char *class[] = { NULL, NULL };
+ char **classes = class[0];
const char *args[2] = { NULL, NULL };
+ const char *dirname = (const char *)data;
+ const char *devid = grub_env_get ("boot");
@ -67,7 +70,7 @@ index 4274aca..af838d2 100644
if (filename[0] == '.')
return 0;
@@ -67,12 +72,14 @@ static int parse_entry (
@@ -67,12 +75,14 @@ static int parse_entry (
if (grub_strcmp (filename + n - 5, ".conf") != 0)
return 0;
@ -83,7 +86,27 @@ index 4274aca..af838d2 100644
sz = grub_file_size (f);
if (sz == GRUB_FILE_SIZE_UNKNOWN || sz > 1024*1024)
goto finish;
@@ -119,12 +126,13 @@ static int parse_entry (
@@ -113,18 +123,33 @@ static int parse_entry (
if (!initrd)
goto finish;
}
+ else if (grub_strncmp (buf, "id ", 3) == 0)
+ {
+ grub_free (id);
+ id = grub_strdup (buf + 3);
+ if (!id)
+ goto finish;
+ }
+ else if (grub_strncmp (buf, "index ", 6) == 0)
+ {
+ grub_free (class[0]);
+ class[0] = grub_strdup (buf + 6);
+ if (!class[0])
+ goto finish;
+ }
grub_free(buf);
}
if (!linux)
{
@ -98,10 +121,28 @@ index 4274aca..af838d2 100644
src = grub_xasprintf ("load_video\n"
"set gfx_payload=keep\n"
"insmod gzio\n"
@@ -149,6 +157,181 @@ finish:
return 0;
}
@@ -133,7 +158,7 @@ static int parse_entry (
GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "",
initrd ? GRUB_INITRD_CMD " " : "", initrd ? GRUB_BOOT_DEVICE : "", initrd ? initrd : "", initrd ? "\n" : "");
- grub_normal_add_menu_entry (1, args, NULL, NULL, "bls", NULL, NULL, src, 0);
+ grub_normal_add_menu_entry (1, args, classes, id, "bls", NULL, NULL, src, 0);
finish:
grub_free (p);
@@ -142,15 +167,192 @@ finish:
grub_free (clinux);
grub_free (initrd);
grub_free (src);
+ grub_free (id);
+ grub_free (class[0]);
+
+ if (f)
+ grub_file_close (f);
+
+ return 0;
+}
+
+#ifdef GRUB_MACHINE_EFI
+static grub_envblk_t saved_env = NULL;
+
@ -267,20 +308,23 @@ index 4274aca..af838d2 100644
+
+ if (env)
+ grub_envblk_close (env);
+
+ if (f)
+ grub_file_close (f);
+
if (f)
grub_file_close (f);
+ grub_free (default_blsdir);
+
+ return 0;
+}
return 0;
}
+#endif
+
static grub_err_t
grub_cmd_bls_import (grub_extcmd_context_t ctxt __attribute__ ((unused)),
-grub_cmd_bls_import (grub_extcmd_context_t ctxt __attribute__ ((unused)),
+grub_cmd_blscfg (grub_extcmd_context_t ctxt __attribute__ ((unused)),
int argc __attribute__ ((unused)),
@@ -158,15 +341,22 @@ grub_cmd_bls_import (grub_extcmd_context_t ctxt __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
@@ -158,15 +360,22 @@ grub_cmd_bls_import (grub_extcmd_context_t ctxt __attribute__ ((unused)),
grub_device_t dev;
static grub_err_t r;
const char *devid;
@ -305,7 +349,7 @@ index 4274aca..af838d2 100644
fs = grub_fs_probe (dev);
if (!fs)
{
@@ -174,7 +364,14 @@ grub_cmd_bls_import (grub_extcmd_context_t ctxt __attribute__ ((unused)),
@@ -174,7 +383,14 @@ grub_cmd_bls_import (grub_extcmd_context_t ctxt __attribute__ ((unused)),
goto finish;
}
@ -321,6 +365,17 @@ index 4274aca..af838d2 100644
finish:
if (dev)
@@ -187,8 +403,8 @@ static grub_extcmd_t cmd;
GRUB_MOD_INIT(bls)
{
- cmd = grub_register_extcmd ("bls_import",
- grub_cmd_bls_import,
+ cmd = grub_register_extcmd ("blscfg",
+ grub_cmd_blscfg,
0,
NULL,
N_("Import Boot Loader Specification snippets."),
diff --git a/grub-core/commands/loadenv.c b/grub-core/commands/loadenv.c
index acd93d1..91c9945 100644
--- a/grub-core/commands/loadenv.c

View file

@ -1,14 +1,15 @@
From 7d96844d560e9a4ce14f785abbb4b9d25ee49987 Mon Sep 17 00:00:00 2001
From 4f85d4f9b7b98ff8657628004410e8ba840c3f40 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 25 Oct 2016 13:26:38 -0400
Subject: [PATCH 2/2] Make grub2-mkconfig able to output BLS based config file
Subject: [PATCH 89/89] Make grub2-mkconfig able to output BLS based config
file
Signed-off-by: Peter Jones <pjones@redhat.com>
---
util/grub-mkconfig.in | 3 ++-
util/grub-mkconfig_lib.in | 24 +++++++++++++++---------
util/grub.d/10_linux.in | 20 ++++++++++++++++++++
3 files changed, 37 insertions(+), 10 deletions(-)
util/grub.d/10_linux.in | 23 +++++++++++++++++++++++
3 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
index e32de5e..0e0475d 100644
@ -90,10 +91,10 @@ index 9c410ea..54b3576 100644
fi
IFS="$old_ifs"
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index 0c5b227..8d31b1d 100644
index 0c5b227..e19d7ed 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -105,6 +105,26 @@ linux_entry ()
@@ -105,6 +105,29 @@ linux_entry ()
if [ -z "$boot_device_id" ]; then
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
fi
@ -112,7 +113,10 @@ index 0c5b227..8d31b1d 100644
+ bootefi_device="`${grub_probe} --target=device /boot/efi/`"
+ prepare_grub_to_access_device ${bootefi_device} boot
+
+ echo bls_import
+ echo
+ echo '# load bls config options'
+ echo blscfg
+ echo
+
+ exit 0
+ fi

View file

@ -86,6 +86,5 @@ Patch0084: 0084-linuxefi-fix-double-free-on-verification-failure.patch
Patch0085: 0085-fix-machine-type-test-in-30_os-prober.in.patch
Patch0086: 0086-ppc64le-has-no-separate-boot-mount-1261926.patch
Patch0087: 0087-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch
Patch0088: 0001-blscfg-make-the-bls_import-command-know-to-search-en.patch
Patch0089: 0002-Make-grub2-mkconfig-able-to-output-BLS-based-config-.patch
Patch0090: 0001-Make-blscfg-include-some-IDs-and-indices.patch
Patch0088: 0088-blscfg-make-the-bls_import-command-know-to-search-en.patch
Patch0089: 0089-Make-grub2-mkconfig-able-to-output-BLS-based-config-.patch

View file

@ -45,7 +45,7 @@
Name: grub2
Epoch: 1
Version: 2.02
Release: 0.36%{?dist}.bls2
Release: 0.36%{?dist}.bls3
Summary: Bootloader with support for Linux, Multiboot and more
Group: System Environment/Base