Skip to content

Commit 0fc9ced

Browse files
committed
FHS nuance fixed when providing /usr as GNUTLS_INSTALL (proper dir splitting when installing via debian builder)
1 parent 6da7054 commit 0fc9ced

5 files changed

Lines changed: 63 additions & 19 deletions

File tree

.github/workflows/deb.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
- name: Wrapper-load smoke test
5656
run: |
5757
set -e
58-
OUT=$(WGW_LOGGING=1 /opt/gnutls/bin/gnutls-cli --version 2>&1 || true)
58+
OUT=$(WGW_LOGGING=1 gnutls-cli --version 2>&1 || true)
5959
echo "$OUT"
6060
echo "$OUT" | grep -q "ENTER: _gnutls_wolfssl_init" \
6161
|| { echo "::error ::wrapper not initialised – FAIL"; exit 1; }

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,11 @@ fips-*
99
/wolfssl-gnutls-wrapper/.cache/
1010
/wolfssl-gnutls-wrapper/compile_commands.json
1111
/wolfssl-gnutls-wrapper/tidy-fixes.yaml
12+
debian/.debhelper/
13+
debian/debhelper-build-stamp
14+
debian/files
15+
debian/gnutls-build/
16+
debian/gnutls-wolfssl.install
17+
debian/gnutls-wolfssl.substvars
18+
debian/gnutls-wolfssl/
19+
debian/tmp/

debian/control

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,16 @@ Rules-Requires-Root: no
3131
Package: gnutls-wolfssl
3232
Architecture: any
3333
Depends: ${shlibs:Depends}, ${misc:Depends}
34+
Provides: libgnutls30 (= 3.8.9)
35+
Conflicts: libgnutls30
36+
Replaces: libgnutls30
3437
Section: libs
35-
Description: GnuTLS linked against wolfSSL (/opt prefix)
38+
Description: GnuTLS linked against wolfSSL
3639
GnuTLS 3.x rebuilt to use wolfSSL as its cryptographic backend.
37-
Installs under /opt/gnutls (To prevent conflicts).
40+
Installs to standard system locations (/usr/lib, /usr/bin, etc.).
41+
.
42+
This package provides a drop-in replacement for libgnutls30, satisfying
43+
all dependencies while using wolfSSL as the cryptographic backend.
3844

3945
Package: wolfssl-gnutls-wrapper
4046
Architecture: any

debian/rules

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/usr/bin/make -f
22

3-
GNUTLS_INSTALL ?= /opt/gnutls
3+
GNUTLS_BUILD_DIR := $(CURDIR)/debian/gnutls-build
4+
GNUTLS_INSTALL ?= $(GNUTLS_BUILD_DIR)
45
PROVIDER_PATH ?= /opt/wolfssl-gnutls-wrapper
56

67
export GNUTLS_INSTALL
78
export PROVIDER_PATH
89

9-
GNUTLS_INSTALL_REL := $(patsubst /%,%,$(GNUTLS_INSTALL))
1010
PROVIDER_PATH_REL := $(patsubst /%,%,$(PROVIDER_PATH))
1111

1212
FIPS_ARG :=
@@ -27,21 +27,36 @@ endif
2727
dh $@ --buildsystem=makefile
2828

2929
override_dh_auto_configure:
30-
echo "$(GNUTLS_INSTALL_REL)/*" > debian/gnutls-wolfssl.install
30+
echo "usr/lib/*" > debian/gnutls-wolfssl.install
31+
echo "usr/bin/*" >> debian/gnutls-wolfssl.install
32+
echo "usr/include/*" >> debian/gnutls-wolfssl.install
33+
echo "usr/share/*" >> debian/gnutls-wolfssl.install
3134
echo "$(PROVIDER_PATH_REL)/*" > debian/wolfssl-gnutls-wrapper.install
3235

3336
override_dh_auto_build:
3437
:
3538

3639
override_dh_auto_install:
37-
-sudo rm -rf $(GNUTLS_INSTALL) $(PROVIDER_PATH)
38-
40+
mkdir -p $(GNUTLS_BUILD_DIR)
41+
3942
./setup.sh $(FIPS_ARG)
40-
41-
mkdir -p $(CURDIR)/debian/tmp$(dir $(GNUTLS_INSTALL))
43+
44+
mkdir -p $(CURDIR)/debian/tmp/usr
45+
46+
if [ -d $(GNUTLS_BUILD_DIR)/lib ]; then \
47+
cp -a $(GNUTLS_BUILD_DIR)/lib $(CURDIR)/debian/tmp/usr/; \
48+
fi
49+
if [ -d $(GNUTLS_BUILD_DIR)/bin ]; then \
50+
cp -a $(GNUTLS_BUILD_DIR)/bin $(CURDIR)/debian/tmp/usr/; \
51+
fi
52+
if [ -d $(GNUTLS_BUILD_DIR)/include ]; then \
53+
cp -a $(GNUTLS_BUILD_DIR)/include $(CURDIR)/debian/tmp/usr/; \
54+
fi
55+
if [ -d $(GNUTLS_BUILD_DIR)/share ]; then \
56+
cp -a $(GNUTLS_BUILD_DIR)/share $(CURDIR)/debian/tmp/usr/; \
57+
fi
58+
4259
mkdir -p $(CURDIR)/debian/tmp$(dir $(PROVIDER_PATH))
43-
44-
cp -a $(GNUTLS_INSTALL) $(CURDIR)/debian/tmp$(GNUTLS_INSTALL)
4560
cp -a $(PROVIDER_PATH) $(CURDIR)/debian/tmp$(PROVIDER_PATH)
4661

4762
override_dh_clean:

wolfssl-gnutls-wrapper/tests/Makefile

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
TESTS = test_hash test_long_hash test_shake test_aescbc test_aescfb8 test_aesgcm test_aesccm test_aesxts test_hmac test_cmac test_gmac test_rnd test_rnd_fork test_tls_prf test_hkdf test_pbkdf2 test_ecdsa_sign_and_verify test_ecdh_encrypt_and_decrypt test_eddsa_sign_and_verify test_rsa_sign_and_verify test_rsa_encrypt_and_decrypt test_dh_encrypt_and_decrypt test_pk_import_export test_long_hash test_fips test_aessiv
1+
TESTS = test_hash test_shake test_aescbc test_aescfb8 test_aesgcm test_aesccm test_aesxts test_hmac test_cmac test_gmac test_rnd test_rnd_fork test_tls_prf test_hkdf test_pbkdf2 test_ecdsa_sign_and_verify test_ecdh_encrypt_and_decrypt test_eddsa_sign_and_verify test_rsa_sign_and_verify test_rsa_encrypt_and_decrypt test_dh_encrypt_and_decrypt test_pk_import_export test_long_hash test_fips test_aessiv
22

33
PKGCONF ?= pkg-config
44
UNAME_S := $(shell uname -s)
@@ -7,12 +7,27 @@ UNAME_S := $(shell uname -s)
77
GNUTLS_PREFIX := $(if $(GNUTLS_INSTALL),$(GNUTLS_INSTALL),/opt/gnutls)
88
PROVIDER_PATH := $(if $(PROVIDER_PATH),$(PROVIDER_PATH),/opt/wolfssl-gnutls-wrapper)
99

10-
# Use a *scoped* pkg-config for GnuTLS only (no global fallback).
11-
# PKG_CONFIG_LIBDIR overrides default search dirs so we don't touch system /usr.
12-
GNUTLS_PKGCONF := PKG_CONFIG_LIBDIR=$(GNUTLS_PREFIX)/lib/pkgconfig $(PKGCONF)
13-
14-
# Detect pkg-config availability of gnutls (ONLY under GNUTLS_PREFIX)
15-
HAVE_PC_GNUTLS := $(shell $(GNUTLS_PKGCONF) --exists gnutls && echo yes || echo no)
10+
# Auto-detect GnuTLS location:
11+
# 1. If GNUTLS_INSTALL is set, use scoped pkg-config lookup
12+
# 2. If not set, first try system pkg-config (for Debian packages installed to /usr)
13+
# 3. Otherwise fall back to /opt/gnutls
14+
ifdef GNUTLS_INSTALL
15+
# Use scoped pkg-config for the specified prefix
16+
GNUTLS_PKGCONF := PKG_CONFIG_LIBDIR=$(GNUTLS_PREFIX)/lib/pkgconfig $(PKGCONF)
17+
HAVE_PC_GNUTLS := $(shell $(GNUTLS_PKGCONF) --exists gnutls && echo yes || echo no)
18+
else
19+
# Try system pkg-config first (no PKG_CONFIG_LIBDIR restriction)
20+
HAVE_PC_GNUTLS := $(shell $(PKGCONF) --exists gnutls && echo yes || echo no)
21+
ifeq ($(HAVE_PC_GNUTLS),yes)
22+
# Found via system pkg-config, update GNUTLS_PREFIX to match
23+
GNUTLS_PREFIX := $(shell $(PKGCONF) --variable=prefix gnutls)
24+
GNUTLS_PKGCONF := $(PKGCONF)
25+
else
26+
# Fall back to /opt/gnutls
27+
GNUTLS_PKGCONF := PKG_CONFIG_LIBDIR=$(GNUTLS_PREFIX)/lib/pkgconfig $(PKGCONF)
28+
HAVE_PC_GNUTLS := $(shell $(GNUTLS_PKGCONF) --exists gnutls && echo yes || echo no)
29+
endif
30+
endif
1631

1732
ifeq ($(HAVE_PC_GNUTLS),yes)
1833
GNUTLS_CFLAGS := $(shell $(GNUTLS_PKGCONF) --cflags gnutls)

0 commit comments

Comments
 (0)