Skip to content

Commit 9f379d0

Browse files
authored
Alpine Linux 3.16 (#126)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
1 parent 857d85a commit 9f379d0

File tree

3 files changed

+174
-8
lines changed

3 files changed

+174
-8
lines changed

Dockerfile

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
1-
ARG FAIL2BAN_VERSION="0.11.2"
1+
# syntax=docker/dockerfile:1
22

3-
FROM alpine:3.15
3+
ARG FAIL2BAN_VERSION=0.11.2
4+
ARG ALPINE_VERSION=3.16
45

6+
FROM --platform=$BUILDPLATFORM alpine:${ALPINE_VERSION} AS fail2ban-src
7+
RUN apk add --no-cache git patch
8+
WORKDIR /src/fail2ban
59
ARG FAIL2BAN_VERSION
6-
RUN apk --update --no-cache add \
10+
RUN <<EOT
11+
git clone https://github.com/fail2ban/fail2ban.git .
12+
git reset --hard $FAIL2BAN_VERSION
13+
EOT
14+
COPY patches /src/patches
15+
RUN for i in /src/patches/*.patch; do patch -p1 < $i; done
16+
17+
FROM alpine:${ALPINE_VERSION}
18+
RUN --mount=from=fail2ban-src,source=/src/fail2ban,target=/tmp/fail2ban,rw \
19+
apk --update --no-cache add \
720
bash \
821
curl \
922
grep \
@@ -25,14 +38,11 @@ RUN apk --update --no-cache add \
2538
python3-dev \
2639
&& pip3 install --upgrade pip \
2740
&& pip3 install dnspython3 pyinotify \
28-
&& cd /tmp \
29-
&& curl -SsOL https://github.com/fail2ban/fail2ban/archive/${FAIL2BAN_VERSION}.zip \
30-
&& unzip ${FAIL2BAN_VERSION}.zip \
31-
&& cd fail2ban-${FAIL2BAN_VERSION} \
41+
&& cd /tmp/fail2ban \
3242
&& 2to3 -w --no-diffs bin/* fail2ban \
3343
&& python3 setup.py install \
3444
&& apk del build-dependencies \
35-
&& rm -rf /etc/fail2ban/jail.d /tmp/*
45+
&& rm -rf /etc/fail2ban/jail.d
3646

3747
COPY entrypoint.sh /entrypoint.sh
3848

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
From 5ac303df8a171f748330d4c645ccbf1c2c7f3497 Mon Sep 17 00:00:00 2001
2+
From: sebres <info@sebres.de>
3+
Date: Sun, 19 Sep 2021 18:49:18 +0200
4+
Subject: [PATCH] fix gh-3098: build fails with error in fail2ban setup
5+
command: use_2to3 is invalid (setuptools 58+)
6+
7+
---
8+
setup.py | 16 +---------------
9+
1 file changed, 1 insertion(+), 15 deletions(-)
10+
11+
diff --git a/setup.py b/setup.py
12+
index f4c2550f..98413273 100755
13+
--- a/setup.py
14+
+++ b/setup.py
15+
@@ -48,7 +48,7 @@ import warnings
16+
from glob import glob
17+
18+
from fail2ban.setup import updatePyExec
19+
-
20+
+from fail2ban.version import version
21+
22+
source_dir = os.path.realpath(os.path.dirname(
23+
# __file__ seems to be overwritten sometimes on some python versions (e.g. bug of 2.6 by running under cProfile, etc.):
24+
@@ -112,22 +112,12 @@ class install_scripts_f2b(install_scripts):
25+
# Wrapper to specify fail2ban own options:
26+
class install_command_f2b(install):
27+
user_options = install.user_options + [
28+
- ('disable-2to3', None, 'Specify to deactivate 2to3, e.g. if the install runs from fail2ban test-cases.'),
29+
('without-tests', None, 'without tests files installation'),
30+
]
31+
def initialize_options(self):
32+
- self.disable_2to3 = None
33+
self.without_tests = not with_tests
34+
install.initialize_options(self)
35+
def finalize_options(self):
36+
- global _2to3
37+
- ## in the test cases 2to3 should be already done (fail2ban-2to3):
38+
- if self.disable_2to3:
39+
- _2to3 = False
40+
- if _2to3:
41+
- cmdclass = self.distribution.cmdclass
42+
- cmdclass['build_py'] = build_py_2to3
43+
- cmdclass['build_scripts'] = build_scripts_2to3
44+
if self.without_tests:
45+
self.distribution.scripts.remove('bin/fail2ban-testcases')
46+
47+
@@ -178,7 +168,6 @@ commands.'''
48+
if setuptools:
49+
setup_extra = {
50+
'test_suite': "fail2ban.tests.utils.gatherTests",
51+
- 'use_2to3': True,
52+
}
53+
else:
54+
setup_extra = {}
55+
@@ -202,9 +191,6 @@ if platform_system in ('linux', 'solaris', 'sunos') or platform_system.startswit
56+
('/usr/share/doc/fail2ban', doc_files)
57+
)
58+
59+
-# Get version number, avoiding importing fail2ban.
60+
-# This is due to tests not functioning for python3 as 2to3 takes place later
61+
-exec(open(join("fail2ban", "version.py")).read())
62+
63+
setup(
64+
name = "fail2ban",
65+
--
66+
2.34.1
67+
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
From 2b6bb2c1bed8f7009631e8f8c306fa3160324a49 Mon Sep 17 00:00:00 2001
2+
From: "Sergey G. Brester" <serg.brester@sebres.de>
3+
Date: Mon, 8 Feb 2021 17:19:24 +0100
4+
Subject: [PATCH 1/3] follow bpo-37324:
5+
:ref:`collections-abstract-base-classes` moved to the :mod:`collections.abc`
6+
module
7+
8+
(since 3.10-alpha.5 `MutableMapping` is missing in collections module)
9+
---
10+
fail2ban/server/action.py | 5 ++++-
11+
1 file changed, 4 insertions(+), 1 deletion(-)
12+
13+
diff --git a/fail2ban/server/action.py b/fail2ban/server/action.py
14+
index 3bc48fe0..f0f1e6f5 100644
15+
--- a/fail2ban/server/action.py
16+
+++ b/fail2ban/server/action.py
17+
@@ -30,7 +30,10 @@ import tempfile
18+
import threading
19+
import time
20+
from abc import ABCMeta
21+
-from collections import MutableMapping
22+
+try:
23+
+ from collections.abc import MutableMapping
24+
+except ImportError:
25+
+ from collections import MutableMapping
26+
27+
from .failregex import mapTag2Opt
28+
from .ipdns import DNSUtils
29+
--
30+
2.34.1
31+
32+
33+
From 42dee38ad2ac5c3f23bdf297d824022923270dd9 Mon Sep 17 00:00:00 2001
34+
From: "Sergey G. Brester" <serg.brester@sebres.de>
35+
Date: Mon, 8 Feb 2021 17:25:45 +0100
36+
Subject: [PATCH 2/3] amend for `Mapping`
37+
38+
---
39+
fail2ban/server/actions.py | 5 ++++-
40+
1 file changed, 4 insertions(+), 1 deletion(-)
41+
42+
diff --git a/fail2ban/server/actions.py b/fail2ban/server/actions.py
43+
index b7b95b44..897d907c 100644
44+
--- a/fail2ban/server/actions.py
45+
+++ b/fail2ban/server/actions.py
46+
@@ -28,7 +28,10 @@ import logging
47+
import os
48+
import sys
49+
import time
50+
-from collections import Mapping
51+
+try:
52+
+ from collections.abc import Mapping
53+
+except ImportError:
54+
+ from collections import Mapping
55+
try:
56+
from collections import OrderedDict
57+
except ImportError:
58+
--
59+
2.34.1
60+
61+
62+
From 9f1d1f4fbd0804695a976beb191f2c49a2739834 Mon Sep 17 00:00:00 2001
63+
From: "Sergey G. Brester" <serg.brester@sebres.de>
64+
Date: Mon, 8 Feb 2021 17:35:59 +0100
65+
Subject: [PATCH 3/3] amend for `Mapping` (jails)
66+
67+
---
68+
fail2ban/server/jails.py | 5 ++++-
69+
1 file changed, 4 insertions(+), 1 deletion(-)
70+
71+
diff --git a/fail2ban/server/jails.py b/fail2ban/server/jails.py
72+
index 972a8c4b..27e12ddf 100644
73+
--- a/fail2ban/server/jails.py
74+
+++ b/fail2ban/server/jails.py
75+
@@ -22,7 +22,10 @@ __copyright__ = "Copyright (c) 2004 Cyril Jaquier, 2013- Yaroslav Halchenko"
76+
__license__ = "GPL"
77+
78+
from threading import Lock
79+
-from collections import Mapping
80+
+try:
81+
+ from collections.abc import Mapping
82+
+except ImportError:
83+
+ from collections import Mapping
84+
85+
from ..exceptions import DuplicateJailException, UnknownJailException
86+
from .jail import Jail
87+
--
88+
2.34.1
89+

0 commit comments

Comments
 (0)