Skip to content

Commit 556016d

Browse files
committed
[temp] probe: Termux bootstrap in the emulator; no heredoc under mksh
1 parent 0fb028a commit 556016d

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

‎.github/probe/termux_emulator.sh‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,22 @@ run)
3131
for f in mcpp.tar.gz cacert.pem termux_inner.sh; do adb push "$EMU/$f" /data/local/tmp/ >/dev/null; done
3232
adb shell chmod 644 /data/local/tmp/mcpp.tar.gz /data/local/tmp/cacert.pem /data/local/tmp/termux_inner.sh
3333
A=/data/data/com.termux/files
34+
# Launch Termux once so it installs its bootstrap ($PREFIX: bash, curl,
35+
# resolv.conf, termux-exec), which is what a real Termux session has.
36+
adb shell am start -n com.termux/com.termux.app.TermuxActivity 2>&1 | tail -1
37+
for i in $(seq 1 60); do
38+
adb shell run-as com.termux ls $A/usr/bin/bash >/dev/null 2>&1 && break
39+
sleep 5
40+
done
41+
say "- Termux bootstrap: $(adb shell run-as com.termux ls -l $A/usr/bin/bash 2>&1 | tr -d '\r')"
3442
adb shell run-as com.termux sh -c "'mkdir -p $A/home $A/probe && cp /data/local/tmp/mcpp.tar.gz /data/local/tmp/cacert.pem /data/local/tmp/termux_inner.sh $A/probe/'" 2>&1
3543
adb shell run-as com.termux sh -c "'id; cat /proc/self/attr/current; echo; ls -la $A'" 2>&1 | tee -a "$LOGS/sandbox.txt"
36-
# The bash in termux_inner.sh is not there without Termux's bootstrap; run it
37-
# with the system sh, which handles everything the script uses.
44+
# A Termux session's environment, as the app sets it up for its shell.
45+
TENV="PREFIX=$A/usr HOME=$A/home TMPDIR=$A/usr/tmp PATH=$A/usr/bin LANG=en_US.UTF-8 LD_PRELOAD=$A/usr/lib/libtermux-exec.so"
3846
start=$(date +%s)
39-
timeout 5400 adb shell run-as com.termux sh -c \
40-
"'PROBE_OUT=$A/probe/out PROBE_TARBALL=$A/probe/mcpp.tar.gz PROBE_HOME=$A/home SSL_CERT_FILE=$A/probe/cacert.pem sh $A/probe/termux_inner.sh'" \
41-
2>&1 | tee "$LOGS/inner.log"
47+
timeout 5400 adb shell run-as com.termux $A/usr/bin/env $TENV \
48+
PROBE_OUT=$A/probe/out PROBE_TARBALL=$A/probe/mcpp.tar.gz PROBE_HOME=$A/home \
49+
$A/usr/bin/sh $A/probe/termux_inner.sh 2>&1 | tee "$LOGS/inner.log"
4250
say "- wall: $(( $(date +%s) - start )) s"
4351
for f in first-build.log; do
4452
adb shell run-as com.termux cat "$A/probe/out/$f" > "$LOGS/$f" 2>/dev/null
@@ -47,11 +55,11 @@ run)
4755
say '### sandbox'
4856
say '```'
4957
cat "$LOGS/sandbox.txt" >> "$S"
50-
grep -E '^(ENV|UNAME|ID|HARDLINK|MCPP|TIMING)' "$LOGS/inner.log" >> "$S"
58+
grep -E '^(ENV|UNAME|ID|HARDLINK|MCPP|TIMING|XLINGS|STAGE)' "$LOGS/inner.log" >> "$S"
5159
say '```'
5260
say '### first run: key lines'
5361
say '```'
54-
grep -E 'First run|Resolving|Installing|Downloading|error|warning|hint|Finished|glibc|Can.t create' \
62+
grep -E 'First run|Resolving|Resolved|Installing|Downloading|error|warning|hint|Finished|glibc|llvm|musl|Can.t create|did not complete' \
5563
"$LOGS/inner.log" | head -60 >> "$S"
5664
say '```'
5765
say '### plan stage timings'

‎.github/probe/termux_inner.sh‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,7 @@ echo "XLINGS exit: $?"
3737

3838
mkdir -p "$HOME/hello/src"
3939
cd "$HOME/hello"
40-
cat > mcpp.toml <<'EOF'
41-
[package]
42-
name = "hello"
43-
version = "0.1.0"
44-
45-
[targets.hello]
46-
kind = "bin"
47-
main = "src/main.cpp"
48-
EOF
40+
printf '[package]\nname = "hello"\nversion = "0.1.0"\n\n[targets.hello]\nkind = "bin"\nmain = "src/main.cpp"\n' > mcpp.toml
4941
printf 'import std;\nint main() { std::println("hello from termux"); }\n' > src/main.cpp
5042

5143
t0=$(date +%s)

0 commit comments

Comments
 (0)