2018-07-12 14:56:34 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2016-08-25 18:42:57 +00:00
|
|
|
From: Peter Jones <pjones@redhat.com>
|
|
|
|
Date: Thu, 23 Jun 2016 11:01:39 -0400
|
2018-07-10 18:39:10 +00:00
|
|
|
Subject: [PATCH] Add grub-get-kernel-settings and use it in 10_linux
|
2016-08-25 18:42:57 +00:00
|
|
|
|
|
|
|
This patch adds grub-get-kernel-settings, which reads the system kernel
|
|
|
|
installation configuration from /etc/sysconfig/kernel, and outputs
|
|
|
|
${GRUB_...} variables suitable for evaluation by grub-mkconfig. Those
|
|
|
|
variables are then used by 10_linux to choose whether or not to create
|
|
|
|
debug stanzas.
|
|
|
|
|
|
|
|
Resolves: rhbz#1226325
|
2022-03-31 21:21:43 +00:00
|
|
|
[rharwood: migrate man page to h2m]
|
2016-08-25 18:42:57 +00:00
|
|
|
---
|
2022-03-31 21:21:43 +00:00
|
|
|
configure.ac | 1 +
|
2019-07-16 09:23:51 +00:00
|
|
|
Makefile.util.def | 7 ++
|
2022-03-31 21:21:43 +00:00
|
|
|
docs/man/grub-get-kernel-settings.h2m | 2 +
|
2019-07-16 09:23:51 +00:00
|
|
|
util/bash-completion.d/grub-completion.bash.in | 22 +++++++
|
|
|
|
util/grub-get-kernel-settings.in | 88 ++++++++++++++++++++++++++
|
2016-08-25 18:42:57 +00:00
|
|
|
util/grub-mkconfig.in | 3 +
|
2019-07-16 09:23:51 +00:00
|
|
|
util/grub.d/10_linux.in | 23 +++++--
|
2022-03-31 21:21:43 +00:00
|
|
|
7 files changed, 141 insertions(+), 5 deletions(-)
|
|
|
|
create mode 100644 docs/man/grub-get-kernel-settings.h2m
|
2016-08-25 18:42:57 +00:00
|
|
|
create mode 100644 util/grub-get-kernel-settings.in
|
|
|
|
|
|
|
|
diff --git a/configure.ac b/configure.ac
|
2024-08-01 23:56:47 +00:00
|
|
|
index 493e336ec6c..3602b4ab62b 100644
|
2016-08-25 18:42:57 +00:00
|
|
|
--- a/configure.ac
|
|
|
|
+++ b/configure.ac
|
2024-08-01 23:56:47 +00:00
|
|
|
@@ -70,6 +70,7 @@ grub_TRANSFORM([grub-install])
|
2016-08-25 18:42:57 +00:00
|
|
|
grub_TRANSFORM([grub-mkconfig])
|
|
|
|
grub_TRANSFORM([grub-mkfont])
|
|
|
|
grub_TRANSFORM([grub-mkimage])
|
|
|
|
+grub_TRANSFORM([grub-get-kernel-settings])
|
|
|
|
grub_TRANSFORM([grub-glue-efi])
|
|
|
|
grub_TRANSFORM([grub-mklayout])
|
|
|
|
grub_TRANSFORM([grub-mkpasswd-pbkdf2])
|
2018-02-27 18:56:41 +00:00
|
|
|
diff --git a/Makefile.util.def b/Makefile.util.def
|
2024-08-01 23:56:47 +00:00
|
|
|
index 95884956a68..84a17ef5cfa 100644
|
2018-02-27 18:56:41 +00:00
|
|
|
--- a/Makefile.util.def
|
|
|
|
+++ b/Makefile.util.def
|
2024-08-01 23:56:47 +00:00
|
|
|
@@ -725,6 +725,13 @@ script = {
|
2018-02-27 18:56:41 +00:00
|
|
|
installdir = sbin;
|
|
|
|
};
|
|
|
|
|
|
|
|
+script = {
|
|
|
|
+ name = grub-get-kernel-settings;
|
|
|
|
+ common = util/grub-get-kernel-settings.in;
|
|
|
|
+ mansection = 3;
|
|
|
|
+ installdir = sbin;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
script = {
|
|
|
|
name = grub-set-default;
|
|
|
|
common = util/grub-set-default.in;
|
2022-03-31 21:21:43 +00:00
|
|
|
diff --git a/docs/man/grub-get-kernel-settings.h2m b/docs/man/grub-get-kernel-settings.h2m
|
|
|
|
new file mode 100644
|
2024-08-01 23:56:47 +00:00
|
|
|
index 00000000000..b8051f01f3a
|
2022-03-31 21:21:43 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/docs/man/grub-get-kernel-settings.h2m
|
|
|
|
@@ -0,0 +1,2 @@
|
|
|
|
+[NAME]
|
|
|
|
+grub-get-kernel-settings \- Evaluate the system's kernel installation settings for use while making a grub configuration file
|
2016-08-25 18:42:57 +00:00
|
|
|
diff --git a/util/bash-completion.d/grub-completion.bash.in b/util/bash-completion.d/grub-completion.bash.in
|
2024-08-01 23:56:47 +00:00
|
|
|
index 213ce1e57cf..da7fca5efac 100644
|
2016-08-25 18:42:57 +00:00
|
|
|
--- a/util/bash-completion.d/grub-completion.bash.in
|
|
|
|
+++ b/util/bash-completion.d/grub-completion.bash.in
|
2024-08-01 23:56:47 +00:00
|
|
|
@@ -275,6 +275,28 @@ have ${__grub_sparc64_setup_program} && \
|
2018-01-17 20:40:19 +00:00
|
|
|
unset __grub_sparc64_setup_program
|
2016-08-25 18:42:57 +00:00
|
|
|
|
|
|
|
|
2018-01-17 20:40:19 +00:00
|
|
|
+#
|
2016-08-25 18:42:57 +00:00
|
|
|
+# grub-get-kernel-settings
|
|
|
|
+#
|
|
|
|
+_grub_get_kernel_settings () {
|
|
|
|
+ local cur
|
|
|
|
+
|
|
|
|
+ COMPREPLY=()
|
|
|
|
+ cur=`_get_cword`
|
|
|
|
+
|
|
|
|
+ if [[ "$cur" == -* ]]; then
|
|
|
|
+ __grubcomp "$(__grub_get_options_from_help)"
|
|
|
|
+ else
|
|
|
|
+ # Default complete with a filename
|
|
|
|
+ _filedir
|
|
|
|
+ fi
|
|
|
|
+}
|
|
|
|
+__grub_get_kernel_settings_program="@grub_get_kernel_settings@"
|
|
|
|
+have ${__grub_get_kernel_settings_program} && \
|
|
|
|
+ complete -F _grub_get_kernel_settings -o filenames ${__grub_get_kernel_settings_program}
|
|
|
|
+unset __grub_get_kernel_settings_program
|
|
|
|
+
|
|
|
|
+
|
2018-01-17 20:40:19 +00:00
|
|
|
#
|
2016-08-25 18:42:57 +00:00
|
|
|
# grub-install
|
|
|
|
#
|
|
|
|
diff --git a/util/grub-get-kernel-settings.in b/util/grub-get-kernel-settings.in
|
|
|
|
new file mode 100644
|
2024-08-01 23:56:47 +00:00
|
|
|
index 00000000000..7e87dfccc0e
|
2016-08-25 18:42:57 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/util/grub-get-kernel-settings.in
|
2019-07-16 09:23:51 +00:00
|
|
|
@@ -0,0 +1,88 @@
|
2016-08-25 18:42:57 +00:00
|
|
|
+#!/bin/sh
|
|
|
|
+set -e
|
|
|
|
+
|
|
|
|
+# Evaluate new-kernel-pkg's configuration file.
|
|
|
|
+# Copyright (C) 2016 Free Software Foundation, Inc.
|
|
|
|
+#
|
|
|
|
+# GRUB is free software: you can redistribute it and/or modify
|
|
|
|
+# it under the terms of the GNU General Public License as published by
|
|
|
|
+# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
+# (at your option) any later version.
|
|
|
|
+#
|
|
|
|
+# GRUB is distributed in the hope that it will be useful,
|
|
|
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
+# GNU General Public License for more details.
|
|
|
|
+#
|
|
|
|
+# You should have received a copy of the GNU General Public License
|
|
|
|
+# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
+
|
|
|
|
+PACKAGE_NAME=@PACKAGE_NAME@
|
|
|
|
+PACKAGE_VERSION=@PACKAGE_VERSION@
|
|
|
|
+datadir="@datadir@"
|
|
|
|
+if [ "x$pkgdatadir" = x ]; then
|
|
|
|
+ pkgdatadir="${datadir}/@PACKAGE@"
|
|
|
|
+fi
|
|
|
|
+
|
|
|
|
+self=`basename $0`
|
|
|
|
+
|
|
|
|
+export TEXTDOMAIN=@PACKAGE@
|
|
|
|
+export TEXTDOMAINDIR="@localedir@"
|
|
|
|
+
|
|
|
|
+. "${pkgdatadir}/grub-mkconfig_lib"
|
|
|
|
+
|
|
|
|
+# Usage: usage
|
|
|
|
+# Print the usage.
|
|
|
|
+usage () {
|
|
|
|
+ gettext_printf "Usage: %s [OPTION]\n" "$self"
|
|
|
|
+ gettext "Evaluate new-kernel-pkg configuration"; echo
|
|
|
|
+ echo
|
|
|
|
+ print_option_help "-h, --help" "$(gettext "print this message and exit")"
|
|
|
|
+ print_option_help "-v, --version" "$(gettext "print the version information and exit")"
|
|
|
|
+ echo
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+# Check the arguments.
|
|
|
|
+while test $# -gt 0
|
|
|
|
+do
|
|
|
|
+ option=$1
|
|
|
|
+ shift
|
|
|
|
+
|
|
|
|
+ case "$option" in
|
|
|
|
+ -h | --help)
|
|
|
|
+ usage
|
|
|
|
+ exit 0 ;;
|
|
|
|
+ -v | --version)
|
|
|
|
+ echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
|
|
|
|
+ exit 0 ;;
|
|
|
|
+ -*)
|
|
|
|
+ gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2
|
|
|
|
+ usage
|
|
|
|
+ exit 1
|
|
|
|
+ ;;
|
|
|
|
+ # Explicitly ignore non-option arguments, for compatibility.
|
|
|
|
+ esac
|
|
|
|
+done
|
|
|
|
+
|
|
|
|
+if test -f /etc/sysconfig/kernel ; then
|
|
|
|
+ . /etc/sysconfig/kernel
|
|
|
|
+fi
|
|
|
|
+
|
|
|
|
+if [ "$MAKEDEBUG" = "yes" ]; then
|
|
|
|
+ echo GRUB_LINUX_MAKE_DEBUG=true
|
|
|
|
+ echo export GRUB_LINUX_MAKE_DEBUG
|
|
|
|
+ echo GRUB_CMDLINE_LINUX_DEBUG=\"systemd.log_level=debug systemd.log_target=kmsg\"
|
|
|
|
+ echo export GRUB_CMDLINE_LINUX_DEBUG
|
|
|
|
+ echo GRUB_LINUX_DEBUG_TITLE_POSTFIX=\" with debugging\"
|
|
|
|
+ echo export GRUB_LINUX_DEBUG_TITLE_POSTFIX
|
|
|
|
+fi
|
2019-07-16 09:23:51 +00:00
|
|
|
+if [ "$DEFAULTDEBUG" = "yes" ]; then
|
|
|
|
+ echo GRUB_DEFAULT_TO_DEBUG=true
|
|
|
|
+else
|
|
|
|
+ echo GRUB_DEFAULT_TO_DEBUG=false
|
|
|
|
+fi
|
|
|
|
+echo export GRUB_DEFAULT_TO_DEBUG
|
|
|
|
+if [ "$UPDATEDEFAULT" = "yes" ]; then
|
|
|
|
+ echo GRUB_UPDATE_DEFAULT_KERNEL=true
|
|
|
|
+ echo export GRUB_UPDATE_DEFAULT_KERNEL
|
|
|
|
+fi
|
2016-08-25 18:42:57 +00:00
|
|
|
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
|
2024-08-01 23:56:47 +00:00
|
|
|
index 5f2824d4f58..28e92515795 100644
|
2016-08-25 18:42:57 +00:00
|
|
|
--- a/util/grub-mkconfig.in
|
|
|
|
+++ b/util/grub-mkconfig.in
|
|
|
|
@@ -45,6 +45,7 @@ grub_probe="${sbindir}/@grub_probe@"
|
|
|
|
grub_file="${bindir}/@grub_file@"
|
|
|
|
grub_editenv="${bindir}/@grub_editenv@"
|
|
|
|
grub_script_check="${bindir}/@grub_script_check@"
|
|
|
|
+grub_get_kernel_settings="${sbindir}/@grub_get_kernel_settings@"
|
|
|
|
|
|
|
|
export TEXTDOMAIN=@PACKAGE@
|
|
|
|
export TEXTDOMAINDIR="@localedir@"
|
2021-06-14 08:48:27 +00:00
|
|
|
@@ -158,6 +159,8 @@ if test -f ${sysconfdir}/default/grub ; then
|
2016-08-25 18:42:57 +00:00
|
|
|
. ${sysconfdir}/default/grub
|
|
|
|
fi
|
|
|
|
|
|
|
|
+eval "$("${grub_get_kernel_settings}")" || true
|
|
|
|
+
|
2021-03-12 21:54:28 +00:00
|
|
|
if [ "x${GRUB_DISABLE_UUID}" = "xtrue" ]; then
|
|
|
|
if [ -z "${GRUB_DISABLE_LINUX_UUID}" ]; then
|
|
|
|
GRUB_DISABLE_LINUX_UUID="true"
|
2016-08-25 18:42:57 +00:00
|
|
|
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
|
2024-08-01 23:56:47 +00:00
|
|
|
index 993c53ad92e..e8ab4082f87 100644
|
2016-08-25 18:42:57 +00:00
|
|
|
--- a/util/grub.d/10_linux.in
|
|
|
|
+++ b/util/grub.d/10_linux.in
|
2024-08-01 23:56:47 +00:00
|
|
|
@@ -113,7 +113,8 @@ linux_entry ()
|
2016-08-25 18:42:57 +00:00
|
|
|
os="$1"
|
|
|
|
version="$2"
|
|
|
|
type="$3"
|
|
|
|
- args="$4"
|
|
|
|
+ isdebug="$4"
|
|
|
|
+ args="$5"
|
|
|
|
|
2018-07-17 14:20:54 +00:00
|
|
|
if [ -z "$boot_device_id" ]; then
|
|
|
|
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
|
2024-08-01 23:56:47 +00:00
|
|
|
@@ -125,6 +126,9 @@ linux_entry ()
|
2016-08-25 18:42:57 +00:00
|
|
|
quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
|
|
|
|
title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
|
|
|
|
fi
|
|
|
|
+ if [ x$isdebug = xdebug ]; then
|
|
|
|
+ title="$title${GRUB_LINUX_DEBUG_TITLE_POSTFIX}"
|
|
|
|
+ fi
|
|
|
|
echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
|
|
|
|
else
|
|
|
|
echo "menuentry '$(echo "$os" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
|
2024-08-01 23:56:47 +00:00
|
|
|
@@ -320,11 +324,15 @@ for linux in ${reverse_sorted_list}; do
|
2016-08-25 18:42:57 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then
|
|
|
|
- linux_entry "${OS}" "${version}" simple \
|
|
|
|
+ linux_entry "${OS}" "${version}" simple standard \
|
|
|
|
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
|
|
|
|
+ if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then
|
|
|
|
+ linux_entry "${OS}" "${version}" simple debug \
|
|
|
|
+ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX_DEBUG}"
|
|
|
|
+ fi
|
|
|
|
|
|
|
|
submenu_indentation="$grub_tab"
|
|
|
|
-
|
|
|
|
+
|
|
|
|
if [ -z "$boot_device_id" ]; then
|
|
|
|
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
|
|
|
|
fi
|
2024-08-01 23:56:47 +00:00
|
|
|
@@ -333,10 +341,15 @@ for linux in ${reverse_sorted_list}; do
|
2016-08-25 18:42:57 +00:00
|
|
|
is_top_level=false
|
|
|
|
fi
|
|
|
|
|
|
|
|
- linux_entry "${OS}" "${version}" advanced \
|
|
|
|
+ linux_entry "${OS}" "${version}" advanced standard \
|
|
|
|
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
|
|
|
|
+ if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then
|
|
|
|
+ linux_entry "${OS}" "${version}" advanced debug \
|
|
|
|
+ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX_DEBUG}"
|
|
|
|
+ fi
|
|
|
|
+
|
|
|
|
if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
|
|
|
|
- linux_entry "${OS}" "${version}" recovery \
|
|
|
|
+ linux_entry "${OS}" "${version}" recovery standard \
|
2024-08-01 23:56:47 +00:00
|
|
|
"${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}"
|
2016-08-25 18:42:57 +00:00
|
|
|
fi
|
2024-08-01 23:56:47 +00:00
|
|
|
done
|