1
Fork 0
mirror of https://https.git.savannah.gnu.org/git/guix.git/ synced 2025-07-14 02:50:45 +02:00

gnu: fail2ban: Improve style.

* gnu/packages/admin.scm (fail2ban): Use gexps and run guix style.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Nicolas Graves 2025-05-04 10:56:24 +02:00 committed by Ludovic Courtès
parent 6567fd4072
commit 30f240b034
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -6173,37 +6173,35 @@ alias cysdig=sudo csysdig --modern-bpf
(package
(name "fail2ban")
(version "1.1.0")
(source (origin
(source
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/fail2ban/fail2ban")
(commit version)))
(file-name (git-file-name name version))
(sha256
(base32
"0lfakna6ad2xwz95sjxzkavipcsxiy7ybavkdkf9zzmspf2ws4yk"))
(base32 "0lfakna6ad2xwz95sjxzkavipcsxiy7ybavkdkf9zzmspf2ws4yk"))
(modules '((guix build utils)))
(snippet
'(begin
(snippet #~(begin
;; Replacing those by our own paths-guix.conf
(with-directory-excursion "config"
(for-each delete-file
'("paths-arch.conf"
"paths-debian.conf"
"paths-fedora.conf"
"paths-freebsd.conf"
"paths-opensuse.conf"
"paths-osx.conf")))))
'("paths-arch.conf" "paths-debian.conf"
"paths-fedora.conf" "paths-freebsd.conf"
"paths-opensuse.conf" "paths-osx.conf")))))
(patches (search-patches "fail2ban-paths-guix-conf.patch"))))
(build-system pyproject-build-system)
(arguments
'(#:phases (modify-phases %standard-phases
(list
#:phases
#~(modify-phases %standard-phases
(add-after 'unpack 'avoid-external-binary-in-/bin
(lambda _
(delete-file "fail2ban/setup.py")
(substitute* '("bin/fail2ban-testcases"
"setup.py")
((".*updatePyExec.*") ""))))
(substitute* '("bin/fail2ban-testcases" "setup.py")
((".*updatePyExec.*")
""))))
(add-after 'unpack 'patch-setup.py
(lambda _
;; Get rid of absolute file names.
@ -6246,16 +6244,14 @@ alias cysdig=sudo csysdig --modern-bpf
"fail2ban/client/fail2bancmdline.py"
"fail2ban/client/fail2banregex.py")
(("/etc/fail2ban")
(string-append (assoc-ref outputs "out")
"/etc/fail2ban")))))
(string-append (assoc-ref outputs "out") "/etc/fail2ban")))))
(add-after 'fix-default-config 'set-action-dependencies
(lambda* (#:key inputs #:allow-other-keys)
;; deleting things that are not feasible to fix
;; or won't be used any way
(with-directory-excursion "config/action.d"
(for-each delete-file
'("apf.conf"
"bsd-ipfw.conf"
'("apf.conf" "bsd-ipfw.conf"
"dshield.conf"
"ipfilter.conf"
"ipfw.conf"
@ -6286,11 +6282,9 @@ alias cysdig=sudo csysdig --modern-bpf
;; TODO: deal with geoiplookup ..
(("(awk|curl|dig|jq)" all cmd)
(bin cmd))
(("(cat|echo|grep|head|printf|wc) " all
cmd)
(("(cat|echo|grep|head|printf|wc) " all cmd)
(string-append (bin cmd) " "))
((" (date|rm|sed|tail|touch|tr) " all
cmd)
((" (date|rm|sed|tail|touch|tr) " all cmd)
(string-append " "
(bin cmd) " "))
(("cut -d")
@ -6313,7 +6307,8 @@ alias cysdig=sudo csysdig --modern-bpf
(("mail -E")
(string-append sendmail " -E"))
(("nftables = nft")
(string-append "nftables = " (sbin "nft")))
(string-append "nftables = "
(sbin "nft")))
(("perl -e")
(string-append (bin "perl") " -e"))
(("/usr/sbin/sendmail")
@ -6321,34 +6316,29 @@ alias cysdig=sudo csysdig --modern-bpf
(("test -e")
(string-append (bin "test") " -e"))
(("_whois = whois")
(string-append "_whois = " (bin "whois")))))
(string-append "_whois = "
(bin "whois")))))
(substitute* "config/jail.conf"
(("before = paths-debian\\.conf")
"before = paths-guix.conf"))))
(add-after 'install 'copy-man-pages
(lambda* (#:key outputs #:allow-other-keys)
(let* ((man (string-append (assoc-ref outputs "out")
"/man"))
(let* ((man (string-append (assoc-ref outputs "out") "/man"))
(install-man (lambda (m)
(lambda (f)
(install-file (string-append f
"." m)
(string-append man
"/man" m)))))
(install-file (string-append f "." m)
(string-append man "/man"
m)))))
(install-man1 (install-man "1"))
(install-man5 (install-man "5")))
(with-directory-excursion "man"
(for-each install-man1
'("fail2ban"
"fail2ban-client"
"fail2ban-python"
"fail2ban-regex"
"fail2ban-server"
'("fail2ban" "fail2ban-client" "fail2ban-python"
"fail2ban-regex" "fail2ban-server"
"fail2ban-testcases"))
(for-each install-man5
'("jail.conf")))))))))
(native-inputs
(list python-setuptools python-wheel))
(native-inputs (list python-setuptools python-wheel))
(inputs (list gawk
coreutils-minimal
curl