; Keep the libssl.so.3 and libcrypto.so.3 ABI used by the Alpine 3.21 userland. ; Use upstream's supported 3.5 LTS branch and Alpine's corresponding fixes. selected := get-environment-variable("VPAC_TARGET_ARCH") arch := if string?(selected) { selected } else if memq(string->symbol("aarch64"), features()) { "aarch64" } else { "x86_64" } arm := string=?(arch, "aarch64") musl := if arm { "musl>=1.2.6-4" } else { "musl" } cross := get-environment-variable("CROSS_COMPILE") prefix := if string?(cross) { cross } else { "" } defpkgbuild(openssl, #:pkgname, "openssl", #:pkgver, "3.5.9", #:pkgrel, if arm { 5 } else { 4 }, #:pkgdesc, "OpenSSL TLS toolkit, libraries and development headers for Vinix", #:arch, [#:x86-64, #:aarch64], #:url, "https://openssl-library.org/", #:license, "Apache-2.0", #:depends, [musl], #:makedepends, ["linux-headers"], #:source, [ "https://github.com/openssl/openssl/releases/download/openssl-3.5.9/openssl-3.5.9.tar.gz", "https://raw.githubusercontent.com/alpinelinux/aports/f2f8ff7cc28e26fb08d050e3cc19eb44a6f749e9/main/openssl/CVE-2026-88822.patch", "https://raw.githubusercontent.com/alpinelinux/aports/f2f8ff7cc28e26fb08d050e3cc19eb44a6f749e9/main/openssl/CVE-2026-88823.patch", "https://raw.githubusercontent.com/alpinelinux/aports/f2f8ff7cc28e26fb08d050e3cc19eb44a6f749e9/main/openssl/CVE-2026-95691.patch", "https://raw.githubusercontent.com/alpinelinux/aports/f2f8ff7cc28e26fb08d050e3cc19eb44a6f749e9/main/openssl/CVE-2026-95692.patch", "https://raw.githubusercontent.com/alpinelinux/aports/f2f8ff7cc28e26fb08d050e3cc19eb44a6f749e9/main/openssl/CVE-2026-107496.patch", "ec-methods.c"], #:sha256sums, ["603f5602e2eef00d77fbd429d34dcd5822bb301757a1bc9cdb24c670f1eb859a", "50f7cc52fb146703379ca043d17e204c4fda99c684efe3db6d6f3ae1d175bd2a", "a945077c0a978dbfe5af5e4f7174a2151466547f8fb94562f395baa7b6b7c147", "93d8e82fdc995172a6d5cc6952491658106191bd5ac221d34596adbddfcd1afe", "0e328604c0038de6629a29322ae5f02d2f5f5128c2625b57ca64262efab99e05", "77d3759d279c71af59629c4a0fa82d8272a099762f2fa9e3f66d7ca5ed544157", "84d12e762fc20464364d1eba38de830c159bde249ef9cf29e10b4d1f3e8d59fd"], #:prepare, fn() { for-each(fn(patch) { run("patch", "--batch", "--fuzz=0", "-p1", "-d", "openssl-3.5.9", "-i", string-append("../", patch)) }, list("CVE-2026-88822.patch", "CVE-2026-88823.patch", "CVE-2026-95691.patch", "CVE-2026-95692.patch", "CVE-2026-107496.patch")) }, #:build, fn() { ; OpenSSL prefixes tool names itself. vinix-cc selects the real target ; compiler and sysroot, so pass the archive tools to Configure explicitly. run("env", "-u", "CROSS_COMPILE", "CC=vinix-cc", string-append("VINIX_REAL_CC=", prefix, "gcc"), string-append("AR=", prefix, "ar"), string-append("RANLIB=", prefix, "ranlib"), "perl", "openssl-3.5.9/Configure", string-append("linux-", arch), "--prefix=/usr", "--libdir=lib", "--openssldir=/etc/ssl", "shared", "enable-ec_nistp_64_gcc_128", "no-tests", "no-docs", "no-zlib", "no-async", "no-afalgeng") ; OpenSSL's configured Makefile exports its own empty CROSS_COMPILE. run("env", "-u", "CPATH", "-u", "C_INCLUDE_PATH", "-u", "LIBRARY_PATH", string-append("VINIX_REAL_CC=", prefix, "gcc"), "make", "build_sw") }, #:check, fn() { run("vinix-run", "--library-path", ".", "apps/openssl", "version") run("vinix-run", "--library-path", ".", "apps/openssl", "dgst", "-sha256", "/dev/null") run("vinix-cc", "-Iinclude", "-Iopenssl-3.5.9/include", "ec-methods.c", "-L.", "-lcrypto", "-o", "ec-methods") run("vinix-run", "--library-path", ".", "./ec-methods") }, #:package, fn() { ; The core command implements 'openssl rehash'. Optional upstream Perl ; convenience scripts require a Perl installation in the guest. run("env", string-append("VINIX_REAL_CC=", prefix, "gcc"), "make", "BIN_SCRIPTS=", "MISC_SCRIPTS=", string-append("DESTDIR=", pkgdir()), "install_sw", "install_ssldirs") run("install", "-Dm644", "openssl-3.5.9/LICENSE.txt", string-append(pkgdir(), "/usr/share/licenses/openssl/LICENSE.txt")) })