AtlatestRepositorysigil-http3

sigil-http3 / tree / scriptsphantom-browser-preflight.sh

1#!/usr/bin/env bash
2set -euo pipefail
3cd "$(dirname "$0")/.."
4mkdir -p build/browser .deps
5result_path="$PWD/build/browser/result.txt"
6record_result() {
7 local job_rc=$?
8 printf 'RESULT browser-preflight rc=%s\n' "$job_rc" | tee -a "$result_path"
9}
10trap record_result EXIT
11bash scripts/prepare-nat-dependency.sh
12if [ -z "${HTTP3_CHROME:-}" ]; then
13 for candidate in chromium chromium-browser google-chrome google-chrome-stable; do
14 if chrome_binary=$(command -v "$candidate"); then
15 export HTTP3_CHROME="$chrome_binary"
16 break
17 fi
18 done
19fi
20test -n "${HTTP3_CHROME:-}" && test -x "$HTTP3_CHROME"
21openssl_command=(openssl)
22if ! command -v openssl >/dev/null; then
23 openssl_command=(guix shell openssl -- openssl)
24fi
25printf 'Chrome binary: %s\n' "$HTTP3_CHROME" | tee build/browser/tool-versions.txt
26timeout --foreground 180 "${openssl_command[@]}" version | tee -a build/browser/tool-versions.txt
27if [ ! -e .deps/sigil-quic ]; then
28 bash scripts/prepare-quic.sh
29fi
30test "$(git -C .deps/sigil-quic rev-parse HEAD)" = "$(cat quic.rev)"
31chmod 700 build/browser
32timeout --foreground 180 "${openssl_command[@]}" genpkey \
33 -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out build/browser/key.pem
34chmod 600 build/browser/key.pem
35timeout --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}"
39node scripts/prepare-certificate.mjs "$PWD/build/browser"
40if [ "${HTTP3_PREFLIGHT_PREBUILT:-0}" = 1 ]; then
41 test -x tools/interop/build/native/bin/http3-preflight
42else
43 cd tools/interop
44 timeout --foreground 180 sigil deps install
45 timeout --foreground 240 sigil build --config native
46 cd ../..
47fi
48browser_deadline=60
49if [ "${HTTP3_PREFLIGHT_HTTPS_PAGE:-0}" = 1 ]; then browser_deadline=90; fi
50timeout --foreground "$browser_deadline" node scripts/browser-preflight.mjs