Skip to content

Commit e4d989d

Browse files
committed
Add static OpenSSL build support and update Dockerfile dependencies
1 parent d602f56 commit e4d989d

4 files changed

Lines changed: 89 additions & 1 deletion

File tree

.github/workflows/graphs/build-test-publish.act

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ nodes:
142142
macos)
143143
P4_LIB="$(pwd)/p4api/macos/lib"
144144
P4_CGO_CPPFLAGS="-I$P4_INCLUDE"
145-
P4_CGO_LDFLAGS="-L$P4_LIB -lp4api -lssl -lcrypto -framework ApplicationServices -framework Foundation -framework Security"
145+
# Build static OpenSSL for macOS (not available on the runner)
146+
SSL_LIB="$(pwd)/p4api/ssl-macos-${ARCH}/lib"
147+
bash setup-openssl.sh macos "$ARCH" "$SSL_LIB"
148+
P4_CGO_LDFLAGS="-L$P4_LIB -lp4api $SSL_LIB/libssl.a $SSL_LIB/libcrypto.a -framework ApplicationServices -framework Foundation -framework Security -framework CoreFoundation"
146149
;;
147150
windows)
148151
if [[ "$ARCH" == "arm64" ]]; then

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ require (
7272
github.com/bahlo/generic-list-go v0.2.0 // indirect
7373
github.com/bmatcuk/doublestar/v4 v4.9.1 // indirect
7474
github.com/buger/jsonparser v1.1.1 // indirect
75+
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
7576
github.com/cespare/xxhash/v2 v2.3.0 // indirect
7677
github.com/clipperhouse/stringish v0.1.1 // indirect
7778
github.com/clipperhouse/uax29/v2 v2.3.0 // indirect
@@ -88,6 +89,7 @@ require (
8889
github.com/gage-technologies/mistral-go v1.1.0 // indirect
8990
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
9091
github.com/go-git/go-billy/v5 v5.8.0 // indirect
92+
github.com/go-jose/go-jose/v4 v4.1.3 // indirect
9193
github.com/go-logr/logr v1.4.3 // indirect
9294
github.com/go-logr/stdr v1.2.2 // indirect
9395
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
@@ -115,6 +117,8 @@ require (
115117
github.com/mattn/go-isatty v0.0.20 // indirect
116118
github.com/mattn/go-runewidth v0.0.19 // indirect
117119
github.com/mattn/go-shellwords v1.0.12 // indirect
120+
github.com/mitchellh/go-homedir v1.1.0 // indirect
121+
github.com/mitchellh/mapstructure v1.5.0 // indirect
118122
github.com/moby/docker-image-spec v1.3.1 // indirect
119123
github.com/moby/sys/atomicwriter v0.1.0 // indirect
120124
github.com/montanaflynn/stats v0.7.1 // indirect
@@ -124,6 +128,7 @@ require (
124128
github.com/pkoukk/tiktoken-go v0.1.8 // indirect
125129
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
126130
github.com/robfig/cron/v3 v3.0.1 // indirect
131+
github.com/ryanuber/go-glob v1.0.0 // indirect
127132
github.com/sergi/go-diff v1.4.0 // indirect
128133
github.com/skeema/knownhosts v1.3.2 // indirect
129134
github.com/spf13/cast v1.7.1 // indirect

go.sum

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ github.com/bmatcuk/doublestar/v4 v4.9.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTS
8080
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
8181
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
8282
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
83+
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
84+
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
8385
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
8486
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
8587
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
@@ -142,6 +144,8 @@ github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMj
142144
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
143145
github.com/go-git/go-git/v5 v5.17.1 h1:WnljyxIzSj9BRRUlnmAU35ohDsjRK0EKmL0evDqi5Jk=
144146
github.com/go-git/go-git/v5 v5.17.1/go.mod h1:pW/VmeqkanRFqR6AljLcs7EA7FbZaN5MQqO7oZADXpo=
147+
github.com/go-jose/go-jose/v4 v4.1.3 h1:CVLmWDhDVRa6Mi/IgCgaopNosCaHz7zrMeF9MlZRkrs=
148+
github.com/go-jose/go-jose/v4 v4.1.3/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08=
145149
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
146150
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
147151
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
@@ -231,6 +235,10 @@ github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byF
231235
github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
232236
github.com/mattn/go-shellwords v1.0.12 h1:M2zGm7EW6UQJvDeQxo4T51eKPurbeFbe8WtebGE2xrk=
233237
github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
238+
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
239+
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
240+
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
241+
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
234242
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
235243
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
236244
github.com/moby/sys/atomicwriter v0.1.0 h1:kw5D/EqkBwsBFi0ss9v1VG3wIkVhzGvLklJ+w3A14Sw=
@@ -249,6 +257,8 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8
249257
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
250258
github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040=
251259
github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M=
260+
github.com/perforce/p4go v1.20252.2872356 h1:1nqGOnASTJsQu+94BmxHKTQax67cmOf+M2lraI5HG2s=
261+
github.com/perforce/p4go v1.20252.2872356/go.mod h1:CMKXvGa7/KJMxWVQZgwy4AtjR8ZYoNsQloQO4yHiQco=
252262
github.com/pjbgf/sha1cd v0.5.0 h1:a+UkboSi1znleCDUNT3M5YxjOnN1fz2FhN48FlwCxs0=
253263
github.com/pjbgf/sha1cd v0.5.0/go.mod h1:lhpGlyHLpQZoxMv8HcgXvZEhcGs0PG/vsZnEJ7H0iCM=
254264
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
@@ -269,6 +279,8 @@ github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7
269279
github.com/rossmacarthur/cases v0.3.0 h1:7rlsXK2qHb6mQUOX+/IGDO9YyFXqjiDiMpkHfIl54Yg=
270280
github.com/rossmacarthur/cases v0.3.0/go.mod h1:ebnckUNBu5QAJGxFNai/H0IN133rLze6gmoxJyYvHW0=
271281
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
282+
github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk=
283+
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
272284
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 h1:KRzFb2m7YtdldCEkzs6KqmJw4nqEVZGK7IN2kJkjTuQ=
273285
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU=
274286
github.com/sergi/go-diff v1.4.0 h1:n/SP9D5ad1fORl+llWyN+D6qoUETXNZARKjyY2/KVCw=

setup-openssl.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Builds static OpenSSL libraries for the given platform and architecture.
5+
# Usage:
6+
# ./setup-openssl.sh <os> <arch> <output-lib-dir>
7+
#
8+
# Examples:
9+
# ./setup-openssl.sh macos arm64 ./ssl-libs
10+
# ./setup-openssl.sh macos x64 ./ssl-libs
11+
12+
OPENSSL_VERSION="3.5.0"
13+
14+
OS="${1:?Usage: $0 <os> <arch> <output-lib-dir>}"
15+
ARCH="${2:?Usage: $0 <os> <arch> <output-lib-dir>}"
16+
OUTPUT_LIB_DIR="${3:?Usage: $0 <os> <arch> <output-lib-dir>}"
17+
18+
if [[ -f "$OUTPUT_LIB_DIR/libssl.a" ]]; then
19+
echo "Static OpenSSL already present at $OUTPUT_LIB_DIR"
20+
exit 0
21+
fi
22+
23+
# Determine OpenSSL configure target
24+
case "$OS" in
25+
macos)
26+
if [[ "$ARCH" == "arm64" ]]; then
27+
OPENSSL_TARGET="darwin64-arm64-cc"
28+
else
29+
OPENSSL_TARGET="darwin64-x86_64-cc"
30+
fi
31+
;;
32+
linux)
33+
if [[ "$ARCH" == "arm64" ]]; then
34+
OPENSSL_TARGET="linux-aarch64"
35+
else
36+
OPENSSL_TARGET="linux-x86_64"
37+
fi
38+
;;
39+
windows)
40+
OPENSSL_TARGET="mingw64"
41+
;;
42+
*)
43+
echo "Unsupported OS: $OS"
44+
exit 1
45+
;;
46+
esac
47+
48+
echo "Building static OpenSSL $OPENSSL_VERSION ($OPENSSL_TARGET) for $OS/$ARCH..."
49+
50+
TMPDIR_SSL="$(mktemp -d)"
51+
trap 'rm -rf "$TMPDIR_SSL"' EXIT
52+
53+
curl -sL "https://github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VERSION}/openssl-${OPENSSL_VERSION}.tar.gz" \
54+
-o "$TMPDIR_SSL/openssl.tar.gz"
55+
tar xzf "$TMPDIR_SSL/openssl.tar.gz" -C "$TMPDIR_SSL"
56+
57+
OPENSSL_SRC="$TMPDIR_SSL/openssl-${OPENSSL_VERSION}"
58+
59+
BUILD_LOG="$TMPDIR_SSL/build.log"
60+
(
61+
cd "$OPENSSL_SRC"
62+
./Configure "$OPENSSL_TARGET" no-shared no-tests no-apps no-docs --libdir=lib >> "$BUILD_LOG" 2>&1
63+
make -j"$(nproc 2>/dev/null || sysctl -n hw.ncpu)" build_libs >> "$BUILD_LOG" 2>&1
64+
) || { echo "OpenSSL build failed. Last 30 lines of build log:"; tail -30 "$BUILD_LOG"; exit 1; }
65+
66+
mkdir -p "$OUTPUT_LIB_DIR"
67+
cp "$OPENSSL_SRC/libssl.a" "$OPENSSL_SRC/libcrypto.a" "$OUTPUT_LIB_DIR/"
68+
echo "Installed static OpenSSL $OPENSSL_VERSION to $OUTPUT_LIB_DIR"

0 commit comments

Comments
 (0)