# Contributor: Valery Kartel <valery.kartel@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=fuse-exfat
pkgver=1.4.0
pkgrel=1
pkgdesc="Free exFAT file system implementation"
url="https://github.com/relan/exfat"
arch="all"
license="GPL-2.0-or-later"
options="!check" # No test suite
provides="exfat"
provider_priority=20
makedepends="autoconf automake fuse3-dev"
subpackages="$pkgname-doc $pkgname-utils"
source="$pkgname-$pkgver.tar.gz::https://github.com/relan/exfat/archive/v$pkgver.tar.gz
	0001-allow-command-line-argument-order-used-by-mount-8.patch
	"
builddir="$srcdir/exfat-$pkgver"

prepare() {
	default_prepare
	autoreconf -fvi
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sbindir=/usr/sbin
	make
}

package() {
	make DESTDIR="$pkgdir" install

	# resove conflict with community/exfatprogs.
	# while -utils provides the same binaries there is no need for
	# the two packages two conflict if -utils is not installed.
	mv "$pkgdir"/usr/share/man/man8/exfatlabel.8 \
		"$pkgdir"/usr/share/man/man8/exfatlabel.exfat-fuse.8
}

utils() {
	pkgdesc="$pkgdesc (utilities)"
	# other provider is exfatprogs
	provides="exfat-utils"
	provider_priority=1
	replaces="exfatprogs"

	cd "$pkgdir"
	local file; for file in $(find usr/sbin ! -name "mount*" -a ! -type d); do
		amove $file
	done
}

sha512sums="
70a951c878e3eb9173c8bc24908da1a64e4e83990b4ae3bb53a9f20e9d618f30ef7e93e818f0387fe9a76a87c8ba970aa2d8728c386865fe658d76c1bee830ae  fuse-exfat-1.4.0.tar.gz
1c3d61310f6a2f7b126d57825f7eee7acde46f809bb2f1eb9857b35c831b9499a4d63c39a76c4d67f85e8541565e6dafb7321fbe0cbe4af6d4fa6eb9f1c00dd1  0001-allow-command-line-argument-order-used-by-mount-8.patch
"
