|
|
f96e0b |
From 1424a23f9d76785da41d3f8ccd9f0658abd062da Mon Sep 17 00:00:00 2001
|
|
|
f96e0b |
From: Andrey Borzenkov <arvidjaar@gmail.com>
|
|
|
f96e0b |
Date: Mon, 6 May 2013 22:13:34 +0400
|
|
|
f96e0b |
Subject: [PATCH 428/482] Reimplement grub-reboot to not depend on
|
|
|
f96e0b |
saved_entry. Use next_entry variable for one time boot menu entry.
|
|
|
f96e0b |
|
|
|
f96e0b |
---
|
|
|
f96e0b |
ChangeLog | 5 +++++
|
|
|
f96e0b |
util/grub-reboot.in | 17 ++++++-----------
|
|
|
f96e0b |
util/grub-set-default.in | 1 +
|
|
|
f96e0b |
util/grub.d/00_header.in | 14 +++++++++++++-
|
|
|
f96e0b |
4 files changed, 25 insertions(+), 12 deletions(-)
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/ChangeLog b/ChangeLog
|
|
|
f96e0b |
index b79c57a..16c5404 100644
|
|
|
f96e0b |
--- a/ChangeLog
|
|
|
f96e0b |
+++ b/ChangeLog
|
|
|
f96e0b |
@@ -1,3 +1,8 @@
|
|
|
f96e0b |
+2013-05-06 Andrey Borzenkov <arvidjaar@gmail.com>
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ Reimplement grub-reboot to not depend on saved_entry. Use next_entry
|
|
|
f96e0b |
+ variable for one time boot menu entry.
|
|
|
f96e0b |
+
|
|
|
f96e0b |
2013-05-05 Bean <bean123ch@gmail.com>
|
|
|
f96e0b |
|
|
|
f96e0b |
* grub-core/commands/testspeed.c: New command testspeed.
|
|
|
f96e0b |
diff --git a/util/grub-reboot.in b/util/grub-reboot.in
|
|
|
f96e0b |
index 1a91d36..d132e4f 100644
|
|
|
f96e0b |
--- a/util/grub-reboot.in
|
|
|
f96e0b |
+++ b/util/grub-reboot.in
|
|
|
f96e0b |
@@ -46,8 +46,6 @@ export TEXTDOMAINDIR="@localedir@"
|
|
|
f96e0b |
usage () {
|
|
|
f96e0b |
gettext_printf "Usage: %s [OPTION] MENU_ENTRY\n" "$self"
|
|
|
f96e0b |
gettext "Set the default boot menu entry for GRUB, for the next boot only."; echo
|
|
|
f96e0b |
- gettext_printf "This requires setting GRUB_DEFAULT=saved in %s/default/grub.\n" "$sysconfdir"
|
|
|
f96e0b |
- echo
|
|
|
f96e0b |
print_option_help "-h, --help" "$(gettext "print this message and exit")"
|
|
|
f96e0b |
print_option_help "-v, --version" "$(gettext "print the version information and exit")"
|
|
|
f96e0b |
dirmsg="$(gettext_printf "expect GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")"
|
|
|
f96e0b |
@@ -129,17 +127,14 @@ fi
|
|
|
f96e0b |
|
|
|
f96e0b |
grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
|
|
|
f96e0b |
|
|
|
f96e0b |
-prev_saved_entry=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^saved_entry=//p'`
|
|
|
f96e0b |
+# Restore saved_entry if it was set by previous version
|
|
|
f96e0b |
+prev_saved_entry=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^prev_saved_entry=//p'`
|
|
|
f96e0b |
if [ "$prev_saved_entry" ]; then
|
|
|
f96e0b |
- $grub_editenv ${grubdir}/grubenv set prev_saved_entry="$prev_saved_entry"
|
|
|
f96e0b |
-else
|
|
|
f96e0b |
- # We need some non-empty value for prev_saved_entry so that GRUB will
|
|
|
f96e0b |
- # recognise that grub-reboot has been used and restore the previous
|
|
|
f96e0b |
- # saved entry. "0" is the same as an empty value, i.e. the first menu
|
|
|
f96e0b |
- # entry.
|
|
|
f96e0b |
- $grub_editenv ${grubdir}/grubenv set prev_saved_entry=0
|
|
|
f96e0b |
+ $grub_editenv ${grubdir}/grubenv set saved_entry="$prev_saved_entry"
|
|
|
f96e0b |
+ $grub_editenv ${grubdir}/grubenv unset prev_saved_entry
|
|
|
f96e0b |
fi
|
|
|
f96e0b |
-$grub_editenv ${grubdir}/grubenv set saved_entry="$entry"
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+$grub_editenv ${grubdir}/grubenv set next_entry="$entry"
|
|
|
f96e0b |
|
|
|
f96e0b |
# Bye.
|
|
|
f96e0b |
exit 0
|
|
|
f96e0b |
diff --git a/util/grub-set-default.in b/util/grub-set-default.in
|
|
|
f96e0b |
index ea18da1..d607318 100644
|
|
|
f96e0b |
--- a/util/grub-set-default.in
|
|
|
f96e0b |
+++ b/util/grub-set-default.in
|
|
|
f96e0b |
@@ -130,6 +130,7 @@ fi
|
|
|
f96e0b |
grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
|
|
|
f96e0b |
|
|
|
f96e0b |
$grub_editenv ${grubdir}/grubenv unset prev_saved_entry
|
|
|
f96e0b |
+$grub_editenv ${grubdir}/grubenv unset next_entry
|
|
|
f96e0b |
$grub_editenv ${grubdir}/grubenv set saved_entry="$entry"
|
|
|
f96e0b |
|
|
|
f96e0b |
# Bye.
|
|
|
f96e0b |
diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in
|
|
|
f96e0b |
index 3da5d12..2c4bb0a 100644
|
|
|
f96e0b |
--- a/util/grub.d/00_header.in
|
|
|
f96e0b |
+++ b/util/grub.d/00_header.in
|
|
|
f96e0b |
@@ -51,13 +51,25 @@ if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
|
|
|
f96e0b |
cat <
|
|
|
f96e0b |
if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then
|
|
|
f96e0b |
set default="${GRUB_DEFAULT_BUTTON}"
|
|
|
f96e0b |
+elif [ "\${next_entry}" ] ; then
|
|
|
f96e0b |
+ set default="\${next_entry}"
|
|
|
f96e0b |
+ set next_entry=
|
|
|
f96e0b |
+ save_env next_entry
|
|
|
f96e0b |
+ set boot_once=true
|
|
|
f96e0b |
else
|
|
|
f96e0b |
set default="${GRUB_DEFAULT}"
|
|
|
f96e0b |
fi
|
|
|
f96e0b |
EOF
|
|
|
f96e0b |
else
|
|
|
f96e0b |
cat <
|
|
|
f96e0b |
-set default="${GRUB_DEFAULT}"
|
|
|
f96e0b |
+if [ "\${next_entry}" ] ; then
|
|
|
f96e0b |
+ set default="\${next_entry}"
|
|
|
f96e0b |
+ set next_entry=
|
|
|
f96e0b |
+ save_env next_entry
|
|
|
f96e0b |
+ set boot_once=true
|
|
|
f96e0b |
+else
|
|
|
f96e0b |
+ set default="${GRUB_DEFAULT}"
|
|
|
f96e0b |
+fi
|
|
|
f96e0b |
EOF
|
|
|
f96e0b |
fi
|
|
|
f96e0b |
cat <
|
|
|
f96e0b |
--
|
|
|
f96e0b |
1.8.2.1
|
|
|
f96e0b |
|