Skip to content

Commit

Permalink
borg2 - Support other OpenSSL versions on OpenBSD
Browse files Browse the repository at this point in the history
`setup.py` hardcoded crypto library paths for OpenBSD, causing build
issue when OpenBSD drops specific OpenSSL version. Solution is to make
paths configurable.

Addresses #8553.
  • Loading branch information
bket committed Nov 23, 2024
1 parent d1b2884 commit 6e5a94c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 6 additions & 0 deletions docs/man/borg.1
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,12 @@ operations), see \fI\%tempfile\fP for details.
.B Building:
.INDENT 7.0
.TP
.B BORG_OPENSSL_INC
Adds given OpenSSL header file directory (setup.py, only applicable for OpenBSD).
.TP
.B BORG_OPENSSL_LIB
Adds given OpenSSL library directory (setup, only applicable for OpenBSD).
.TP
.B BORG_OPENSSL_PREFIX
Adds given OpenSSL header file directory to the default locations (setup.py).
.TP
Expand Down
4 changes: 4 additions & 0 deletions docs/usage/general/environment.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ Directories and files:
operations), see tempfile_ for details.

Building:
BORG_OPENSSL_INC
Adds given OpenSSL header file directory (setup.py, only applicable for OpenBSD).
BORG_OPENSSL_LIB
Adds given OpenSSL library directory (setup.py, only applicable for OpenBSD).
BORG_OPENSSL_PREFIX
Adds given OpenSSL header file directory to the default locations (setup.py).
BORG_LIBACL_PREFIX
Expand Down
9 changes: 4 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,23 +132,22 @@ def lib_ext_kwargs(pc, prefix_env_var, lib_name, lib_pkg_name, pc_version, lib_s
f"or ensure {lib_pkg_name}.pc is in PKG_CONFIG_PATH."
)

crypto_extra_objects = []
if is_win32:
crypto_ext_lib = lib_ext_kwargs(pc, "BORG_OPENSSL_PREFIX", "libcrypto", "libcrypto", ">=1.1.1", lib_subdir="")
elif is_openbsd:
# Use openssl (not libressl) because we need AES-OCB via EVP api. Link
# it statically to avoid conflicting with shared libcrypto from the base
# OS pulled in via dependencies.
crypto_ext_lib = {"include_dirs": ["/usr/local/include/eopenssl30"]}
crypto_extra_objects += ["/usr/local/lib/eopenssl30/libcrypto.a"]
# OS pulled in via dependencies. Make crypto paths configurable.
include_dirs = [os.environ.get("BORG_OPENSSL_INC", "/usr/local/include/eopenssl30")]
extra_objects = [os.path.join(os.environ.get("BORG_OPENSSL_LIB", "/usr/local/lib/eopenssl30"), "libcrypto.a")]
crypto_ext_lib = {"include_dirs": include_dirs, "extra_objects": extra_objects}
else:
crypto_ext_lib = lib_ext_kwargs(pc, "BORG_OPENSSL_PREFIX", "crypto", "libcrypto", ">=1.1.1")

crypto_ext_kwargs = members_appended(
dict(sources=[crypto_ll_source]),
crypto_ext_lib,
dict(extra_compile_args=cflags),
dict(extra_objects=crypto_extra_objects),
)

compress_ext_kwargs = members_appended(
Expand Down

0 comments on commit 6e5a94c

Please sign in to comment.