1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
5 PYTHON_COMPAT=( python3_{6,7} )
6 DISTUTILS_SINGLE_IMPL=1
8 inherit bash-completion-r1 distutils-r1 systemd
10 DESCRIPTION="scans log files and bans IPs that show malicious signs"
11 HOMEPAGE="https://www.fail2ban.org/"
12 SRC_URI="https://github.com/${PN}/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz"
16 KEYWORDS="~alpha amd64 arm ~hppa ppc ~ppc64 ~sparc ~x86"
17 IUSE="selinux systemd"
22 selinux? ( sec-policy/selinux-fail2ban )
23 systemd? ( $(python_gen_cond_dep '|| (
24 dev-python/python-systemd[${PYTHON_MULTI_USEDEP}]
25 sys-apps/systemd[python(-),${PYTHON_MULTI_USEDEP}]
30 DOCS=( ChangeLog DEVELOP README.md THANKS TODO doc/run-rootless.txt )
32 python_prepare_all() {
35 # Replace /var/run with /run, but not in the top source directory
36 find . -mindepth 2 -type f -exec \
37 sed -i -e 's|/var\(/run/fail2ban\)|\1|g' {} + || die
39 sed -i -e 's|runscript|openrc-run|g' files/gentoo-initd || die
41 distutils-r1_python_prepare_all
45 if python_is_python3; then
46 ./fail2ban-2to3 || die
48 distutils-r1_python_compile
51 python_install_all() {
52 distutils-r1_python_install_all
54 rm -rf "${D}"/usr/share/doc/${PN} "${D}"/run || die
57 newconfd files/gentoo-confd ${PN}
58 newinitd files/gentoo-initd ${PN}
59 sed -e "s:@BINDIR@:${EPREFIX}/usr/bin:g" files/${PN}.service.in > "${T}/${PN}.service" || die
60 systemd_dounit "${T}/${PN}.service"
61 systemd_dotmpfilesd files/${PN}-tmpfiles.conf
64 # Use INSTALL_MASK if you do not want to touch /etc/logrotate.d.
65 # See http://thread.gmane.org/gmane.linux.gentoo.devel/35675
66 insinto /etc/logrotate.d
67 newins files/${PN}-logrotate ${PN}
69 keepdir /var/lib/${PN}
71 newbashcomp files/bash-completion ${PN}-client
72 bashcomp_alias ${PN}-client ${PN}-server ${PN}-regex
76 has_version "<${CATEGORY}/${PN}-0.7"
77 previous_less_than_0_7=$?
81 if [[ $previous_less_than_0_7 = 0 ]] ; then
83 elog "Configuration files are now in /etc/fail2ban/"
84 elog "You probably have to manually update your configuration"
85 elog "files before restarting Fail2ban!"
87 elog "Fail2ban is not installed under /usr/lib anymore. The"
88 elog "new location is under /usr/share."
90 elog "You are upgrading from version 0.6.x, please see:"
91 elog "http://www.fail2ban.org/wiki/index.php/HOWTO_Upgrade_from_0.6_to_0.8"
94 if ! has_version dev-python/pyinotify && ! has_version app-admin/gamin; then
95 elog "For most jail.conf configurations, it is recommended you install either"
96 elog "dev-python/pyinotify or app-admin/gamin (in order of preference)"
97 elog "to control how log file modifications are detected"
100 if ! has_version dev-lang/python[sqlite]; then
101 elog "If you want to use ${PN}'s persistent database, then reinstall"
102 elog "dev-lang/python with USE=sqlite. If you do not use the"
103 elog "persistent database feature, then you should set"
104 elog "dbfile = :memory: in fail2ban.conf accordingly."
107 if has_version sys-apps/systemd[-python]; then
108 elog "If you want to track logins through sys-apps/systemd's"
109 elog "journal backend, then reinstall sys-apps/systemd with USE=python"