summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a6cef793644f0038d64f8779d003db486aa29e8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Maintainer: LinRs <20455421+LinRs AT users.noreply.github.com>
# Contributor: Jameson Pugh <imntreal@gmail.com>
# Contributor: Felix Yan <felixonmars@archlinux.org>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Geoffroy Carrier <geoffroy.carrier@koon.fr>
# Contributor: michalzxc
# Contributor: nbags <neilbags@gmail.com>

pkgname=fail2ban-git
pkgver=0.10.4.r327.g1e59d53b
pkgrel=1
pkgdesc='Bans IPs after too many failed authentication attempts (git version)'
url='http://www.fail2ban.org/'
license=('GPL')
arch=('any')
depends=('python-pyinotify' 'whois' 'sqlite' 'python-systemd')
optdepends=('iptables' 'nftables')
makedepends=('python-setuptools' 'git')
checkdepends=('python-coverage')
provides=('fail2ban')
conflicts=('fail2ban')
backup=(etc/fail2ban/fail2ban.conf
        etc/fail2ban/jail.conf
        etc/logrotate.d/fail2ban)
source=("${pkgname}::git+https://github.com/fail2ban/fail2ban.git"
)
sha256sums=('SKIP')

pkgver() {
  cd "${pkgname}"
  (set -o pipefail
   git describe --long --tags 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
   printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
  )

}
prepare() {
  cd $pkgname
  sed -i 's|self.install_dir|"/usr/bin"|' setup.py
  sed -i 's/^before = paths-debian.conf/before = paths-arch.conf/' config/jail.conf
}
build() {
  cd "${pkgname}"
  ./fail2ban-2to3
  python setup.py build
}

check() {
  # make temp copy to run coverage since it messes with file permissions
  cp -r $pkgname{,-coverage}
  cd "${pkgname}"
  coverage run bin/fail2ban-testcases || warning "Tests failed"
}

package() {
  cd "${pkgname}"
  python setup.py install --prefix /usr --root "${pkgdir}" --optimize=1

  install -Dm644 build/fail2ban.service \
    "${pkgdir}"/usr/lib/systemd/system/fail2ban.service
  install -Dm644 files/fail2ban-tmpfiles.conf \
    "${pkgdir}"/usr/lib/tmpfiles.d/fail2ban.conf
  install -Dm644 files/fail2ban-logrotate \
    "${pkgdir}"/etc/logrotate.d/fail2ban
  install -Dm644 files/bash-completion \
    "${pkgdir}"/usr/share/bash-completion/completions/fail2ban

  # fix sendmail location
  sed -i 's/sbin/bin/g' "${pkgdir}"/etc/fail2ban/action.d/sendmail*.conf

  install -Dm644 man/fail2ban.1 "${pkgdir}"/usr/share/man/man1/fail2ban.1
  install -Dm644 man/fail2ban-client.1 \
    "${pkgdir}"/usr/share/man/man1/fail2ban-client.1
  install -Dm644 man/fail2ban-regex.1 \
    "${pkgdir}"/usr/share/man/man1/fail2ban-regex.1
  install -Dm644 man/fail2ban-server.1 \
    "${pkgdir}"/usr/share/man/man1/fail2ban-server.1
  install -Dm644 man/jail.conf.5 "${pkgdir}"/usr/share/man/man5/jail.conf.5

  rm -r "${pkgdir}/run"
}