Skip to content

Commit 3a83ff8

Browse files
authored
fix: xmlsec static-linking (#4)
1 parent 62948b7 commit 3a83ff8

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
- name: get dependencies
2020
run: |
21-
sudo apt install -y cpanminus build-essential libncurses5-dev libreadline-dev libssl-dev perl lua5.1 liblua5.1-0-dev libxmlsec1-dev
21+
sudo apt install -y cpanminus build-essential libncurses5-dev libreadline-dev libssl-dev libxml2-dev libxslt-dev perl
2222
2323
# openresty
2424
wget -O - https://openresty.org/package/pubkey.gpg | sudo apt-key add -
@@ -30,7 +30,7 @@ jobs:
3030
sudo cpanm --notest Test::Nginx > build.log 2>&1 || (cat build.log && exit 1)
3131
3232
# luarocks
33-
curl -fsSL https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh | sudo sh
33+
curl -fsSL https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh | bash
3434
3535
- name: script
3636
run: |

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
*.so
33
t/servroot
44
deps
5+
xmlsec1-1.2.28*

Makefile

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,33 @@ INSTALL ?= install
66
LUA_INCDIR=/usr/local/openresty/luajit/include/luajit-2.1/
77
LUAJIT_DIR=/usr/local/openresty/luajit
88

9+
XMLSEC_VER=1.2.28
10+
911
CC=gcc
1012
CFLAGS=-g -fPIC -O2
11-
XMLSEC1_CFLAGS=$(shell xmlsec1-config --cflags --crypto=openssl)
13+
XMLSEC1_CFLAGS=-D__XMLSEC_FUNCTION__=__func__ -DXMLSEC_NO_SIZE_T -DXMLSEC_NO_GOST=1 -DXMLSEC_NO_GOST2012=1 -DXMLSEC_NO_CRYPTO_DYNAMIC_LOADING=1 -Ixmlsec1-$(XMLSEC_VER)/include/ -I/usr/include/libxml2 -DXMLSEC_CRYPTO_OPENSSL=1
1214
CFLAGS_ALL=$(CFLAGS) -Wall -Werror -std=c99 $(XMLSEC1_CFLAGS)
1315
LIBFLAG=-shared
1416
LDFLAGS=-g -O2
15-
XMLSEC1_LDFLAGS=$(shell xmlsec1-config --libs --crypto=openssl)
17+
XMLSEC1_STATIC_LIBS=xmlsec1-$(XMLSEC_VER)/./src/openssl/.libs/libxmlsec1-openssl.a xmlsec1-$(XMLSEC_VER)/./src/.libs/libxmlsec1.a
18+
XMLSEC1_LDFLAGS=-lxml2 -lssl -lcrypto -ldl -Wl,--whole-archive $(XMLSEC1_STATIC_LIBS) -Wl,--no-whole-archive -lxslt
1619
LDFLAGS_ALL=$(LIBFLAG) $(LDFLAGS) $(XMLSEC1_LDFLAGS)
1720

1821
.PHONY: build
19-
build: saml.so
22+
build: $(XMLSEC1_STATIC_LIBS) saml.so
23+
24+
$(XMLSEC1_STATIC_LIBS):
25+
wget --no-check-certificate https://www.aleksey.com/xmlsec/download/older-releases/xmlsec1-$(XMLSEC_VER).tar.gz
26+
tar zxf xmlsec1-$(XMLSEC_VER).tar.gz
27+
cd xmlsec1-$(XMLSEC_VER); CFLAGS="-std=c99" ./configure --with-openssl --with-pic --disable-crypto-dl --disable-apps-crypto-dl; make
2028

2129
.PHONY: test
22-
test: build deps
30+
test: build deps/
2331
prove -r t/
2432

2533
.PHONY: clean
2634
clean:
27-
rm -f *.so *.o
35+
rm -rf *.so *.o xmlsec1-$(XMLSEC_VER)*
2836

2937
saml.o: src/*.c
3038
$(CC) -c $(CFLAGS_ALL) -o saml.o src/saml.c
@@ -45,6 +53,5 @@ install:
4553
$(INSTALL) xsd/* $(INST_LUADIR)/resty/saml/xsd/
4654
$(INSTALL) t/lib/keycloak.lua $(INST_LUADIR)/resty/saml/
4755

48-
.PHONY: deps
49-
deps:
56+
deps/:
5057
luarocks install --lua-dir=$(LUAJIT_DIR) rockspec/lua-resty-saml-main-0-0.rockspec --tree=deps --only-deps --local

0 commit comments

Comments
 (0)