### this file is sourced not run
PKGVER=6.1.3
PKGBUILD=1
PKGARCH=x86_64

# source: BLFS 11.3
TARBALL=btrfs-progs-v$PKGVER.tar.xz
MD5SUM=d5f703b4085dc745003c16d046d32c2b
SRC_URL=https://www.kernel.org/pub/linux/kernel/people/kdave/btrfs-progs/$TARBALL
BUNDLE=

SLACKREQ='libacl e2fsprogs zstd' # liblzo2, sphinx build-time dependency only
SLACKDESC="btrfs-progs: btrfs-progs $PKGVER (Btrfs filesystem utilities)  
btrfs-progs:  
btrfs-progs: This package contains utilities to create, check and generally 
btrfs-progs: maintain btrfs - the next-generation Linux filesystem. Note that 
btrfs-progs: btrfs is not considered as production ready yet.  
btrfs-progs: 
btrfs-progs: https://btrfs.wiki.kernel.org/index.php/Main_Page
btrfs-progs: https://btrfs.wiki.kernel.org/index.php/Btrfs_source_repositories
btrfs-progs: https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git
btrfs-progs: https://mirrors.edge.kernel.org/pub/linux/kernel/people/kdave/btrfs-progs/
btrfs-progs: 
"

### default pkg_download
### default pkg_prepare
### default pkg_package
### pkg_build
pkg_build() {
	cd /tmp/btrfs*

	# BLFS - disable manpages compression
	sed -i '40,107 s/\.gz//g' Documentation/Makefile.in &&
	
	CONFFLAGS="--prefix=/usr  \
            --bindir=/bin  \
            --libdir=/$LIBDIR \
            --disable-documentation \
    " &&

	pkg_build_autoconf &&

	# earlier BLFS adjust paths
	ln -sfv ../../$LIBDIR/$(readlink /$LIBDIR/libbtrfs.so) /usr/$LIBDIR/libbtrfs.so &&
	ln -sfv ../../$LIBDIR/$(readlink /$LIBDIR/libbtrfsutil.so) /usr/$LIBDIR/libbtrfsutil.so &&
	rm -fv /$LIBDIR/libbtrfs.{a,so} /$LIBDIR/libbtrfsutil.{a,so} &&
	mv -v /bin/{mkfs,fsck}.btrfs /sbin &&

	# since we don't build documentation yet, copy the source files
	mkdir /usr/share/doc/btrfs-progs-$PKGVER &&
	cp -a Documentation/* /usr/share/doc/btrfs-progs-$PKGVER &&

	# build additional programs
	# https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Hibernation_into_swap_file_on_Btrfs
	gcc -o /bin/btrfs_map_physical /tmp/pkg/btrfs_map_physical.c &&
	
	pkg_build_slackdesc
}

