# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=tcpdump
pkgver=4.99.5
pkgrel=1
pkgdesc='Powerful command-line packet analyzer'
url="https://www.tcpdump.org/"
arch=(x86_64)
license=(BSD-3-Clause)
depends=(glibc)
makedepends=(
  cmake
  libpcap
  libcap-ng
  openssl
)
source=(https://www.tcpdump.org/release/$pkgname-$pkgver.tar.gz{,.sig})
sha512sums=('69bc52ef7af7fd562370adf2e95cb592aad6193df9ab1708de52ac86a4c1cff72e8b256a739b435c324ee2df61051abde7d2659bc40f061d7c4fbcab1dcaa2e2'
            'SKIP')
b2sums=('754c25eafe84754465356042faa1369678655aa93d1b736c259ca9a6bd1e18c44784ae136dc6a3e64af9903c05c29e1379aafd7badc0e129c5a29ae908db13ff'
        'SKIP')
validpgpkeys=('1F166A5742ABB9E0249A8D30E089DEF1D9C15D0D') # The Tcpdump Group (Package signing key) <release@tcpdump.org>

build() {
  local cmake_options=(
    -DCMAKE_INSTALL_PREFIX=/usr
    -DCMAKE_BUILD_TYPE=None
    -Wno-dev
    -B build
    -S $pkgname-$pkgver
  )

  cmake "${cmake_options[@]}"
  cmake --build build --verbose
}

check() {
  make VERBOSE=1 check -C build
}

package() {
  depends+=(
    libpcap libpcap.so
    libcap-ng libcap-ng.so
    openssl libcrypto.so
  )

  DESTDIR="$pkgdir" cmake --install build
  install -vDm 644 $pkgname-$pkgver/LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
}
