#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobextra/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=kismet
pkgver=2022_08_R1
_realver="${pkgver//_/-}"
pkgrel=01
pkgdesc="802.11 layer2 wireless network detector, sniffer, and intrusion detection system w/o systemd"
url="https://www.kismetwireless.net/"
arch=('x86_64')
depends=('libpcap' 'pcre' 'bluez-libs' 'libcap' 'protobuf-c' 'libprotobuf-c.so'
         'sqlite' 'libnm' 'gcc-libs' 'libusb' 'libusb-1.0.so' 'libnl' 'glibc' 'zlib' 'libelf'
         'lm_sensors' 'python' 'python-setuptools' 'python-protobuf' 'python-pyserial'
         'python-numpy' 'python-websockets' 'libwebsockets' 'libcap-ng'
         'python-numpy' 'libwebsockets' 'libcap-ng'
         libpcap.so libprotobuf.so libnm.so libwebsockets.so libsensors.so)
makedepends=('python-setuptools')
optdepends=(
  'gpsd: log coordinates of detected networks'
  'wireshark-cli: provide OUI files used to determine device manufacturer'
  'wireshark-cli: mergecap, to merge multiple capture files'
  'sox: provide the default kismet sound playback binary'
  'festival: text-to-speech support'
  'flite:  alternative/lightweight text-to-speech support')
backup=(
  etc/kismet/kismet.conf
  etc/kismet/kismet_80211.conf
  etc/kismet/kismet_alerts.conf
  etc/kismet/kismet_filter.conf
  etc/kismet/kismet_httpd.conf
  etc/kismet/kismet_logging.conf
  etc/kismet/kismet_memory.conf
#  etc/kismet/kismet_storage.conf
  etc/kismet/kismet_uav.conf)
install=kismet.install
source=(https://www.kismetwireless.net/code/${pkgname}-${_realver}.tar.xz
        kismet.sysusers
        python-install-flags.patch)

prepare() {
  cd ${pkgname}-${_realver}
  patch -Np0 < ../python-install-flags.patch
  autoreconf -fiv
}

build() {
  cd ${pkgname}-${_realver}
  ./configure \
    --prefix=/usr \
    --localstatedir=/var \
    --sysconfdir=/etc/kismet \
    --with-suidgroup=315
  make all plugins
}

package() {
  cd ${pkgname}-${_realver}
  make DESTDIR="${pkgdir}" install

  # Makepkg strip bug #43600
  chmod u+w "${pkgdir}"/usr/bin/kismet*
  chmod o-x "${pkgdir}"/usr/bin/kismet_cap*
  chown 0:315 "${pkgdir}"/usr/bin/kismet_cap*

  install -Dm 644 ../kismet.sysusers "${pkgdir}/usr/lib/sysusers.d/kismet.conf"
}

#---- license gpg-key sha256sums ----

license=('GPL')

validpgpkeys=(354689DF3C9DED803381A661D7B28822738BBDB1) # Michael Kershaw

sha256sums=(2149cceac5526508653f4d02dcf7a694e3da3dc000a2372a1ee4bf9988279781 # kismet-2022-08-R1.tar.xz
	0ac08bf5016e00596e2fc0bc89e7907c2186b811ed8d8a2bffe6b95b42e147a3 # kismet.sysusers
	d7eb99f9d3294e53c053b039cab3706a912dbaf0bbf34d9db012cbe46d0f1535) # python-install-flags.patch
 
