Compare commits
15 Commits
Author | SHA1 | Date |
---|---|---|
Javier Martinez Canillas | 53711828a3 | |
Javier Martinez Canillas | 4c3c0c390f | |
Javier Martinez Canillas | f52f8fe0ab | |
Javier Martinez Canillas | e95ccc7ba6 | |
Javier Martinez Canillas | fded58021e | |
Javier Martinez Canillas | 50f79d8617 | |
Javier Martinez Canillas | 115e0f60fa | |
Javier Martinez Canillas | 89b65757a9 | |
Zbigniew Jędrzejewski-Szmek | bbe7d2e505 | |
Javier Martinez Canillas | c916dad5b6 | |
Javier Martinez Canillas | c31e801897 | |
Javier Martinez Canillas | b9750a4853 | |
Javier Martinez Canillas | 388b8a4e20 | |
Javier Martinez Canillas | 6882a13215 | |
Peter Jones | ca870c05c4 |
|
@ -0,0 +1,60 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Tue, 26 Feb 2019 20:11:27 +0100
|
||||
Subject: [PATCH] blscfg: fallback to default_kernelopts if BLS option field
|
||||
isn't set
|
||||
|
||||
If the $kernelopts variable isn't found, then the entry will fail to boot
|
||||
since there won't be a kernel command line params set. This makes the BLS
|
||||
configuration more fragile than a non-BLS one, since in that case it will
|
||||
boot even without a correct grubenv file.
|
||||
|
||||
So set a $default_kernelopts in the GRUB config file that will be used as
|
||||
a fallback if the value in the BLS options field can't be resolved.
|
||||
|
||||
Related: rhbz#1625124
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
grub-core/commands/blscfg.c | 7 +++++++
|
||||
util/grub.d/10_linux.in | 2 ++
|
||||
2 files changed, 9 insertions(+)
|
||||
|
||||
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
|
||||
index 1ef2ae06cff..5635066e3eb 100644
|
||||
--- a/grub-core/commands/blscfg.c
|
||||
+++ b/grub-core/commands/blscfg.c
|
||||
@@ -629,6 +629,9 @@ static char *expand_val(char *value)
|
||||
char *end = value;
|
||||
bool is_var = false;
|
||||
|
||||
+ if (!value)
|
||||
+ return NULL;
|
||||
+
|
||||
while (*value) {
|
||||
if (*value == '$') {
|
||||
if (start != end) {
|
||||
@@ -732,6 +735,10 @@ static void create_entry (struct bls_entry *entry)
|
||||
|
||||
title = bls_get_val (entry, "title", NULL);
|
||||
options = expand_val (bls_get_val (entry, "options", NULL));
|
||||
+
|
||||
+ if (!options)
|
||||
+ options = expand_val (grub_env_get("default_kernelopts"));
|
||||
+
|
||||
initrds = bls_make_list (entry, "initrd", NULL);
|
||||
|
||||
hotkey = bls_get_val (entry, "grub_hotkey", NULL);
|
||||
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
|
||||
index 22a85c69ea0..2547dd52115 100644
|
||||
--- a/util/grub.d/10_linux.in
|
||||
+++ b/util/grub.d/10_linux.in
|
||||
@@ -158,6 +158,8 @@ linux_entry ()
|
||||
populate_header_warn
|
||||
|
||||
cat << EOF
|
||||
+set default_kernelopts="root=${linux_root_device_thisversion} ro ${args}"
|
||||
+
|
||||
insmod blscfg
|
||||
blscfg
|
||||
if [ -s \$prefix/grubenv ]; then
|
|
@ -0,0 +1,43 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Tue, 26 Feb 2019 21:25:39 +0100
|
||||
Subject: [PATCH] grub-switch-to-blscfg: copy increment.mod for legacy BIOS and
|
||||
ppc64
|
||||
|
||||
This module is also used in newer GRUB config and weren't present in old
|
||||
GRUB installations, so it has to be copied before attempting to generate
|
||||
a BLS configuration.
|
||||
|
||||
Resolves: rhbz#1652806
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
util/grub-switch-to-blscfg.in | 14 ++++++++------
|
||||
1 file changed, 8 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in
|
||||
index eeea1307706..49b3985fadb 100644
|
||||
--- a/util/grub-switch-to-blscfg.in
|
||||
+++ b/util/grub-switch-to-blscfg.in
|
||||
@@ -288,13 +288,15 @@ if [ "${GENERATE}" -eq 1 ] ; then
|
||||
copy_bls
|
||||
|
||||
if [ $arch = "x86_64" ] && [ ! -d /sys/firmware/efi ]; then
|
||||
- if ! cp ${prefix}/lib/grub//i386-pc/blscfg.mod ${grubdir}/i386-pc/ ; then
|
||||
- exit 1
|
||||
- fi
|
||||
+ mod_dir="i386-pc"
|
||||
elif [ $arch = "ppc64" -o $arch = "ppc64le" ] && [ ! -d /sys/firmware/opal ]; then
|
||||
- if ! cp ${prefix}/lib/grub/powerpc-ieee1275/blscfg.mod ${grubdir}/powerpc-ieee1275/ ; then
|
||||
- exit 1
|
||||
- fi
|
||||
+ mod_dir="powerpc-ieee1275"
|
||||
+ fi
|
||||
+
|
||||
+ if [ -n "${mod_dir}" ]; then
|
||||
+ for mod in blscfg increment; do
|
||||
+ cp ${prefix}/lib/grub/${mod_dir}/${mod}.mod ${grubdir}/$mod_dir/ || exit 1
|
||||
+ done
|
||||
fi
|
||||
|
||||
cp -af "${GRUB_CONFIG_FILE}" "${GRUB_CONFIG_FILE}${backupsuffix}"
|
|
@ -0,0 +1,55 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Tue, 19 Mar 2019 01:27:57 +0100
|
||||
Subject: [PATCH] Only set blsdir if /boot/loader/entries is in a btrfs or zfs
|
||||
partition
|
||||
|
||||
Commit bfc756f8d86 ("Set blsdir if the BLS directory path isn't one of the
|
||||
looked up by default") attempted to set blsdir if /boot/loader/entries was
|
||||
not the real path of the directory containing the BLS snippets. Which may
|
||||
be the case if for example /boot/loader/entries is in a btrfs subvolume.
|
||||
|
||||
But in the case of ostree, /boot/loader is a symlink to the directory with
|
||||
the entries for the current deployment. So with ostree the blsdir will be
|
||||
wrongly set, since GRUB is able to follow the symlinks just fine. In fact,
|
||||
it has to follow the symlink since otherwise GRUB will always use the BLS
|
||||
files for the deployment that the symlink pointed out when blsdir was set.
|
||||
|
||||
So only set blsdir if /boot/loader/entries is in a btrfs or zfs partition.
|
||||
|
||||
Related: rhbz#1688453
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
util/grub.d/10_linux.in | 3 ++-
|
||||
util/grub.d/10_linux_bls.in | 3 ++-
|
||||
2 files changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
|
||||
index 2547dd52115..8f7ecf65df9 100644
|
||||
--- a/util/grub.d/10_linux.in
|
||||
+++ b/util/grub.d/10_linux.in
|
||||
@@ -169,7 +169,8 @@ EOF
|
||||
|
||||
if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then
|
||||
blsdir="/boot/loader/entries"
|
||||
- if [ -d "${blsdir}" ]; then
|
||||
+ [ -d "${blsdir}" ] && GRUB_BLS_FS="$(${grub_probe} --target=fs ${blsdir})"
|
||||
+ if [ "x${GRUB_BLS_FS}" = "xbtrfs" ] || [ "x${GRUB_BLS_FS}" = "xzfs" ]; then
|
||||
blsdir=$(make_system_path_relative_to_its_root "${blsdir}")
|
||||
if [ "x${blsdir}" != "x/loader/entries" ] && [ "x${blsdir}" != "x/boot/loader/entries" ]; then
|
||||
${grub_editenv} - set blsdir="${blsdir}"
|
||||
diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in
|
||||
index 47b87c8a14b..1707e86f2d3 100644
|
||||
--- a/util/grub.d/10_linux_bls.in
|
||||
+++ b/util/grub.d/10_linux_bls.in
|
||||
@@ -227,7 +227,8 @@ linux_entry ()
|
||||
|
||||
if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then
|
||||
blsdir="/boot/loader/entries"
|
||||
- if [ -d "${blsdir}" ]; then
|
||||
+ [ -d "${blsdir}" ] && GRUB_BLS_FS="$(${grub_probe} --target=fs ${blsdir})"
|
||||
+ if [ "x${GRUB_BLS_FS}" = "xbtrfs" ] || [ "x${GRUB_BLS_FS}" = "xzfs" ]; then
|
||||
blsdir=$(make_system_path_relative_to_its_root "${blsdir}")
|
||||
if [ "x${blsdir}" != "x/loader/entries" ] && [ "x${blsdir}" != "x/boot/loader/entries" ]; then
|
||||
${grub_editenv} - set blsdir="${blsdir}"
|
|
@ -0,0 +1,76 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Fri, 22 Mar 2019 11:14:26 +0100
|
||||
Subject: [PATCH] blscfg: don't use grub_list_t and the GRUB_AS_LIST() macro
|
||||
|
||||
We are not using GRUB's list functions anyways since we want to add new
|
||||
items in the middle ot the list but GRUB's grub_list_push() only allows
|
||||
to add new items at the beginning of the list. So don't use grub_list_t
|
||||
and GRUB_AS_LIST() macro and just reference struct bls_entry * directly.
|
||||
|
||||
We can't change GRUB lists API because we want the blscfg module to not
|
||||
need external symbols so it can be updated without updating GRUB's core.
|
||||
|
||||
This also solves a bug where the struct bls_entry .next field wasn't set
|
||||
correctly which caused some entries to not be populated in the grub menu.
|
||||
|
||||
Resolves: rhbz#1691232
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
grub-core/commands/blscfg.c | 10 +++++-----
|
||||
include/grub/menu.h | 2 +-
|
||||
2 files changed, 6 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
|
||||
index 5635066e3eb..bb93b7f4904 100644
|
||||
--- a/grub-core/commands/blscfg.c
|
||||
+++ b/grub-core/commands/blscfg.c
|
||||
@@ -350,13 +350,13 @@ static int bls_cmp(const struct bls_entry *e0, const struct bls_entry *e1)
|
||||
return r;
|
||||
}
|
||||
|
||||
-static void list_add_tail(grub_list_t head, grub_list_t item)
|
||||
+static void list_add_tail(struct bls_entry *head, struct bls_entry *item)
|
||||
{
|
||||
item->next = head;
|
||||
if (head->prev)
|
||||
- (*head->prev)->next = item;
|
||||
+ head->prev->next = item;
|
||||
item->prev = head->prev;
|
||||
- head->prev = &item;
|
||||
+ head->prev = item;
|
||||
}
|
||||
|
||||
static int bls_add_entry(struct bls_entry *entry)
|
||||
@@ -378,7 +378,7 @@ static int bls_add_entry(struct bls_entry *entry)
|
||||
|
||||
if (rc == 1) {
|
||||
grub_dprintf ("blscfg", "Add entry with id \"%s\"\n", entry->filename);
|
||||
- list_add_tail (GRUB_AS_LIST (e), GRUB_AS_LIST (entry));
|
||||
+ list_add_tail (e, entry);
|
||||
if (e == entries) {
|
||||
entries = entry;
|
||||
entry->prev = NULL;
|
||||
@@ -391,7 +391,7 @@ static int bls_add_entry(struct bls_entry *entry)
|
||||
if (last) {
|
||||
grub_dprintf ("blscfg", "Add entry with id \"%s\"\n", entry->filename);
|
||||
last->next = entry;
|
||||
- entry->prev = &last;
|
||||
+ entry->prev = last;
|
||||
}
|
||||
|
||||
return 0;
|
||||
diff --git a/include/grub/menu.h b/include/grub/menu.h
|
||||
index eea493f74b1..0acdc2aa6bf 100644
|
||||
--- a/include/grub/menu.h
|
||||
+++ b/include/grub/menu.h
|
||||
@@ -23,7 +23,7 @@
|
||||
struct bls_entry
|
||||
{
|
||||
struct bls_entry *next;
|
||||
- struct bls_entry **prev;
|
||||
+ struct bls_entry *prev;
|
||||
struct keyval **keyvals;
|
||||
int nkeyvals;
|
||||
char *filename;
|
|
@ -0,0 +1,37 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Thu, 28 Mar 2019 16:34:42 +0100
|
||||
Subject: [PATCH] 10_linux_bls: don't add --users option to generated menu
|
||||
entries
|
||||
|
||||
The generated menu entries have a --users $grub_users option but this will
|
||||
fail on old versions of GRUB, since it expects the --users option argument
|
||||
to either be a constant or a variable that has been set.
|
||||
|
||||
The latest GRUB version fix this but the GRUB core isn't updated on a GRUB
|
||||
package update, so this will cause the entries to not be shown in the menu
|
||||
after a system upgrade.
|
||||
|
||||
Since can cause issues and because the entries that weren't generated from
|
||||
the BLS snippets didn't have the --users option either, just don't add it.
|
||||
|
||||
Resolves: rhbz#1693515
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
util/grub.d/10_linux_bls.in | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in
|
||||
index 1707e86f2d3..b8ee9916329 100644
|
||||
--- a/util/grub.d/10_linux_bls.in
|
||||
+++ b/util/grub.d/10_linux_bls.in
|
||||
@@ -180,7 +180,7 @@ populate_menu()
|
||||
for bls in "${files[@]}" ; do
|
||||
read_config "${blsdir}/${bls}.conf"
|
||||
|
||||
- menu="${menu}menuentry '${title}' --class ${grub_class} ${grub_arg} --users ${grub_users} --id ${bls} {\n"
|
||||
+ menu="${menu}menuentry '${title}' --class ${grub_class} ${grub_arg} --id ${bls} {\n"
|
||||
menu="${menu}\t linux ${linux} ${options}\n"
|
||||
if [ -n "${initrd}" ] ; then
|
||||
menu="${menu}\t initrd ${boot_prefix}${initrd}\n"
|
|
@ -0,0 +1,152 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Christian Glombek <lorbus@fedoraproject.org>
|
||||
Date: Tue, 2 Apr 2019 16:22:21 +0200
|
||||
Subject: [PATCH] grub.d: Split out boot success reset from menu auto hide
|
||||
script
|
||||
|
||||
Also rename fallback and menu auto hide script to be executed
|
||||
before and after boot success reset script.
|
||||
In menu auto hide script, rename last_boot_ok var to menu_hide_ok
|
||||
---
|
||||
Makefile.util.def | 8 +++----
|
||||
...allback_counting.in => 08_fallback_counting.in} | 14 ++++++------
|
||||
util/grub.d/10_reset_boot_success.in | 25 ++++++++++++++++++++++
|
||||
.../{01_menu_auto_hide.in => 12_menu_auto_hide.in} | 23 +++++---------------
|
||||
4 files changed, 42 insertions(+), 28 deletions(-)
|
||||
rename util/grub.d/{01_fallback_counting.in => 08_fallback_counting.in} (65%)
|
||||
create mode 100644 util/grub.d/10_reset_boot_success.in
|
||||
rename util/grub.d/{01_menu_auto_hide.in => 12_menu_auto_hide.in} (58%)
|
||||
|
||||
diff --git a/Makefile.util.def b/Makefile.util.def
|
||||
index eca3dfa753f..cae6002d2e3 100644
|
||||
--- a/Makefile.util.def
|
||||
+++ b/Makefile.util.def
|
||||
@@ -449,14 +449,14 @@ script = {
|
||||
};
|
||||
|
||||
script = {
|
||||
- name = '01_fallback_counting';
|
||||
- common = util/grub.d/01_fallback_counting.in;
|
||||
+ name = '08_fallback_counting';
|
||||
+ common = util/grub.d/08_fallback_counting.in;
|
||||
installdir = grubconf;
|
||||
};
|
||||
|
||||
script = {
|
||||
- name = '01_menu_auto_hide';
|
||||
- common = util/grub.d/01_menu_auto_hide.in;
|
||||
+ name = '12_menu_auto_hide';
|
||||
+ common = util/grub.d/12_menu_auto_hide.in;
|
||||
installdir = grubconf;
|
||||
};
|
||||
|
||||
diff --git a/util/grub.d/01_fallback_counting.in b/util/grub.d/08_fallback_counting.in
|
||||
similarity index 65%
|
||||
rename from util/grub.d/01_fallback_counting.in
|
||||
rename to util/grub.d/08_fallback_counting.in
|
||||
index be0e770ea82..2e2c3ff7d31 100644
|
||||
--- a/util/grub.d/01_fallback_counting.in
|
||||
+++ b/util/grub.d/08_fallback_counting.in
|
||||
@@ -1,15 +1,17 @@
|
||||
#! /bin/sh -e
|
||||
-
|
||||
-# Boot Counting
|
||||
+# Fallback Countdown
|
||||
+#
|
||||
+# This snippet depends on 10_reset_boot_success and needs to be kept in sync.
|
||||
+#
|
||||
# The boot_counter env var can be used to count down boot attempts after an
|
||||
-# OSTree upgrade and choose the rollback deployment when 0 is reached. Both
|
||||
-# boot_counter and boot_success need to be (re-)set from userspace.
|
||||
+# OSTree upgrade and choose the rollback deployment when 0 is reached.
|
||||
+# Both boot_counter=X and boot_success=1 need to be set from userspace.
|
||||
cat << EOF
|
||||
insmod increment
|
||||
# Check if boot_counter exists and boot_success=0 to activate this behaviour.
|
||||
if [ -n "\${boot_counter}" -a "\${boot_success}" = "0" ]; then
|
||||
- # if countdown has ended, choose to boot rollback deployment (default=1 on
|
||||
- # OSTree-based systems)
|
||||
+ # if countdown has ended, choose to boot rollback deployment,
|
||||
+ # i.e. default=1 on OSTree-based systems.
|
||||
if [ "\${boot_counter}" = "0" -o "\${boot_counter}" = "-1" ]; then
|
||||
set default=1
|
||||
set boot_counter=-1
|
||||
diff --git a/util/grub.d/10_reset_boot_success.in b/util/grub.d/10_reset_boot_success.in
|
||||
new file mode 100644
|
||||
index 00000000000..6c88d933dde
|
||||
--- /dev/null
|
||||
+++ b/util/grub.d/10_reset_boot_success.in
|
||||
@@ -0,0 +1,25 @@
|
||||
+#! /bin/sh -e
|
||||
+# Reset Boot Success
|
||||
+#
|
||||
+# The 08_fallback_counting and 12_menu_auto_hide snippets rely on this one
|
||||
+# and need to be kept in sync.
|
||||
+#
|
||||
+# The boot_success var needs to be set to 1 from userspace to mark a boot successful.
|
||||
+cat << EOF
|
||||
+insmod increment
|
||||
+# Hiding the menu is ok if last boot was ok or if this is a first boot attempt to boot the entry
|
||||
+if [ "\${boot_success}" = "1" -o "\${boot_indeterminate}" = "1" ]; then
|
||||
+ set menu_hide_ok=1
|
||||
+else
|
||||
+ set menu_hide_ok=0
|
||||
+fi
|
||||
+# Reset boot_indeterminate after a successful boot, increment otherwise
|
||||
+if [ "\${boot_success}" = "1" ] ; then
|
||||
+ set boot_indeterminate=0
|
||||
+else
|
||||
+ increment boot_indeterminate
|
||||
+fi
|
||||
+# Reset boot_success for current boot
|
||||
+set boot_success=0
|
||||
+save_env boot_success boot_indeterminate
|
||||
+EOF
|
||||
diff --git a/util/grub.d/01_menu_auto_hide.in b/util/grub.d/12_menu_auto_hide.in
|
||||
similarity index 58%
|
||||
rename from util/grub.d/01_menu_auto_hide.in
|
||||
rename to util/grub.d/12_menu_auto_hide.in
|
||||
index ad175870a54..6a7c0fa0d43 100644
|
||||
--- a/util/grub.d/01_menu_auto_hide.in
|
||||
+++ b/util/grub.d/12_menu_auto_hide.in
|
||||
@@ -1,5 +1,8 @@
|
||||
#! /bin/sh
|
||||
-
|
||||
+# Menu Auto Hide
|
||||
+#
|
||||
+# This snippet depends on 10_reset_boot_success and needs to be kept in sync.
|
||||
+#
|
||||
# Disable / skip generating menu-auto-hide config parts on serial terminals
|
||||
for x in ${GRUB_TERMINAL_INPUT} ${GRUB_TERMINAL_OUTPUT}; do
|
||||
case "$x" in
|
||||
@@ -10,29 +13,13 @@ for x in ${GRUB_TERMINAL_INPUT} ${GRUB_TERMINAL_OUTPUT}; do
|
||||
done
|
||||
|
||||
cat << EOF
|
||||
-if [ "\${boot_success}" = "1" -o "\${boot_indeterminate}" = "1" ]; then
|
||||
- set last_boot_ok=1
|
||||
-else
|
||||
- set last_boot_ok=0
|
||||
-fi
|
||||
-
|
||||
-# Reset boot_indeterminate after a successful boot
|
||||
-if [ "\${boot_success}" = "1" ] ; then
|
||||
- set boot_indeterminate=0
|
||||
-# Avoid boot_indeterminate causing the menu to be hidden more then once
|
||||
-elif [ "\${boot_indeterminate}" = "1" ]; then
|
||||
- set boot_indeterminate=2
|
||||
-fi
|
||||
-set boot_success=0
|
||||
-save_env boot_success boot_indeterminate
|
||||
-
|
||||
if [ x\$feature_timeout_style = xy ] ; then
|
||||
if [ "\${menu_show_once}" ]; then
|
||||
unset menu_show_once
|
||||
save_env menu_show_once
|
||||
set timeout_style=menu
|
||||
set timeout=60
|
||||
- elif [ "\${menu_auto_hide}" -a "\${last_boot_ok}" = "1" ]; then
|
||||
+ elif [ "\${menu_auto_hide}" -a "\${menu_hide_ok}" = "1" ]; then
|
||||
set orig_timeout_style=\${timeout_style}
|
||||
set orig_timeout=\${timeout}
|
||||
if [ "\${fastboot}" = "1" ]; then
|
|
@ -0,0 +1,22 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stephen Benjamin <stephen@redhat.com>
|
||||
Date: Fri, 12 Apr 2019 10:43:13 -0400
|
||||
Subject: [PATCH] HTTP boot: strncmp returns 0 on equal
|
||||
|
||||
---
|
||||
grub-core/net/efi/http.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c
|
||||
index 2a9624dacc4..484e0c68cee 100644
|
||||
--- a/grub-core/net/efi/http.c
|
||||
+++ b/grub-core/net/efi/http.c
|
||||
@@ -19,7 +19,7 @@ http_configure (struct grub_efi_net_device *dev, int prefer_ip6)
|
||||
const char *rest, *http_server, *http_path = NULL;
|
||||
|
||||
http_server = grub_env_get ("root");
|
||||
- https = grub_strncmp (http_server, "https", 5) ? 1 : 0;
|
||||
+ https = (grub_strncmp (http_server, "https", 5) == 0) ? 1 : 0;
|
||||
|
||||
/* extract http server + port */
|
||||
if (http_server)
|
|
@ -0,0 +1,29 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Thu, 18 Apr 2019 19:16:18 +0200
|
||||
Subject: [PATCH] Add 10_reset_boot_success to Makefile
|
||||
|
||||
This was missing in a previous commit that added this script.
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
Makefile.util.def | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
diff --git a/Makefile.util.def b/Makefile.util.def
|
||||
index cae6002d2e3..5062a0e50fa 100644
|
||||
--- a/Makefile.util.def
|
||||
+++ b/Makefile.util.def
|
||||
@@ -515,6 +515,12 @@ script = {
|
||||
condition = COND_HOST_LINUX;
|
||||
};
|
||||
|
||||
+script = {
|
||||
+ name = '10_reset_boot_success';
|
||||
+ common = util/grub.d/10_reset_boot_success.in;
|
||||
+ installdir = grubconf;
|
||||
+};
|
||||
+
|
||||
script = {
|
||||
name = '10_xnu';
|
||||
common = util/grub.d/10_xnu.in;
|
|
@ -0,0 +1,58 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Tue, 7 May 2019 13:54:23 +0200
|
||||
Subject: [PATCH] blscfg: remove BLS file size check
|
||||
|
||||
The read_entry() function checks the BLS file size and ignores the entry
|
||||
if the file size isn't correct. The problem is that it will only work if
|
||||
the struct grub_file layout and fields are the same in the GRUB version
|
||||
used to build the blscfg.mod, than the one that's installed as GRUB core.
|
||||
|
||||
But commit 84a0e9699f8 ("Add progress module to display load progress of
|
||||
files.") added a .name field to struct grub_file, and this change landed
|
||||
in the GRUB version used by Fedora 21.
|
||||
|
||||
Since the GRUB core is never updated when the grub2 package is upgraded,
|
||||
the blscfg module won't be compatible with any GRUB that was installed by
|
||||
Fedora 20 or eralier.
|
||||
|
||||
The blscfg.mod is copied to /boot/grub2/i386-pc/ in legacy BIOS installs
|
||||
when the GRUB configuration is switched to BLS, so this will lead to BLS
|
||||
files being ignored due grub_file_size() reporting wrong file sizes. This
|
||||
is caused by the struct grub_file .size field offset being different in
|
||||
Fedora 20 than later releases.
|
||||
|
||||
This check is doing more harm than good, so let's just remove it to make
|
||||
the blscfg module compatible at least up to GRUB core that was installed
|
||||
by Fedora 19.
|
||||
|
||||
Related: rhbz#1652806
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
grub-core/commands/blscfg.c | 5 -----
|
||||
1 file changed, 5 deletions(-)
|
||||
|
||||
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
|
||||
index bb93b7f4904..bd008b04bec 100644
|
||||
--- a/grub-core/commands/blscfg.c
|
||||
+++ b/grub-core/commands/blscfg.c
|
||||
@@ -412,7 +412,6 @@ static int read_entry (
|
||||
int rc = 0;
|
||||
char *p = NULL;
|
||||
grub_file_t f = NULL;
|
||||
- grub_off_t sz;
|
||||
struct bls_entry *entry;
|
||||
struct read_entry_info *info = (struct read_entry_info *)data;
|
||||
|
||||
@@ -442,10 +441,6 @@ static int read_entry (
|
||||
goto finish;
|
||||
}
|
||||
|
||||
- sz = grub_file_size (f);
|
||||
- if (sz == GRUB_FILE_SIZE_UNKNOWN || sz > 1024*1024)
|
||||
- goto finish;
|
||||
-
|
||||
entry = grub_zalloc (sizeof (*entry));
|
||||
if (!entry)
|
||||
goto finish;
|
|
@ -0,0 +1,27 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Tue, 14 May 2019 20:37:44 +0200
|
||||
Subject: [PATCH] Remove bogus load_env after blscfg command in 10_linux
|
||||
|
||||
The grubenv is already loaded in the 00_header snippet, so there's
|
||||
no need to load it anywhere else.
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
util/grub.d/10_linux.in | 3 ---
|
||||
1 file changed, 3 deletions(-)
|
||||
|
||||
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
|
||||
index 8f7ecf65df9..350903fa5ab 100644
|
||||
--- a/util/grub.d/10_linux.in
|
||||
+++ b/util/grub.d/10_linux.in
|
||||
@@ -162,9 +162,6 @@ set default_kernelopts="root=${linux_root_device_thisversion} ro ${args}"
|
||||
|
||||
insmod blscfg
|
||||
blscfg
|
||||
-if [ -s \$prefix/grubenv ]; then
|
||||
- load_env
|
||||
-fi
|
||||
EOF
|
||||
|
||||
if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then
|
|
@ -0,0 +1,44 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Wed, 15 May 2019 01:46:00 +0200
|
||||
Subject: [PATCH] blscfg: Don't leave grub_errno set to an error if the command
|
||||
succeeded
|
||||
|
||||
After a command is executed, the function grub_print_error() is called to
|
||||
print any active error messages if these exist.
|
||||
|
||||
The blscfg command calls to the grub_strtol() function to try to convert
|
||||
the default entry string to a number, in case the default is an index.
|
||||
|
||||
If this function is not able to do the conversion, it sets the grub_errno
|
||||
variable to GRUB_ERR_BAD_NUMBER. But the blscfg command wrongly left that
|
||||
set and so the caller would be confused thinking that the command failed
|
||||
and that an error message has to be printed.
|
||||
|
||||
This caused the first error in the stack to be printed, polluting the GRUB
|
||||
output and preventing the menu to be hidden. So reset the grub_error var
|
||||
to GRUB_ERR_NONE again if was set to GRUB_ERR_BAD_NUMBER by grub_strtol().
|
||||
|
||||
Resolves: rhbz#1699761
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
---
|
||||
grub-core/commands/blscfg.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
|
||||
index bd008b04bec..26dbe873fe4 100644
|
||||
--- a/grub-core/commands/blscfg.c
|
||||
+++ b/grub-core/commands/blscfg.c
|
||||
@@ -999,8 +999,10 @@ is_default_entry(const char *def_entry, struct bls_entry *entry, int idx)
|
||||
return true;
|
||||
|
||||
def_idx = (int)grub_strtol(def_entry, NULL, 0);
|
||||
- if (grub_errno == GRUB_ERR_BAD_NUMBER)
|
||||
+ if (grub_errno == GRUB_ERR_BAD_NUMBER) {
|
||||
+ grub_errno = GRUB_ERR_NONE;
|
||||
return false;
|
||||
+ }
|
||||
|
||||
if (def_idx == idx)
|
||||
return true;
|
|
@ -16,8 +16,8 @@ KERNEL_DIR="${KERNEL_IMAGE%/*}"
|
|||
|
||||
MACHINE_ID=$KERNEL_INSTALL_MACHINE_ID
|
||||
|
||||
# Remove it, since for grub2 the images are always installed in /boot
|
||||
rm -rf "${BOOT_DIR_ABS%/*}"
|
||||
# If ${BOOT_DIR_ABS} exists, some other boot loader is active.
|
||||
[[ -d "${BOOT_DIR_ABS}" ]] && exit 0
|
||||
|
||||
BLS_DIR="/boot/loader/entries"
|
||||
|
||||
|
@ -62,6 +62,7 @@ case "$COMMAND" in
|
|||
"$KERNEL_DIR"/dtb
|
||||
do
|
||||
[[ -e "$i" ]] || continue
|
||||
rm -f "/boot/${i##*/}-${KERNEL_VERSION}"
|
||||
cp -aT "$i" "/boot/${i##*/}-${KERNEL_VERSION}"
|
||||
command -v restorecon &>/dev/null && \
|
||||
restorecon -R "/boot/${i##*/}-${KERNEL_VERSION}"
|
||||
|
@ -69,6 +70,7 @@ case "$COMMAND" in
|
|||
# hmac is .vmlinuz-<version>.hmac so needs a special treatment
|
||||
i="$KERNEL_DIR/.${KERNEL_IMAGE##*/}.hmac"
|
||||
if [[ -e "$i" ]]; then
|
||||
rm -f "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
|
||||
cp -a "$i" "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
|
||||
command -v restorecon &>/dev/null && \
|
||||
restorecon "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
|
||||
|
@ -92,6 +94,7 @@ case "$COMMAND" in
|
|||
INITRD="$(grep '^initrd[ \t]' "${BLS_TARGET}" | sed -e 's,^initrd[ \t]*,,')"
|
||||
LINUX_RELPATH="$(grub2-mkrelpath /boot${LINUX})"
|
||||
BOOTPREFIX="$(dirname ${LINUX_RELPATH})"
|
||||
ROOTPREFIX="$(dirname "/boot${LINUX}")"
|
||||
|
||||
if [[ $LINUX != $LINUX_RELPATH ]]; then
|
||||
sed -i -e "s,^linux.*,linux ${BOOTPREFIX}${LINUX},g" "${BLS_TARGET}"
|
||||
|
@ -124,10 +127,10 @@ case "$COMMAND" in
|
|||
fi
|
||||
|
||||
# this probably isn't the best place to do this, but it will do for now.
|
||||
if [ -e "${BOOTPREFIX}${INITRD}" -a -e "${BOOTPREFIX}${LINUX}" -a \
|
||||
"${BOOTPREFIX}${INITRD}" -ot "${BOOTPREFIX}${LINUX}" -a \
|
||||
if [ -e "${ROOTPREFIX}${INITRD}" -a -e "${ROOTPREFIX}${LINUX}" -a \
|
||||
"${ROOTPREFIX}${INITRD}" -ot "${ROOTPREFIX}${LINUX}" -a \
|
||||
-x /usr/lib/kernel/install.d/50-dracut.install ]; then
|
||||
rm -f "${BOOTPREFIX}${INITRD}"
|
||||
rm -f "${ROOTPREFIX}${INITRD}"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
@ -17,7 +17,7 @@ COMMAND="$1"
|
|||
|
||||
case "$COMMAND" in
|
||||
add|remove)
|
||||
grub2-mkconfig -o /boot/grub2/grub.cfg >& /dev/null
|
||||
grub2-mkconfig --no-grubenv-update -o /boot/grub2/grub.cfg >& /dev/null
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
|
|
|
@ -532,7 +532,7 @@ touch ${RPM_BUILD_ROOT}/boot/%{name}/grub.cfg \
|
|||
%dir %attr(0700,root,root)%{efi_esp_dir}/fonts \
|
||||
%dir %attr(0700,root,root)/boot/loader/entries \
|
||||
%ghost %config(noreplace) %attr(0700,root,root)%{efi_esp_dir}/grub.cfg \
|
||||
/boot/grub2/grubenv \
|
||||
%config(noreplace) /boot/grub2/grubenv \
|
||||
%ghost %config(noreplace) %attr(0700,root,root)%{efi_esp_dir}/grubenv \
|
||||
%{expand:%if 0%{?without_efi_modules} \
|
||||
%exclude %{_libdir}/grub/%{6} \
|
||||
|
|
11
grub.patches
11
grub.patches
|
@ -281,3 +281,14 @@ Patch0280: 0280-Try-to-set-fPIE-and-friends-on-libgnu.a.patch
|
|||
Patch0281: 0281-Don-t-make-grub_strtoull-print-an-error-if-no-conver.patch
|
||||
Patch0282: 0282-Set-blsdir-if-the-BLS-directory-path-isn-t-one-of-th.patch
|
||||
Patch0283: 0283-Check-if-blsdir-exists-before-attempting-to-get-it-s.patch
|
||||
Patch0284: 0284-blscfg-fallback-to-default_kernelopts-if-BLS-option-.patch
|
||||
Patch0285: 0285-grub-switch-to-blscfg-copy-increment.mod-for-legacy-.patch
|
||||
Patch0286: 0286-Only-set-blsdir-if-boot-loader-entries-is-in-a-btrfs.patch
|
||||
Patch0287: 0287-blscfg-don-t-use-grub_list_t-and-the-GRUB_AS_LIST-ma.patch
|
||||
Patch0288: 0288-10_linux_bls-don-t-add-users-option-to-generated-men.patch
|
||||
Patch0289: 0289-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch
|
||||
Patch0290: 0290-HTTP-boot-strncmp-returns-0-on-equal.patch
|
||||
Patch0291: 0291-Add-10_reset_boot_success-to-Makefile.patch
|
||||
Patch0292: 0292-blscfg-remove-BLS-file-size-check.patch
|
||||
Patch0293: 0293-Remove-bogus-load_env-after-blscfg-command-in-10_lin.patch
|
||||
Patch0294: 0294-blscfg-Don-t-leave-grub_errno-set-to-an-error-if-the.patch
|
||||
|
|
69
grub2.spec
69
grub2.spec
|
@ -7,7 +7,7 @@
|
|||
Name: grub2
|
||||
Epoch: 1
|
||||
Version: 2.02
|
||||
Release: 70%{?dist}
|
||||
Release: 81%{?dist}
|
||||
Summary: Bootloader with support for Linux, Multiboot and more
|
||||
License: GPLv3+
|
||||
URL: http://www.gnu.org/software/grub/
|
||||
|
@ -215,8 +215,6 @@ install -d -m 0755 %{buildroot}%{_prefix}/lib/kernel/install.d/
|
|||
install -D -m 0755 -t %{buildroot}%{_prefix}/lib/kernel/install.d/ %{SOURCE9}
|
||||
install -D -m 0755 -t %{buildroot}%{_prefix}/lib/kernel/install.d/ %{SOURCE13}
|
||||
install -d -m 0755 %{buildroot}%{_sysconfdir}/kernel/install.d/
|
||||
install -m 0644 /dev/null %{buildroot}%{_sysconfdir}/kernel/install.d/20-grubby.install
|
||||
install -m 0644 /dev/null %{buildroot}%{_sysconfdir}/kernel/install.d/90-loaderentry.install
|
||||
# Install systemd user service to set the boot_success flag
|
||||
install -D -m 0755 -t %{buildroot}%{_userunitdir} \
|
||||
docs/grub-boot-success.{timer,service}
|
||||
|
@ -278,6 +276,13 @@ elif [ -f /etc/grub.d/01_users ] && \
|
|||
fi
|
||||
fi
|
||||
|
||||
%posttrans tools
|
||||
|
||||
if [ -f /etc/default/grub ]; then
|
||||
! grep -q '^GRUB_ENABLE_BLSCFG=.*' /etc/default/grub && \
|
||||
/sbin/grub2-switch-to-blscfg --backup-suffix=.rpmsave &>/dev/null || :
|
||||
fi
|
||||
|
||||
%triggerun -- grub2 < 1:1.99-4
|
||||
# grub2 < 1.99-4 removed a number of essential files in postun. To fix upgrades
|
||||
# from the affected grub2 packages, we first back up the files in triggerun and
|
||||
|
@ -310,8 +315,6 @@ rm -r /boot/grub2.tmp/ || :
|
|||
%exclude %{_datarootdir}/grub/themes/*
|
||||
%attr(0700,root,root) %dir %{_sysconfdir}/grub.d
|
||||
%{_prefix}/lib/kernel/install.d/20-grub.install
|
||||
%{_sysconfdir}/kernel/install.d/20-grubby.install
|
||||
%{_sysconfdir}/kernel/install.d/90-loaderentry.install
|
||||
%{_prefix}/lib/kernel/install.d/99-grub-mkconfig.install
|
||||
%dir %{_datarootdir}/grub
|
||||
%exclude %{_datarootdir}/grub/*
|
||||
|
@ -473,6 +476,62 @@ rm -r /boot/grub2.tmp/ || :
|
|||
%endif
|
||||
|
||||
%changelog
|
||||
* Mon May 20 2019 Javier Martinez Canillas <javierm@redhat.com> - 2.02-81
|
||||
- Don't try to switch to a BLS config if GRUB_ENABLE_BLSCFG is already set
|
||||
|
||||
* Wed May 15 2019 Javier Martinez Canillas <javierm@redhat.com> - 2.02-80
|
||||
- Fix error messages wrongly being printed when executing blscfg command
|
||||
Resolves: rhbz#1699761
|
||||
- Remove bogus load_env after blscfg command in 10_linux
|
||||
|
||||
* Tue May 07 2019 Javier Martinez Canillas <javierm@redhat.com> - 2.02-79
|
||||
- Make blscfg module compatible at least up to the Fedora 19 GRUB core
|
||||
Related: rhbz#1652806
|
||||
|
||||
* Thu Apr 18 2019 Javier Martinez Canillas <javierm@redhat.com> - 2.02-78
|
||||
- Add 10_reset_boot_success to Makefile
|
||||
Related: rhbz#1701003
|
||||
|
||||
* Thu Apr 18 2019 Javier Martinez Canillas <javierm@redhat.com> - 2.02-77
|
||||
- grub.d: Split out boot success reset from menu auto hide script (lorbus)
|
||||
Resolves: rhbz#1701003
|
||||
- HTTP boot: strncmp returns 0 on equal (stephen)
|
||||
|
||||
* Mon Apr 15 2019 Javier Martinez Canillas <javierm@redhat.com> - 2.02-76
|
||||
- Execute grub2-switch-to-blscfg script in %%posttrans instead of %%post
|
||||
Resolves: rhbz#1652806
|
||||
|
||||
* Thu Mar 28 2019 Javier Martinez Canillas <javierm@redhat.com> - 2.02-75
|
||||
- 10_linux_bls: don't add --users option to generated menu entries
|
||||
Resolves: rhbz#1693515
|
||||
|
||||
* Fri Mar 22 2019 Javier Martinez Canillas <javierm@redhat.com> 2.02-74
|
||||
- Only set blsdir if /boot/loader/entries is in a btrfs or zfs partition
|
||||
Related: rhbz#1688453
|
||||
- Fix some BLS snippets not being displayed in the GRUB menu
|
||||
Resolves: rhbz#1691232
|
||||
|
||||
* Tue Mar 12 2019 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 2.02-73
|
||||
- Never remove boot loader configuration for other boot loaders from the ESP.
|
||||
This would render machines with sd-boot unbootable (#1648907).
|
||||
- Do not mask systemd's kernel-install scriptlets.
|
||||
|
||||
* Mon Mar 11 2019 Javier Martinez Canillas <javierm@redhat.com> - 2.02-72
|
||||
- Avoid grub2-efi package to overwrite existing /boot/grub2/grubenv file
|
||||
Resolves: rhbz#1687323
|
||||
- Switch to BLS in tools package %%post scriptlet
|
||||
Resolves: rhbz#1652806
|
||||
|
||||
* Wed Feb 27 2019 Javier Martinez Canillas <javierm@redhat.com> - 2.02-71
|
||||
- 20-grub-install: Replace, rather than overwrite, the existing kernel (pjones)
|
||||
Resolves: rhbz#1642402
|
||||
- 99-grub-mkconfig: Don't update grubenv generating entries on ppc64le
|
||||
Related: rhbz#1637875
|
||||
- blscfg: fallback to default_kernelopts if BLS option field isn't set
|
||||
Related: rhbz#1625124
|
||||
- grub-switch-to-blscfg: copy increment.mod for legacy BIOS and ppc64
|
||||
Resolves: rhbz#1652806
|
||||
|
||||
* Fri Feb 15 2019 Javier Martinez Canillas <javierm@redhat.com> - 2.02-70
|
||||
- Check if blsdir exists before attempting to get it's real path
|
||||
Resolves: rhbz#1677415
|
||||
|
|
Loading…
Reference in New Issue