# Maintainer: MrDuartePT <gonegrier.duarte@gmail.com>
# Maintainer: xenhat <aur@xenh.at>
# Maintainer: johnfanv2 <https://github.com/johnfanv2>

pkgname=lenovolegionlinux-dkms
_pkgname=lenovolegionlinux
pkgver=0.0.20
pkgrel=1
pkgdesc="LenovoLegionLinux (LLL) DKMS module"
arch=("x86_64")
url="https://github.com/johnfanv2/LenovoLegionLinux"
license=('GPL-2.0-only')
makedepends=(
    lm_sensors
    i2c-tools
    dmidecode
    git
)
depends=(
    dkms
    lenovolegionlinux
)
source=("${_pkgname}::git+https://github.com/johnfanv2/LenovoLegionLinux.git")
sha256sums=('SKIP')
install="lenovolegionlinux.install"

pkgver() {
    cd "${srcdir}/${_pkgname}"
    git describe --long --tags --abbrev=7 | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

package() {
    cd "${srcdir}/${_pkgname}/kernel_module/"
    install -Dm644 dkms.conf "${pkgdir}/usr/src/${_pkgname}-${pkgver}/dkms.conf"
    cp -r {issue-warning.sh,legion-laptop-unused-snippets.c,legion-laptop.c,Makefile} "${pkgdir}/usr/src/$_pkgname-${pkgver}/"

    cd "${srcdir}/${_pkgname}/deploy/"
    install -Dm644 LenovoLegionLinux.hook "${pkgdir}/etc/pacman.d/hooks/LenovoLegionLinux.hook"
    install -Dm755 LenovoLegionLinux "${pkgdir}/usr/bin/LenovoLegionLinux"
}
