summaryrefslogtreecommitdiff
path: root/debian/signing-template
diff options
context:
space:
mode:
authorSteve McIntyre <steve@einval.com>2021-05-03 20:52:35 +0100
committerSteve McIntyre <steve@einval.com>2021-05-03 20:24:52 +0000
commit29f231fd049f023bcf57810544b757b325fac2ce (patch)
treea79a133ef50834a6d91c3ad0b3eb1005f4a119f3 /debian/signing-template
parent11e0f1dafde51f35d216e6405804a1462e2db983 (diff)
downloadefi-boot-shim-debian/15.4-3.tar.gz
efi-boot-shim-debian/15.4-3.zip
Add maintainer scripts to the template packagesdebian/15.4-3
Manage installing and removing fbXXX.efi and mmXXX.efi when we install/remove the shim-helpers-$arch-signed packages. Closes: #966845
Diffstat (limited to 'debian/signing-template')
-rw-r--r--debian/signing-template/@final_pkg_name@.postinst.in81
-rw-r--r--debian/signing-template/@final_pkg_name@.postrm.in53
2 files changed, 134 insertions, 0 deletions
diff --git a/debian/signing-template/@final_pkg_name@.postinst.in b/debian/signing-template/@final_pkg_name@.postinst.in
new file mode 100644
index 00000000..6da2a3d8
--- /dev/null
+++ b/debian/signing-template/@final_pkg_name@.postinst.in
@@ -0,0 +1,81 @@
+#! /bin/sh
+set -e
+
+# Must load the confmodule for our template to be installed correctly.
+. /usr/share/debconf/confmodule
+
+# Select the right target architecture for grub-install
+ARCH=@arch@
+case ${ARCH} in
+ i386|amd64)
+ FW_SIZE=$(cat /sys/firmware/efi/fw_platform_size)
+ if [ "$FW_SIZE"x = "32"x ]; then
+ GRUB_EFI_TARGET="i386-efi"
+ elif [ "$FW_SIZE"x = "64"x ]; then
+ GRUB_EFI_TARGET="x86_64-efi"
+ else
+ echo "Unable to read a valid value from fw_platform_size, ABORT"
+ exit 1
+ fi
+ ;;
+ arm64)
+ GRUB_EFI_TARGET="arm64-efi"
+ ;;
+ *)
+ echo "Unsupported dpkg architecture ${ARCH} in $0. ABORT"
+ exit 1
+ ;;
+esac
+
+# Pull out a config value from /etc/default/grub
+config_item ()
+{
+ if [ -f /etc/default/grub ]; then
+ . /etc/default/grub || return
+ for x in /etc/default/grub.d/*.cfg; do
+ if [ -e "$x" ]; then
+ . "$x"
+ fi
+ done
+ fi
+ eval echo "\$$1"
+}
+
+case $1 in
+ configure)
+ bootloader_id="$(config_item GRUB_DISTRIBUTOR | tr A-Z a-z | \
+ cut -d' ' -f1)"
+ case $bootloader_id in
+ kubuntu) bootloader_id=ubuntu ;;
+ esac
+
+ # Call grub-install to make sure we're added to the ESP as
+ # needed
+ if [ "$bootloader_id" ] && \
+ [ -d "/boot/efi/EFI/$bootloader_id" ] && \
+ [ -d /sys/firmware/efi ] && \
+ which grub-install >/dev/null 2>&1
+ then
+ # Check for some of the options that matter, so we can
+ # call grub-install safely without dropping them
+ OPTIONS=""
+
+ db_get grub2/force_efi_extra_removable
+ if [ "$RET" = true ]; then
+ OPTIONS="$OPTIONS --force-extra-removable"
+ fi
+
+ db_get grub2/update_nvram
+ if [ "$RET" = false ]; then
+ OPTIONS="$OPTIONS --no-nvram"
+ fi
+
+ grub-install --target=${GRUB_EFI_TARGET} $OPTIONS
+ fi
+ ;;
+esac
+
+#DEBHELPER#
+
+exit 0
+
diff --git a/debian/signing-template/@final_pkg_name@.postrm.in b/debian/signing-template/@final_pkg_name@.postrm.in
new file mode 100644
index 00000000..cd261b15
--- /dev/null
+++ b/debian/signing-template/@final_pkg_name@.postrm.in
@@ -0,0 +1,53 @@
+#! /bin/sh
+set -e
+
+case @arch@ in
+ i386)
+ SHIM_REMOVE="mmia32.efi fbia32.efi";;
+ amd64)
+ SHIM_REMOVE="mmx64.efi fbx64.efi";;
+ arm64)
+ SHIM_REMOVE="mmaa64.efi fbaa64.efi";;
+ *)
+ echo "Unsupported dpkg architecture @arch@ in $0. ABORT"
+ exit 1
+ ;;
+esac
+
+# Pull out a config value from /etc/default/grub
+config_item ()
+{
+ if [ -f /etc/default/grub ]; then
+ . /etc/default/grub || return
+ for x in /etc/default/grub.d/*.cfg; do
+ if [ -e "$x" ]; then
+ . "$x"
+ fi
+ done
+ fi
+ eval echo "\$$1"
+}
+
+case $1 in
+ remove|purge)
+ bootloader_id="$(config_item GRUB_DISTRIBUTOR | tr A-Z a-z | \
+ cut -d' ' -f1)"
+ case $bootloader_id in
+ kubuntu) bootloader_id=ubuntu ;;
+ esac
+
+ # If we're being removed, remove the copies installed in the
+ # ESP. grub-install doesn't clean those up for us.
+ if [ "$bootloader_id" ] && \
+ [ -d "/boot/efi/EFI/$bootloader_id" ] && \
+ [ -d /sys/firmware/efi ]; then
+
+ cd /boot/efi/EFI/$bootloader_id
+ rm -f $SHIM_REMOVE
+ fi
+ ;;
+esac
+
+#DEBHELPER#
+
+exit 0