summaryrefslogtreecommitdiff
path: root/libre/tp_smapi-libre/PKGBUILD
blob: 4a9a91be13a7c80decbb7edf425f46fad80a7b5f (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
58
59
60
61
62
63
64
# $Id: PKGBUILD 92750 2013-06-14 12:14:28Z tpowa $
# Maintainer: Lukas Fleischer <archlinux at cryptocrack dot de>
# Contributor: xduugu
# Contributor: nh2
# Contributor: Steven Davidovitz <steviedizzle ð gmail đ com>
# Contributor: Nick B <Shirakawasuna ð gmail đ com>
# Contributor: Christof Musik <christof ð senfdax đ de>
# Contributor: Stefan Rupp <archlinux ð stefanrupp đ de>
# Contributor: Ignas Anikevicius <anikevicius ð gmail đ com>
# Maintainer (Parabola): André Silva <emulatorman@lavabit.com>

_pkgname=tp_smapi
pkgname=tp_smapi-libre
pkgver=0.41
pkgrel=23
pkgdesc="Modules for ThinkPad's SMAPI functionality (built for the linux-libre kernel package)"
arch=('i686' 'x86_64' 'mips64el')
url='https://github.com/evgeni/tp_smapi'
license=('GPL')
depends=('linux-libre>=3.9' 'linux-libre<3.10')
makedepends=('linux-libre-headers>=3.9' 'linux-libre-headers<3.10')
replaces=("${_pkgname}")
conflicts=("${_pkgname}")
provides=("${_pkgname}=${pkgver}")
install="${_pkgname}.install"
source=("https://github.com/downloads/evgeni/${_pkgname}/${_pkgname}-${pkgver}.tar.gz")
md5sums=('63c683415c764568f6bf17c7eabe4752')

build() {
  cd "${srcdir}/${_pkgname}-${pkgver}"

  _kernver=${_kernver:-$(uname -r)}
  _extramodules=$(readlink -f "/usr/lib/modules/${_kernver}/extramodules" || true)
  _kernver=$(< "${_extramodules}/version")

  sed -ri -e "s/^(KVER\s*:=).*$/\1 ${_kernver}/" \
	  -e "s#^(KBASE\s*:=).*\$#\1 ${_extramodules%/*}/${_kernver}#" Makefile

  make HDAPS=1
}

package() {
  _kernver=${_kernver:-$(uname -r)}
  _extramodules=$(readlink -f "/usr/lib/modules/${_kernver}/extramodules" || true)
  _kernver=$(< "${_extramodules}/version")

  make -C "${_extramodules%/*}/${_kernver}/build" \
    INSTALL_MOD_PATH="${pkgdir}/${_extramodules%%/lib/*}" \
    M="${srcdir}/${_pkgname}-${pkgver}" modules_install

  cd "${pkgdir}/${_extramodules%/*}"
  mv "${_kernver}/extra" "${_extramodules##*/}"
  rmdir "${_kernver}"

  # compress kernel modules
  find "${pkgdir}" -name "*.ko" -exec gzip -9 {} +

  # load module on startup
  echo tp_smapi > "${srcdir}/${_pkgname}.conf"
  install -Dm644 "${srcdir}/${_pkgname}.conf" "${pkgdir}/usr/lib/modules-load.d/${_pkgname}.conf"

  # update kernel version in install file
  sed -ri "s#^(extramodules=).*\$#\1${_extramodules}#" "${startdir}/${_pkgname}.install"
}