summaryrefslogtreecommitdiffstats
path: root/kernel_prerm.d_dkms.in
blob: cbf0c9423fdc5f06b0cb4f4050d7224a6a9fd0d7 (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
#!/bin/sh

# This script is triggered when the kernel (linux-image) package is being
# removed.  We're passed the version of the kernel being removed.
inst_kern=$1

if command -v dkms > /dev/null; then
	dkms status -k "$inst_kern" 2>/dev/null | while IFS=",:/ " read -r name vers _ arch status; do
		[ "$status" = "installed" ] || continue
		echo "dkms: removing: $name $vers ($inst_kern) ($arch)" >&2
		# Compromise on using 'unbuild' to remove the module when a
		# kernel is being removed.  The 'remove' command is too
		# destructive.  The 'uninstall' command leaves built files
		# around that have no other trigger to 'unbuild' them.
		# (Triggering 'unbuild' on kernel header removal would not be
		# a good idea because that would also cause the module to be
		# uninstalled for the kernel, even though only the headers are
		# being removed.)
		dkms unbuild -m "$name" -v "$vers" -k "$inst_kern" -a "$arch"
	done
fi

rmdir --ignore-fail-on-non-empty \
	"@MODDIR@/$inst_kern/updates/dkms" \
	"@MODDIR@/$inst_kern/updates" 2>/dev/null

exit 0