grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fix timeout handling with GRUB_HIDDEN_TIMEOUT=0
@ 2013-12-07 17:24 Andrey Borzenkov
  2013-12-18 17:22 ` Andrey Borzenkov
  2013-12-24 16:26 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 2 replies; 4+ messages in thread
From: Andrey Borzenkov @ 2013-12-07 17:24 UTC (permalink / raw)
  To: grub-devel

Before 44d488477902f0786d6bce44b74713f1713a34a9 combination of
GRUB_HIDDEN_TIMEOUT=0 and GRUB_TIMEOUT!=0 resulted in normal menu with
timeout. Now due to GRUB_HIDDEN_TIMEOUT taking precedence, it will always
set timeout to 0 and immediately load default entry.

To ensure that update does not break existing configuration, refactor
make_timeout code. We have

a) GRUB_TIMEOUT_STYLE set - assume new code
b) GRUB_HIDDEN_TIMEOUT > 0 - use existing logic to set GRUB_TIMEOUT_STYLE to
hidden|countdown
c) GRUB_HIDDEN_TIMEOUT = 0 - set GRUB_TIMOUT_STYLE to menu

There is no need to have special case for GRUB_TIMEOUT_STYLE not set - it is the
same as having it set to menu, so consolidate it with previous code.

---
 util/grub.d/00_header.in | 58 +++++++++++++++++++++++++-----------------------
 1 file changed, 30 insertions(+), 28 deletions(-)

diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in
index d2e7252..0c82f23 100644
--- a/util/grub.d/00_header.in
+++ b/util/grub.d/00_header.in
@@ -282,48 +282,50 @@ fi
 
 make_timeout ()
 {
-    if [ "x${1}${3}" != "x" ] ; then
-	if [ "x${3}" != "x" ] ; then
-	    timeout="${2}"
-	    style="${3}"
-	else
-	    # Handle the deprecated GRUB_HIDDEN_TIMEOUT scheme.
-	    timeout="${1}"
-	    if [ "x${2}" != "x0" ] ; then
-		grub_warn "$(gettext "Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.")"
-	    fi
-	    if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
-		style="hidden"
-	    else
-		style="countdown"
-	    fi
+    if [ "x${3}" != "x" ] ; then
+	timeout="${2}"
+	style="${3}"
+    elif [ "x${1}" != "x" -a "x${1}" != "x0" ] ; then
+	# Handle the deprecated GRUB_HIDDEN_TIMEOUT scheme.
+	timeout="${1}"
+	if [ "x${2}" != "x0" ] ; then
+	    grub_warn "$(gettext "Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.")"
 	fi
-	if [ "x${style}" = "xcountdown" ] ; then
-	    verbose=" --verbose"
-	else
+	if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
+	    style="hidden"
 	    verbose=
+	else
+	    style="countdown"
+	    verbose=" --verbose"
 	fi
-	cat << EOF
+    else
+	# No hidden timeout, so treat as GRUB_TIMEOUT_STYLE=menu
+	timeout="${2}"
+	style="menu"
+    fi
+    cat << EOF
 if [ x\$feature_timeout_style = xy ] ; then
   set timeout_style=${style}
   set timeout=${timeout}
 EOF
-	if [ "x${style}" != "xmenu" ] ; then
-	    cat << EOF
+    if [ "x${style}" = "xmenu" ] ; then
+	cat << EOF
+# Fallback normal timeout code in case the timeout_style feature is
+# unavailable.
+else
+  set timeout=${timeout}
+EOF
+    else
+	cat << EOF
 # Fallback hidden-timeout code in case the timeout_style feature is
 # unavailable.
 elif sleep${verbose} --interruptible ${timeout} ; then
   set timeout=0
 EOF
-	fi
-	cat << EOF
+    fi
+    cat << EOF
 fi
 EOF
-    else
-	cat << EOF
-set timeout=${2}
-EOF
-    fi
 }
 
 if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
-- 
tg: (bb05e31..) u/fix-hidden-timeout (depends on: master)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] fix timeout handling with GRUB_HIDDEN_TIMEOUT=0
  2013-12-07 17:24 [PATCH] fix timeout handling with GRUB_HIDDEN_TIMEOUT=0 Andrey Borzenkov
@ 2013-12-18 17:22 ` Andrey Borzenkov
  2013-12-18 17:34   ` Vladimir 'φ-coder/phcoder' Serbinenko
  2013-12-24 16:26 ` Vladimir 'φ-coder/phcoder' Serbinenko
  1 sibling, 1 reply; 4+ messages in thread
From: Andrey Borzenkov @ 2013-12-18 17:22 UTC (permalink / raw)
  To: grub-devel; +Cc: cjwatson

Ping? This fixes actual problem - default /etc/default/grub shipped on
openSUSE included GRUB_HIDDEN_TIMEOUT=0 which means timeout gets
disabled after update.

Colin, I Cc you as author of original patch - what do you think?


В Sat,  7 Dec 2013 21:24:19 +0400
Andrey Borzenkov <arvidjaar@gmail.com> пишет:

> Before 44d488477902f0786d6bce44b74713f1713a34a9 combination of
> GRUB_HIDDEN_TIMEOUT=0 and GRUB_TIMEOUT!=0 resulted in normal menu with
> timeout. Now due to GRUB_HIDDEN_TIMEOUT taking precedence, it will always
> set timeout to 0 and immediately load default entry.
> 
> To ensure that update does not break existing configuration, refactor
> make_timeout code. We have
> 
> a) GRUB_TIMEOUT_STYLE set - assume new code
> b) GRUB_HIDDEN_TIMEOUT > 0 - use existing logic to set GRUB_TIMEOUT_STYLE to
> hidden|countdown
> c) GRUB_HIDDEN_TIMEOUT = 0 - set GRUB_TIMOUT_STYLE to menu
> 
> There is no need to have special case for GRUB_TIMEOUT_STYLE not set - it is the
> same as having it set to menu, so consolidate it with previous code.
> 
> ---
>  util/grub.d/00_header.in | 58 +++++++++++++++++++++++++-----------------------
>  1 file changed, 30 insertions(+), 28 deletions(-)
> 
> diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in
> index d2e7252..0c82f23 100644
> --- a/util/grub.d/00_header.in
> +++ b/util/grub.d/00_header.in
> @@ -282,48 +282,50 @@ fi
>  
>  make_timeout ()
>  {
> -    if [ "x${1}${3}" != "x" ] ; then
> -	if [ "x${3}" != "x" ] ; then
> -	    timeout="${2}"
> -	    style="${3}"
> -	else
> -	    # Handle the deprecated GRUB_HIDDEN_TIMEOUT scheme.
> -	    timeout="${1}"
> -	    if [ "x${2}" != "x0" ] ; then
> -		grub_warn "$(gettext "Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.")"
> -	    fi
> -	    if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
> -		style="hidden"
> -	    else
> -		style="countdown"
> -	    fi
> +    if [ "x${3}" != "x" ] ; then
> +	timeout="${2}"
> +	style="${3}"
> +    elif [ "x${1}" != "x" -a "x${1}" != "x0" ] ; then
> +	# Handle the deprecated GRUB_HIDDEN_TIMEOUT scheme.
> +	timeout="${1}"
> +	if [ "x${2}" != "x0" ] ; then
> +	    grub_warn "$(gettext "Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.")"
>  	fi
> -	if [ "x${style}" = "xcountdown" ] ; then
> -	    verbose=" --verbose"
> -	else
> +	if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
> +	    style="hidden"
>  	    verbose=
> +	else
> +	    style="countdown"
> +	    verbose=" --verbose"
>  	fi
> -	cat << EOF
> +    else
> +	# No hidden timeout, so treat as GRUB_TIMEOUT_STYLE=menu
> +	timeout="${2}"
> +	style="menu"
> +    fi
> +    cat << EOF
>  if [ x\$feature_timeout_style = xy ] ; then
>    set timeout_style=${style}
>    set timeout=${timeout}
>  EOF
> -	if [ "x${style}" != "xmenu" ] ; then
> -	    cat << EOF
> +    if [ "x${style}" = "xmenu" ] ; then
> +	cat << EOF
> +# Fallback normal timeout code in case the timeout_style feature is
> +# unavailable.
> +else
> +  set timeout=${timeout}
> +EOF
> +    else
> +	cat << EOF
>  # Fallback hidden-timeout code in case the timeout_style feature is
>  # unavailable.
>  elif sleep${verbose} --interruptible ${timeout} ; then
>    set timeout=0
>  EOF
> -	fi
> -	cat << EOF
> +    fi
> +    cat << EOF
>  fi
>  EOF
> -    else
> -	cat << EOF
> -set timeout=${2}
> -EOF
> -    fi
>  }
>  
>  if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fix timeout handling with GRUB_HIDDEN_TIMEOUT=0
  2013-12-18 17:22 ` Andrey Borzenkov
@ 2013-12-18 17:34   ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 0 replies; 4+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2013-12-18 17:34 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 3944 bytes --]

@Colin: can you review this?
On 18.12.2013 18:22, Andrey Borzenkov wrote:
> Ping? This fixes actual problem - default /etc/default/grub shipped on
> openSUSE included GRUB_HIDDEN_TIMEOUT=0 which means timeout gets
> disabled after update.
> 
> Colin, I Cc you as author of original patch - what do you think?
> 
> 
> В Sat,  7 Dec 2013 21:24:19 +0400
> Andrey Borzenkov <arvidjaar@gmail.com> пишет:
> 
>> Before 44d488477902f0786d6bce44b74713f1713a34a9 combination of
>> GRUB_HIDDEN_TIMEOUT=0 and GRUB_TIMEOUT!=0 resulted in normal menu with
>> timeout. Now due to GRUB_HIDDEN_TIMEOUT taking precedence, it will always
>> set timeout to 0 and immediately load default entry.
>>
>> To ensure that update does not break existing configuration, refactor
>> make_timeout code. We have
>>
>> a) GRUB_TIMEOUT_STYLE set - assume new code
>> b) GRUB_HIDDEN_TIMEOUT > 0 - use existing logic to set GRUB_TIMEOUT_STYLE to
>> hidden|countdown
>> c) GRUB_HIDDEN_TIMEOUT = 0 - set GRUB_TIMOUT_STYLE to menu
>>
>> There is no need to have special case for GRUB_TIMEOUT_STYLE not set - it is the
>> same as having it set to menu, so consolidate it with previous code.
>>
>> ---
>>  util/grub.d/00_header.in | 58 +++++++++++++++++++++++++-----------------------
>>  1 file changed, 30 insertions(+), 28 deletions(-)
>>
>> diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in
>> index d2e7252..0c82f23 100644
>> --- a/util/grub.d/00_header.in
>> +++ b/util/grub.d/00_header.in
>> @@ -282,48 +282,50 @@ fi
>>  
>>  make_timeout ()
>>  {
>> -    if [ "x${1}${3}" != "x" ] ; then
>> -	if [ "x${3}" != "x" ] ; then
>> -	    timeout="${2}"
>> -	    style="${3}"
>> -	else
>> -	    # Handle the deprecated GRUB_HIDDEN_TIMEOUT scheme.
>> -	    timeout="${1}"
>> -	    if [ "x${2}" != "x0" ] ; then
>> -		grub_warn "$(gettext "Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.")"
>> -	    fi
>> -	    if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
>> -		style="hidden"
>> -	    else
>> -		style="countdown"
>> -	    fi
>> +    if [ "x${3}" != "x" ] ; then
>> +	timeout="${2}"
>> +	style="${3}"
>> +    elif [ "x${1}" != "x" -a "x${1}" != "x0" ] ; then
>> +	# Handle the deprecated GRUB_HIDDEN_TIMEOUT scheme.
>> +	timeout="${1}"
>> +	if [ "x${2}" != "x0" ] ; then
>> +	    grub_warn "$(gettext "Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.")"
>>  	fi
>> -	if [ "x${style}" = "xcountdown" ] ; then
>> -	    verbose=" --verbose"
>> -	else
>> +	if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
>> +	    style="hidden"
>>  	    verbose=
>> +	else
>> +	    style="countdown"
>> +	    verbose=" --verbose"
>>  	fi
>> -	cat << EOF
>> +    else
>> +	# No hidden timeout, so treat as GRUB_TIMEOUT_STYLE=menu
>> +	timeout="${2}"
>> +	style="menu"
>> +    fi
>> +    cat << EOF
>>  if [ x\$feature_timeout_style = xy ] ; then
>>    set timeout_style=${style}
>>    set timeout=${timeout}
>>  EOF
>> -	if [ "x${style}" != "xmenu" ] ; then
>> -	    cat << EOF
>> +    if [ "x${style}" = "xmenu" ] ; then
>> +	cat << EOF
>> +# Fallback normal timeout code in case the timeout_style feature is
>> +# unavailable.
>> +else
>> +  set timeout=${timeout}
>> +EOF
>> +    else
>> +	cat << EOF
>>  # Fallback hidden-timeout code in case the timeout_style feature is
>>  # unavailable.
>>  elif sleep${verbose} --interruptible ${timeout} ; then
>>    set timeout=0
>>  EOF
>> -	fi
>> -	cat << EOF
>> +    fi
>> +    cat << EOF
>>  fi
>>  EOF
>> -    else
>> -	cat << EOF
>> -set timeout=${2}
>> -EOF
>> -    fi
>>  }
>>  
>>  if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
> 
> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 291 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fix timeout handling with GRUB_HIDDEN_TIMEOUT=0
  2013-12-07 17:24 [PATCH] fix timeout handling with GRUB_HIDDEN_TIMEOUT=0 Andrey Borzenkov
  2013-12-18 17:22 ` Andrey Borzenkov
@ 2013-12-24 16:26 ` Vladimir 'φ-coder/phcoder' Serbinenko
  1 sibling, 0 replies; 4+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2013-12-24 16:26 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 2628 bytes --]

Committed, thanks

On 07.12.2013 18:24, Andrey Borzenkov wrote:
>  util/grub.d/00_header.in | 58 +++++++++++++++++++++++++-----------------------
>  1 file changed, 30 insertions(+), 28 deletions(-)
> 
> diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in
> index d2e7252..0c82f23 100644
> --- a/util/grub.d/00_header.in
> +++ b/util/grub.d/00_header.in
> @@ -282,48 +282,50 @@ fi
>  
>  make_timeout ()
>  {
> -    if [ "x${1}${3}" != "x" ] ; then
> -	if [ "x${3}" != "x" ] ; then
> -	    timeout="${2}"
> -	    style="${3}"
> -	else
> -	    # Handle the deprecated GRUB_HIDDEN_TIMEOUT scheme.
> -	    timeout="${1}"
> -	    if [ "x${2}" != "x0" ] ; then
> -		grub_warn "$(gettext "Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.")"
> -	    fi
> -	    if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
> -		style="hidden"
> -	    else
> -		style="countdown"
> -	    fi
> +    if [ "x${3}" != "x" ] ; then
> +	timeout="${2}"
> +	style="${3}"
> +    elif [ "x${1}" != "x" -a "x${1}" != "x0" ] ; then
> +	# Handle the deprecated GRUB_HIDDEN_TIMEOUT scheme.
> +	timeout="${1}"
> +	if [ "x${2}" != "x0" ] ; then
> +	    grub_warn "$(gettext "Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.")"
>  	fi
> -	if [ "x${style}" = "xcountdown" ] ; then
> -	    verbose=" --verbose"
> -	else
> +	if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
> +	    style="hidden"
>  	    verbose=
> +	else
> +	    style="countdown"
> +	    verbose=" --verbose"
>  	fi
> -	cat << EOF
> +    else
> +	# No hidden timeout, so treat as GRUB_TIMEOUT_STYLE=menu
> +	timeout="${2}"
> +	style="menu"
> +    fi
> +    cat << EOF
>  if [ x\$feature_timeout_style = xy ] ; then
>    set timeout_style=${style}
>    set timeout=${timeout}
>  EOF
> -	if [ "x${style}" != "xmenu" ] ; then
> -	    cat << EOF
> +    if [ "x${style}" = "xmenu" ] ; then
> +	cat << EOF
> +# Fallback normal timeout code in case the timeout_style feature is
> +# unavailable.
> +else
> +  set timeout=${timeout}
> +EOF
> +    else
> +	cat << EOF
>  # Fallback hidden-timeout code in case the timeout_style feature is
>  # unavailable.
>  elif sleep${verbose} --interruptible ${timeout} ; then
>    set timeout=0
>  EOF
> -	fi
> -	cat << EOF
> +    fi
> +    cat << EOF
>  fi
>  EOF
> -    else
> -	cat << EOF
> -set timeout=${2}
> -EOF
> -    fi
>  }
>  
>  if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
> -- tg: (bb05e31..) u/fix-hidden-timeout (depends on: master)



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 291 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-12-24 16:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-07 17:24 [PATCH] fix timeout handling with GRUB_HIDDEN_TIMEOUT=0 Andrey Borzenkov
2013-12-18 17:22 ` Andrey Borzenkov
2013-12-18 17:34   ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-12-24 16:26 ` Vladimir 'φ-coder/phcoder' Serbinenko

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).