Subject: [bug#78066] [PATCH v2 2/6] gnu: fail2ban: Move setup and test patches to phases.

From: Nicolas Graves <[email-masked]>
Date: Sat, 3 May 2025 15:59:58 +0200

* gnu/packages/admin.scm (fail2ban)
  [source]<snippet>: Move setup and test substitutions...
  [arguments]<phases>: ...to phases 'patch-setup.py and
  'disable-some-tests.
---
 gnu/packages/admin.scm | 71 +++++++++++++++++++++---------------------
 1 file changed, 35 insertions(+), 36 deletions(-)

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index bd07a73c99..ee428c00df 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -6252,42 +6252,7 @@ (define-public fail2ban
                                 "paths-fedora.conf"
                                 "paths-freebsd.conf"
                                 "paths-opensuse.conf"
-                                "paths-osx.conf")))
-                  ;; Get rid of absolute file names.
-                  (substitute* "setup.py"
-                    (("/etc/fail2ban")
-                     "etc/fail2ban")
-                    (("/var/lib/fail2ban")
-                     "var/lib/fail2ban")
-                    (("\"/usr/bin/\"")
-                     "\"usr/bin/\"")
-                    (("\"/usr/lib/fail2ban/\"")
-                     "\"usr/lib/fail2ban/\"")
-                    (("'/usr/share/doc/fail2ban'")
-                     "'usr/share/doc/fail2ban'"))
-                  ;; disable tests performing unacceptable side-effects
-                  (let ((make-suite (lambda (t)
-                                      (string-append
-                                       "tests.addTest.unittest.makeSuite."
-                                       t ".."))))
-                    (substitute* "fail2ban/tests/utils.py"
-                      (((make-suite "actiontestcase.CommandActionTest"))
-                       "")
-                      (((make-suite "misctestcase.SetupTest"))
-                       "")
-                      (((make-suite
-                         "filtertestcase.DNSUtilsNetworkTests"))
-                       "")
-                      (((make-suite "filtertestcase.IgnoreIPDNS"))
-                       "")
-                      (((make-suite "filtertestcase.GetFailures"))
-                       "")
-                      (((make-suite
-                         "fail2banclienttestcase.Fail2banServerTest"))
-                       "")
-                      (((make-suite
-                         "servertestcase.ServerConfigReaderTests"))
-                       "")))))
+                                "paths-osx.conf")))))
               (patches (search-patches
                         "fail2ban-0.11.2_fix-setuptools-drop-2to3.patch"
                         "fail2ban-python310-server-action.patch"
@@ -6302,6 +6267,40 @@ (define-public fail2ban
                   (add-before 'build 'invoke-2to3
                     (lambda _
                       (invoke "./fail2ban-2to3")))
+                  (add-after 'unpack 'patch-setup.py
+                    (lambda _
+                      ;; Get rid of absolute file names.
+                      (substitute* "setup.py"
+                        (("/etc/fail2ban")
+                         "etc/fail2ban")
+                        (("/var/lib/fail2ban")
+                         "var/lib/fail2ban")
+                        (("\"/usr/bin/\"")
+                         "\"usr/bin/\"")
+                        (("\"/usr/lib/fail2ban/\"")
+                         "\"usr/lib/fail2ban/\"")
+                        (("'/usr/share/doc/fail2ban'")
+                         "'usr/share/doc/fail2ban'"))))
+                  (add-after 'unpack 'disable-some-tests
+                    (lambda _
+                      (define (make-suite str)
+                        (string-append "tests.addTest.unittest.makeSuite." str ".."))
+                      ;; disable tests performing unacceptable side-effects
+                      (substitute* "fail2ban/tests/utils.py"
+                        (((make-suite "actiontestcase.CommandActionTest"))
+                         "")
+                        (((make-suite "misctestcase.SetupTest"))
+                         "")
+                        (((make-suite "filtertestcase.DNSUtilsNetworkTests"))
+                         "")
+                        (((make-suite "filtertestcase.IgnoreIPDNS"))
+                         "")
+                        (((make-suite "filtertestcase.GetFailures"))
+                         "")
+                        (((make-suite "fail2banclienttestcase.Fail2banServerTest"))
+                         "")
+                        (((make-suite "servertestcase.ServerConfigReaderTests"))
+                         ""))))
                   (add-before 'install 'fix-default-config
                     (lambda* (#:key outputs #:allow-other-keys)
                       (substitute* '("config/paths-common.conf"
-- 
2.49.0