~hamo/ubuntu/precise/grub2/grub2.lp1297128

« back to all changes in this revision

Viewing changes to debian/patches/ubuntu_quick_boot.patch

  • Committer: Colin Watson
  • Date: 2013-12-04 14:01:16 UTC
  • Revision ID: cjwatson@canonical.com-20131204140116-xrlm630n0613wwfg
Revamp hidden timeout handling by adding a new timeout_style environment
variable and a corresponding GRUB_TIMEOUT_STYLE configuration key for
grub-mkconfig.  This controls hidden-timeout handling more simply than
the previous arrangements, and pressing any hotkeys associated with menu
entries during the hidden timeout will now boot the corresponding menu
entry immediately (LP: #1178618).  As part of merging this, radically
simplify /etc/grub.d/30_os-prober; if it finds other OSes it can now
just set timeout_style=menu and make sure the timeout is non-zero.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 https://wiki.ubuntu.com/DesktopExperienceTeam/KarmicBootExperienceDesignSpec#Bootloader.
11
11
Author: Colin Watson <cjwatson@ubuntu.com>
12
12
Forwarded: no
13
 
Last-Update: 2011-01-05
 
13
Last-Update: 2013-12-04
14
14
 
15
 
Index: b/util/grub.d/00_header.in
16
 
===================================================================
17
 
--- a/util/grub.d/00_header.in
18
 
+++ b/util/grub.d/00_header.in
19
 
@@ -225,22 +225,9 @@
20
 
 
21
 
 make_timeout ()
22
 
 {
23
 
-    if [ "x${1}" != "x" ] ; then
24
 
-       if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
25
 
-           verbose=
26
 
-       else
27
 
-           verbose=" --verbose"
28
 
-       fi
29
 
-       cat << EOF
30
 
-if sleep$verbose --interruptible ${1} ; then
31
 
-  set timeout=${2}
32
 
-fi
33
 
-EOF
34
 
-    else
35
 
-       cat << EOF
36
 
+    cat << EOF
37
 
 set timeout=${2}
38
 
 EOF
39
 
-    fi
40
 
 }
41
 
 
42
 
 if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
43
15
Index: b/util/grub.d/30_os-prober.in
44
16
===================================================================
45
17
--- a/util/grub.d/30_os-prober.in
46
18
+++ b/util/grub.d/30_os-prober.in
47
 
@@ -23,22 +23,80 @@
 
19
@@ -23,6 +23,19 @@
48
20
 
49
21
 . "@datadir@/grub/grub-mkconfig_lib"
50
22
 
51
23
+found_other_os=
52
24
+
53
 
+make_timeout () {
54
 
+  if [ "x${found_other_os}" = "x" ] ; then
55
 
+    if [ "x${1}" != "x" ] ; then
56
 
+      if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
57
 
+       verbose=
58
 
+      else
59
 
+       verbose=" --verbose"
60
 
+      fi
61
 
+
62
 
+      if [ "x${1}" = "x0" ] ; then
63
 
+       cat <<EOF
64
 
+if [ "x\${timeout}" != "x-1" ]; then
65
 
+  if keystatus; then
66
 
+    if keystatus --shift; then
67
 
+      set timeout=-1
68
 
+    else
69
 
+      set timeout=0
70
 
+    fi
71
 
+  else
72
 
+    if sleep$verbose --interruptible 3 ; then
73
 
+      set timeout=0
74
 
+    fi
75
 
+  fi
76
 
+fi
77
 
+EOF
78
 
+      else
79
 
+       cat << EOF
80
 
+if [ "x\${timeout}" != "x-1" ]; then
81
 
+  if sleep$verbose --interruptible ${GRUB_HIDDEN_TIMEOUT} ; then
82
 
+    set timeout=0
83
 
+  fi
84
 
+fi
85
 
+EOF
86
 
+      fi
87
 
+    fi
88
 
+  fi
89
 
+}
90
 
+
91
25
+adjust_timeout () {
92
 
+  if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
93
 
+    cat <<EOF
94
 
+if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then
 
26
+  if [ "x${found_other_os}" != "x" ]; then
 
27
+    cat << EOF
 
28
+set timeout_style=menu
 
29
+if [ "\${timeout}" = 0 ]; then
 
30
+  set timeout=10
 
31
+fi
95
32
+EOF
96
 
+    make_timeout "${GRUB_HIDDEN_TIMEOUT_BUTTON}" "${GRUB_TIMEOUT_BUTTON}"
97
 
+    echo else
98
 
+    make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}"
99
 
+    echo fi
100
 
+  else
101
 
+    make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}"
102
33
+  fi
103
34
+}
104
35
+
105
36
 if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then
106
 
+  adjust_timeout
107
 
   exit 0
108
 
 fi
109
 
 
110
 
 if [ -z "`which os-prober 2> /dev/null`" -o -z "`which linux-boot-prober 2> /dev/null`" ] ; then
111
 
   # missing os-prober and/or linux-boot-prober
112
 
+  adjust_timeout
113
 
   exit 0
114
 
 fi
115
 
 
116
 
 OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`"
117
 
 if [ -z "${OSPROBED}" ] ; then
118
 
   # empty os-prober output, nothing doing
119
 
+  adjust_timeout
120
 
   exit 0
 
37
   exit 0
 
38
 fi
 
39
@@ -39,6 +52,7 @@
121
40
 fi
122
41
 
123
42
 osx_entry() {
125
44
         cat << EOF
126
45
 menuentry "${LONGNAME} (${2}-bit) (on ${DEVICE})" --class osx --class darwin --class os {
127
46
 EOF
128
 
@@ -104,6 +162,7 @@
 
47
@@ -104,6 +118,7 @@
129
48
   case ${BOOT} in
130
49
     chain)
131
50
 
133
52
       cat << EOF
134
53
 menuentry "${LONGNAME} (on ${DEVICE})" --class windows --class os {
135
54
 EOF
136
 
@@ -146,6 +205,7 @@
 
55
@@ -146,6 +161,7 @@
137
56
          LINITRD="${LINITRD#/boot}"
138
57
        fi
139
58
 
141
60
         cat << EOF
142
61
 menuentry "${LLABEL} (on ${DEVICE})" --class gnu-linux --class gnu --class os {
143
62
 EOF
144
 
@@ -173,6 +233,7 @@
 
63
@@ -173,6 +189,7 @@
145
64
       osx_entry xnu_kernel64 64
146
65
     ;;
147
66
     hurd)
149
68
       cat << EOF
150
69
 menuentry "${LONGNAME} (on ${DEVICE})" --class hurd --class gnu --class os {
151
70
 EOF
152
 
@@ -202,3 +263,5 @@
 
71
@@ -202,3 +219,5 @@
153
72
     ;;
154
73
   esac
155
74
 done