# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: T.J. Townsend <blakkheim@archlinux.org>
# Contributor: Kyle Keen <keenerd@gmail.com>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Jaroslav Lichtblau <dragonlord@aur.archlinux.org>
# Contributor: Kessia 'even' Pinheiro <kessiapinheiro at gmail.com>
# Contributor: Sorin Ionescu <sorin.ionescu@gmail.com>

pkgname=ufw
pkgver=0.36.2
pkgrel=4
pkgdesc="Uncomplicated and easy to use CLI tool for managing a netfilter firewall"
arch=(any)
url="https://launchpad.net/ufw"
license=('GPL3')
makedepends=('git' 'python-setuptools')
depends=('iptables' 'python')
backup=('etc/ufw/before.rules'
        'etc/ufw/before6.rules'
        'etc/ufw/after.rules'
        'etc/ufw/after6.rules'
        'etc/ufw/ufw.conf'
        'etc/ufw/user.rules'
        'etc/ufw/sysctl.conf'
        'etc/default/ufw'
        'etc/ufw/user6.rules')
source=("git+https://git.launchpad.net/ufw?signed#tag=${pkgver}"
        "service")
sha256sums=('c2b36d70d003050e54310b55a6bf6a7d17c649a8f056eba09b6a24f3500ed8c5'
            'fdface6f4690e4748fbbd5661c02e1967a8750fdb23581d35516174017a3fe39')
validpgpkeys=('4C20C06B5D8BDE688854D28A51DBDC58CC559573')

prepare() {
  cd $pkgname
  # FS#28769 - move from /lib to /usr/lib
  sed -i -e 's|/lib|/usr/lib|' \
         -e 's|sbin|bin|g' setup.py

  # FS#35458, FS#54110 - correct iptables location
  sed -i -e 's|sbin|bin|g' setup.py
  sed -i -e 's|sbin|bin|g' src/util.py

  # don't force-enable tcp selective acks
  sed -i -e '/net\/ipv4\/tcp_sack/s/^/#/g' conf/sysctl.conf
}

package() {
  cd $pkgname

  python3 setup.py install --root="$pkgdir"

  install -Dm644 shell-completion/bash "$pkgdir/usr/share/bash-completion/completions/ufw"
  install -Dm644 "$srcdir/service" "$pkgdir/usr/lib/systemd/system/ufw.service"
  chmod 644 "$pkgdir/etc/ufw/"*.rules
  rm -rf "$pkgdir/usr/share/ufw/messages"
}
