app=fail2ban
version=0.10.4
build=1sml
homepage="http://www.fail2ban.org/wiki/index.php/Main_Page"
download="https://github.com/fail2ban/fail2ban/archive/refs/tags/0.10.4.tar.gz"
desc="Log-based intrusion detection and prevention system written in Python"
requires="python3"

build() {
  mkandenterbuilddir
  rm -rf $app-$version

  tar xf $srcdir/$app-$version.tar.?z* 
  cd $app-$version 
  fixbuilddirpermissions

  sh fail2ban-2to3
  python setup.py install --prefix="" --root=$pkg

  # move config files to .new
  ( cd $pkg/etc/fail2ban 
    for file in $(find . -type f); do
     mv $file "$file.new"
    done
  )

  ( cd $pkg/etc/fail2ban ; patch -p0 < $srcdir/jail.conf.patch )

  install -D -m 0644 $srcdir/rc.fail2ban $pkg/etc/rc.d/rc.fail2ban.new
  install -D -m 0644 $srcdir/paths-smlinux.conf $pkg/etc/fail2ban/paths-smlinux.conf.new
  rm -f $pkg/etc/fail2ban/paths-{arch,debian,fedora,freebsd,osx,opensuse}.conf.new

  mkdir -p $pkg/var/{run,lib/fail2ban}
  mv $pkg/usr/share/doc/$app/* $pkgdocs/ 
  rm -r $pkg/usr

  mkfinalpkg
}

sha512sums="
3f4af84b7e3332b887240c927c1f706d2b3020217df2a68c64897619d54eb6dfa972992e3153f4ea150d025e2c8a2b537da47cf71a6dfee1df3c8d029a6d5f42  fail2ban-0.10.4.tar.gz
89c6e4bbb1a01f3f7601372bbd49d72dd6a17a58503cce30f754110cdc8b55fc80dfa21b5e97a16525bd80c7cae961af5024e5cca45d922245eeefa83cb54ef2  jail.conf.patch
"
