diff --git a/crates/libbui/src/startup.rs b/crates/libbui/src/startup.rs index c156f85..b8a8413 100644 --- a/crates/libbui/src/startup.rs +++ b/crates/libbui/src/startup.rs @@ -221,7 +221,7 @@ async fn launch_sample(config: Config, keymap: Keymap, paths: Paths, no_color: b debug_assert_eq!(settings.library_dir, library_dir); settings.write_sidecars = false; settings.ebook_processor = Some(Arc::new(crate::sample::SampleProcessor)); - let content = content_client().wrap_err("could not set up the download client")?; + let content = sample_content_client().wrap_err("could not set up the download client")?; let (engine, engine_events) = Engine::start( &paths, settings, @@ -404,6 +404,22 @@ pub fn content_client() -> reqwest::Result { .build() } +/// The HTTP client the sample library hands the download queue. The sample +/// never fetches anything, so this client trusts no certificate authority +/// at all: it starts on a machine with no certificate store (the in-browser +/// one has none), and could not reach an HTTPS server if something tried. +/// +/// # Errors +/// The HTTP client could not be built. +fn sample_content_client() -> reqwest::Result { + reqwest::Client::builder() + .user_agent(concat!("libbui/", env!("CARGO_PKG_VERSION"))) + .redirect(libbui_core::download::secure::redirect_policy()) + .tls_certs_only([]) + .no_proxy() + .build() +} + /// Saves the identity whenever it changes (pairing, token refresh) and /// forgets it when the device is unlinked. /// @@ -471,6 +487,11 @@ mod content_client_tests { assert!(error.is_redirect(), "{error:?}"); assert_eq!(server.received_requests().await.unwrap().len(), 1); } + + #[test] + fn the_sample_client_builds_without_reading_the_certificate_store() { + super::sample_content_client().unwrap(); + } } fn save_identity(store: &dyn SecretStore, identity: Option) -> Result<(), IdentityError> { -- knotmirror 0.0.1 From 837e4dfc960f1c20cf764150301dab283c2ca89a Mon Sep 17 00:00:00 2001 From: Vincent Taverna Date: Fri, 20 Nov 2026 15:47:39 -0500 Subject: [PATCH 2/2] feat(web): run on unkernel 0.2 with the arm64 binary unkernel 0.2 runs aarch64 user space natively where 0.1 ran riscv64, so the page now mounts the static aarch64 libbui. The kernel file is unkernel.wasm, and the deploy scripts build and smoke-test the aarch64 target. The riscv64 release binary and its CI job are unchanged. --- docs/install.md | 2 +- scripts/static-linux.sh | 2 +- web/.gitignore | 2 +- web/README.md | 4 ++-- web/deploy/deploy.sh | 4 ++-- web/deploy/update.sh | 6 +++--- web/package-lock.json | 8 ++++---- web/package.json | 4 ++-- web/scripts/binary.mjs | 6 +++--- web/src/main.ts | 4 ++-- web/vite.config.ts | 2 +- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/docs/install.md b/docs/install.md index 73cebc6..81abfbf 100644 --- a/docs/install.md +++ b/docs/install.md @@ -40,7 +40,7 @@ Tagged releases publish it alongside the other platforms. ## Try it in a browser -[libbui.vinnymac.dev](https://libbui.vinnymac.dev) runs that RISC-V binary on +[libbui.vinnymac.dev](https://libbui.vinnymac.dev) runs the static ARM64 Linux binary on Linux inside your browser, through [unkernel](https://github.com/pithings/unkernel), against a built-in sample library. Nothing leaves the tab. The page lives in [`web/`](../web/README.md). diff --git a/scripts/static-linux.sh b/scripts/static-linux.sh index bcaf3a9..49c50c3 100755 --- a/scripts/static-linux.sh +++ b/scripts/static-linux.sh @@ -33,7 +33,7 @@ cargo zigbuild --locked --release -p libbui --target "$target" binary="${CARGO_TARGET_DIR:-target}/$target/release/libbui" # A static binary has no interpreter: it must run on any Linux of its -# architecture, Alpine and the browser's riscv64 machine included. +# architecture, Alpine and the browser's aarch64 machine included. if readelf -l "$binary" | grep -q 'Requesting program interpreter'; then echo "error: $binary is dynamically linked" >&2 exit 1 diff --git a/web/.gitignore b/web/.gitignore index c293ab7..ef411a3 100644 --- a/web/.gitignore +++ b/web/.gitignore @@ -1,3 +1,3 @@ node_modules/ dist/ -src/libbui-riscv64.bin +src/libbui-aarch64.bin diff --git a/web/README.md b/web/README.md index bfbe785..bbaaa4d 100644 --- a/web/README.md +++ b/web/README.md @@ -1,7 +1,7 @@ # libbui.vinnymac.dev -The landing page. It boots RISC-V Linux in the browser with -[unkernel](https://github.com/pithings/unkernel), mounts the static riscv64 +The landing page. It boots Linux in the browser with +[unkernel](https://github.com/pithings/unkernel), mounts the static aarch64 libbui from this tab's memory, and runs `libbui --sample-library`: the real interface on a built-in library, with no network and nothing saved. diff --git a/web/deploy/deploy.sh b/web/deploy/deploy.sh index 4d4945b..68d6257 100755 --- a/web/deploy/deploy.sh +++ b/web/deploy/deploy.sh @@ -16,8 +16,8 @@ name=libbui-web host=libbui.vinnymac.dev test -f "$web/dist/index.html" || { echo "error: run npm run build first" >&2; exit 1; } -set -- "$web"/dist/assets/libbui-riscv64-*.bin -test -f "$1" || { echo "error: dist has no assets/libbui-riscv64-*.bin; run npm run binary, then build" >&2; exit 1; } +set -- "$web"/dist/assets/libbui-aarch64-*.bin +test -f "$1" || { echo "error: dist has no assets/libbui-aarch64-*.bin; run npm run binary, then build" >&2; exit 1; } mkdir -p "$home_dir/releases" previous="$(readlink "$home_dir/current" || true)" diff --git a/web/deploy/update.sh b/web/deploy/update.sh index 9c45a7f..4425bf8 100755 --- a/web/deploy/update.sh +++ b/web/deploy/update.sh @@ -36,7 +36,7 @@ export PATH="$base/tools:$HOME/.cargo/bin:$HOME/.volta/bin:/home/linuxbrew/.linu export GIT_TERMINAL_PROMPT=0 GIT_SSH_COMMAND="ssh -o BatchMode=yes" export CARGO_TARGET_DIR="$base/target" CARGO_TERM_COLOR=never # A binary that was never run must not go live. -export QEMU=qemu-riscv64-static REQUIRE_QEMU=1 +export QEMU=qemu-aarch64-static REQUIRE_QEMU=1 # Waits for `url` to answer with exactly `want`. serves() { @@ -100,8 +100,8 @@ main() { git -C "$source_dir" clean -fdxq -e web/node_modules cd "$source_dir" - scripts/riscv64.sh - binary="$CARGO_TARGET_DIR/riscv64gc-unknown-linux-musl/release/libbui" + scripts/static-linux.sh aarch64-unknown-linux-musl + binary="$CARGO_TARGET_DIR/aarch64-unknown-linux-musl/release/libbui" cd web # No install scripts: they would run with this user's keys and tokens. diff --git a/web/package-lock.json b/web/package-lock.json index 19b513f..580ad80 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -10,7 +10,7 @@ "@xterm/addon-fit": "0.11.0", "@xterm/addon-image": "0.9.0", "@xterm/xterm": "6.0.0", - "unkernel": "0.1.0-261116-447d26f" + "unkernel": "0.2.0-261119-040e142" }, "devDependencies": { "typescript": "7.0.2", @@ -1214,9 +1214,9 @@ } }, "node_modules/unkernel": { - "version": "0.1.0-261116-447d26f", - "resolved": "https://registry.npmjs.org/unkernel/-/unkernel-0.1.0-261116-447d26f.tgz", - "integrity": "sha512-Y/aB4mjkW7JF9gnDanZu3FDVucx7ei2YZvDn6LIijTTfkB5v9+tFVwODzWsoE6BGHVFSYTorHXVOhZmEbDNX/A==", + "version": "0.2.0-261119-040e142", + "resolved": "https://registry.npmjs.org/unkernel/-/unkernel-0.2.0-261119-040e142.tgz", + "integrity": "sha512-FIhmd2Fh9xBg0Zt2YVUvVOkQnoerPS+oCnOhb8HpY6A4nrQbaXrhX06PsYi5hoDgm/krSqeiXlwPjSF7BkdgTg==", "license": "MIT AND GPL-2.0-only", "bin": { "unkernel": "dist/cli.mjs" diff --git a/web/package.json b/web/package.json index 8c9b82c..bcd1d3b 100644 --- a/web/package.json +++ b/web/package.json @@ -2,7 +2,7 @@ "name": "libbui-web", "private": true, "type": "module", - "description": "libbui.vinnymac.dev: libbui running in a RISC-V Linux machine inside the browser.", + "description": "libbui.vinnymac.dev: libbui running on Linux inside the browser.", "license": "Apache-2.0", "scripts": { "binary": "node scripts/binary.mjs", @@ -16,7 +16,7 @@ "@xterm/addon-fit": "0.11.0", "@xterm/addon-image": "0.9.0", "@xterm/xterm": "6.0.0", - "unkernel": "0.1.0-261116-447d26f" + "unkernel": "0.2.0-261119-040e142" }, "devDependencies": { "typescript": "7.0.2", diff --git a/web/scripts/binary.mjs b/web/scripts/binary.mjs index b17e6e5..272eddc 100644 --- a/web/scripts/binary.mjs +++ b/web/scripts/binary.mjs @@ -1,4 +1,4 @@ -// Builds the static riscv64 libbui and copies it to src/libbui-riscv64.bin, +// Builds the static aarch64 libbui and copies it to src/libbui-aarch64.bin, // which the page imports as a hashed asset. The same binary the release ships. // // npm run binary # cargo zigbuild, then copy @@ -7,9 +7,9 @@ import { execFileSync } from "node:child_process"; import { copyFileSync, statSync } from "node:fs"; import { fileURLToPath } from "node:url"; -const TARGET = "riscv64gc-unknown-linux-musl"; +const TARGET = "aarch64-unknown-linux-musl"; const root = fileURLToPath(new URL("../../", import.meta.url)); -const out = fileURLToPath(new URL("../src/libbui-riscv64.bin", import.meta.url)); +const out = fileURLToPath(new URL("../src/libbui-aarch64.bin", import.meta.url)); let source = process.env.LIBBUI_BINARY; if (!source) { diff --git a/web/src/main.ts b/web/src/main.ts index 4572eb3..ade2439 100644 --- a/web/src/main.ts +++ b/web/src/main.ts @@ -13,8 +13,8 @@ import { createKernel, } from "unkernel/web"; // Both are hashed assets, so they are cached for good and fetched together. -import kernelUrl from "unkernel/alpine.wasm?url"; -import binaryUrl from "./libbui-riscv64.bin?url"; +import kernelUrl from "unkernel/unkernel.wasm?url"; +import binaryUrl from "./libbui-aarch64.bin?url"; /** Where the guest sees libbui: a 9p mount served from this tab's memory. */ const MOUNT = "/opt/libbui"; diff --git a/web/vite.config.ts b/web/vite.config.ts index bc79303..b67163a 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -1,6 +1,6 @@ import { defineConfig } from "vite"; -// A static page. The kernel (unkernel's bundled Alpine build) is a Vite +// A static page. The kernel (unkernel's bundled unkernel.wasm) is a Vite // asset found through `new URL(..., import.meta.url)` in the SDK, so the // SDK must not be pre-bundled in dev or that URL points nowhere. export default defineConfig({