From: Andrey Borzenkov <arvidjaar@gmail.com>
To: grub-devel@gnu.org
Subject: Re: [PATCH] reimplement grub-reboot to nor depend on GRUB_DEFAULT=saved
Date: Fri, 19 Apr 2013 18:12:05 +0400 [thread overview]
Message-ID: <20130419181205.4a7753e1@opensuse.site> (raw)
In-Reply-To: <1365338320.7207.35.camel@mattotaupa>
[-- Attachment #1: Type: text/plain, Size: 4690 bytes --]
В Sun, 07 Apr 2013 14:38:40 +0200
Paul Menzel <paulepanter@users.sourceforge.net> пишет:
>
> s,nor,not,
>
>
> s,consequitive,consecutive,
>
>
> *variab*l*e
>
>
> Otherwise I did not spot anything.
>
Thank you for review. Updated patch follows.
From: Andrey Borzenkov <arvidjaar@gmail.com>
Subject: [PATCH] reimplement grub-reboot to not depend on GRUB_DEFAULT=saved
To: grub-devel@gnu.org
Use separate environment variable next_entry to indicate one time
boot entry. CMOS button still takes precedent. It makes grub-reboot
usable also when GRUB_DEFAULT is set to explicit value.
It retains support for prev_saved_entry for compatibility. Also
grub-reboot will restore saved_entry from prev_saved_entry first time
it is called.
As a side effect it also fixes a problem that saved_entry is lost
after two consecutive grub-reboot calls.
Signed-off-by: Andrey Borzenkov <arvidjaar@gmail.com>
---
ChangeLog | 5 +++++
util/grub-reboot.in | 17 ++++++-----------
util/grub-set-default.in | 1 +
| 14 +++++++++++++-
4 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3e606cb..d282ff2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-04-19 Andrey Borzenkov <arvidjaar@gmail.com>
+
+ Reimplement grub-reboot to not depend on saved_entry. Use next_entry
+ variable for one time boot menu entry.
+
2013-04-19 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/ieee1275/init.c (grub_claim_heap): Improve handling
diff --git a/util/grub-reboot.in b/util/grub-reboot.in
index 1a91d36..d132e4f 100644
--- a/util/grub-reboot.in
+++ b/util/grub-reboot.in
@@ -46,8 +46,6 @@ export TEXTDOMAINDIR="@localedir@"
usage () {
gettext_printf "Usage: %s [OPTION] MENU_ENTRY\n" "$self"
gettext "Set the default boot menu entry for GRUB, for the next boot only."; echo
- gettext_printf "This requires setting GRUB_DEFAULT=saved in %s/default/grub.\n" "$sysconfdir"
- echo
print_option_help "-h, --help" "$(gettext "print this message and exit")"
print_option_help "-v, --version" "$(gettext "print the version information and exit")"
dirmsg="$(gettext_printf "expect GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")"
@@ -129,17 +127,14 @@ fi
grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
-prev_saved_entry=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^saved_entry=//p'`
+# Restore saved_entry if it was set by previous version
+prev_saved_entry=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^prev_saved_entry=//p'`
if [ "$prev_saved_entry" ]; then
- $grub_editenv ${grubdir}/grubenv set prev_saved_entry="$prev_saved_entry"
-else
- # We need some non-empty value for prev_saved_entry so that GRUB will
- # recognise that grub-reboot has been used and restore the previous
- # saved entry. "0" is the same as an empty value, i.e. the first menu
- # entry.
- $grub_editenv ${grubdir}/grubenv set prev_saved_entry=0
+ $grub_editenv ${grubdir}/grubenv set saved_entry="$prev_saved_entry"
+ $grub_editenv ${grubdir}/grubenv unset prev_saved_entry
fi
-$grub_editenv ${grubdir}/grubenv set saved_entry="$entry"
+
+$grub_editenv ${grubdir}/grubenv set next_entry="$entry"
# Bye.
exit 0
diff --git a/util/grub-set-default.in b/util/grub-set-default.in
index ea18da1..d607318 100644
--- a/util/grub-set-default.in
+++ b/util/grub-set-default.in
@@ -130,6 +130,7 @@ fi
grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
$grub_editenv ${grubdir}/grubenv unset prev_saved_entry
+$grub_editenv ${grubdir}/grubenv unset next_entry
$grub_editenv ${grubdir}/grubenv set saved_entry="$entry"
# Bye.
--git a/util/grub.d/00_header.in b/util/grub.d/00_header.in
index 3da5d12..2c4bb0a 100644
--- a/util/grub.d/00_header.in
+++ b/util/grub.d/00_header.in
@@ -51,13 +51,25 @@ if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
cat <<EOF
if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then
set default="${GRUB_DEFAULT_BUTTON}"
+elif [ "\${next_entry}" ] ; then
+ set default="\${next_entry}"
+ set next_entry=
+ save_env next_entry
+ set boot_once=true
else
set default="${GRUB_DEFAULT}"
fi
EOF
else
cat <<EOF
-set default="${GRUB_DEFAULT}"
+if [ "\${next_entry}" ] ; then
+ set default="\${next_entry}"
+ set next_entry=
+ save_env next_entry
+ set boot_once=true
+else
+ set default="${GRUB_DEFAULT}"
+fi
EOF
fi
cat <<EOF
--
tg: (e25eae7..) u/boot-once (depends on: master)
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2013-04-19 14:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-30 9:08 [PATCH] reimplement grub-reboot to nor depend on GRUB_DEFAULT=saved Andrey Borzenkov
2013-04-06 19:52 ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-04-07 10:34 ` Andrey Borzenkov
2013-04-07 12:38 ` Paul Menzel
2013-04-19 14:12 ` Andrey Borzenkov [this message]
2013-05-04 22:18 ` Vladimir 'φ-coder/phcoder' Serbinenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130419181205.4a7753e1@opensuse.site \
--to=arvidjaar@gmail.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).