# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Rin Cat <me@rin.cat>

pkgname=rtl88x2bu-dkms
_pkgbase=${pkgname/-dkms/}
pkgver=5.6.1.r181.2812290
_pkgver=5.6.1
pkgrel=1.1
pkgdesc="Kernel module for Realtek rtl88x2bu WiFi chipset"
arch=(powerpc64le powerpc)
url="https://github.com/RinCat/RTL88x2BU-Linux-Driver"
license=('GPL2')
depends=('dkms' 'bc')
makedepends=('git')
_commit="281229078fd32c06ecf80c701ad5dd54a42d2f6a"
source=("git+https://github.com/RinCat/RTL88x2BU-Linux-Driver.git#commit=${_commit}"
	rtl88x2bu-5.6.1-disable-debug.patch)
sha512sums=('SKIP'
            'ea2797682778fccd8ebc63275a4dea1b47fc8c7b78265d7b26043c097dd5d21f1be59c22c9085aadfb520b70faa6759046af30854216bc5d9c6e824fb5697fa3')

pkgver() {
    cd "${srcdir}/RTL88x2BU-Linux-Driver"
    printf '%s.r%s.%s' "${_pkgver}" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
    cd "${srcdir}/RTL88x2BU-Linux-Driver"
    sed "s@^MAKE=\"'make'@MAKE=\"ARCH=powerpc 'make'@" -i dkms.conf

    patch -Np1 -i ${srcdir}/rtl88x2bu-5.6.1-disable-debug.patch
}

package() {
    cd "${srcdir}/RTL88x2BU-Linux-Driver"
    mkdir -p "${pkgdir}/usr/src/${_pkgbase}-${pkgver}"
    cp -pr * "${pkgdir}/usr/src/${_pkgbase}-${pkgver}"
    install -Dm644 dkms.conf "${pkgdir}/usr/src/${_pkgbase}-${pkgver}/dkms.conf"
    sed -e "s/@PKGVER@/${pkgver}/" -i "${pkgdir}/usr/src/${_pkgbase}-${pkgver}/dkms.conf"
}

