AtlatestRepositorysigil-http3
sigil-http3 / tree / scriptsphantom-browser-preflight.sh
1
#!/usr/bin/env bash2
set -euo pipefail3
cd "$(dirname "$0")/.."4
mkdir -p build/browser .deps5
result_path="$PWD/build/browser/result.txt"6
record_result() {7
local job_rc=$?8
printf 'RESULT browser-preflight rc=%s\n' "$job_rc" | tee -a "$result_path"9
}10
trap record_result EXIT11
bash scripts/prepare-nat-dependency.sh12
if [ -z "${HTTP3_CHROME:-}" ]; then13
for candidate in chromium chromium-browser google-chrome google-chrome-stable; do14
if chrome_binary=$(command -v "$candidate"); then15
export HTTP3_CHROME="$chrome_binary"16
break17
fi18
done19
fi20
test -n "${HTTP3_CHROME:-}" && test -x "$HTTP3_CHROME"21
openssl_command=(openssl)22
if ! command -v openssl >/dev/null; then23
openssl_command=(guix shell openssl -- openssl)24
fi25
printf 'Chrome binary: %s\n' "$HTTP3_CHROME" | tee build/browser/tool-versions.txt26
timeout --foreground 180 "${openssl_command[@]}" version | tee -a build/browser/tool-versions.txt27
if [ ! -e .deps/sigil-quic ]; then28
bash scripts/prepare-quic.sh29
fi30
test "$(git -C .deps/sigil-quic rev-parse HEAD)" = "$(cat quic.rev)"31
chmod 700 build/browser32
timeout --foreground 180 "${openssl_command[@]}" genpkey \33
-algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out build/browser/key.pem34
chmod 600 build/browser/key.pem35
timeout --foreground 180 "${openssl_command[@]}" req \36
-new -x509 -key build/browser/key.pem -out build/browser/cert.pem \37
-days 13 -sha256 -subj /CN=localhost \38
-addext "subjectAltName=${HTTP3_PREFLIGHT_SAN:-IP:127.0.0.1,DNS:localhost}"39
node scripts/prepare-certificate.mjs "$PWD/build/browser"40
if [ "${HTTP3_PREFLIGHT_PREBUILT:-0}" = 1 ]; then41
test -x tools/interop/build/native/bin/http3-preflight42
else43
cd tools/interop44
timeout --foreground 180 sigil deps install45
timeout --foreground 240 sigil build --config native46
cd ../..47
fi48
browser_deadline=6049
if [ "${HTTP3_PREFLIGHT_HTTPS_PAGE:-0}" = 1 ]; then browser_deadline=90; fi50
timeout --foreground "$browser_deadline" node scripts/browser-preflight.mjs