From d648ce07cd4828b4f2a848464a31efd76f00cb7c Mon Sep 17 00:00:00 2001 From: Simon South Date: Fri, 15 May 2020 11:18:44 -0400 Subject: [PATCH 1/3] gnu: Add luajit-ossl. * gnu/packages/lua.scm (make-lua-ossl): New function. (luajit-ossl): New variable. --- gnu/packages/lua.scm | 82 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/gnu/packages/lua.scm b/gnu/packages/lua.scm index 181ce76559..ab86e24bb9 100644 --- a/gnu/packages/lua.scm +++ b/gnu/packages/lua.scm @@ -11,6 +11,7 @@ ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice ;;; Copyright © 2018 Fis Trivial ;;; Copyright © 2020 Nicolas Goaziou +;;; Copyright © 2020 Simon South ;;; ;;; This file is part of GNU Guix. ;;; @@ -38,6 +39,7 @@ #:use-module (guix build-system trivial) #:use-module (gnu packages) #:use-module (gnu packages readline) + #:use-module (gnu packages m4) #:use-module (gnu packages tls) #:use-module (gnu packages xml) #:use-module (gnu packages glib) @@ -292,6 +294,86 @@ directory structure and file attributes.") (define-public lua5.2-filesystem (make-lua-filesystem "lua5.2-filesystem" lua-5.2)) +(define (make-lua-ossl name lua) + (package + (name name) + (version "20190731") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/wahern/luaossl.git") + (commit (string-append "rel-" version)))) + (sha256 + (base32 + "03xmhy90qrby8pbwqdwy2xa7bk5jbpfzzrmpj83klzw7zkyf2k96")))) + (build-system gnu-build-system) + (arguments + `(#:modules ((guix build gnu-build-system) + (guix build utils) + (ice-9 popen) + (ice-9 rdelim)) + #:make-flags + (let ((out (assoc-ref %outputs "out")) + (lua-api-version ,(if (eq? lua luajit) + "5.1" + (version-major+minor + (package-version lua))))) + (list "CC=gcc" + "CFLAGS='-D HAVE_SYS_SYSCTL_H=0'" ; sys/sysctl.h is deprecated + (string-append "DESTDIR=" out) + (string-append "LUA_APIS=" lua-api-version) + "prefix=")) + #:phases + (modify-phases %standard-phases + (delete 'configure) + (delete 'check) + (add-after 'install 'check + (lambda* (#:key outputs #:allow-other-keys) + (let* ((lua-api-version ,(if (eq? lua luajit) + "5.1" + (version-major+minor + (package-version lua)))) + (lua-cpath (lambda (p) + (string-append p "/lib/lua/" lua-api-version + "/?.so"))) + (lua-path (lambda (p) + (string-append p "/share/lua/" lua-api-version + "/?.lua"))) + (lua-interp (begin + (setenv "CC" "gcc") + (read-line + (open-pipe* OPEN_READ "mk/luapath" "lua")))) + (out (assoc-ref outputs "out"))) + (setenv "LUA_CPATH" (string-append (lua-cpath out) ";;")) + (setenv "LUA_PATH" (string-append (lua-path out) ";;")) + + (with-directory-excursion "regress" + (for-each (lambda (f) + (invoke lua-interp f)) + (filter + ;; Omit a test that requires lua-cqueues, as that + ;; requires this package also + (lambda (f) + (not (equal? f "./148-custom-extensions.lua"))) + (find-files "." "^[0-9].*\\.lua$"))))) + #t))))) + (inputs + `(("lua" ,lua) + ;; TODO: Support interpreters other than LuaJIT using luaffifb or a + ;; similar FFI-compatibility module + ("openssl" ,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))) + +(define-public luajit-ossl + (make-lua-ossl "luajit-ossl" luajit)) + (define (make-lua-sec name lua) (package (name name) -- 2.26.2