# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=lsof
pkgver=4.91
pkgrel=0
pkgdesc="LiSt Open Files"
url="https://people.freebsd.org/~abe"
arch="all"
license="custom"
subpackages="$pkgname-doc"
makedepends="linux-headers"
source="https://fossies.org/linux/misc/${pkgname}_${pkgver}_src.tar.xz"
builddir="$srcdir/${pkgname}_${pkgver}_src"

prepare() {
	default_prepare
	cd "$builddir"

	sed -i "s|/\* #define\tHASSECURITY\t1 \*/|#define\tHASSECURITY\t1|" \
		dialects/linux/machine.h
	sed -n 6,30p lsof.h > COPYING
}

build () {
	cd "$builddir"

	./Configure -n linux
	make
}

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
	install -D -m644 COPYING "$pkgdir"/usr/share/licenses/lsof/COPYING
}

sha512sums="d6b378d65152708aa255a74a8bfc8c07ecf923aa4ef02212f7b2af6cb31394f3c11980e1b197cbc47e1b1881d3024a542982c3f67605d8bbb60e1c3df4fb3608  lsof_4.91_src.tar.xz"
