#!/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=nftables
epoch=1
pkgver=1.0.7
pkgrel=01
pkgdesc='Netfilter tables userspace tools w/o systemd'
url='https://netfilter.org/projects/nftables/'
depends=('libmnl' 'libnftnl' 'gmp' 'readline' 'ncurses' 'jansson')
optdepends=('python: Python bindings')
makedepends=('asciidoc' 'python')
backup=('etc/nftables.conf')
validpgpkeys=('37D964ACC04981C75500FB9BD55D978A8A1420E4') # Netfilter Core Team
source=("https://netfilter.org/projects/nftables/files/nftables-$pkgver.tar.xz"{,.sig}
        'nftables.conf')
#        'nftables.service')

install=nftables.install

prepare() {
  cd $pkgname-$pkgver
  # apply patch from the source array (should be a pacman feature)
  local src
  for src in "${source[@]}"; do
    src="${src%%::*}"
    src="${src##*/}"
    [[ $src = *.patch ]] || continue
    msg2 "Applying patch $src..."
    patch -Np1 < "../$src"
  done
  :
}

build() {
  cd $pkgname-$pkgver
  autoreconf -fi #FIXME: To remove with 01.patch
  ./configure \
    --prefix=/usr \
    --sbindir=/usr/bin \
    --sysconfdir=/usr/share \
    --with-json \
    --with-cli=readline \
    --disable-debug
  make
}

package() {
  pushd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
  popd
  # basic safe firewall config
  install -Dm644 nftables.conf "$pkgdir/etc/nftables.conf"
#  # systemd
#  install -Dm644 nftables.service "$pkgdir/usr/lib/systemd/system/nftables.service"
}

#---- arch license gpg-key & sha256sums ----

arch=(x86_64)

license=('GPL2')

sha256sums=(c12ac941fff9adaedf17367d5ce213789b98a0d314277bc22b3d71e10891f412  # nftables-1.0.7.tar.xz
	ee39beda503fe0e29853bf102056484d9b21e3b000c7d3c7d5add27d5ebf6c78  # nftables-1.0.7.tar.xz.sig
	2aff88019097d21dbfa4713f5b54c184751c86376e458b683f8d90f3abd232a8) # nftables.conf

##  c464b8c23bf85341e07ffda694b57a66d947fd94e29cb4182c8f20559e7cde17  nftables-1:1.0.7-01-x86_64.pkg.tar.lz


