]> git.proxmox.com Git - grub2.git/blob - debian/patches/maybe-quiet.patch
Drop mkconfig-mid-upgrade.patch
[grub2.git] / debian / patches / maybe-quiet.patch
1 From 4225ea9ee7c546c4340e658b0bd6983c436a5f51 Mon Sep 17 00:00:00 2001
2 From: Colin Watson <cjwatson@ubuntu.com>
3 Date: Mon, 13 Jan 2014 12:13:26 +0000
4 Subject: Add configure option to reduce visual clutter at boot time
5
6 If this option is enabled, then do all of the following:
7
8 Don't display introductory message about line editing unless we're
9 actually offering a shell prompt. (This is believed to be a workaround
10 for a different bug. We'll go with this for now, but will drop this in
11 favour of a better fix upstream if somebody figures out what that is.)
12
13 Don't clear the screen just before booting if we never drew the menu in
14 the first place.
15
16 Remove verbose messages printed before reading configuration. In some
17 ways this is awkward because it makes debugging harder, but it's a
18 requirement for a smooth-looking boot process; we may be able to do
19 better in future. Upstream doesn't want this, though.
20
21 Disable the cursor as well, for similar reasons of tidiness.
22
23 Suppress kernel/initrd progress messages, except in recovery mode.
24
25 Suppress "GRUB loading" message unless Shift is held down. Upstream
26 doesn't want this, as it makes debugging harder. Ubuntu wants it to
27 provide a cleaner boot experience.
28
29 Author: Will Thompson <will@willthompson.co.uk>
30 Bug-Ubuntu: https://bugs.launchpad.net/bugs/386922
31 Bug-Ubuntu: https://bugs.launchpad.net/bugs/861048
32 Forwarded: (partial) http://lists.gnu.org/archive/html/grub-devel/2009-09/msg00056.html
33 Last-Update: 2019-06-24
34
35 Patch-Name: maybe-quiet.patch
36 ---
37 config.h.in | 2 ++
38 configure.ac | 16 ++++++++++++++++
39 grub-core/boot/i386/pc/boot.S | 11 +++++++++++
40 grub-core/boot/i386/pc/diskboot.S | 26 ++++++++++++++++++++++++++
41 grub-core/kern/main.c | 17 +++++++++++++++++
42 grub-core/kern/rescue_reader.c | 2 ++
43 grub-core/normal/main.c | 11 +++++++++++
44 grub-core/normal/menu.c | 17 +++++++++++++++--
45 util/grub.d/10_linux.in | 15 +++++++++++----
46 9 files changed, 111 insertions(+), 6 deletions(-)
47
48 diff --git a/config.h.in b/config.h.in
49 index 9e8f9911b..d2c4ce8e5 100644
50 --- a/config.h.in
51 +++ b/config.h.in
52 @@ -12,6 +12,8 @@
53 /* Define to 1 to enable disk cache statistics. */
54 #define DISK_CACHE_STATS @DISK_CACHE_STATS@
55 #define BOOT_TIME_STATS @BOOT_TIME_STATS@
56 +/* Define to 1 to make GRUB quieter at boot time. */
57 +#define QUIET_BOOT @QUIET_BOOT@
58
59 /* We don't need those. */
60 #define MINILZO_CFG_SKIP_LZO_PTR 1
61 diff --git a/configure.ac b/configure.ac
62 index 1e5abc67d..ea00ccd69 100644
63 --- a/configure.ac
64 +++ b/configure.ac
65 @@ -1857,6 +1857,17 @@ else
66 fi
67 AC_SUBST([UBUNTU_RECOVERY])
68
69 +AC_ARG_ENABLE([quiet-boot],
70 + [AS_HELP_STRING([--enable-quiet-boot],
71 + [emit fewer messages at boot time (default=no)])],
72 + [], [enable_quiet_boot=no])
73 +if test x"$enable_quiet_boot" = xyes ; then
74 + QUIET_BOOT=1
75 +else
76 + QUIET_BOOT=0
77 +fi
78 +AC_SUBST([QUIET_BOOT])
79 +
80 LIBS=""
81
82 AC_SUBST([FONT_SOURCE])
83 @@ -2114,5 +2125,10 @@ echo "Without liblzma (no support for XZ-compressed mips images) ($liblzma_excus
84 else
85 echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)"
86 fi
87 +if [ x"$enable_quiet_boot" = xyes ]; then
88 +echo With quiet boot: Yes
89 +else
90 +echo With quiet boot: No
91 +fi
92 echo "*******************************************************"
93 ]
94 diff --git a/grub-core/boot/i386/pc/boot.S b/grub-core/boot/i386/pc/boot.S
95 index 2bd0b2d28..b0c0f2225 100644
96 --- a/grub-core/boot/i386/pc/boot.S
97 +++ b/grub-core/boot/i386/pc/boot.S
98 @@ -19,6 +19,9 @@
99
100 #include <grub/symbol.h>
101 #include <grub/machine/boot.h>
102 +#if QUIET_BOOT && !defined(HYBRID_BOOT)
103 +#include <grub/machine/memory.h>
104 +#endif
105
106 /*
107 * defines for the code go here
108 @@ -249,9 +252,17 @@ real_start:
109 /* save drive reference first thing! */
110 pushw %dx
111
112 +#if QUIET_BOOT && !defined(HYBRID_BOOT)
113 + /* is either shift key held down? */
114 + movw $(GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR + 0x17), %bx
115 + testb $3, (%bx)
116 + jz 2f
117 +#endif
118 +
119 /* print a notification message on the screen */
120 MSG(notification_string)
121
122 +2:
123 /* set %si to the disk address packet */
124 movw $disk_address_packet, %si
125
126 diff --git a/grub-core/boot/i386/pc/diskboot.S b/grub-core/boot/i386/pc/diskboot.S
127 index c1addc0df..9b6d7a7ed 100644
128 --- a/grub-core/boot/i386/pc/diskboot.S
129 +++ b/grub-core/boot/i386/pc/diskboot.S
130 @@ -18,6 +18,9 @@
131
132 #include <grub/symbol.h>
133 #include <grub/machine/boot.h>
134 +#if QUIET_BOOT
135 +#include <grub/machine/memory.h>
136 +#endif
137
138 /*
139 * defines for the code go here
140 @@ -25,6 +28,12 @@
141
142 #define MSG(x) movw $x, %si; call LOCAL(message)
143
144 +#if QUIET_BOOT
145 +#define SILENT(x) call LOCAL(check_silent); jz LOCAL(x)
146 +#else
147 +#define SILENT(x)
148 +#endif
149 +
150 .file "diskboot.S"
151
152 .text
153 @@ -50,11 +59,14 @@ _start:
154 /* save drive reference first thing! */
155 pushw %dx
156
157 + SILENT(after_notification_string)
158 +
159 /* print a notification message on the screen */
160 pushw %si
161 MSG(notification_string)
162 popw %si
163
164 +LOCAL(after_notification_string):
165 /* this sets up for the first run through "bootloop" */
166 movw $LOCAL(firstlist), %di
167
168 @@ -279,7 +291,10 @@ LOCAL(copy_buffer):
169 /* restore addressing regs and print a dot with correct DS
170 (MSG modifies SI, which is saved, and unused AX and BX) */
171 popw %ds
172 + SILENT(after_notification_step)
173 MSG(notification_step)
174 +
175 +LOCAL(after_notification_step):
176 popa
177
178 /* check if finished with this dataset */
179 @@ -295,8 +310,11 @@ LOCAL(copy_buffer):
180 /* END OF MAIN LOOP */
181
182 LOCAL(bootit):
183 + SILENT(after_notification_done)
184 /* print a newline */
185 MSG(notification_done)
186 +
187 +LOCAL(after_notification_done):
188 popw %dx /* this makes sure %dl is our "boot" drive */
189 ljmp $0, $(GRUB_BOOT_MACHINE_KERNEL_ADDR + 0x200)
190
191 @@ -320,6 +338,14 @@ LOCAL(general_error):
192 /* go here when you need to stop the machine hard after an error condition */
193 LOCAL(stop): jmp LOCAL(stop)
194
195 +#if QUIET_BOOT
196 +LOCAL(check_silent):
197 + /* is either shift key held down? */
198 + movw $(GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR + 0x17), %bx
199 + testb $3, (%bx)
200 + ret
201 +#endif
202 +
203 notification_string: .asciz "loading"
204
205 notification_step: .asciz "."
206 diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c
207 index 9cad0c448..714b63d67 100644
208 --- a/grub-core/kern/main.c
209 +++ b/grub-core/kern/main.c
210 @@ -264,15 +264,25 @@ reclaim_module_space (void)
211 void __attribute__ ((noreturn))
212 grub_main (void)
213 {
214 +#if QUIET_BOOT
215 + struct grub_term_output *term;
216 +#endif
217 +
218 /* First of all, initialize the machine. */
219 grub_machine_init ();
220
221 grub_boot_time ("After machine init.");
222
223 +#if QUIET_BOOT
224 + /* Disable the cursor until we need it. */
225 + FOR_ACTIVE_TERM_OUTPUTS(term)
226 + grub_term_setcursor (term, 0);
227 +#else
228 /* Hello. */
229 grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
230 grub_printf ("Welcome to GRUB!\n\n");
231 grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
232 +#endif
233
234 grub_load_config ();
235
236 @@ -308,5 +318,12 @@ grub_main (void)
237 grub_boot_time ("After execution of embedded config. Attempt to go to normal mode");
238
239 grub_load_normal_mode ();
240 +
241 +#if QUIET_BOOT
242 + /* If we have to enter rescue mode, enable the cursor again. */
243 + FOR_ACTIVE_TERM_OUTPUTS(term)
244 + grub_term_setcursor (term, 1);
245 +#endif
246 +
247 grub_rescue_run ();
248 }
249 diff --git a/grub-core/kern/rescue_reader.c b/grub-core/kern/rescue_reader.c
250 index dcd7d4439..a93524eab 100644
251 --- a/grub-core/kern/rescue_reader.c
252 +++ b/grub-core/kern/rescue_reader.c
253 @@ -78,7 +78,9 @@ grub_rescue_read_line (char **line, int cont,
254 void __attribute__ ((noreturn))
255 grub_rescue_run (void)
256 {
257 +#if QUIET_BOOT
258 grub_printf ("Entering rescue mode...\n");
259 +#endif
260
261 while (1)
262 {
263 diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
264 index 1b03dfd57..0aa389fa1 100644
265 --- a/grub-core/normal/main.c
266 +++ b/grub-core/normal/main.c
267 @@ -389,6 +389,15 @@ static grub_err_t
268 grub_normal_read_line_real (char **line, int cont, int nested)
269 {
270 const char *prompt;
271 +#if QUIET_BOOT
272 + static int displayed_intro;
273 +
274 + if (! displayed_intro)
275 + {
276 + grub_normal_reader_init (nested);
277 + displayed_intro = 1;
278 + }
279 +#endif
280
281 if (cont)
282 /* TRANSLATORS: it's command line prompt. */
283 @@ -441,7 +450,9 @@ grub_cmdline_run (int nested, int force_auth)
284 return;
285 }
286
287 +#if !QUIET_BOOT
288 grub_normal_reader_init (nested);
289 +#endif
290
291 while (1)
292 {
293 diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
294 index 3611ee9ea..ebf5a0f10 100644
295 --- a/grub-core/normal/menu.c
296 +++ b/grub-core/normal/menu.c
297 @@ -827,12 +827,18 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
298
299 /* Callback invoked immediately before a menu entry is executed. */
300 static void
301 -notify_booting (grub_menu_entry_t entry,
302 +notify_booting (grub_menu_entry_t entry
303 +#if QUIET_BOOT
304 + __attribute__((unused))
305 +#endif
306 + ,
307 void *userdata __attribute__((unused)))
308 {
309 +#if !QUIET_BOOT
310 grub_printf (" ");
311 grub_printf_ (N_("Booting `%s'"), entry->title);
312 grub_printf ("\n\n");
313 +#endif
314 }
315
316 /* Callback invoked when a default menu entry executed because of a timeout
317 @@ -880,6 +886,9 @@ show_menu (grub_menu_t menu, int nested, int autobooted)
318 int boot_entry;
319 grub_menu_entry_t e;
320 int auto_boot;
321 +#if QUIET_BOOT
322 + int initial_timeout = grub_menu_get_timeout ();
323 +#endif
324
325 boot_entry = run_menu (menu, nested, &auto_boot);
326 if (boot_entry < 0)
327 @@ -889,7 +898,11 @@ show_menu (grub_menu_t menu, int nested, int autobooted)
328 if (! e)
329 continue; /* Menu is empty. */
330
331 - grub_cls ();
332 +#if QUIET_BOOT
333 + /* Only clear the screen if we drew the menu in the first place. */
334 + if (initial_timeout != 0)
335 +#endif
336 + grub_cls ();
337
338 if (auto_boot)
339 grub_menu_execute_with_fallback (menu, e, autobooted,
340 diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
341 index 61335e908..2e4dff9fb 100644
342 --- a/util/grub.d/10_linux.in
343 +++ b/util/grub.d/10_linux.in
344 @@ -21,6 +21,7 @@ prefix="@prefix@"
345 exec_prefix="@exec_prefix@"
346 datarootdir="@datarootdir@"
347 ubuntu_recovery="@UBUNTU_RECOVERY@"
348 +quiet_boot="@QUIET_BOOT@"
349
350 . "$pkgdatadir/grub-mkconfig_lib"
351
352 @@ -158,10 +159,12 @@ linux_entry ()
353 fi
354 printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
355 fi
356 - message="$(gettext_printf "Loading Linux %s ..." ${version})"
357 - sed "s/^/$submenu_indentation/" << EOF
358 + if [ x"$quiet_boot" = x0 ] || [ x"$type" != xsimple ]; then
359 + message="$(gettext_printf "Loading Linux %s ..." ${version})"
360 + sed "s/^/$submenu_indentation/" << EOF
361 echo '$(echo "$message" | grub_quote)'
362 EOF
363 + fi
364 if test -d /sys/firmware/efi && test -e "${linux}.efi.signed"; then
365 sed "s/^/$submenu_indentation/" << EOF
366 linux ${rel_dirname}/${basename}.efi.signed root=${linux_root_device_thisversion} ro ${args}
367 @@ -173,13 +176,17 @@ EOF
368 fi
369 if test -n "${initrd}" ; then
370 # TRANSLATORS: ramdisk isn't identifier. Should be translated.
371 - message="$(gettext_printf "Loading initial ramdisk ...")"
372 + if [ x"$quiet_boot" = x0 ] || [ x"$type" != xsimple ]; then
373 + message="$(gettext_printf "Loading initial ramdisk ...")"
374 + sed "s/^/$submenu_indentation/" << EOF
375 + echo '$(echo "$message" | grub_quote)'
376 +EOF
377 + fi
378 initrd_path=
379 for i in ${initrd}; do
380 initrd_path="${initrd_path} ${rel_dirname}/${i}"
381 done
382 sed "s/^/$submenu_indentation/" << EOF
383 - echo '$(echo "$message" | grub_quote)'
384 initrd $(echo $initrd_path)
385 EOF
386 fi