Skip to content

Commit d70e1a5

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

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
@@ -153,6 +154,14 @@ def lib_ext_kwargs(pc, prefix_env_var, lib_name, lib_pkg_name, pc_version, lib_s
153154
include_dirs=[os.path.join(openssl_prefix, "include", openssl_name)],
154155
extra_objects=[os.path.join(openssl_prefix, "lib", openssl_name, "libcrypto.a")],
155156
)
157+
elif is_netbsd and os.environ.get("BORG_OPENSSL_PREFIX"):
158+
# Similarly for NetBSD, if we built a custom OpenSSL, link it statically
159+
# to avoid dynamic linker conflicts with the system OpenSSL loaded by Python.
160+
openssl_prefix = os.environ.get("BORG_OPENSSL_PREFIX")
161+
crypto_ext_lib = dict(
162+
include_dirs=[os.path.join(openssl_prefix, "include")],
163+
extra_objects=[os.path.join(openssl_prefix, "lib", "libcrypto.a")],
164+
)
156165
else:
157166
crypto_ext_lib = lib_ext_kwargs(pc, "BORG_OPENSSL_PREFIX", "crypto", "libcrypto", ">=3.2.0")
158167

0 commit comments

Comments
 (0)