Skip to content

Commit 8232e39

Browse files
CI: NetBSD: build a fresh OpenSSL from source, we need >= 3.2
1 parent 4aa9b38 commit 8232e39

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,30 @@ jobs:
409409
touch ${TMPDIR}/testfile
410410
lsextattr user ${TMPDIR}/testfile && echo "[xattr] *** xattrs SUPPORTED on ${TMPDIR}! ***"
411411
412+
# NetBSD 10 has a too old OpenSSL, build a fresher one.
413+
VERSION="3.5.6"
414+
echo "--- Building OpenSSL ${VERSION} ---"
415+
PREFIX="/usr/local"
416+
JOBS=$(sysctl -n hw.ncpu)
417+
418+
pushd /tmp
419+
ftp -o "openssl-${VERSION}.tar.gz" "https://www.openssl.org/source/openssl-${VERSION}.tar.gz"
420+
tar xzf "openssl-${VERSION}.tar.gz"
421+
pushd "openssl-${VERSION}"
422+
423+
./Configure --prefix="${PREFIX}" --openssldir="${PREFIX}/etc/ssl" --libdir=lib \
424+
-Wl,-rpath,${PREFIX}/lib shared threads no-tests no-docs
425+
export LD_LIBRARY_PATH="/usr/local/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
426+
make -j"${JOBS}"
427+
sudo -E make install
428+
popd
429+
rm -rf "/tmp/openssl-${VERSION}" "/tmp/openssl-${VERSION}.tar.gz"
430+
popd
431+
432+
"${PREFIX}/bin/openssl" version
433+
export BORG_OPENSSL_PREFIX="${PREFIX}"
434+
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
435+
412436
tox3 -e py311-none
413437
;;
414438

setup.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
is_win32 = sys.platform.startswith("win32")
3131
is_openbsd = sys.platform.startswith("openbsd")
32+
is_netbsd = sys.platform.startswith("netbsd")
3233

3334
# Number of threads to use for cythonize, not used on Windows
3435
cpu_threads = multiprocessing.cpu_count() if multiprocessing and multiprocessing.get_start_method() != "spawn" else None
@@ -150,6 +151,14 @@ def lib_ext_kwargs(pc, prefix_env_var, lib_name, lib_pkg_name, pc_version, lib_s
150151
include_dirs=[os.path.join(openssl_prefix, "include", openssl_name)],
151152
extra_objects=[os.path.join(openssl_prefix, "lib", openssl_name, "libcrypto.a")],
152153
)
154+
elif is_netbsd and os.environ.get("BORG_OPENSSL_PREFIX"):
155+
# Similarly for NetBSD, if we built a custom OpenSSL, link it statically
156+
# to avoid dynamic linker conflicts with the system OpenSSL loaded by Python.
157+
openssl_prefix = os.environ.get("BORG_OPENSSL_PREFIX")
158+
crypto_ext_lib = dict(
159+
include_dirs=[os.path.join(openssl_prefix, "include")],
160+
extra_objects=[os.path.join(openssl_prefix, "lib", "libcrypto.a")],
161+
)
153162
else:
154163
crypto_ext_lib = lib_ext_kwargs(pc, "BORG_OPENSSL_PREFIX", "crypto", "libcrypto", ">=3.2.0")
155164

0 commit comments

Comments
 (0)