# btrfs-progs - Btrfs filesystem tools
# Generated from manifest.tsv by gen-ports.py. Edit the manifest, not this file,
# unless the package needs something the template cannot express - in which case
# drop a `recipe.local` beside it and it will be preserved.
name=btrfs-progs
version=6.19
release=1
desc="Btrfs filesystem tools"
url="https://btrfs.readthedocs.io/"
license="GPL-2.0-only"
depend="glibc zlib zstd lz4 util-linux-libs"
makedepend=""
source="https://kernel.org/pub/linux/kernel/people/kdave/btrfs-progs/btrfs-progs-v6.19.tar.xz"
sha256="SKIP"

build() {
	cd "btrfs-progs-v6.19"
	# Not every configure script accepts the same options - sqlite rejects
	# --disable-nls outright, for instance - so only pass the ones this one
	# actually advertises. Guessing wrong fails the whole build.
	_opts="--prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib"
	_help=$(./configure --help 2>/dev/null)
	case "$_help" in *--disable-static*)  _opts="$_opts --disable-static" ;; esac
	case "$_help" in *--disable-nls*)     _opts="$_opts --disable-nls" ;; esac
	# Both auto-detect against whatever the build host happens to have and
	# link against it if found - real udev and liblzo2 on the build host,
	# neither of which ScrapLinux ships. The result was mkfs.btrfs and every
	# other btrfs-progs binary failing to start at all on a real install:
	# "cannot open shared object file: libudev.so.1". lzo is a legacy
	# compression option nobody uses over zstd by default anyway; udev
	# support here is only for multipath device correlation, not needed
	# for a normal install.
	case "$_help" in *--disable-lzo*)      _opts="$_opts --disable-lzo" ;; esac
	case "$_help" in *--disable-libudev*)  _opts="$_opts --disable-libudev" ;; esac
	# shellcheck disable=SC2086
	./configure $_opts
	make -j"$JOBS"
}

package() {
	cd "btrfs-progs-v6.19"
	make DESTDIR="$pkgdir" install
}
