# Contributor: Valery Kartel <valery.kartel@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=xfsprogs
pkgver=4.14.0
pkgrel=0
pkgdesc="XFS filesystem utilities"
url="http://xfs.org/index.php/Main_Page"
arch="all"
license="LGPL"
makedepends="linux-headers util-linux-dev bash gzip"
options="!check"  # no test suite
subpackages="$pkgname-dev $pkgname-doc $pkgname-libs $pkgname-extra"
source="https://www.kernel.org/pub/linux/utils/fs/xfs/$pkgname/$pkgname-$pkgver.tar.gz
	"

builddir="$srcdir/$pkgname-$pkgver"

build() {
	cd "$builddir"
	export DEBUG=-DNDEBUG
	export OPTIMIZER="$CFLAGS"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sbindir=/sbin \
		--libexecdir=/usr/lib \
		--enable-gettext=no
	make SHELL=/bin/bash
}

package() {
	cd "$builddir"
	make -j1 DIST_ROOT="$pkgdir" install install-dev
	find "$pkgdir" -name *.la -delete
	mv "$pkgdir"/sbin "$pkgdir"/usr
	mkdir -p "$pkgdir"/sbin
	for i in mkfs.xfs fsck.xfs xfs_repair; do
		mv "$pkgdir"/usr/sbin/$i "$pkgdir"/sbin/
	done
}

extra() {
	depends="$pkgname"
	pkgdesc="XFS filesystem extra utilities"
	mkdir -p "$subpkgdir"
	rmdir "$pkgdir"/lib "$pkgdir"/usr/lib
	mv "$pkgdir"/usr "$subpkgdir"/
}

sha512sums="6b8e5e12aa5c4d197feb7c464495a1da163cf7a61416a5b9960dbae9456d776d815d5bb2f60850027274bd8d2cd4409f0fa8d572117043ba38ecc5c785f24967  xfsprogs-4.14.0.tar.gz"
