summaryrefslogtreecommitdiff
path: root/debian/signing-template/@final_pkg_name@.postrm.in
blob: 2da291d8cfc7351fd72736d308472e7c816073c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#! /bin/sh
set -e

# If we're not on an EFI system, do nothing
if [ ! -d /sys/firmware/efi ]; then
    exit 0
fi

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" ]; then

	    cd /boot/efi/EFI/$bootloader_id
	    rm -f $SHIM_REMOVE
	fi
	;;
esac

#DEBHELPER#

exit 0