# Template file for 'btrfs-progs'
pkgname=btrfs-progs
version=4.17.1
revision=1
wrksrc="${pkgname}-v${version}"
build_style=gnu-configure
configure_args="--disable-backtrace --disable-python"
hostmakedepends="asciidoc automake libtool pkg-config xmlto"
makedepends="acl-devel e2fsprogs-devel libzstd-devel lzo-devel"
checkdepends="acl-progs e2fsprogs util-linux"
short_desc="Btrfs filesystem utilities"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
license="GPL-2.0-only, LGPL-3.0-or-later"
homepage="https://btrfs.wiki.kernel.org/index.php/Main_Page"
changelog="https://raw.githubusercontent.com/kdave/btrfs-progs/master/CHANGES"
distfiles="${KERNEL_SITE}/kernel/people/kdave/${pkgname}/${pkgname}-v${version}.tar.xz"
checksum=bf0b34f1538c0b6e88f959937b0419678cadbf2ba7044336dcbfb2bcdc28cd74
make_check_target=test

pre_configure() {
	NOCONFIGURE=1 ./autogen.sh
}

pre_build() {
	if [ $CROSS_BUILD ]; then
		${BUILD_CC} ${BUILD_CFLAGS} kernel-lib/mktables.c -o mktables
	fi
}

pre_check() {
	# Requires losetup which is part of util-linux, but even with it installed it fails
	rm -rf -- tests/mkfs-tests/017-small-backing-size-thin-provision-device
}

post_install() {
	vinstall btrfs-completion 644 /usr/share/bash-completion/completions btrfs
}

libbtrfs_package() {
	short_desc+=" - btrfs library"
	pkg_install() {
		vmove "usr/lib/libbtrfs.so.*"
	}
}

libbtrfs-devel_package() {
	short_desc+=" - libbtrfs development files"
	depends="libbtrfs>=${version}_${revision}"
	pkg_install() {
		vmove usr/include/btrfs
		vmove usr/lib/libbtrfs.a
		vmove usr/lib/libbtrfs.so
	}
}

libbtrfsutil_package() {
	short_desc+=" - btrfsutil library"
	pkg_install() {
		vmove "usr/lib/libbtrfsutil.so.*"
	}
}

libbtrfsutil-devel_package() {
	depends="libbtrfsutil-${version}_${revision}"
	short_desc+=" - libbtrfsutil development files"
	pkg_install() {
		vmove usr/include/btrfsutil.h
		vmove usr/lib/libbtrfsutil.a
		vmove usr/lib/libbtrfsutil.so
	}
}
