Handle os-prober and tftp path generation better.
- Try to emit linux16/initrd16 and linuxefi/initrdefi when appropriate in 30_os-prober. Resolves: rhbz#1108296 - If $fw_path doesn't work to find the config file, try $prefix as well Resolves: rhbz#1148652 Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
parent
58fe9aa736
commit
9d85b1d3af
211
0153-Try-prefix-if-fw_path-doesn-t-work.patch
Normal file
211
0153-Try-prefix-if-fw_path-doesn-t-work.patch
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
From b5adb83344dfeb6ff142dc41bd2a82d29029c1c2 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Peter Jones <pjones@redhat.com>
|
||||||
|
Date: Fri, 3 Oct 2014 11:08:03 -0400
|
||||||
|
Subject: [PATCH 153/154] Try $prefix if $fw_path doesn't work.
|
||||||
|
|
||||||
|
Related: rhbz#1148652
|
||||||
|
|
||||||
|
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||||
|
---
|
||||||
|
grub-core/kern/ieee1275/init.c | 30 ++++++-----
|
||||||
|
grub-core/net/net.c | 2 +-
|
||||||
|
grub-core/normal/main.c | 118 ++++++++++++++++++++---------------------
|
||||||
|
3 files changed, 75 insertions(+), 75 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c
|
||||||
|
index 8191f8c..8ca4bf7 100644
|
||||||
|
--- a/grub-core/kern/ieee1275/init.c
|
||||||
|
+++ b/grub-core/kern/ieee1275/init.c
|
||||||
|
@@ -131,23 +131,25 @@ grub_machine_get_bootlocation (char **device, char **path)
|
||||||
|
grub_free (canon);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
- *device = grub_ieee1275_encode_devname (bootpath);
|
||||||
|
- grub_free (type);
|
||||||
|
-
|
||||||
|
- filename = grub_ieee1275_get_filename (bootpath);
|
||||||
|
- if (filename)
|
||||||
|
{
|
||||||
|
- char *lastslash = grub_strrchr (filename, '\\');
|
||||||
|
-
|
||||||
|
- /* Truncate at last directory. */
|
||||||
|
- if (lastslash)
|
||||||
|
+ filename = grub_ieee1275_get_filename (bootpath);
|
||||||
|
+ if (filename)
|
||||||
|
{
|
||||||
|
- *lastslash = '\0';
|
||||||
|
- grub_translate_ieee1275_path (filename);
|
||||||
|
-
|
||||||
|
- *path = filename;
|
||||||
|
- }
|
||||||
|
+ char *lastslash = grub_strrchr (filename, '\\');
|
||||||
|
+
|
||||||
|
+ /* Truncate at last directory. */
|
||||||
|
+ if (lastslash)
|
||||||
|
+ {
|
||||||
|
+ *lastslash = '\0';
|
||||||
|
+ grub_translate_ieee1275_path (filename);
|
||||||
|
+
|
||||||
|
+ *path = filename;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ *device = grub_ieee1275_encode_devname (bootpath);
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ grub_free (type);
|
||||||
|
grub_free (bootpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/grub-core/net/net.c b/grub-core/net/net.c
|
||||||
|
index 578e057..10bfed3 100644
|
||||||
|
--- a/grub-core/net/net.c
|
||||||
|
+++ b/grub-core/net/net.c
|
||||||
|
@@ -1817,7 +1817,7 @@ grub_net_search_configfile (char *config)
|
||||||
|
/* Remove the remaining minus sign at the end. */
|
||||||
|
config[config_len] = '\0';
|
||||||
|
|
||||||
|
- return GRUB_ERR_NONE;
|
||||||
|
+ return GRUB_ERR_FILE_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct grub_preboot *fini_hnd;
|
||||||
|
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
|
||||||
|
index 4190985..aa14499 100644
|
||||||
|
--- a/grub-core/normal/main.c
|
||||||
|
+++ b/grub-core/normal/main.c
|
||||||
|
@@ -331,74 +331,72 @@ grub_enter_normal_mode (const char *config)
|
||||||
|
grub_boot_time ("Exiting normal mode");
|
||||||
|
}
|
||||||
|
|
||||||
|
+static grub_err_t
|
||||||
|
+grub_try_normal (const char *variable)
|
||||||
|
+{
|
||||||
|
+ char *config;
|
||||||
|
+ const char *prefix;
|
||||||
|
+ grub_err_t err = GRUB_ERR_FILE_NOT_FOUND;
|
||||||
|
+
|
||||||
|
+ prefix = grub_env_get (variable);
|
||||||
|
+ if (!prefix)
|
||||||
|
+ return GRUB_ERR_FILE_NOT_FOUND;
|
||||||
|
+
|
||||||
|
+ if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0)
|
||||||
|
+ {
|
||||||
|
+ grub_size_t config_len;
|
||||||
|
+ config_len = grub_strlen (prefix) +
|
||||||
|
+ sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
|
||||||
|
+ config = grub_malloc (config_len);
|
||||||
|
+
|
||||||
|
+ if (! config)
|
||||||
|
+ return GRUB_ERR_FILE_NOT_FOUND;
|
||||||
|
+
|
||||||
|
+ grub_snprintf (config, config_len, "%s/grub.cfg", prefix);
|
||||||
|
+ err = grub_net_search_configfile (config);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (err != GRUB_ERR_NONE)
|
||||||
|
+ {
|
||||||
|
+ config = grub_xasprintf ("%s/grub.cfg", prefix);
|
||||||
|
+ if (config)
|
||||||
|
+ {
|
||||||
|
+ grub_file_t file;
|
||||||
|
+ file = grub_file_open (config);
|
||||||
|
+ if (file)
|
||||||
|
+ {
|
||||||
|
+ grub_file_close (file);
|
||||||
|
+ err = GRUB_ERR_NONE;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (err == GRUB_ERR_NONE)
|
||||||
|
+ grub_enter_normal_mode (config);
|
||||||
|
+
|
||||||
|
+ grub_errno = 0;
|
||||||
|
+ grub_free (config);
|
||||||
|
+ return err;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/* Enter normal mode from rescue mode. */
|
||||||
|
static grub_err_t
|
||||||
|
grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
|
||||||
|
int argc, char *argv[])
|
||||||
|
{
|
||||||
|
- if (argc == 0)
|
||||||
|
+ if (argc)
|
||||||
|
+ grub_enter_normal_mode (argv[0]);
|
||||||
|
+ else
|
||||||
|
{
|
||||||
|
- /* Guess the config filename. It is necessary to make CONFIG static,
|
||||||
|
- so that it won't get broken by longjmp. */
|
||||||
|
- char *config;
|
||||||
|
- const char *prefix;
|
||||||
|
-
|
||||||
|
- prefix = grub_env_get ("fw_path");
|
||||||
|
- if (! prefix)
|
||||||
|
- prefix = grub_env_get ("prefix");
|
||||||
|
-
|
||||||
|
- if (prefix)
|
||||||
|
- {
|
||||||
|
- if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0)
|
||||||
|
- {
|
||||||
|
- grub_size_t config_len;
|
||||||
|
- config_len = grub_strlen (prefix) +
|
||||||
|
- sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
|
||||||
|
- config = grub_malloc (config_len);
|
||||||
|
-
|
||||||
|
- if (! config)
|
||||||
|
- goto quit;
|
||||||
|
-
|
||||||
|
- grub_snprintf (config, config_len, "%s/grub.cfg", prefix);
|
||||||
|
-
|
||||||
|
- grub_net_search_configfile (config);
|
||||||
|
-
|
||||||
|
- grub_enter_normal_mode (config);
|
||||||
|
- grub_free (config);
|
||||||
|
- config = NULL;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (!config)
|
||||||
|
- {
|
||||||
|
- config = grub_xasprintf ("%s/grub.cfg", prefix);
|
||||||
|
- if (config)
|
||||||
|
- {
|
||||||
|
- grub_file_t file;
|
||||||
|
-
|
||||||
|
- file = grub_file_open (config);
|
||||||
|
- if (file)
|
||||||
|
- {
|
||||||
|
- grub_file_close (file);
|
||||||
|
- grub_enter_normal_mode (config);
|
||||||
|
- }
|
||||||
|
- else
|
||||||
|
- {
|
||||||
|
- /* Ignore all errors. */
|
||||||
|
- grub_errno = 0;
|
||||||
|
- }
|
||||||
|
- grub_free (config);
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- else
|
||||||
|
- {
|
||||||
|
- grub_enter_normal_mode (0);
|
||||||
|
- }
|
||||||
|
+ /* Guess the config filename. */
|
||||||
|
+ grub_err_t err;
|
||||||
|
+ err = grub_try_normal ("fw_path");
|
||||||
|
+ if (err == GRUB_ERR_FILE_NOT_FOUND)
|
||||||
|
+ err = grub_try_normal ("prefix");
|
||||||
|
+ if (err == GRUB_ERR_FILE_NOT_FOUND)
|
||||||
|
+ grub_enter_normal_mode (0);
|
||||||
|
}
|
||||||
|
- else
|
||||||
|
- grub_enter_normal_mode (argv[0]);
|
||||||
|
|
||||||
|
-quit:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
1.9.3
|
||||||
|
|
@ -0,0 +1,77 @@
|
|||||||
|
From 53e38c3eefd1e5f41bf1f3b5bc7bae4e5b667ff1 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Peter Jones <pjones@redhat.com>
|
||||||
|
Date: Mon, 27 Oct 2014 09:22:55 -0400
|
||||||
|
Subject: [PATCH 154/154] Try to emit linux16/initrd16 and linuxefi/initrdefi
|
||||||
|
in 30-os_prober.
|
||||||
|
|
||||||
|
Resolves: rhbz#1108296
|
||||||
|
|
||||||
|
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||||
|
---
|
||||||
|
util/grub.d/30_os-prober.in | 30 ++++++++++++++++++++++++++----
|
||||||
|
1 file changed, 26 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in
|
||||||
|
index 9f955ab..908a09d 100644
|
||||||
|
--- a/util/grub.d/30_os-prober.in
|
||||||
|
+++ b/util/grub.d/30_os-prober.in
|
||||||
|
@@ -135,6 +135,28 @@ for OS in ${OSPROBED} ; do
|
||||||
|
LONGNAME="${LABEL}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
+ sixteenbit=""
|
||||||
|
+ linuxefi="linux"
|
||||||
|
+ initrdefi="initrd"
|
||||||
|
+ case "$machine" in
|
||||||
|
+ i?86|x86_64)
|
||||||
|
+ sixteenbit="16"
|
||||||
|
+ linuxefi="linuxefi"
|
||||||
|
+ initrdefi="initrdefi"
|
||||||
|
+ ;;
|
||||||
|
+ aarch64)
|
||||||
|
+ linuxefi="linux"
|
||||||
|
+ initrdefi="initrd"
|
||||||
|
+ esac
|
||||||
|
+ linux="linux${sixteenbit}"
|
||||||
|
+ initrd="initrd${sixteenbit}"
|
||||||
|
+ # there's no way to tell that the /other/ os is booting through UEFI,
|
||||||
|
+ # but if we are it's an okay bet...
|
||||||
|
+ if [ -d /sys/firmware/efi ]; then
|
||||||
|
+ linux=$linuxefi
|
||||||
|
+ initrd=$initrdefi
|
||||||
|
+ fi
|
||||||
|
+
|
||||||
|
gettext_printf "Found %s on %s\n" "${LONGNAME}" "${DEVICE}" >&2
|
||||||
|
|
||||||
|
case ${BOOT} in
|
||||||
|
@@ -235,11 +257,11 @@ EOF
|
||||||
|
save_default_entry | grub_add_tab
|
||||||
|
printf '%s\n' "${prepare_boot_cache}"
|
||||||
|
cat << EOF
|
||||||
|
- linux ${LKERNEL} ${LPARAMS}
|
||||||
|
+ ${linux} ${LKERNEL} ${LPARAMS}
|
||||||
|
EOF
|
||||||
|
if [ -n "${LINITRD}" ] ; then
|
||||||
|
cat << EOF
|
||||||
|
- initrd ${LINITRD}
|
||||||
|
+ ${initrd} ${LINITRD}
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
cat << EOF
|
||||||
|
@@ -255,11 +277,11 @@ EOF
|
||||||
|
save_default_entry | sed -e "s/^/$grub_tab$grub_tab/"
|
||||||
|
printf '%s\n' "${prepare_boot_cache}" | grub_add_tab
|
||||||
|
cat << EOF
|
||||||
|
- linux ${LKERNEL} ${LPARAMS}
|
||||||
|
+ ${linux} ${LKERNEL} ${LPARAMS}
|
||||||
|
EOF
|
||||||
|
if [ -n "${LINITRD}" ] ; then
|
||||||
|
cat << EOF
|
||||||
|
- initrd ${LINITRD}
|
||||||
|
+ ${initrd} ${LINITRD}
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
cat << EOF
|
||||||
|
--
|
||||||
|
1.9.3
|
||||||
|
|
14
grub2.spec
14
grub2.spec
@ -47,7 +47,7 @@
|
|||||||
Name: grub2
|
Name: grub2
|
||||||
Epoch: 1
|
Epoch: 1
|
||||||
Version: 2.02
|
Version: 2.02
|
||||||
Release: 0.9%{?dist}
|
Release: 0.10%{?dist}
|
||||||
Summary: Bootloader with support for Linux, Multiboot and more
|
Summary: Bootloader with support for Linux, Multiboot and more
|
||||||
|
|
||||||
Group: System Environment/Base
|
Group: System Environment/Base
|
||||||
@ -212,6 +212,8 @@ Patch0149: 0149-Add-GRUB_DISABLE_UUID.patch
|
|||||||
Patch0150: 0150-Allow-fallback-to-include-entries-by-title-not-just-.patch
|
Patch0150: 0150-Allow-fallback-to-include-entries-by-title-not-just-.patch
|
||||||
Patch0151: 0151-Initialized-initrd_ctx-so-we-don-t-free-a-random-poi.patch
|
Patch0151: 0151-Initialized-initrd_ctx-so-we-don-t-free-a-random-poi.patch
|
||||||
Patch0152: 0152-Load-arm-with-SB-enabled.patch
|
Patch0152: 0152-Load-arm-with-SB-enabled.patch
|
||||||
|
Patch0153: 0153-Try-prefix-if-fw_path-doesn-t-work.patch
|
||||||
|
Patch0154: 0154-Try-to-emit-linux16-initrd16-and-linuxefi-initrdefi-.patch
|
||||||
|
|
||||||
BuildRequires: flex bison binutils python
|
BuildRequires: flex bison binutils python
|
||||||
BuildRequires: ncurses-devel xz-devel bzip2-devel
|
BuildRequires: ncurses-devel xz-devel bzip2-devel
|
||||||
@ -234,8 +236,9 @@ BuildRequires: pesign >= 0.99-8
|
|||||||
%endif
|
%endif
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
Requires: gettext os-prober which file
|
Requires: gettext which file
|
||||||
Requires: %{name}-tools = %{epoch}:%{version}-%{release}
|
Requires: %{name}-tools = %{epoch}:%{version}-%{release}
|
||||||
|
Requires: os-prober >= 1.58-11
|
||||||
Requires(pre): dracut
|
Requires(pre): dracut
|
||||||
Requires(post): dracut
|
Requires(post): dracut
|
||||||
|
|
||||||
@ -644,6 +647,13 @@ fi
|
|||||||
%{_datarootdir}/grub/themes/
|
%{_datarootdir}/grub/themes/
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Oct 27 2014 Peter Jones <pjones@redhat.com> - 2.02-0.10
|
||||||
|
- Try to emit linux16/initrd16 and linuxefi/initrdefi when appropriate
|
||||||
|
in 30_os-prober.
|
||||||
|
Resolves: rhbz#1108296
|
||||||
|
- If $fw_path doesn't work to find the config file, try $prefix as well
|
||||||
|
Resolves: rhbz#1148652
|
||||||
|
|
||||||
* Mon Sep 29 2014 Peter Jones <pjones@redhat.com> - 2.02-0.9
|
* Mon Sep 29 2014 Peter Jones <pjones@redhat.com> - 2.02-0.9
|
||||||
- Clean up the build a bit to make it faster
|
- Clean up the build a bit to make it faster
|
||||||
- Make grubenv work right on UEFI machines
|
- Make grubenv work right on UEFI machines
|
||||||
|
Loading…
Reference in New Issue
Block a user