Browse Source

lua-openssl: Upgrade to v0.7.4

Signed-off-by: Amnon Paz <pazamnon@gmail.com>
lilik-openwrt-22.03
Amnon Paz 6 years ago
parent
commit
ff0fa834af
4 changed files with 149 additions and 166 deletions
  1. +3
    -3
      lang/lua-openssl/Makefile
  2. +146
    -96
      lang/lua-openssl/patches/0001-Revise-Makefile.patch
  3. +0
    -36
      lang/lua-openssl/patches/0010-Fix-Linkage.patch
  4. +0
    -31
      lang/lua-openssl/patches/0020-use-X509_REQ_to_X509-in-openssl-1.1.patch

+ 3
- 3
lang/lua-openssl/Makefile View File

@ -8,16 +8,16 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=lua-openssl
PKG_VERSION:=0.7.1
PKG_VERSION:=0.7.4
PKG_RELEASE:=1
PKG_MAINTAINER:=Amnon Paz <pazamnon@gmail.com>
PKG_LICENSE:=MIT
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_MIRROR_HASH:=225e3fe09226ff72968a7f36a33e207d27332107456a754abbaa59f99a3038f3
PKG_MIRROR_HASH:=c27cedee438de95877823b1ae0607556564d82c8692be40f43743ca9cc5a029a
PKG_SOURCE_URL:=https://github.com/zhaozg/lua-openssl.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=b104bbe914d279276560f188854036075b99f724
PKG_SOURCE_VERSION:=96effbaf477ca205f1787aaf1cce643bd208066b
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk


+ 146
- 96
lang/lua-openssl/patches/0001-Revise-Makefile.patch View File

@ -1,98 +1,148 @@
diff --git a/Makefile b/Makefile
index 10c1142..2a94df4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,58 +1,36 @@
T=openssl
+.PHONY: install clean
-PREFIX ?=/usr/local
-LIB_OPTION ?= -shared
+PKGC ?= pkg-config
-#Lua auto detect
-LUA_VERSION ?= $(shell pkg-config luajit --print-provides)
-ifeq ($(LUA_VERSION),) ############ Not use luajit
-LUAV ?= $(shell lua -e "_,_,v=string.find(_VERSION,'Lua (.+)');print(v)")
-LUA_CFLAGS ?= -I$(PREFIX)/include/lua$(LUAV)
-LUA_LIBS ?= -L$(PREFIX)/lib
-LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUAV)
-else
-LUAV ?= $(shell lua -e "_,_,v=string.find(_VERSION,'Lua (.+)');print(v)")
-LUA_CFLAGS ?= $(shell pkg-config luajit --cflags)
-LUA_LIBS ?= $(shell pkg-config luajit --libs)
-LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUAV)
-endif
+LIB_OPTION = -shared
-#OS auto detect
-SYS := $(shell gcc -dumpmachine)
+# lua's package config can be under various names
+LUAPKGC := $(shell for pc in lua lua5.1 lua5.2 lua5.3; do \
+ $(PKGC) --exists $$pc && echo $$pc && break; \
+ done)
-ifneq (, $(findstring linux, $(SYS)))
-# Do linux things
-LDFLAGS = -fPIC -lrt -ldl
-OPENSSL_LIBS ?= $(shell pkg-config openssl --libs)
-OPENSSL_CFLAGS ?= $(shell pkg-config openssl --cflags)
-CFLAGS = -fPIC $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
-endif
-ifneq (, $(findstring apple, $(SYS)))
-# Do darwin things
-LDFLAGS = -fPIC -lrt -ldl
+BUILD_DIR = $(shell pwd)
+
+# LUA include/libraries build flags
+#LUAV ?= $(shell lua -e "_,_,v=string.find(_VERSION,'Lua (.+)');print(v)")
+LUA_LIBDIR := $(shell $(PKGC) --variable=libdir $(LUAPKGC))
+LUA_CFLAGS := $(shell $(PKGC) --cflags $(LUAPKGC))
+LUA_LIBS := $(shell $(PKGC) --libs-only-L $(LUAPKGC))
+#LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUAV)
+
+# openssl include/libraries build flags
+LDFLAGS += -lrt -ldl $(OPENSSL_LIBS) $(LUA_LIBS)
OPENSSL_LIBS ?= $(shell pkg-config openssl --libs)
OPENSSL_CFLAGS ?= $(shell pkg-config openssl --cflags)
-CFLAGS = -fPIC $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
-endif
-ifneq (, $(findstring mingw, $(SYS)))
-# Do mingw things
-V = $(shell lua -e "v=string.gsub('$(LUAV)','%.','');print(v)")
-LDFLAGS = -mwindows -lcrypt32 -lssl -lcrypto -lws2_32 $(PREFIX)/bin/lua$(V).dll
-LUA_CFLAGS = -DLUA_LIB -DLUA_BUILD_AS_DLL -I$(PREFIX)/include/
-CFLAGS = $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
-endif
-ifneq (, $(findstring cygwin, $(SYS)))
-# Do cygwin things
-OPENSSL_LIBS ?= $(shell pkg-config openssl --libs)
-OPENSSL_CFLAGS ?= $(shell pkg-config openssl --cflags)
-CFLAGS = -fPIC $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
-endif
-#custome config
+# openssl include/libraries build flags
+LOCAL_INCLUDE = -I$(BUILD_DIR)/deps
+CFLAGS += -fPIC -DPTHREADS $(LOCAL_INCLUDE) $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
ifeq (.config, $(wildcard .config))
include .config
endif
-LIBNAME= $T.so.$V
+LIBNAME= $T.so
#LIB_OPTION= -bundle -undefined dynamic_lookup #for MacOS X
@@ -68,11 +46,12 @@ OBJS=src/asn1.o src/auxiliar.o src/bio.o
src/ec.o src/engine.o src/hmac.o src/lbn.o src/lhash.o src/misc.o src/ocsp.o src/openssl.o src/ots.o src/pkcs12.o src/pkcs7.o \
src/pkey.o src/rsa.o src/ssl.o src/th-lock.o src/util.o src/x509.o src/xattrs.o src/xexts.o src/xname.o src/xstore.o src/xalgor.o src/callback.o
-.c.o:
- $(CC) -c -o $@ $?
+%.o: %.c
+ $(CC) $(CFLAGS) -c $< -o $@
all: $T.so
echo $(SYS)
+ $(CC) $(LDFLAGS) $(LIB_OPTION) $(OBJS) -o $@
$T.so: $(OBJS)
MACOSX_DEPLOYMENT_TARGET="10.3"; export MACOSX_DEPLOYMENT_TARGET; $(CC) $(CFLAGS) $(LIB_OPTION) -o $T.so $(OBJS) $(OPENSSL_LIBS) $(LUA_LIBS) $(LDFLAGS)
@@ -1,121 +1,52 @@
T=openssl
+.PHONY: install clean
-PREFIX ?=/usr/local
-CC := $(CROSS)$(CC)
-AR := $(CROSS)$(AR)
-LD := $(CROSS)$(LD)
+PKGC ?= pkg-config
-#OS auto detect
-ifneq (,$(TARGET_SYS))
- SYS := $(TARGET_SYS)
-else
- SYS := $(shell gcc -dumpmachine)
-endif
-
-#Lua auto detect
-LUA_VERSION := $(shell pkg-config luajit --print-provides)
-ifeq ($(LUA_VERSION),)
- # Not found luajit package, try lua
- LUA_VERSION := $(shell pkg-config lua --print-provides)
- ifeq ($(LUA_VERSION),)
- # Not found lua package, try from prefix
- LUA_VERSION := $(shell lua -e "_,_,v=string.find(_VERSION,'Lua (.+)');print(v)")
- LUA_CFLAGS ?= -I$(PREFIX)/include/lua$(LUA_VERSION)
- LUA_LIBS ?= -L$(PREFIX)/lib -llua
- LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION)
- else
- # Found lua package
- LUA_VERSION := $(shell lua -e "_,_,v=string.find(_VERSION,'Lua (.+)');print(v)")
- LUA_CFLAGS ?= $(shell pkg-config lua --cflags)
- LUA_LIBS ?= $(shell pkg-config lua --libs)
- LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION)
- endif
-else
- # Found luajit package
- LUA_VERSION := $(shell luajit -e "_,_,v=string.find(_VERSION,'Lua (.+)');print(v)")
- LUA_CFLAGS ?= $(shell pkg-config luajit --cflags)
- LUA_LIBS ?= $(shell pkg-config luajit --libs)
- LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION)
-endif
-
-#OpenSSL auto detect
-OPENSSL_CFLAGS ?= $(shell pkg-config openssl --cflags)
-OPENSSL_LIBS ?= $(shell pkg-config openssl --static --libs)
-
-ifneq (, $(findstring linux, $(SYS)))
- # Do linux things
- CFLAGS = -fpic
- LDFLAGS = -Wl,--no-undefined -fpic -lrt -ldl -lm
-endif
-
-ifneq (, $(findstring apple, $(SYS)))
- # Do darwin things
- CFLAGS = -fPIC
- LDFLAGS = -fPIC -undefined dynamic_lookup -ldl
- #MACOSX_DEPLOYMENT_TARGET="10.3"
- CC := MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} $(CC)
-endif
+LIB_OPTION = -shared
+LUAPKGC = lua
-ifneq (, $(findstring mingw, $(SYS)))
- # Do mingw things
- CFLAGS = -DLUA_LIB -DLUA_BUILD_AS_DLL -DWIN32_LEAN_AND_MEAN
-endif
-
-ifneq (, $(findstring cygwin, $(SYS)))
- # Do cygwin things
- CFLAGS = -fPIC
-endif
+# LUA include/libraries build flags
+LUA_CFLAGS := $(shell $(PKGC) --cflags $(LUAPKGC))
+LUA_LIBS_DIR := $(shell $(PKGC) --libs $(LUAPKGC))
-ifneq (, $(findstring iOS, $(SYS)))
- # Do iOS things
- CFLAGS = -fPIC
- LDFLAGS = -fPIC -ldl
-endif
+# openssl include/libraries build flags
+OPENSSL_CFLAGS ?= $(shell $(PKGC) openssl --cflags)
+OPENSSL_LIBS_DIR ?= $(shell $(PKGC) openssl --libs)
-#custom config
+LDFLAGS = -Wl,--no-undefined -fpic -lrt -ldl -lm $(OPENSSL_LIBS_DIR) $(LUA_LIBS_DIR)
+CFLAGS += -fPIC -DPTHREADS $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
ifeq (.config, $(wildcard .config))
- include .config
+include .config
endif
-LIBNAME= $T.so.$V
+LIBNAME= $T.so
-CFLAGS += $(OPENSSL_CFLAGS) $(LUA_CFLAGS) $(TARGET_FLAGS)
-LDFLAGS += -shared $(OPENSSL_LIBS) $(LUA_LIBS)
# Compilation directives
WARN_MIN = -Wall -Wno-unused-value
WARN = -Wall
WARN_MOST = $(WARN) -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -pedantic
CFLAGS += -g $(WARN_MIN) -DPTHREADS -Ideps -Ideps/lua-compat -Ideps/auxiliar
-
OBJS=src/asn1.o deps/auxiliar/auxiliar.o src/bio.o src/cipher.o src/cms.o src/compat.o src/crl.o src/csr.o src/dh.o src/digest.o src/dsa.o \
src/ec.o src/engine.o src/hmac.o src/lbn.o src/lhash.o src/misc.o src/ocsp.o src/openssl.o src/ots.o src/pkcs12.o src/pkcs7.o \
src/pkey.o src/rsa.o src/ssl.o src/th-lock.o src/util.o src/x509.o src/xattrs.o src/xexts.o src/xname.o src/xstore.o \
src/xalgor.o src/callback.o src/srp.o deps/auxiliar/subsidiar.o
-.c.o:
- $(CC) $(CFLAGS) -c -o $@ $?
+%.o: %.c
+ $(CC) $(CFLAGS) -c $< -o $@
all: $T.so
- @echo "Target system: "$(SYS)
-
-$T.so: lib$T.a
- $(CC) -o $@ src/openssl.o -L. -l$T $(LDFLAGS)
+ echo $(SYS)
+ $(CC) $(LDFLAGS) $(LIB_OPTION) $(OBJS) -o $@
-lib$T.a: $(OBJS)
- $(AR) rcs $@ $?
+$T.so: $(OBJS)
+ echo "LUA LIBS_DIR: " $(LUA_LIBS_DIR)
+ $(CC) $(CFLAGS) $(LIB_OPTION) -o $T.so $(OBJS) $(LDFLAGS)
install: all
mkdir -p $(LUA_LIBDIR)
cp $T.so $(LUA_LIBDIR)
-info:
- @echo "Target system: "$(SYS)
- @echo "CC:" $(CC)
- @echo "AR:" $(AR)
- @echo "PREFIX:" $(PREFIX)
-
clean:
- rm -f $T.so lib$T.a $(OBJS)
-
-# vim: ts=8 sw=8 noet
+ rm -f $T.so $(OBJS)

+ 0
- 36
lang/lua-openssl/patches/0010-Fix-Linkage.patch View File

@ -1,36 +0,0 @@
diff --git a/deps/lua-compat/c-api/compat-5.3.c b/deps/lua-compat/c-api/compat-5.3.c
index 4395bbc..4a8877c 100644
--- a/deps/lua-compat/c-api/compat-5.3.c
+++ b/deps/lua-compat/c-api/compat-5.3.c
@@ -491,17 +491,6 @@ COMPAT53_API int lua_geti (lua_State *L, int index, lua_Integer i) {
}
-COMPAT53_API int lua_isinteger (lua_State *L, int index) {
- if (lua_type(L, index) == LUA_TNUMBER) {
- lua_Number n = lua_tonumber(L, index);
- lua_Integer i = lua_tointeger(L, index);
- if (i == n)
- return 1;
- }
- return 0;
-}
-
-
static void compat53_reverse (lua_State *L, int a, int b) {
for (; a < b; ++a, --b) {
lua_pushvalue(L, a);
diff --git a/deps/lua-compat/c-api/compat-5.3.h b/deps/lua-compat/c-api/compat-5.3.h
index 2309294..8e67bae 100644
--- a/deps/lua-compat/c-api/compat-5.3.h
+++ b/deps/lua-compat/c-api/compat-5.3.h
@@ -244,9 +244,6 @@ typedef int (*lua_KFunction)(lua_State *L, int status, lua_KContext ctx);
#define lua_geti COMPAT53_CONCAT(COMPAT53_PREFIX, _geti)
COMPAT53_API int lua_geti (lua_State *L, int index, lua_Integer i);
-#define lua_isinteger COMPAT53_CONCAT(COMPAT53_PREFIX, _isinteger)
-COMPAT53_API int lua_isinteger (lua_State *L, int index);
-
#define lua_numbertointeger(n, p) \
((*(p) = (lua_Integer)(n)), 1)

+ 0
- 31
lang/lua-openssl/patches/0020-use-X509_REQ_to_X509-in-openssl-1.1.patch View File

@ -1,31 +0,0 @@
--- a/src/csr.c
+++ b/src/csr.c
@@ -38,7 +38,7 @@ static LUA_FUNCTION(openssl_csr_read)
return openssl_pushresult(L, 0);
}
-
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
static X509 *X509_REQ_to_X509_ex(X509_REQ *r, int days, EVP_PKEY *pkey, const EVP_MD* md)
{
X509 *ret = NULL;
@@ -91,14 +91,19 @@ static X509 *X509_REQ_to_X509_ex(X509_RE
}
return (ret);
}
+#endif
static LUA_FUNCTION(openssl_csr_to_x509)
{
X509_REQ * csr = CHECK_OBJECT(1, X509_REQ, "openssl.x509_req");
EVP_PKEY * pkey = CHECK_OBJECT(2, EVP_PKEY, "openssl.evp_pkey");
int days = luaL_optint(L, 3, 365);
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
const EVP_MD* md = get_digest(L, 4, "sha256");
X509* cert = X509_REQ_to_X509_ex(csr, days, pkey, md);
+#else
+ X509* cert = X509_REQ_to_X509(csr, days, pkey);
+#endif
if (cert)
{
PUSH_OBJECT(cert, "openssl.x509");

Loading…
Cancel
Save