#!/bin/mkpkg # description: Daemon to ban hosts that cause multiple authentication errors # url: https://www.fail2ban.org/ name=fail2ban version=1.1.1 release=1 depends=(python3) makedeps=(py-setuptools) source=(https://github.com/fail2ban/fail2ban/archive/$version.tar.gz) sha256sums=( "4be0ea0488e32de260058462a44a040f0542cd26a9fb6fa6d2514f9dd8ec1609" ) build() { cd $name-$version /usr/bin/python3 setup.py build /usr/bin/python3 setup.py install --root="$PKG" --skip-build # fail2ban's setup.py installs config trees under prefix/etc. # Relocate them to /etc if they landed in /usr/etc. if [ -d "$PKG/usr/etc" ]; then install -dm755 "$PKG/etc" cp -a "$PKG/usr/etc/." "$PKG/etc/" rm -rf "$PKG/usr/etc" fi # Drop systemd bits (krypt/sh uses runit) rm -rf "$PKG/usr/lib/systemd" "$PKG/lib/systemd" 2>/dev/null || true rm -rf "$PKG/etc/fail2ban/fail2ban.service.d" 2>/dev/null || true # Bytecode-compile Python sources _pyver=$(/usr/bin/python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")') _sitedir="$PKG/usr/lib/python${_pyver}/site-packages" if [ -d "$_sitedir" ]; then /usr/bin/python3 -OO -m compileall -b -q "$_sitedir" find "$_sitedir" -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true fi # Strip dev-only bits: test runner binary and tests tree rm -f "$PKG/usr/bin/fail2ban-testcases" || true rm -rf "$_sitedir/fail2ban/tests" || true # Runit service: /etc/sv/fail2ban/run install -dm755 "$PKG/etc/sv/fail2ban" printf '%s\n' \ '#!/bin/sh' \ 'exec 2>&1' \ 'exec /usr/bin/fail2ban-server -f -x start' \ > "$PKG/etc/sv/fail2ban/run" chmod 755 "$PKG/etc/sv/fail2ban/run" # Runit log service: /etc/sv/fail2ban/log/run install -dm755 "$PKG/etc/sv/fail2ban/log" printf '%s\n' \ '#!/bin/sh' \ 'exec svlogd -tt /var/log/fail2ban' \ > "$PKG/etc/sv/fail2ban/log/run" chmod 755 "$PKG/etc/sv/fail2ban/log/run" # Pre-create log directory install -dm755 "$PKG/var/log/fail2ban" } signify() { untrusted comment: public key RWTZ9IduCSQ/mL8337TEUinPwT92xFEUpD92hkS7IxcOnzTt9QdpohT3 } # vim: filetype=sh