# Maintainer: Melvyn <melvyn2@brcok.tk>
# Maintainer: HurricanePootis <hurricanepootis@protonmail.com>
# Forked from: aur/linux-apfs-dkms-git
# Contributor: Chih-Hsuan Yen <yan12125@archlinux.org>
# Contributor: ManU
# Forked from aur/linux-can-dkms
# Contributor: Kyle Manna <kyle(at)kylemanna(dot)com>

pkgname=linux-apfs-rw-dkms-git
_pkgname=${pkgname%-dkms-git}
epoch=1
pkgver=0.3.20.r3.gf0e88ca
pkgrel=1
pkgdesc="Experimental APFS kernel module with Write support (DKMS)"
arch=('any')
url="https://github.com/linux-apfs/${_pkgname}"
license=('GPL-2.0-only AND BSD-3-Clause')
depends=('dkms')
makedepends=('git')
provides=("${_pkgname}")
conflicts=("${_pkgname}")
source=("git+${url}.git")
sha256sums=('SKIP')

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

prepare() {
	# Extract BSD-3-Clause terms from sources
	sed -n '2,21p' "${_pkgname}/lzfse/lzfse.h" > BSD-3-Clause.txt
}

package() {
	local dkms_dir="${pkgdir}/usr/src/${_pkgname}-${pkgver}/"
	install -d "${dkms_dir}"
	cp -r ${_pkgname}/* "${dkms_dir}"
	install -Dm644 BSD-3-Clause.txt -t "${pkgdir}/usr/share/licenses/${pkgname}/"
}
