Skip to contentSkip to conversation

package/fail2ban: add python3 support

PATCH New Pascal de Bruijn 2 participants 3 messages Jan 22, 2020 – Feb 3, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/fail2ban: add python3 support

the fail2ban codebase is still native python2, but 2to3 is supported

---
 package/fail2ban/Config.in   | 2 +-
 package/fail2ban/fail2ban.mk | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
package/fail2ban/Config.in +1 -1
index f05adbb..86e6233 100644
@@ -1,6 +1,6 @@
 config BR2_PACKAGE_FAIL2BAN
 	bool "fail2ban"
-	depends on BR2_PACKAGE_PYTHON
+	depends on BR2_PACKAGE_PYTHON || BR2_PACKAGE_PYTHON3
 	select BR2_PACKAGE_PYTHON_SYSTEMD if BR2_PACKAGE_SYSTEMD
 	help
 	  Fail2ban scans log files (e.g. /var/log/apache/error_log) and
package/fail2ban/fail2ban.mk +7 -0
index 0a8f3c6..0c5de9a 100644
@@ -10,6 +10,13 @@ FAIL2BAN_LICENSE = GPL-2.0+
 FAIL2BAN_LICENSE_FILES = COPYING
 FAIL2BAN_SETUP_TYPE = distutils
 
+define FAIL2BAN_PYTHON_2TO3
+	$(HOST_DIR)/bin/2to3 --write --nobackups --no-diffs $(@D)/bin/* $(@D)/fail2ban
+endef
+ifeq ($(BR2_PACKAGE_PYTHON3),y)
+FAIL2BAN_POST_PATCH_HOOKS += FAIL2BAN_PYTHON_2TO3
+endif
+
 define FAIL2BAN_FIX_DEFAULT_CONFIG
 	$(SED) '/^socket/c\socket = /run/fail2ban.sock' $(TARGET_DIR)/etc/fail2ban/fail2ban.conf
 	$(SED) '/^pidfile/c\pidfile = /run/fail2ban.pid' $(TARGET_DIR)/etc/fail2ban/fail2ban.conf
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 package/fail2ban: add python3 support

Quoted 26 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Pascal" == Pascal de Bruijn <[email protected]> writes:

the fail2ban codebase is still native python2, but 2to3 is supported

---
 package/fail2ban/Config.in   | 2 +-
 package/fail2ban/fail2ban.mk | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
package/fail2ban/Config.in +1 -1
index f05adbb..86e6233 100644
@@ -1,6 +1,6 @@
 config BR2_PACKAGE_FAIL2BAN
 	bool "fail2ban"
-	depends on BR2_PACKAGE_PYTHON
+	depends on BR2_PACKAGE_PYTHON || BR2_PACKAGE_PYTHON3
 	select BR2_PACKAGE_PYTHON_SYSTEMD if BR2_PACKAGE_SYSTEMD
 	help
 	  Fail2ban scans log files (e.g. /var/log/apache/error_log) and
package/fail2ban/fail2ban.mk +0 -0
index 0a8f3c6..0c5de9a 100644

package/fail2ban/fail2ban.mk FAIL2BAN_LICENSE = GPL-2.0+ · line 14

Quoted 5 lines
package/fail2ban/fail2ban.mk +2 -0
@@ -10,6 +10,13 @@ FAIL2BAN_LICENSE = GPL-2.0+
 FAIL2BAN_LICENSE_FILES = COPYING
 FAIL2BAN_SETUP_TYPE = distutils
 
+define FAIL2BAN_PYTHON_2TO3
+	$(HOST_DIR)/bin/2to3 --write --nobackups --no-diffs $(@D)/bin/* $(@D)/fail2ban

I was going to say that this is horrible, but this is indeed apparently how upstream expects you to use it (with the fail2ban-2to3 script).

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#2 lore raw

PATCH 1/1 package/fail2ban: add python3 support

In reply to Pascal de Bruijn
Quoted 26 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Pascal" == Pascal de Bruijn <[email protected]> writes:

the fail2ban codebase is still native python2, but 2to3 is supported

---
 package/fail2ban/Config.in   | 2 +-
 package/fail2ban/fail2ban.mk | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
package/fail2ban/Config.in +1 -1
index f05adbb..86e6233 100644
@@ -1,6 +1,6 @@
 config BR2_PACKAGE_FAIL2BAN
 	bool "fail2ban"
-	depends on BR2_PACKAGE_PYTHON
+	depends on BR2_PACKAGE_PYTHON || BR2_PACKAGE_PYTHON3
 	select BR2_PACKAGE_PYTHON_SYSTEMD if BR2_PACKAGE_SYSTEMD
 	help
 	  Fail2ban scans log files (e.g. /var/log/apache/error_log) and
package/fail2ban/fail2ban.mk +0 -0
index 0a8f3c6..0c5de9a 100644

package/fail2ban/fail2ban.mk FAIL2BAN_LICENSE = GPL-2.0+ · line 17

Quoted 8 lines
package/fail2ban/fail2ban.mk +5 -0
@@ -10,6 +10,13 @@ FAIL2BAN_LICENSE = GPL-2.0+
 FAIL2BAN_LICENSE_FILES = COPYING
 FAIL2BAN_SETUP_TYPE = distutils
 
+define FAIL2BAN_PYTHON_2TO3
+	$(HOST_DIR)/bin/2to3 --write --nobackups --no-diffs $(@D)/bin/* $(@D)/fail2ban
+endef
+ifeq ($(BR2_PACKAGE_PYTHON3),y)
+FAIL2BAN_POST_PATCH_HOOKS += FAIL2BAN_PYTHON_2TO3

Ups, sent too fast - We need to ensure that host-python3 is available here at patch time for 2to3, so I've added FAIL2BAN_DEPENDENCIES += host-python3

Signature · 1 line
Bye, Peter Korsgaard