|
|
f731ee |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
f731ee |
From: Peter Jones <pjones@redhat.com>
|
|
|
f731ee |
Date: Thu, 23 Jun 2016 11:01:39 -0400
|
|
|
f731ee |
Subject: [PATCH] Add grub-get-kernel-settings and use it in 10_linux
|
|
|
f731ee |
|
|
|
f731ee |
This patch adds grub-get-kernel-settings, which reads the system kernel
|
|
|
f731ee |
installation configuration from /etc/sysconfig/kernel, and outputs
|
|
|
f731ee |
${GRUB_...} variables suitable for evaluation by grub-mkconfig. Those
|
|
|
f731ee |
variables are then used by 10_linux to choose whether or not to create
|
|
|
f731ee |
debug stanzas.
|
|
|
f731ee |
|
|
|
f731ee |
Resolves: rhbz#1226325
|
|
|
f731ee |
---
|
|
|
f731ee |
configure.ac | 2 +
|
|
|
f731ee |
Makefile.util.def | 7 ++
|
|
|
f731ee |
.gitignore | 1 +
|
|
|
f731ee |
util/bash-completion.d/grub-completion.bash.in | 22 +++++++
|
|
|
f731ee |
util/grub-get-kernel-settings.3 | 20 ++++++
|
|
|
f731ee |
util/grub-get-kernel-settings.in | 91 ++++++++++++++++++++++++++
|
|
|
f731ee |
util/grub-mkconfig.in | 3 +
|
|
|
f731ee |
util/grub.d/10_linux.in | 23 +++++--
|
|
|
f731ee |
8 files changed, 164 insertions(+), 5 deletions(-)
|
|
|
f731ee |
create mode 100644 util/grub-get-kernel-settings.3
|
|
|
f731ee |
create mode 100644 util/grub-get-kernel-settings.in
|
|
|
f731ee |
|
|
|
f731ee |
diff --git a/configure.ac b/configure.ac
|
|
|
f731ee |
index 04c052dc610..8b10a93cb56 100644
|
|
|
f731ee |
--- a/configure.ac
|
|
|
f731ee |
+++ b/configure.ac
|
|
|
f731ee |
@@ -58,6 +58,7 @@ grub_TRANSFORM([grub-install])
|
|
|
f731ee |
grub_TRANSFORM([grub-mkconfig])
|
|
|
f731ee |
grub_TRANSFORM([grub-mkfont])
|
|
|
f731ee |
grub_TRANSFORM([grub-mkimage])
|
|
|
f731ee |
+grub_TRANSFORM([grub-get-kernel-settings])
|
|
|
f731ee |
grub_TRANSFORM([grub-glue-efi])
|
|
|
f731ee |
grub_TRANSFORM([grub-mklayout])
|
|
|
f731ee |
grub_TRANSFORM([grub-mkpasswd-pbkdf2])
|
|
|
f731ee |
@@ -75,6 +76,7 @@ grub_TRANSFORM([grub-file])
|
|
|
f731ee |
grub_TRANSFORM([grub-bios-setup.3])
|
|
|
f731ee |
grub_TRANSFORM([grub-editenv.1])
|
|
|
f731ee |
grub_TRANSFORM([grub-fstest.3])
|
|
|
f731ee |
+grub_TRANSFORM([grub-get-kernel-settings.3])
|
|
|
f731ee |
grub_TRANSFORM([grub-glue-efi.3])
|
|
|
f731ee |
grub_TRANSFORM([grub-install.1])
|
|
|
f731ee |
grub_TRANSFORM([grub-kbdcomp.3])
|
|
|
f731ee |
diff --git a/Makefile.util.def b/Makefile.util.def
|
|
|
f731ee |
index e2821a2f3a5..3918e3b5292 100644
|
|
|
f731ee |
--- a/Makefile.util.def
|
|
|
f731ee |
+++ b/Makefile.util.def
|
|
|
f731ee |
@@ -704,6 +704,13 @@ script = {
|
|
|
f731ee |
installdir = sbin;
|
|
|
f731ee |
};
|
|
|
f731ee |
|
|
|
f731ee |
+script = {
|
|
|
f731ee |
+ name = grub-get-kernel-settings;
|
|
|
f731ee |
+ common = util/grub-get-kernel-settings.in;
|
|
|
f731ee |
+ mansection = 3;
|
|
|
f731ee |
+ installdir = sbin;
|
|
|
f731ee |
+};
|
|
|
f731ee |
+
|
|
|
f731ee |
script = {
|
|
|
f731ee |
name = grub-set-default;
|
|
|
f731ee |
common = util/grub-set-default.in;
|
|
|
f731ee |
diff --git a/.gitignore b/.gitignore
|
|
|
f731ee |
index e49f76b114a..547ef0bcff0 100644
|
|
|
f731ee |
--- a/.gitignore
|
|
|
f731ee |
+++ b/.gitignore
|
|
|
f731ee |
@@ -61,6 +61,7 @@ grub-fstest.exe
|
|
|
f731ee |
grub_fstest_init.c
|
|
|
f731ee |
grub_fstest_init.h
|
|
|
f731ee |
grub_func_test
|
|
|
f731ee |
+grub-get-kernel-settings
|
|
|
f731ee |
grub-install
|
|
|
f731ee |
grub-install.exe
|
|
|
f731ee |
grub-kbdcomp
|
|
|
f731ee |
diff --git a/util/bash-completion.d/grub-completion.bash.in b/util/bash-completion.d/grub-completion.bash.in
|
|
|
f731ee |
index 44bf135b9f8..5c4acd496d4 100644
|
|
|
f731ee |
--- a/util/bash-completion.d/grub-completion.bash.in
|
|
|
f731ee |
+++ b/util/bash-completion.d/grub-completion.bash.in
|
|
|
f731ee |
@@ -264,6 +264,28 @@ have ${__grub_sparc64_setup_program} && \
|
|
|
f731ee |
unset __grub_sparc64_setup_program
|
|
|
f731ee |
|
|
|
f731ee |
|
|
|
f731ee |
+#
|
|
|
f731ee |
+# grub-get-kernel-settings
|
|
|
f731ee |
+#
|
|
|
f731ee |
+_grub_get_kernel_settings () {
|
|
|
f731ee |
+ local cur
|
|
|
f731ee |
+
|
|
|
f731ee |
+ COMPREPLY=()
|
|
|
f731ee |
+ cur=`_get_cword`
|
|
|
f731ee |
+
|
|
|
f731ee |
+ if [[ "$cur" == -* ]]; then
|
|
|
f731ee |
+ __grubcomp "$(__grub_get_options_from_help)"
|
|
|
f731ee |
+ else
|
|
|
f731ee |
+ # Default complete with a filename
|
|
|
f731ee |
+ _filedir
|
|
|
f731ee |
+ fi
|
|
|
f731ee |
+}
|
|
|
f731ee |
+__grub_get_kernel_settings_program="@grub_get_kernel_settings@"
|
|
|
f731ee |
+have ${__grub_get_kernel_settings_program} && \
|
|
|
f731ee |
+ complete -F _grub_get_kernel_settings -o filenames ${__grub_get_kernel_settings_program}
|
|
|
f731ee |
+unset __grub_get_kernel_settings_program
|
|
|
f731ee |
+
|
|
|
f731ee |
+
|
|
|
f731ee |
#
|
|
|
f731ee |
# grub-install
|
|
|
f731ee |
#
|
|
|
f731ee |
diff --git a/util/grub-get-kernel-settings.3 b/util/grub-get-kernel-settings.3
|
|
|
f731ee |
new file mode 100644
|
|
|
f731ee |
index 00000000000..ba33330e28d
|
|
|
f731ee |
--- /dev/null
|
|
|
f731ee |
+++ b/util/grub-get-kernel-settings.3
|
|
|
f731ee |
@@ -0,0 +1,20 @@
|
|
|
f731ee |
+.TH GRUB-GET-KERNEL-SETTINGS 3 "Thu Jun 25 2015"
|
|
|
f731ee |
+.SH NAME
|
|
|
f731ee |
+\fBgrub-get-kernel-settings\fR \(em Evaluate the system's kernel installation settings for use while making a grub configuration file.
|
|
|
f731ee |
+
|
|
|
f731ee |
+.SH SYNOPSIS
|
|
|
f731ee |
+\fBgrub-get-kernel-settings\fR [OPTION]
|
|
|
f731ee |
+
|
|
|
f731ee |
+.SH DESCRIPTION
|
|
|
f731ee |
+\fBgrub-get-kernel-settings\fR reads the kernel installation settings on the host system, and emits a set of grub settings suitable for use when creating a grub configuration file.
|
|
|
f731ee |
+
|
|
|
f731ee |
+.SH OPTIONS
|
|
|
f731ee |
+.TP
|
|
|
f731ee |
+-h, --help
|
|
|
f731ee |
+Display program usage and exit.
|
|
|
f731ee |
+.TP
|
|
|
f731ee |
+-v, --version
|
|
|
f731ee |
+Display the current version.
|
|
|
f731ee |
+
|
|
|
f731ee |
+.SH SEE ALSO
|
|
|
f731ee |
+.BR "info grub"
|
|
|
f731ee |
diff --git a/util/grub-get-kernel-settings.in b/util/grub-get-kernel-settings.in
|
|
|
f731ee |
new file mode 100644
|
|
|
f731ee |
index 00000000000..ae0b4696d49
|
|
|
f731ee |
--- /dev/null
|
|
|
f731ee |
+++ b/util/grub-get-kernel-settings.in
|
|
|
f731ee |
@@ -0,0 +1,91 @@
|
|
|
f731ee |
+#!/bin/sh
|
|
|
f731ee |
+set -e
|
|
|
f731ee |
+
|
|
|
f731ee |
+# Evaluate new-kernel-pkg's configuration file.
|
|
|
f731ee |
+# Copyright (C) 2016 Free Software Foundation, Inc.
|
|
|
f731ee |
+#
|
|
|
f731ee |
+# GRUB is free software: you can redistribute it and/or modify
|
|
|
f731ee |
+# it under the terms of the GNU General Public License as published by
|
|
|
f731ee |
+# the Free Software Foundation, either version 3 of the License, or
|
|
|
f731ee |
+# (at your option) any later version.
|
|
|
f731ee |
+#
|
|
|
f731ee |
+# GRUB is distributed in the hope that it will be useful,
|
|
|
f731ee |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f731ee |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
f731ee |
+# GNU General Public License for more details.
|
|
|
f731ee |
+#
|
|
|
f731ee |
+# You should have received a copy of the GNU General Public License
|
|
|
f731ee |
+# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
|
f731ee |
+
|
|
|
f731ee |
+prefix="@prefix@"
|
|
|
f731ee |
+exec_prefix="@exec_prefix@"
|
|
|
f731ee |
+datarootdir="@datarootdir@"
|
|
|
f731ee |
+
|
|
|
f731ee |
+prefix="@prefix@"
|
|
|
f731ee |
+exec_prefix="@exec_prefix@"
|
|
|
f731ee |
+sbindir="@sbindir@"
|
|
|
f731ee |
+bindir="@bindir@"
|
|
|
f731ee |
+sysconfdir="@sysconfdir@"
|
|
|
f731ee |
+PACKAGE_NAME=@PACKAGE_NAME@
|
|
|
f731ee |
+PACKAGE_VERSION=@PACKAGE_VERSION@
|
|
|
f731ee |
+host_os=@host_os@
|
|
|
f731ee |
+datadir="@datadir@"
|
|
|
f731ee |
+if [ "x$pkgdatadir" = x ]; then
|
|
|
f731ee |
+ pkgdatadir="${datadir}/@PACKAGE@"
|
|
|
f731ee |
+fi
|
|
|
f731ee |
+grub_cfg=""
|
|
|
f731ee |
+
|
|
|
f731ee |
+self=`basename $0`
|
|
|
f731ee |
+
|
|
|
f731ee |
+grub_probe="${sbindir}/@grub_probe@"
|
|
|
f731ee |
+grub_file="${bindir}/@grub_file@"
|
|
|
f731ee |
+grub_editenv="${bindir}/@grub_editenv@"
|
|
|
f731ee |
+grub_script_check="${bindir}/@grub_script_check@"
|
|
|
f731ee |
+
|
|
|
f731ee |
+export TEXTDOMAIN=@PACKAGE@
|
|
|
f731ee |
+export TEXTDOMAINDIR="@localedir@"
|
|
|
f731ee |
+
|
|
|
f731ee |
+. "${pkgdatadir}/grub-mkconfig_lib"
|
|
|
f731ee |
+
|
|
|
f731ee |
+# Usage: usage
|
|
|
f731ee |
+# Print the usage.
|
|
|
f731ee |
+usage () {
|
|
|
f731ee |
+ gettext_printf "Usage: %s [OPTION]\n" "$self"
|
|
|
f731ee |
+ gettext "Evaluate new-kernel-pkg configuration"; echo
|
|
|
f731ee |
+ echo
|
|
|
f731ee |
+ print_option_help "-h, --help" "$(gettext "print this message and exit")"
|
|
|
f731ee |
+ print_option_help "-v, --version" "$(gettext "print the version information and exit")"
|
|
|
f731ee |
+ echo
|
|
|
f731ee |
+}
|
|
|
f731ee |
+
|
|
|
f731ee |
+# Check the arguments.
|
|
|
f731ee |
+while test $# -gt 0
|
|
|
f731ee |
+do
|
|
|
f731ee |
+ option=$1
|
|
|
f731ee |
+ shift
|
|
|
f731ee |
+
|
|
|
f731ee |
+ case "$option" in
|
|
|
f731ee |
+ -h | --help)
|
|
|
f731ee |
+ usage
|
|
|
f731ee |
+ exit 0 ;;
|
|
|
f731ee |
+ -v | --version)
|
|
|
f731ee |
+ echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
|
|
|
f731ee |
+ exit 0 ;;
|
|
|
f731ee |
+ -*)
|
|
|
f731ee |
+ gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2
|
|
|
f731ee |
+ usage
|
|
|
f731ee |
+ exit 1
|
|
|
f731ee |
+ ;;
|
|
|
f731ee |
+ # Explicitly ignore non-option arguments, for compatibility.
|
|
|
f731ee |
+ esac
|
|
|
f731ee |
+done
|
|
|
f731ee |
+
|
|
|
f731ee |
+if test -f /etc/sysconfig/kernel ; then
|
|
|
f731ee |
+ . /etc/sysconfig/kernel
|
|
|
f731ee |
+fi
|
|
|
f731ee |
+
|
|
|
f731ee |
+if [ "$MAKEDEBUG" = "yes" ]; then
|
|
|
f731ee |
+ echo GRUB_LINUX_MAKE_DEBUG=true
|
|
|
f731ee |
+ echo GRUB_CMDLINE_LINUX_DEBUG=\"systemd.log_level=debug systemd.log_target=kmsg\"
|
|
|
f731ee |
+ echo GRUB_LINUX_DEBUG_TITLE_POSTFIX=\" with debugging\"
|
|
|
f731ee |
+fi
|
|
|
f731ee |
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
|
|
|
f731ee |
index 0cfe6047539..aa4fdb8a3b2 100644
|
|
|
f731ee |
--- a/util/grub-mkconfig.in
|
|
|
f731ee |
+++ b/util/grub-mkconfig.in
|
|
|
f731ee |
@@ -42,6 +42,7 @@ grub_probe="${sbindir}/@grub_probe@"
|
|
|
f731ee |
grub_file="${bindir}/@grub_file@"
|
|
|
f731ee |
grub_editenv="${bindir}/@grub_editenv@"
|
|
|
f731ee |
grub_script_check="${bindir}/@grub_script_check@"
|
|
|
f731ee |
+grub_get_kernel_settings="${sbindir}/@grub_get_kernel_settings@"
|
|
|
f731ee |
|
|
|
f731ee |
export TEXTDOMAIN=@PACKAGE@
|
|
|
f731ee |
export TEXTDOMAINDIR="@localedir@"
|
|
|
f731ee |
@@ -148,6 +149,8 @@ if test -f ${sysconfdir}/default/grub ; then
|
|
|
f731ee |
. ${sysconfdir}/default/grub
|
|
|
f731ee |
fi
|
|
|
f731ee |
|
|
|
f731ee |
+eval `${grub_get_kernel_settings}` || true
|
|
|
f731ee |
+
|
|
|
f731ee |
if [ "x$GRUB_DISABLE_UUID" != "xtrue" -a -z "$GRUB_DEVICE_UUID" ]; then
|
|
|
f731ee |
GRUB_DEVICE_UUID="$GRUB_DEVICE_UUID_GENERATED"
|
|
|
f731ee |
fi
|
|
|
f731ee |
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
|
|
|
f731ee |
index b3c460cb266..0d0086d3b6a 100644
|
|
|
f731ee |
--- a/util/grub.d/10_linux.in
|
|
|
f731ee |
+++ b/util/grub.d/10_linux.in
|
|
|
f731ee |
@@ -99,7 +99,8 @@ linux_entry ()
|
|
|
f731ee |
os="$1"
|
|
|
f731ee |
version="$2"
|
|
|
f731ee |
type="$3"
|
|
|
f731ee |
- args="$4"
|
|
|
f731ee |
+ isdebug="$4"
|
|
|
f731ee |
+ args="$5"
|
|
|
f731ee |
|
|
|
f731ee |
sixteenbit=""
|
|
|
f731ee |
linuxefi="linux"
|
|
|
f731ee |
@@ -130,6 +131,9 @@ linux_entry ()
|
|
|
f731ee |
else
|
|
|
f731ee |
echo "menuentry '$(echo "$os" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/"
|
|
|
f731ee |
fi
|
|
|
f731ee |
+ if [ x$isdebug = xdebug ]; then
|
|
|
f731ee |
+ title="$title${GRUB_LINUX_DEBUG_TITLE_POSTFIX}"
|
|
|
f731ee |
+ fi
|
|
|
f731ee |
if [ x$type != xrecovery ] ; then
|
|
|
f731ee |
save_default_entry | grub_add_tab
|
|
|
f731ee |
fi
|
|
|
f731ee |
@@ -281,11 +285,15 @@ while [ "x$list" != "x" ] ; do
|
|
|
f731ee |
fi
|
|
|
f731ee |
|
|
|
f731ee |
if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then
|
|
|
f731ee |
- linux_entry "${OS}" "${version}" simple \
|
|
|
f731ee |
+ linux_entry "${OS}" "${version}" simple standard \
|
|
|
f731ee |
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
|
|
|
f731ee |
+ if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then
|
|
|
f731ee |
+ linux_entry "${OS}" "${version}" simple debug \
|
|
|
f731ee |
+ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX_DEBUG}"
|
|
|
f731ee |
+ fi
|
|
|
f731ee |
|
|
|
f731ee |
submenu_indentation="$grub_tab"
|
|
|
f731ee |
-
|
|
|
f731ee |
+
|
|
|
f731ee |
if [ -z "$boot_device_id" ]; then
|
|
|
f731ee |
boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")"
|
|
|
f731ee |
fi
|
|
|
f731ee |
@@ -294,10 +302,15 @@ while [ "x$list" != "x" ] ; do
|
|
|
f731ee |
is_top_level=false
|
|
|
f731ee |
fi
|
|
|
f731ee |
|
|
|
f731ee |
- linux_entry "${OS}" "${version}" advanced \
|
|
|
f731ee |
+ linux_entry "${OS}" "${version}" advanced standard \
|
|
|
f731ee |
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
|
|
|
f731ee |
+ if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then
|
|
|
f731ee |
+ linux_entry "${OS}" "${version}" advanced debug \
|
|
|
f731ee |
+ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX_DEBUG}"
|
|
|
f731ee |
+ fi
|
|
|
f731ee |
+
|
|
|
f731ee |
if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
|
|
|
f731ee |
- linux_entry "${OS}" "${version}" recovery \
|
|
|
f731ee |
+ linux_entry "${OS}" "${version}" recovery standard \
|
|
|
f731ee |
"single ${GRUB_CMDLINE_LINUX}"
|
|
|
f731ee |
fi
|
|
|
f731ee |
|