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

TARBALL=psmisc-$PKGVER.tar.gz
MD5SUM=935c0fd6eb208288262b385fa656f1bf
SRC_URL=http://distro.ibiblio.org/fatdog/source/710/clfs-packages-3.0.0.tar
BUNDLE=clfs-packages-3.0.0.tar

SLACKREQ=libncurses
SLACKDESC="psmisc: psmisc $PKGVER (Misc process management utilities)  
psmisc:  
psmisc: This package contains miscellaneous process management utilities such 
psmisc: as fuser, killall and pstree, among others.  
psmisc: 
psmisc: 
psmisc: 
psmisc: 
psmisc: 
psmisc: 
psmisc: 
"


### override download for LFS sources bundle
# $1-src-dir $2-tarball 
pkg_download() {
	echo downloading $BUNDLE for $TARBALL
	wget -P $1 $SRC_URL
	tar -xf $1/$BUNDLE --strip-components=1 -C $1 
	rm $1/$BUNDLE
}

### default pkg_prepare
### default pkg_package
### build
pkg_build() {
	cd /tmp/psmisc*
	
	# naughty fuser https://gitlab.com/psmisc/psmisc/commit/3638cc55b4d08851faba46635d737b24d016665b
	patch -Np 1 << "EOF" &&
diff -ur a/src/fuser.c b/src/fuser.c
--- a/src/fuser.c	2014-01-31 08:07:32.000000000 -0500
+++ b/src/fuser.c	2014-02-27 12:34:44.352910007 -0500
@@ -1174,7 +1174,7 @@
 		usage(_("No process specification given"));
 
 	/* Check if -M flag was used and if so check mounts */
-	if (opts * OPT_ISMOUNTPOINT) {
+	if (opts & OPT_ISMOUNTPOINT) {
 	    check_mountpoints(&mounts, &names_head, &names_tail);
 	}	
EOF
	 
	if pkg_build_autoconf; then
		# FHS (LFS 7.5)
		mv -v /usr/bin/fuser   /bin
		mv -v /usr/bin/killall /bin
		pkg_build_slackdesc
	else
		return 1
	fi
}
