# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=lsof
pkgver=4.89
pkgrel=1
pkgdesc="LiSt Open Files"
url="https://people.freebsd.org/~abe/"
arch="all"
license="custom"
subpackages="$pkgname-doc"
depends=
makedepends="linux-headers"
source="http://distfiles.alpinelinux.org/distfiles/${pkgname}_$pkgver.tar.bz2"

_builddir="$srcdir"/${pkgname}_${pkgver}/${pkgname}_${pkgver}_src

prepare() {
	# theres a tarball in teh tarball...
	cd "$srcdir"/${pkgname}_${pkgver}
	tar -xf ${pkgname}_${pkgver}_src.tar

	cd "$_builddir"
	sed -e "s|/\* #define\tHASSECURITY\t1 \*/|#define\tHASSECURITY\t1|" \
		-i dialects/linux/machine.h

	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
}

build () {
	cd "$_builddir"
	./Configure -n linux
	make || return 1
}

package() {
	cd "$_builddir"
	install -D -m0755 -o root -g root lsof "$pkgdir"/usr/bin/lsof
	install -D -m0644 -o root -g root lsof.8 \
		"$pkgdir"/usr/share/man/man8/lsof.8
}
md5sums="1b9cd34f3fb86856a125abbf2be3a386  lsof_4.89.tar.bz2"
sha256sums="81ac2fc5fdc944793baf41a14002b6deb5a29096b387744e28f8c30a360a3718  lsof_4.89.tar.bz2"
sha512sums="cafb0209143c7863e5cebe7efc33a2520d36f9e26222350e4edfa18debbcfb5c81f42f71469e5913fb21f49a7562bbe761b72dfc8f297dadf75ac619cdcb318c  lsof_4.89.tar.bz2"
