# Contributor: Michael Mason <ms13sp@gmail.com>
# Maintainer: Francesco Colista <francesco.colista@gmail.com>
pkgname=arpwatch
pkgver=2.1a15
pkgrel=16
pkgdesc="Ethernet monitoring program"
url="http://www-nrg.ee.lbl.gov/"
arch="all"
license="BSD"
pkgusers="arpwatch"
makedepends="libpcap-dev"
install="$pkgname.pre-install"
options="!check"  # No test suite.
subpackages="$pkgname-ethercodes"
source="ftp://ftp.ee.lbl.gov/$pkgname-$pkgver.tar.gz
	arpwatch.confd
	arpwatch.initd
	01_all_arpwatch-2.1a15-manpages.patch
	02_all_arpwatch-2.1a15-srcdir.patch
	03_all_arpwatch-2.1a15-getopt.patch
	04_all_arpwatch-2.1a15-sendmail-cmdline-opt.patch
	05_all_arpwatch-2.1a15-promiscuous-mode.patch
	06_all_arpwatch-2.1a15-bogons-report.patch
	07_all_arpwatch-2.1a15-specify-mail.patch
	08_all_arpwatch-2.1a15-drop-priveleges.patch
	09_all_arpwatch-2.1a15-quite-mail.patch
	10_all_arpwatch-2.1a15-ignore-net.patch
	11_all_arpwatch-2.1a15-secure-tmp.patch
	12_all_arpwatch-2.1a15-defalt-dir-in-manpages.patch
	13_all_arpwatch-2.1a15-scripts-awk.patch
	14_all_arpwatch-2.1a15-paths-fix.patch
	15_all_arpwatch-2.1a15-fix-dead-lock.patch
	16_all_arpwatch-2.1a15-additional-manpages-cleanups.patch
	17_all_arpwatch-2.1a15-restart.patch
	18_all_arpwatch-2.1a15-nofork.patch
	19_all_arpwatch-2.1a15-nonewstation.patch
	20_all_arpwatch-2.1a15-noreversedns-resolve.patch
	21_all_arpwatch-2.1a15-pid-filename.patch
	22_alpine_bihourly_script.patch
	"

builddir="$srcdir/$pkgname-$pkgver"

prepare() {
	default_prepare
	update_config_sub
}

build() {
	cd "$builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info
	make -j1
}

package() {
	cd "$builddir"
	#make install command wouldn't create directory
	mkdir -p "$pkgdir"/usr/sbin/
	make -j1 DESTDIR="$pkgdir" install
	install -d -o arpwatch "$pkgdir"/var/lib/arpwatch
	install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
	for files in arp2ethers arpfetch massagevendor bihourly.sh; do
		install -m755 "$builddir"/$files "$pkgdir"/usr/sbin
	done
}

ethercodes() {
	cd "$builddir"
	pkgdesc="$pkgname ethernet codes"
	mkdir -p "$subpkgdir"/usr/share/$pkgname/awk
	install -Dm644 "$builddir"/ethercodes.dat "$subpkgdir"/usr/share/$pkgname/ethercodes.dat

	install -d "$subpkgdir"/usr/share/$pkgname/awk
	for f in "$builddir"/*.awk; do
		install -m644 $f "$subpkgdir"/usr/share/$pkgname/awk/
	done
}




sha512sums="f770b5b7954afe910dafb016e6e886a4e785564bcdc0ea0de9d7b1ca6a9a0b219a9d1b50b6f42a67afc2f836e782e8ff85ba5780583015d62c9694ac53f0bf90  arpwatch-2.1a15.tar.gz
854f6361bf02586516db4f50afdee729c047cd788985f72f475e592e0e744c24d7d765f0391d733dbf417048c26b6d43c00eb63c58e6798bdb2366b93cbfe03a  arpwatch.confd
d60d8d07c5572ba645f037d2d8a9b028f8cd434d99e76a9f75a046d00959d6b4544ab6d866d3c88b4861175c5407d83ecd954b5f5dad0b2ec3894411e83e5e2f  arpwatch.initd
969e956c4fd192d35ce4f23a1f1461eb94a28a8d1e18845d3b099f8833dece003105b415af0a51b4d50221ded4d7434a49bba0ef7f3cac71fda9317b5edeaac3  01_all_arpwatch-2.1a15-manpages.patch
427a55b7599b8c897f1eae1b8f70b9eaa8e692636b666bf2a3a8703d8227c96e29cdcde8186ebcdcff63d902a919cde660ed6d02f9b5dc650ea9fe23afa44a5f  02_all_arpwatch-2.1a15-srcdir.patch
04ab5ed5e1097901e80d70925936a2ecdb7e1d815b627cbfa246a15a4fb7cbca59b9be04840c694f71c0ff8e2f3201a6047b4fbbb9e62687e7d95ea29c5e6ae4  03_all_arpwatch-2.1a15-getopt.patch
7b23ff5f15b98c7d4a2cca39597d2481d072a935f5021dea09be9735aaf54f9378957bf4548cbe004af13a340f0b0ee6c7db44d44cb3605b3d16fd3c08c06897  04_all_arpwatch-2.1a15-sendmail-cmdline-opt.patch
b4b4ce55ec8b2dba7ce9f49eb77874d8ada26322174a9032176ce28f52edd11edf0fbf16f2a48d974b145fa3e8a10fbf7f1ae72169336d4ed219d41da18007eb  05_all_arpwatch-2.1a15-promiscuous-mode.patch
3b637cbb8a969a43d737ce3a60c4213ed48db7c279cc4776632239d1bd70e150f88e3fee5f14367b1b9fc26a77f512fd5a6d361ce4303a9099ee3b2fb7cca28e  06_all_arpwatch-2.1a15-bogons-report.patch
0a36a7dcb10870735065b50c5979933217f479c91c6749d4ebabacb666a6dd25c4a767094f215c72cbd9fffd5568a0d2dd16ab36446d2bb2d55595801854e0cd  07_all_arpwatch-2.1a15-specify-mail.patch
254ac6d166014a49878bea82db26a61a944348633c81b361b2ab54cd959d7540695c2e96b97c666a2af654b0c30dc2eec56749da5cad8558be6d3cc813f76d31  08_all_arpwatch-2.1a15-drop-priveleges.patch
87bac2fe654e51940d0a8f6ce4131aef8c2c5db10ec73c92c6a4384bb797666beb8d3180895712a2e602fa513daded362cb20f35815563da7ad9a4a6f053d19d  09_all_arpwatch-2.1a15-quite-mail.patch
9f626f5d824c8706af7d5e53f0e5743a606c0ed0ef903f5f721457da6139a19bc39a3546d750d70f90f506d6f03ea7a37b1ff48aca35f49a9ffa702e16e8b6d3  10_all_arpwatch-2.1a15-ignore-net.patch
1c9250346896353857904b43e867ffa5de21bfbe3aa03d8678b2844bb6ad8746ad587884c6b8abe479ddc0bc5fdcfee26c746932c947877862c08f532c1608ee  11_all_arpwatch-2.1a15-secure-tmp.patch
5be13ab5b03ae5ffc1edc8b8657b6f903921c3ffe608ca9bd86a8b0c85f54e3114781bf2ef759b5bcf6e93a50cae55584c5054cb1f510423e7a9b052792829b2  12_all_arpwatch-2.1a15-defalt-dir-in-manpages.patch
cc573ea3f4170be7ff711ad0d63d79802111828d7e913c2eca2e9276fc5f6958f55e2c39b61d885084558bf59f2d95a7c6e3f92f65ac0310ff66505ba4229a57  13_all_arpwatch-2.1a15-scripts-awk.patch
456f3e42f64022cc9999efeaf4b8b7a759a9745e88ff059785ece43a85e2edc8bf56cee1b03c79f90fa9cbda6957cfec61eb40d1db4e03e214c03dcacf749103  14_all_arpwatch-2.1a15-paths-fix.patch
e5145f3f8d7c921148af25844d354bdc83dc8a8fe2e392155147dea6c168000c2e30a69dce902002c82746d918757e107ac2a9389e52ef4b550fb4f26b285155  15_all_arpwatch-2.1a15-fix-dead-lock.patch
e6f5571f8d4823c56f68ea13267f217cc60a9481cf08dfe632124593f8e3a49d3c7fb57c118490b126e2e37eed893470c6b92a079e680b0a03b6d0ffbb10e896  16_all_arpwatch-2.1a15-additional-manpages-cleanups.patch
76c971bd8ce3aec9a6e72f6192ff7f77a5a4b054fad9db4ed29344b0a9b76e07b188ac78b3de654e82de7276ddc877a7f9bbd4f90dd74454a08fd7a5fd2f379c  17_all_arpwatch-2.1a15-restart.patch
91f01db73b7979464db9e0616cfc2a19c950c65f1409342220e1c6e7b22716827b681cb03ede88644e67d81efc38af32a1fd372151474e9b917abb9e13cdafdd  18_all_arpwatch-2.1a15-nofork.patch
5322d2ea02f300d2be2cd17fdf7154cfd6e775376d56c9ad4bdc520196b533060d6602ebb7a02bb1b4088afccb6c843ead3d01b9e0928125fadcdd4d1efadc88  19_all_arpwatch-2.1a15-nonewstation.patch
fd7231744f8025dbcc0bec65ffc02933e0d14717a824187a955a55509316f8667b11bcc4efe847a5002519337b3cc8e778e216ebbb5ad2af504021ea61df4380  20_all_arpwatch-2.1a15-noreversedns-resolve.patch
11da1ec9cce70f2f9fb0657e3bbc2ca9cbad68a292205dfb01effd15643f0aeb693f544f2f8d308b7c3a4901de0a0f91e33676e40cb39dda2314e11097c1eae3  21_all_arpwatch-2.1a15-pid-filename.patch
6823fee4d2190fcd4003c4e0940b05725fb3c408b2ff1f4af39dd5ae29cee05e7211274dbcc06b78931e5cb36e9893a8a9de6e924a9d54a99410bcdf9e6591bb  22_alpine_bihourly_script.patch"
