# Template file for 'nmap'
pkgname=nmap
version=7.95
revision=3
build_style=gnu-configure
configure_args="--without-ndiff --with-openssl --with-zenmap $(vopt_with lua liblua)"
hostmakedepends="python3-setuptools automake python3-build python3-pip pkg-config python3-cairo python3-gobject"
makedepends="libpcap-devel openssl-devel libssh2-devel pcre-devel
 $(vopt_if lua lua54-devel)"
short_desc="Utility for network discovery and security auditing"
maintainer="Piraty <mail@piraty.dev>"
license="custom:nmap"
homepage="https://nmap.org"
changelog="https://raw.githubusercontent.com/nmap/nmap/master/CHANGELOG"
distfiles="https://nmap.org/dist/nmap-${version}.tar.bz2"
checksum=e14ab530e47b5afd88f1c8a2bac7f89cd8fe6b478e22d255c5b9bddb7a1c5778
repository=nonfree
python_version=3

build_options="lua"
build_options_default="lua"

alternatives="
	nc:nc:/usr/bin/ncat
	nc:nc.1:/usr/share/man/man1/ncat.1"

post_install() {
	vlicense LICENSE

	# Do not use bundled certificates, use only system ones
	rm -f ${DESTDIR}/usr/share/ncat/ca-bundle.crt

	# Move zenmap data to /usr/share
	mv ${DESTDIR}/${py3_sitelib}/zenmapCore/data ${DESTDIR}/usr/share/zenmap
	vsed -i \
		-e "s@prefix = join(dirname(__file__).*@prefix = '/usr/share/zenmap'@" \
		${DESTDIR}/${py3_sitelib}/zenmapCore/Paths.py
}

zenmap_package() {
	depends="${sourcepkg}-${version}_${revision} python3-gobject python3-cairo"
	short_desc+=" - GUI Frontend"
	pkg_install() {
		vmove usr/bin/nmapfe
		vmove usr/bin/xnmap
		vmove usr/bin/zenmap
		vmove usr/share/applications
		vmove usr/share/zenmap
		vmove usr/share/man/man1/zenmap.1
		vmove usr/lib
	}
}
