# Maintainer (Arch): Maxime Gauduin <alucryd@gmail.com>
# Contributor (Arch): mortzu <me@mortzu.de>
# Contributor (Arch): fnord0 <fnord0@riseup.net>
# Contributor (Hyperbola): André Silva <emulatorman@hyperbola.info>
# Contributor (Hyperbola): Márcio Silva <coadde@hyperbola.info>
# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>


_basekernel=5.10.39

pkgname=acpi_call-lts
pkgver=1.2.1
pkgrel=55
pkgrel+=.parabola1.basekernel${_basekernel}
pkgdesc='A linux kernel module that enables calls to ACPI methods through /proc/acpi/call'
pkgdesc+=' (for linux-libre-lts)'
url='https://github.com/mkottman/acpi_call'
arch=('x86_64')
arch+=('i686' 'armv7h')
license=('GPL')
makedepends=(linux-libre-lts-headers=${_basekernel} acpi_call-dkms=$pkgver libelf)
conflicts=('acpi_call-dkms')
provides=('acpi_call')

build() {
  _kernver=$(</usr/src/linux-libre-lts/version)

  fakeroot dkms build --dkmstree "$srcdir" -m acpi_call/$pkgver -k $_kernver
}

package() {
  depends=(linux-libre-lts=${_basekernel})

  _kernver=$(</usr/src/linux-libre-lts/version)

  install -Dt "$pkgdir/usr/lib/modules/$_kernver/extramodules" -m0644 \
    acpi_call/${pkgver}/$_kernver/$CARCH/module/*

  # compress each module individually
  find "$pkgdir" -name '*.ko' -exec xz -T1 {} +

  echo acpi_call | install -Dm644 /dev/stdin "$pkgdir/usr/lib/modules-load.d/$pkgname.conf"

  mkdir -p "$pkgdir/usr/share"
  cp -a /usr/share/acpi_call "$pkgdir/usr/share/$pkgname"
}
