Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-analyzer/fail2ban/files/, net-analyzer/fail2ban/
Date: Fri, 14 May 2021 17:23:02
Message-Id: 1621012942.592ea98a632c53260a6358ce42280cd3076c3d34.sam@gentoo
1 commit: 592ea98a632c53260a6358ce42280cd3076c3d34
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Fri May 14 12:51:59 2021 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Fri May 14 17:22:22 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=592ea98a
7
8 net-analyzer/fail2ban: run tests
9
10 Signed-off-by: Sam James <sam <AT> gentoo.org>
11
12 net-analyzer/fail2ban/fail2ban-0.11.2.ebuild | 12 ++++--
13 .../files/fail2ban-0.11.2-fix-tests-for-2021.patch | 50 ++++++++++++++++++++++
14 2 files changed, 58 insertions(+), 4 deletions(-)
15
16 diff --git a/net-analyzer/fail2ban/fail2ban-0.11.2.ebuild b/net-analyzer/fail2ban/fail2ban-0.11.2.ebuild
17 index 8f57fd666aa..1c47a71b51d 100644
18 --- a/net-analyzer/fail2ban/fail2ban-0.11.2.ebuild
19 +++ b/net-analyzer/fail2ban/fail2ban-0.11.2.ebuild
20 @@ -16,8 +16,6 @@ LICENSE="GPL-2"
21 SLOT="0"
22 KEYWORDS="~alpha amd64 arm ~arm64 hppa ppc ppc64 sparc x86"
23 IUSE="selinux systemd"
24 -# Needs some work to enable them right now
25 -RESTRICT="test"
26
27 RDEPEND="
28 virtual/logger
29 @@ -34,9 +32,11 @@ RDEPEND="
30
31 DOCS=( ChangeLog DEVELOP README.md THANKS TODO doc/run-rootless.txt )
32
33 -python_prepare_all() {
34 - default
35 +PATCHES=(
36 + "${FILESDIR}"/${P}-fix-tests-for-2021.patch
37 +)
38
39 +python_prepare_all() {
40 # Replace /var/run with /run, but not in the top source directory
41 find . -mindepth 2 -type f -exec \
42 sed -i -e 's|/var\(/run/fail2ban\)|\1|g' {} + || die
43 @@ -51,6 +51,10 @@ python_compile() {
44 distutils-r1_python_compile
45 }
46
47 +python_test() {
48 + bin/fail2ban-testcases -n -g --verbosity=4 || die "Tests failed with ${EPYTHON}"
49 +}
50 +
51 python_install_all() {
52 distutils-r1_python_install_all
53
54
55 diff --git a/net-analyzer/fail2ban/files/fail2ban-0.11.2-fix-tests-for-2021.patch b/net-analyzer/fail2ban/files/fail2ban-0.11.2-fix-tests-for-2021.patch
56 new file mode 100644
57 index 00000000000..36193b18193
58 --- /dev/null
59 +++ b/net-analyzer/fail2ban/files/fail2ban-0.11.2-fix-tests-for-2021.patch
60 @@ -0,0 +1,50 @@
61 +https://github.com/fail2ban/fail2ban/issues/2904
62 +
63 +From 747d4683221b5584f9663695fb48145689b42ceb Mon Sep 17 00:00:00 2001
64 +From: sebres <info@××××××.de>
65 +Date: Mon, 4 Jan 2021 02:42:38 +0100
66 +Subject: [PATCH] fixes century selector of %ExY and %Exy in datepattern for
67 + tests, considering interval from 2005 (alternate now) to now; + better
68 + grouping algorithm for resulting century RE
69 +
70 +---
71 + fail2ban/server/strptime.py | 24 ++++++++++++++++++++++--
72 + 1 file changed, 22 insertions(+), 2 deletions(-)
73 +
74 +diff --git a/fail2ban/server/strptime.py b/fail2ban/server/strptime.py
75 +index 1464a96d1f..39fc795865 100644
76 +--- a/fail2ban/server/strptime.py
77 ++++ b/fail2ban/server/strptime.py
78 +@@ -36,10 +36,30 @@ def _getYearCentRE(cent=(0,3), distance=3, now=(MyTime.now(), MyTime.alternateNo
79 + Thereby respect possible run in the test-cases (alternate date used there)
80 + """
81 + cent = lambda year, f=cent[0], t=cent[1]: str(year)[f:t]
82 ++ def grp(exprset):
83 ++ c = None
84 ++ if len(exprset) > 1:
85 ++ for i in exprset:
86 ++ if c is None or i[0:-1] == c:
87 ++ c = i[0:-1]
88 ++ else:
89 ++ c = None
90 ++ break
91 ++ if not c:
92 ++ for i in exprset:
93 ++ if c is None or i[0] == c:
94 ++ c = i[0]
95 ++ else:
96 ++ c = None
97 ++ break
98 ++ if c:
99 ++ return "%s%s" % (c, grp([i[len(c):] for i in exprset]))
100 ++ return ("(?:%s)" % "|".join(exprset) if len(exprset[0]) > 1 else "[%s]" % "".join(exprset)) \
101 ++ if len(exprset) > 1 else "".join(exprset)
102 + exprset = set( cent(now[0].year + i) for i in (-1, distance) )
103 + if len(now) and now[1]:
104 +- exprset |= set( cent(now[1].year + i) for i in (-1, distance) )
105 +- return "(?:%s)" % "|".join(exprset) if len(exprset) > 1 else "".join(exprset)
106 ++ exprset |= set( cent(now[1].year + i) for i in xrange(-1, now[0].year-now[1].year+1, distance) )
107 ++ return grp(sorted(list(exprset)))
108 +
109 + timeRE = TimeRE()
110 +