### this file is sourced not run
PKGVER=5.4.1 # latest as of 2020-03-13
PKGBUILD=1
PKGARCH=x86_64

# source: post BLFS 8.2 2018-07-25 updated to latest
TARBALL=btrfs-progs-v$PKGVER.tar.xz
MD5SUM=4fb3ac57dc4e0afcf723cdf34640179b
SRC_URL=https://www.kernel.org/pub/linux/kernel/people/kdave/btrfs-progs/$TARBALL
BUNDLE=

SLACKREQ='libacl e2fsprogs libzstd' # liblzo2, asciidoc 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-zstd" && # we have libzstd
            
	pkg_build_autoconf &&

	# 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 &&

	# 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
}

