openssl: build the TLS toolkit against packaged musl and Linux headers
@@ -0,0 +1,50 @@
1+; Keep the libssl.so.3 and libcrypto.so.3 ABI used by the Alpine 3.21 userland.
2+; Use upstream's supported 3.5 LTS branch and Alpine's corresponding fixes.
3+defpkgbuild(openssl,
4+ #:pkgname, "openssl",
5+ #:pkgver, "3.5.9",
6+ #:pkgrel, 1,
7+ #:pkgdesc, "OpenSSL TLS toolkit, libraries and development headers for Vinix",
8+ #:arch, [#:x86-64],
9+ #:url, "https://openssl-library.org/",
10+ #:license, "Apache-2.0",
11+ #:depends, ["musl"],
12+ #:makedepends, ["linux-headers"],
13+ #:source, [
14+ "https://github.com/openssl/openssl/releases/download/openssl-3.5.9/openssl-3.5.9.tar.gz",
15+ "https://raw.githubusercontent.com/alpinelinux/aports/f2f8ff7cc28e26fb08d050e3cc19eb44a6f749e9/main/openssl/CVE-2026-88822.patch",
16+ "https://raw.githubusercontent.com/alpinelinux/aports/f2f8ff7cc28e26fb08d050e3cc19eb44a6f749e9/main/openssl/CVE-2026-88823.patch",
17+ "https://raw.githubusercontent.com/alpinelinux/aports/f2f8ff7cc28e26fb08d050e3cc19eb44a6f749e9/main/openssl/CVE-2026-95691.patch",
18+ "https://raw.githubusercontent.com/alpinelinux/aports/f2f8ff7cc28e26fb08d050e3cc19eb44a6f749e9/main/openssl/CVE-2026-95692.patch",
19+ "https://raw.githubusercontent.com/alpinelinux/aports/f2f8ff7cc28e26fb08d050e3cc19eb44a6f749e9/main/openssl/CVE-2026-107496.patch"],
20+ #:sha256sums, ["603f5602e2eef00d77fbd429d34dcd5822bb301757a1bc9cdb24c670f1eb859a",
21+ "50f7cc52fb146703379ca043d17e204c4fda99c684efe3db6d6f3ae1d175bd2a",
22+ "a945077c0a978dbfe5af5e4f7174a2151466547f8fb94562f395baa7b6b7c147", "93d8e82fdc995172a6d5cc6952491658106191bd5ac221d34596adbddfcd1afe", "0e328604c0038de6629a29322ae5f02d2f5f5128c2625b57ca64262efab99e05",
23+ "77d3759d279c71af59629c4a0fa82d8272a099762f2fa9e3f66d7ca5ed544157"],
24+
25+ #:prepare, fn() {
26+ for-each(fn(patch) {
27+ run("patch", "--batch", "--fuzz=0", "-p1", "-d", "openssl-3.5.9", "-i", string-append("../", patch))
28+ }, list("CVE-2026-88822.patch", "CVE-2026-88823.patch", "CVE-2026-95691.patch",
29+ "CVE-2026-95692.patch", "CVE-2026-107496.patch"))
30+ run("ln", "-s", get-environment-variable("VPAC_MAKEPKG_ROOT"), "vinix-sysroot")
31+ },
32+ #:build, fn() {
33+ run("env", "CC=gcc --sysroot=vinix-sysroot -specs=vinix-sysroot/usr/lib/musl-gcc-sysroot.specs",
34+ "perl", "openssl-3.5.9/Configure", "linux-x86_64", "--prefix=/usr", "--libdir=lib",
35+ "--openssldir=/etc/ssl", "shared", "no-tests", "no-docs", "no-zlib", "no-async", "no-afalgeng")
36+ run("env", "-u", "CPATH", "-u", "C_INCLUDE_PATH", "-u", "LIBRARY_PATH", "make", "build_sw")
37+ },
38+ #:check, fn() {
39+ run("vinix-sysroot/lib/ld-musl-x86_64.so.1", "--library-path", ".:vinix-sysroot/usr/lib",
40+ "apps/openssl", "version")
41+ run("vinix-sysroot/lib/ld-musl-x86_64.so.1", "--library-path", ".:vinix-sysroot/usr/lib",
42+ "apps/openssl", "dgst", "-sha256", "/dev/null")
43+ },
44+ #:package, fn() {
45+ ; The core command implements 'openssl rehash'. Optional upstream Perl
46+ ; convenience scripts require a Perl installation in the guest.
47+ run("make", "BIN_SCRIPTS=", "MISC_SCRIPTS=", string-append("DESTDIR=", pkgdir()), "install_sw", "install_ssldirs")
48+ run("install", "-Dm644", "openssl-3.5.9/LICENSE.txt",
49+ string-append(pkgdir(), "/usr/share/licenses/openssl/LICENSE.txt"))
50+ })