net-analyzer/fail2ban: ppc stable wrt bug #719458
[gentoo.git] / net-analyzer / fail2ban / fail2ban-0.11.1-r2.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5 PYTHON_COMPAT=( python3_{6,7} )
6 DISTUTILS_SINGLE_IMPL=1
7
8 inherit bash-completion-r1 distutils-r1 systemd
9
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"
13
14 LICENSE="GPL-2"
15 SLOT="0"
16 KEYWORDS="~alpha amd64 arm ~hppa ppc ~ppc64 ~sparc ~x86"
17 IUSE="selinux systemd"
18
19 RDEPEND="
20         virtual/logger
21         virtual/mta
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}]
26         )' 'python*' ) )
27 "
28
29 RESTRICT="test"
30 DOCS=( ChangeLog DEVELOP README.md THANKS TODO doc/run-rootless.txt )
31
32 python_prepare_all() {
33         default
34
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
38
39         sed -i -e 's|runscript|openrc-run|g' files/gentoo-initd || die
40
41         distutils-r1_python_prepare_all
42 }
43
44 python_compile() {
45         if python_is_python3; then
46                 ./fail2ban-2to3 || die
47         fi
48         distutils-r1_python_compile
49 }
50
51 python_install_all() {
52         distutils-r1_python_install_all
53
54         rm -rf "${D}"/usr/share/doc/${PN} "${D}"/run || die
55
56         # not FILESDIR
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
62         doman man/*.{1,5}
63
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}
68
69         keepdir /var/lib/${PN}
70
71         newbashcomp files/bash-completion ${PN}-client
72         bashcomp_alias ${PN}-client ${PN}-server ${PN}-regex
73 }
74
75 pkg_preinst() {
76         has_version "<${CATEGORY}/${PN}-0.7"
77         previous_less_than_0_7=$?
78 }
79
80 pkg_postinst() {
81         if [[ $previous_less_than_0_7 = 0 ]] ; then
82                 elog
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!"
86                 elog
87                 elog "Fail2ban is not installed under /usr/lib anymore. The"
88                 elog "new location is under /usr/share."
89                 elog
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"
92         fi
93
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"
98         fi
99
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."
105         fi
106
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"
110         fi
111 }