Skip to content

Commit 252cf06

Browse files
CI: NetBSD: build a fresh OpenSSL from source, we need >= 3.2
1 parent de2c4ea commit 252cf06

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
@@ -412,6 +412,30 @@ jobs:
412412
touch ${TMPDIR}/testfile
413413
lsextattr user ${TMPDIR}/testfile && echo "[xattr] *** xattrs SUPPORTED on ${TMPDIR}! ***"
414414
415+
# NetBSD 10 has a too old OpenSSL, build a fresher one.
416+
VERSION="3.5.6"
417+
echo "--- Building OpenSSL ${VERSION} ---"
418+
PREFIX="/usr/local"
419+
JOBS=$(sysctl -n hw.ncpu)
420+
421+
pushd /tmp
422+
ftp -o "openssl-${VERSION}.tar.gz" "https://www.openssl.org/source/openssl-${VERSION}.tar.gz"
423+
tar xzf "openssl-${VERSION}.tar.gz"
424+
pushd "openssl-${VERSION}"
425+
426+
./Configure --prefix="${PREFIX}" --openssldir="${PREFIX}/etc/ssl" --libdir=lib \
427+
-Wl,-rpath,${PREFIX}/lib shared threads no-tests no-docs
428+
export LD_LIBRARY_PATH="/usr/local/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
429+
make -j"${JOBS}"
430+
sudo -E make install
431+
popd
432+
rm -rf "/tmp/openssl-${VERSION}" "/tmp/openssl-${VERSION}.tar.gz"
433+
popd
434+
435+
"${PREFIX}/bin/openssl" version
436+
export BORG_OPENSSL_PREFIX="${PREFIX}"
437+
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
438+
415439
tox3 -e py311-none
416440
;;
417441

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)