diff --git a/debian/changelog b/debian/changelog index d077324a7..43add23db 100644 --- a/debian/changelog +++ b/debian/changelog @@ -17,6 +17,7 @@ grub2 (2.00-20) UNRELEASED; urgency=low (LP: #1242417). - If building for Ubuntu: + Bypass menu unless other OSes are installed or Shift is pressed. + + Show the boot menu if the previous boot failed. -- Colin Watson Mon, 07 Oct 2013 09:48:53 +0100 diff --git a/debian/control b/debian/control index 35f3cc9a2..294c36236 100644 --- a/debian/control +++ b/debian/control @@ -71,7 +71,7 @@ Description: GRand Unified Bootloader, version 2 (dummy package) Package: grub-common Priority: optional Architecture: any-i386 any-amd64 any-powerpc any-ppc64 any-sparc any-mipsel any-ia64 -Depends: ${shlibs:Depends}, ${misc:Depends}, gettext-base +Depends: ${shlibs:Depends}, ${misc:Depends}, gettext-base, ${lsb-base-depends} Replaces: grub-pc (<< 2.00-4), grub-ieee1275 (<< 2.00-4), grub-efi (<< 1.99-1), grub-coreboot (<< 2.00-4), grub-linuxbios (<< 1.96+20080831-1), grub-efi-ia32 (<< 2.00-4), grub-efi-amd64 (<< 2.00-4), grub-efi-ia64 (<< 2.00-4), grub-yeeloong (<< 2.00-4) Recommends: os-prober (>= 1.33) Suggests: multiboot-doc, grub-emu, xorriso (>= 0.5.6.pl00), desktop-base (>= 4.0.6), console-setup diff --git a/debian/grub-common.init b/debian/grub-common.init new file mode 100644 index 000000000..9734b1f68 --- /dev/null +++ b/debian/grub-common.init @@ -0,0 +1,42 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: grub-common +# Required-Start: $all +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: +# Short-Description: Record successful boot for GRUB +# Description: GRUB displays the boot menu at the next boot if it +# believes that the previous boot failed. This script +# informs it that the system booted successfully. +### END INIT INFO + +which grub-editenv >/dev/null 2>&1 || exit 0 + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +case $1 in + start|restart|force-reload) + [ "$VERBOSE" != no ] && log_action_msg "Recording successful boot for GRUB" + [ -s /boot/grub/grubenv ] || rm -f /boot/grub/grubenv + mkdir -p /boot/grub + grub-editenv /boot/grub/grubenv unset recordfail + [ "$VERBOSE" != no ] && log_end_msg $? + ;; + stop) + ;; + status) + exit 0 + ;; + *) + echo "Usage: $0 {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + +exit 0 diff --git a/debian/grub-common.pm-sleep b/debian/grub-common.pm-sleep new file mode 100644 index 000000000..eaedb04d7 --- /dev/null +++ b/debian/grub-common.pm-sleep @@ -0,0 +1,11 @@ +#!/bin/sh + +# Tell grub that resume was successful + +case "$1" in + thaw) + [ -s /boot/grub/grubenv ] || rm -f /boot/grub/grubenv + mkdir -p /boot/grub + grub-editenv /boot/grub/grubenv unset recordfail + ;; +esac diff --git a/debian/patches/quick_boot.patch b/debian/patches/quick_boot.patch index 356134c44..2e5ed5ee2 100644 --- a/debian/patches/quick_boot.patch +++ b/debian/patches/quick_boot.patch @@ -8,9 +8,13 @@ Description: Add configure option to bypass boot menu if possible This may or may not remain Ubuntu-specific, although it's not obviously wanted upstream. It implements a requirement of https://wiki.ubuntu.com/DesktopExperienceTeam/KarmicBootExperienceDesignSpec#Bootloader. + . + If the previous boot failed (defined as failing to get to the end of one of + the normal runlevels), then show the boot menu regardless. Author: Colin Watson +Author: Richard Laager Forwarded: no -Last-Update: 2013-11-12 +Last-Update: 2013-11-13 Index: b/configure.ac =================================================================== @@ -34,27 +38,132 @@ Index: b/configure.ac LIBS="" AC_SUBST([FONT_SOURCE]) +Index: b/docs/grub.texi +=================================================================== +--- a/docs/grub.texi ++++ b/docs/grub.texi +@@ -1289,6 +1289,15 @@ + Each module will be loaded as early as possible, at the start of + @file{grub.cfg}. + ++@item GRUB_RECORDFAIL_TIMEOUT ++If this option is set, it overrides the default recordfail setting. The ++default setting is -1, which causes GRUB to wait for user input. This option ++should be set on headless and appliance systems where access to a console is ++restricted or limited. ++ ++This option is only effective when GRUB was configured with the ++@option{--enable-quick-boot} option. ++ + @end table + + For more detailed customisation of @command{grub-mkconfig}'s output, you may +Index: b/util/grub-mkconfig.in +=================================================================== +--- a/util/grub-mkconfig.in ++++ b/util/grub-mkconfig.in +@@ -228,7 +228,8 @@ + GRUB_INIT_TUNE \ + GRUB_SAVEDEFAULT \ + GRUB_ENABLE_CRYPTODISK \ +- GRUB_BADRAM ++ GRUB_BADRAM \ ++ GRUB_RECORDFAIL_TIMEOUT + + if test "x${grub_cfg}" != "x"; then + rm -f "${grub_cfg}.new" Index: b/util/grub.d/00_header.in =================================================================== --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in -@@ -23,6 +23,7 @@ +@@ -23,6 +23,8 @@ exec_prefix="@exec_prefix@" datarootdir="@datarootdir@" grub_lang=`echo $LANG | cut -d . -f 1` ++grubdir="`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`" +quick_boot="@QUICK_BOOT@" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" -@@ -272,7 +273,7 @@ +@@ -46,6 +48,7 @@ + + cat << EOF + if [ -s \$prefix/grubenv ]; then ++ set have_grubenv=true + load_env + fi + EOF +@@ -86,7 +89,31 @@ + save_env saved_entry + fi + } ++EOF ++ ++if [ "$quick_boot" = 1 ]; then ++ cat <= 3.0-6)" else DEFAULT_CMDLINE := quiet +substvars := endif SB_PACKAGE := @@ -303,6 +305,10 @@ install/grub-common: >> debian/grub-common.$$i ; \ fi ; \ done +ifeq (yes,$(shell dpkg-vendor --derives-from Ubuntu && echo yes)) + install -D -m 0755 debian/grub-common.pm-sleep \ + $(CURDIR)/debian/$(package)/etc/pm/sleep.d/10_grub-common +endif override_dh_install: dh_install -pgrub2 -pgrub-linuxbios -pgrub-efi -pgrub-rescue-pc -pgrub-firmware-qemu @@ -331,6 +337,14 @@ override_dh_installdocs: dh_installdocs -pgrub-common -pgrub-rescue-pc -pgrub-firmware-qemu -A AUTHORS NEWS README THANKS TODO dh_installdocs -Ngrub-common -Ngrub-rescue-pc -Ngrub-firmware-qemu --link-doc=grub-common +ifeq (yes,$(shell dpkg-vendor --derives-from Ubuntu && echo yes)) +override_dh_installinit: + dh_installinit -- start 99 2 3 4 5 . +else +override_dh_installinit: + : +endif + override_dh_bugfiles: dh_bugfiles -A @@ -347,7 +361,8 @@ LEGACY_DOC_CONFLICTS := grub-doc (<< 0.97-32), grub-legacy-doc (<< 0.97-59) endif override_dh_gencontrol: - dh_gencontrol -- -Vlegacy-doc-conflicts="$(LEGACY_DOC_CONFLICTS)" + dh_gencontrol -- \ + -Vlegacy-doc-conflicts="$(LEGACY_DOC_CONFLICTS)" $(substvars) TARNAME := grub2_$(deb_version)_$(DEB_HOST_ARCH).tar.gz diff --git a/docs/grub.texi b/docs/grub.texi index b5954da82..57c3073fd 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1289,6 +1289,15 @@ This option may be set to a list of GRUB module names separated by spaces. Each module will be loaded as early as possible, at the start of @file{grub.cfg}. +@item GRUB_RECORDFAIL_TIMEOUT +If this option is set, it overrides the default recordfail setting. The +default setting is -1, which causes GRUB to wait for user input. This option +should be set on headless and appliance systems where access to a console is +restricted or limited. + +This option is only effective when GRUB was configured with the +@option{--enable-quick-boot} option. + @end table For more detailed customisation of @command{grub-mkconfig}'s output, you may diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index 73dae83c8..40c69638d 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -228,7 +228,8 @@ export GRUB_DEFAULT \ GRUB_INIT_TUNE \ GRUB_SAVEDEFAULT \ GRUB_ENABLE_CRYPTODISK \ - GRUB_BADRAM + GRUB_BADRAM \ + GRUB_RECORDFAIL_TIMEOUT if test "x${grub_cfg}" != "x"; then rm -f "${grub_cfg}.new" diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index 068103d97..459153933 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -23,6 +23,7 @@ prefix="@prefix@" exec_prefix="@exec_prefix@" datarootdir="@datarootdir@" grub_lang=`echo $LANG | cut -d . -f 1` +grubdir="`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`" quick_boot="@QUICK_BOOT@" export TEXTDOMAIN=@PACKAGE@ @@ -47,6 +48,7 @@ if [ "x${GRUB_TIMEOUT_BUTTON}" = "x" ] ; then GRUB_TIMEOUT_BUTTON="$GRUB_TIMEOUT cat << EOF if [ -s \$prefix/grubenv ]; then + set have_grubenv=true load_env fi EOF @@ -87,7 +89,31 @@ function savedefault { save_env saved_entry fi } +EOF +if [ "$quick_boot" = 1 ]; then + cat <