summarylogtreecommitdiffstats
path: root/linux-headers.install
blob: 23a1e34e10c3ab5b3f173d3f13780b9e49adcdb1 (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
# arg 1:  the new package version
# arg 2:  the old package version

KERNEL_NAME=
KERNEL_VERSION=

# set a sane PATH to ensure that critical utils like depmod will be found
export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'

pre_remove() {
  OLDVER="${1}${KERNEL_NAME}"
  if pacman -Q | grep -q dkms; then
    KMODS=$(dkms status | fgrep "${OLDVER}" | awk -F', ' '{ print $1"|"$2"|"$3 }')
    for KMOD in $KMODS; do
      IFS='|' read -ra KMODV <<< "$KMOD"
      dkms remove ${KMODV[0]}/${KMODV[1]} -k ${KMODV[2]}
    done
  fi
}

post_install () {
  if pacman -Q | grep -q dkms; then
    dkms autoinstall -k ${KERNEL_VERSION}
    echo ">>> Generating initial ramdisk, using mkinitcpio.  Please wait..."
    mkinitcpio -p linux${KERNEL_NAME}
  fi
}

post_upgrade () {
  post_install "$1"
  pre_remove "$2"
}