Subject: [bug#64449] [PATCH v2 2/4] gnu: lua-ossl: Use G-expressions.

From: Bruno Victal <[email-masked]>
Date: Thu, 31 Aug 2023 16:03:40 +0100

Dropped obsolete flag due to <https://github.com/wahern/luaossl/pull/61>.

* gnu/packages/lua.scm (make-lua-ossl): Use G-Expressions.
[arguments]<#:make-flags>: Drop obsolete flag.
<#:phases>: Add 'remove-luajit-test and 'remove-cqueues-test.
---
 gnu/packages/lua.scm | 99 ++++++++++++++++++++++++--------------------
 1 file changed, 55 insertions(+), 44 deletions(-)

diff --git a/gnu/packages/lua.scm b/gnu/packages/lua.scm
index f98999efc0..8726b7a8db 100644
--- a/gnu/packages/lua.scm
+++ b/gnu/packages/lua.scm
@@ -19,6 +19,7 @@
 ;;; Copyright © 2022 Luis Henrique Gomes Higino <[email-masked]>
 ;;; Copyright © 2022 Leo Nikkilä <[email-masked]>
 ;;; Copyright © 2023 Yovan Naumovski <[email-masked]>
+;;; Copyright © 2023 Bruno Victal <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -368,54 +369,64 @@ (define-public lua5.2-filesystem
   (make-lua-filesystem "lua5.2-filesystem" lua-5.2))
 
 (define (make-lua-ossl name lua)
-  (package
-    (name name)
-    (version "20220711")
-    (source (origin
-              (method git-fetch)
-              (uri (git-reference
-                    (url "https://github.com/wahern/luaossl")
-                    (commit (string-append "rel-" version))))
-              (file-name (git-file-name name version))
-              (sha256
-               (base32
-                "1a9pgmc6fbhgh1m9ksz9fq057yzz46npqgakcsy9vngg47xacfdb"))))
-    (build-system gnu-build-system)
-    (arguments
-     `(#:make-flags
-       (let ((out (assoc-ref %outputs "out"))
-             (lua-api-version ,(version-major+minor (package-version lua))))
-         (list ,(string-append "CC=" (cc-for-target))
-               "CFLAGS='-D HAVE_SYS_SYSCTL_H=0'" ; sys/sysctl.h is deprecated
-               (string-append "prefix=" out)
-               (string-append "LUA_APIS=" lua-api-version)))
-       #:phases
-       (modify-phases %standard-phases
-         (delete 'configure)
-         (delete 'check)
-         (add-after 'install 'check
-           (lambda* (#:key outputs #:allow-other-keys)
-             (let ((out (assoc-ref outputs "out"))
-                   (lua-version ,(version-major+minor (package-version lua))))
-               (setenv "LUA_CPATH"
-                       (string-append out "/lib/lua/" lua-version "/?.so;;"))
-               (setenv "LUA_PATH"
-                       (string-append out "/share/lua/" lua-version "/?.lua;;"))
-               (with-directory-excursion "regress"
-                 (for-each (lambda (f)
-                             (invoke "lua" f))
-                           (find-files "." "^[0-9].*\\.lua$"))))
-             #t)))))
-    (inputs
-     (list lua openssl))
-    (home-page "https://25thandclement.com/~william/projects/luaossl.html")
-    (synopsis "OpenSSL bindings for Lua")
-    (description "The luaossl extension module for Lua provides comprehensive,
+  (let ((lua-api-version (version-major+minor (package-version lua))))
+    (package
+      (name name)
+      (version "20220711")
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/wahern/luaossl")
+                      (commit (string-append "rel-" version))))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1a9pgmc6fbhgh1m9ksz9fq057yzz46npqgakcsy9vngg47xacfdb"))))
+      (build-system gnu-build-system)
+      (arguments
+       (list
+        #:make-flags
+        #~(list #$(string-append "CC=" (cc-for-target))
+                #$(string-append "LUA_APIS=" lua-api-version)
+                (string-append "prefix=" #$output))
+        #:phases
+        #~(modify-phases %standard-phases
+            (add-after 'unpack 'remove-luajit-test
+              (lambda _
+                ;; This test is only meaningful for luajit.
+                ;; <https://lua-users.org/lists/lua-l/2021-01/msg00324.html>
+                (unless (string-prefix? "luajit" #$(package-name lua))
+                  (delete-file "regress/104-interposition-discarded.lua"))))
+            (add-after 'unpack 'remove-cqueues-test
+              (lambda _
+                ;; XXX: This test depends on cqueues and cqueues has a test
+                ;; that depends on lua-ossl.
+                (delete-file "regress/148-custom-extensions.lua")))
+            (delete 'configure)
+            (delete 'check)  ; place 'check after 'install
+            (add-after 'install 'check
+              (lambda* (#:key tests? #:allow-other-keys)
+                (when tests?
+                  (setenv "LUA_CPATH"
+                          (string-append #$output "/lib/lua/"
+                                         #$lua-api-version "/?.so;;"))
+                  (setenv "LUA_PATH"
+                          (string-append #$output "/share/lua/"
+                                         #$lua-api-version "/?.lua;;"))
+                  (with-directory-excursion "regress"
+                    (for-each (lambda (f)
+                                (invoke "lua" f))
+                              (find-files "." "^[0-9].*\\.lua$")))))))))
+      (inputs
+       (list lua openssl))
+      (home-page "https://25thandclement.com/~william/projects/luaossl.html")
+      (synopsis "OpenSSL bindings for Lua")
+      (description "The luaossl extension module for Lua provides comprehensive,
 low-level bindings to the OpenSSL library, including support for certificate and
 key management, key generation, signature verification, and deep bindings to the
 distinguished name, alternative name, and X.509v3 extension interfaces.  It also
 binds OpenSSL's bignum, message digest, HMAC, cipher, and CSPRNG interfaces.")
-    (license license:expat)))
+      (license license:expat))))
 
 (define-public lua-ossl
   (make-lua-ossl "lua-ossl" lua))
-- 
2.40.1