Skip to content

Commit f221b3c

Browse files
committed
termux ci: cross-compile tlscheck, stop pkg-installing nim under qemu
1 parent b36d00c commit f221b3c

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

‎.github/workflows/termux.yml‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ jobs:
5151
--clang.exe:"$NDK_CLANG" --clang.linkerexe:"$NDK_CLANG" \
5252
-o:3code-android src/threecode.nim
5353
file 3code-android
54+
# TLS check for the smoke job, cross-compiled here: installing nim
55+
# inside the emulated container (pkg install under qemu) can
56+
# outlive any reasonable job budget, so the container only RUNS
57+
# binaries now. Same flags; config.nims adds the Termux RUNPATH.
58+
nim c -d:release --os:android --cpu:arm64 -d:ssl -d:testPlainHttp \
59+
--clang.exe:"$NDK_CLANG" --clang.linkerexe:"$NDK_CLANG" \
60+
-o:tlscheck-android tests/android_tlscheck.nim
5461
5562
- name: Verify Termux RUNPATH
5663
# Nim's openssl wrapper dlopens libssl.so.3/libcrypto.so.3 at
@@ -66,6 +73,7 @@ jobs:
6673
run: |
6774
mkdir -p 3code-termux-arm64
6875
cp 3code-android 3code-termux-arm64/3code
76+
cp tlscheck-android 3code-termux-arm64/tlscheck
6977
# Can't run the android binary on the x86 host; version comes
7078
# from the nimble file (tag releases) or the short SHA.
7179
grep -m1 '^version' threecode.nimble | cut -d'"' -f2 > 3code-termux-arm64/VERSION
@@ -102,7 +110,7 @@ jobs:
102110
# The image's Termux tree is owned by uid/gid 1000 (system); run
103111
# the container as that user so pkg and $HOME behave.
104112
CID=$(docker create -t --platform linux/arm64 --user 1000:1000 \
105-
termux/termux-docker:latest sleep 1800)
113+
termux/termux-docker:latest sleep 300)
106114
docker start $CID >/dev/null
107115
trap 'docker rm -f $CID >/dev/null 2>&1 || true' EXIT
108116
docker exec $CID mkdir -p /data/data/com.termux/files/usr/tmp
@@ -116,12 +124,11 @@ jobs:
116124
# TLS init is the fragile part on Termux: the openssl wrapper
117125
# dlopens libssl.so.3/libcrypto.so.3 at module init, and it only
118126
# works when DT_RUNPATH (asserted in the build job) points at the
119-
# Termux lib dir. A bare --version doesn't touch TLS; this tiny
120-
# program does a verified handshake the same way api.nim does.
121-
docker cp tests/android_tlscheck.nim $CID:/data/data/com.termux/files/usr/tmp/
122-
docker exec -t $CID sh -lc \
123-
'command -v nim >/dev/null || pkg install -y nim >/dev/null 2>&1; \
124-
nim c -r -d:ssl /data/data/com.termux/files/usr/tmp/android_tlscheck.nim' \
127+
# Termux lib dir. A bare --version doesn't touch TLS; the
128+
# cross-compiled tlscheck does a verified handshake the same way
129+
# api.nim does. No -t: output must pipe into grep.
130+
docker cp 3code-termux-arm64/tlscheck $CID:/data/data/com.termux/files/usr/tmp/tlscheck
131+
docker exec $CID /data/data/com.termux/files/usr/tmp/tlscheck \
125132
| grep -q 'tls handshake ok'
126133
127134
- name: Upload artifact to 3code.capocasa.dev

‎tests/android_tlscheck.nim‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## TLS smoke check for the Termux CI smoke job (termux.yml). Compiled and
2-
## run inside the emulated Termux container against the freshly built
1+
## TLS smoke check for the Termux CI smoke job (termux.yml).
2+
## Cross-compiled by the build job (same NDK flags as the main binary)
3+
## and run inside the emulated Termux container against the freshly built
34
## android binary's runtime environment: the openssl wrapper dlopens
45
## libssl.so.3/libcrypto.so.3 at module init, which only resolves when the
56
## binary's DT_RUNPATH points at the Termux lib dir (see config.nims). A

0 commit comments

Comments
 (0)