# Description: Secure multithreaded packet sniffer
# URL: https://crates.io/crates/sniffglue
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: rust libpcap libseccomp

name=sniffglue
version=0.15.0
release=1
source=(https://github.com/kpcyrd/sniffglue/archive/v$version/$name-$version.tar.gz)

build() {
  prt-get isinst sccache && export RUSTC_WRAPPER=/usr/bin/sccache
  mkdir "$PKGMK_SOURCE_DIR/rust" || true
  export CARGO_HOME="$PKGMK_SOURCE_DIR/rust"

  cargo update --manifest-path $name-$version/Cargo.toml
  cargo build --release --locked --manifest-path $name-$version/Cargo.toml

  prt-get isinst bash-completions && \
    install -d $PKG/usr/share/bash-completion/completions && \
    $name-$version/target/release/sniffglue --gen-completions bash > $PKG/usr/share/bash-completion/completions/sniffglue
  prt-get isinst zsh && \
    install -d $PKG/usr/share/zsh/site-functions && \
    $name-$version/target/release/sniffglue --gen-completions zsh > $PKG/usr/share/zsh/site-functions/_sniffglue

  install -Dt $PKG/usr/bin $name-$version/target/release/$name
}
