Package: gummiboot
Version: 45-2
Severity: normal
Tags: patch

The attached patch fixes the following issues:

- On first install, gummiboot must be invoked with "install" instead of
  "update". Up until now the user has to manually run "gummiboot install"
  after first installing this package. Looking at src/setup/setup.c,
  it seems okay to always invoke gummiboot with "install" regardless
  if the package is installed for the first time or upgraded: If gummiboot
  is already installed it will simply be overwritten.

- On removing the package, gummiboot is not removed from the EFI partition.

- gummiboot offers the option "--no-variables" which prevents changes to
  the EFI boot order. One example where this option comes in handy is a
  dual-boot Mac on which the user wants to continue booting OS X by default.
  The patch makes this option configurable. I've set the priority to
  "critical" because changing the boot order can break the system.

As always, "there's more than one way to do it", so feel free to make
any modifications you deem necessary. Let me know if there are questions
on why I did something one way or the other.

Kind regards,

Lukas
>From 86049f859bbd5b90415c34cd8badd57a2b7b24bc Mon Sep 17 00:00:00 2001
From: Lukas Wunner <[email protected]>
Date: Fri, 14 Nov 2014 12:41:11 +0100
Subject: [PATCH] Invoke gummiboot with "install" instead of "update" in
 postinst so that it gets copied to EFI partition on first installation of the
 package

Remove gummiboot from EFI partition on package removal

Make changing the EFI variables a user-configurable option

Signed-off-by: Lukas Wunner <[email protected]>
---
 debian/gummiboot.config    | 10 ++++++++++
 debian/gummiboot.postinst  | 17 +++++++++++++----
 debian/gummiboot.prerm     | 25 +++++++++++++++++++++++++
 debian/gummiboot.templates | 21 +++++++++++++++++++++
 4 files changed, 69 insertions(+), 4 deletions(-)
 create mode 100644 debian/gummiboot.config
 create mode 100644 debian/gummiboot.prerm
 create mode 100644 debian/gummiboot.templates

diff --git a/debian/gummiboot.config b/debian/gummiboot.config
new file mode 100644
index 0000000..4971056
--- /dev/null
+++ b/debian/gummiboot.config
@@ -0,0 +1,10 @@
+#!/bin/sh
+set -e
+
+. /usr/share/debconf/confmodule
+db_version 2.0
+
+db_input critical gummiboot/change-efivars || true
+db_go
+
+exit 0
diff --git a/debian/gummiboot.postinst b/debian/gummiboot.postinst
index 02fb99e..5bffac1 100644
--- a/debian/gummiboot.postinst
+++ b/debian/gummiboot.postinst
@@ -4,15 +4,24 @@
 set -e
 
 . /etc/default/gummiboot
+. /usr/share/debconf/confmodule
+
+if [ "$1" = "configure" \
+        -o "$1" = "abort-deconfigure" \
+        -o "$1" = "abort-remove" ]; then
+
+    db_version 2.0
+    db_get gummiboot/change-efivars
+    if [ "$RET" != true ]; then
+        echo "Not changing EFI boot variables, retaining existing boot order." 
>&2
+        efivars="--no-variables"
+    fi
 
-if [ "$1" = "configure" -a "$2" = "" ]; then
     for kernel in /boot/vmlinuz-*; do
         update-gummiboot $(echo $kernel | cut -f2- -d-)
     done
-fi
+    gummiboot install $efivars --path="$GUMMIBOOT_EFI" || :
 
-if [ "$1" = "configure" ]; then
-    gummiboot update --path="$GUMMIBOOT_EFI" || :
 fi
 
 #DEBHELPER#
diff --git a/debian/gummiboot.prerm b/debian/gummiboot.prerm
new file mode 100644
index 0000000..d4d26b0
--- /dev/null
+++ b/debian/gummiboot.prerm
@@ -0,0 +1,25 @@
+#!/bin/sh
+# prerm script for gummiboot
+
+set -e
+
+. /etc/default/gummiboot
+. /usr/share/debconf/confmodule
+
+if [ "$1" = "deconfigure" -o "$1" = "remove" ]; then
+
+    db_version 2.0
+    db_get gummiboot/change-efivars
+    if [ "$RET" != true ]; then
+        echo "Not changing EFI boot variables, retaining existing boot order." 
>&2
+        efivars="--no-variables"
+    fi
+
+    MACHINE_ID=$(cat /etc/machine-id)
+
+    rm -r "$GUMMIBOOT_EFI/loader/" "$GUMMIBOOT_EFI/$MACHINE_ID/" || :
+    gummiboot remove $efivars --path="$GUMMIBOOT_EFI" || :
+
+fi
+
+#DEBHELPER#
diff --git a/debian/gummiboot.templates b/debian/gummiboot.templates
new file mode 100644
index 0000000..9f9f385
--- /dev/null
+++ b/debian/gummiboot.templates
@@ -0,0 +1,21 @@
+Template: gummiboot/change-efivars
+Type: boolean
+Default: true
+Description: Should gummiboot change the EFI boot variables on installation?
+ Normally when gummiboot is installed, it creates an entry in the EFI boot
+ variables and adds it to the top of the boot order list. Disabling this
+ feature retains the existing boot order.
+ .
+ E.g. on an Apple Macintosh, if you would like to continue booting OS X
+ by default, you need to disable this feature. (Hold down the option key
+ on startup whenever you want to load gummiboot instead.)
+Description-de.UTF-8: Soll gummiboot die EFI Boot Variablen Àndern?
+ Normalerweise wird bei Installation von gummiboot ein Eintrag in den EFI
+ Boot Variablen erstellt und an den Anfang der Bootreihenfolge gesetzt.
+ Schalten Sie diese Funktion aus wenn Sie die bisherige Bootreihenfolge
+ beibehalten möchten.
+ .
+ Wenn Sie z.B. einen Apple Macintosh verwenden und weiterhin
+ standardmÀßig OS X booten möchten, mÃŒssen Sie diese Funktion
+ ausschalten. (Halten Sie beim Einschalten die Alt-Taste gedrÃŒckt wann
+ immer Sie stattdessen gummiboot laden möchten.)
-- 
1.8.5.2 (Apple Git-48)

Reply via email to