File: kernel_prerm.d_dkms

package info (click to toggle)
dkms 2.8.4-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 940 kB
  • sloc: sh: 4,010; makefile: 272; perl: 80; python: 67; ansic: 18
file content (30 lines) | stat: -rwxr-xr-x 929 bytes parent folder | download | duplicates (3)
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
#!/bin/bash

# We're passed the version of the kernel being removed
inst_kern=$1

# This is applied from make_initrd function in dkms command, which
# creates the possible initrd backup file.
remove_initrd_backup() {
	for initrd in "initrd-$1.img" "initramfs-$1.img" "initrd.img-$1" "initrd-$1"; do
		rm -fv /boot/"${initrd}".old-dkms >&2
	done
}

if [ -x /usr/sbin/dkms ]; then
while read line; do
   name=`echo "$line" | awk '{print $1}' | sed 's/,$//'`
   vers=`echo "$line" | awk '{print $2}' | sed 's/,$//'`
   arch=`echo "$line" | awk '{print $4}' | sed 's/:$//'`
   echo "dkms: removing: $name $vers ($inst_kern) ($arch)" >&2
   dkms remove -m $name -v $vers -k $inst_kern -a $arch
done < <(dkms status -k $inst_kern 2>/dev/null | grep ": installed")
fi

remove_initrd_backup "$inst_kern"

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

exit 0