* termux: build natively and run plugins on Bun 1.4.2 Select nogui for Android builds, open browser and OAuth links with termux-open-url, and write an executable Termux:Boot script that starts the gateway with shell-quoted paths. Bun 1.3 has no official Android build. Upgrade the default plugin runtime to 1.4.2, add the official Android arm64 and amd64 download targets, and update SHA-256 checksums for every supported platform. Document Termux installation, startup and source updates. Validation on Termux arm64: - Native build and go vet pass. - A fresh config downloads and verifies Android Bun 1.4.2 and loads a test plugin. - Boot startup can be enabled and disabled. - The Web page, authenticated state API, unauthenticated API rejection, gateway healthcheck and Web quit action work. - Browser argument preservation, boot path quoting and permissions, and plugin tests pass. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a10014-56c1-73d3-b3ee-2ea569713989 * site: install Android builds in Termux Detect Termux through TERMUX_VERSION or its PREFIX and select the Android CLI asset instead of a Linux binary. Install into PREFIX/bin by default, keep MAGPIE_BIN_DIR overrides, and suggest the Web or terminal interface without Linux desktop setup instructions. When the release has no Android asset, explain how to build from source. Add android/arm64 to release-cli and stop the build loop on failure. Document the installer and its release-asset requirement. Shell syntax and all 11 site tests pass, covering platform selection, custom paths, missing assets, checksum rejection and existing Linux installation paths. The Android arm64 release build succeeds on Termux; with a simulated release feed, the installer verifies and installs that binary into PREFIX/bin and the installed command runs successfully. Amp-Thread-ID: https://ampcode.com/threads/T-01a10014-56c1-73d3-b3ee-2ea569713989 Co-authored-by: Amp <amp@ampcode.com> * ci: check Android releases and the installer Build both linux/amd64 and android/arm64 through make release-cli in the CLI test matrix. Run the site and installer tests in the Linux job with Node 22, and check the installer's shell syntax. The release workflow in yetone/magpie-releases already calls the source Makefile's release-cli target, uploads dist/magpie-cli-*, and generates checksums for every artifact. The Android target added to TARGETS is therefore included without changing that workflow. Replace the full Termux README section with a short platform note beside the Linux and Windows installation requirements, removing duplicate commands, the fork URL and temporary release availability details. Both CLI release builds, all 11 site tests, shell syntax checks and actionlint validation pass locally. Amp-Thread-ID: https://ampcode.com/threads/T-01a10014-56c1-73d3-b3ee-2ea569713989 Co-authored-by: Amp <amp@ampcode.com> --------- Co-authored-by: Amp <amp@ampcode.com>
107 lines
5.0 KiB
JavaScript
107 lines
5.0 KiB
JavaScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { createHash } from "node:crypto";
|
|
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync, statSync, rmSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { spawnSync } from "node:child_process";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const installer = fileURLToPath(new URL("./public/install.sh", import.meta.url));
|
|
|
|
function install(t, { termux = true, arch = "aarch64", override = false, prefixOnly = false, missing = false, corrupt = false, desktop = false } = {}) {
|
|
const dir = mkdtempSync(join(tmpdir(), "magpie-install-"));
|
|
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
|
const tools = join(dir, "tools");
|
|
const home = join(dir, "home");
|
|
const prefix = join(dir, "com.termux/files/usr");
|
|
const bin = override ? join(dir, "custom bin") : termux ? join(prefix, "bin") : join(home, ".local/bin");
|
|
mkdirSync(tools, { recursive: true });
|
|
mkdirSync(bin, { recursive: true });
|
|
writeFileSync(join(bin, "magpie"), "old installation");
|
|
const payload = "test binary\n";
|
|
const cpu = arch === "aarch64" ? "arm64" : "amd64";
|
|
const file = termux ? `magpie-cli-android-${cpu}` : desktop ? `magpie-linux-${cpu}` : `magpie-cli-linux-${cpu}`;
|
|
const assets = {};
|
|
// A Linux asset is present even when Android's is missing: never use it.
|
|
for (const name of [file, `magpie-cli-linux-${cpu}`]) {
|
|
if (missing && name === file) continue;
|
|
assets[name] = { url: `https://download.invalid/${name}`, sha256: corrupt ? "0".repeat(64) : createHash("sha256").update(payload).digest("hex") };
|
|
}
|
|
const requests = join(dir, "requests");
|
|
writeFileSync(join(tools, "uname"), `#!/bin/sh\ncase "$1" in -m) echo '${arch}';; -s) echo Linux;; esac\n`, { mode: 0o755 });
|
|
writeFileSync(join(tools, "ldconfig"), "#!/bin/sh\necho libwebkit2gtk-4.1.so.0\n", { mode: 0o755 });
|
|
writeFileSync(join(tools, "curl"), `#!${process.execPath}
|
|
const fs = require("node:fs");
|
|
const args = process.argv.slice(2);
|
|
const url = args.at(-1);
|
|
fs.appendFileSync(process.env.INSTALL_REQUESTS, url + String.fromCharCode(10));
|
|
if (url.endsWith("/api/latest")) process.stdout.write(process.env.INSTALL_FEED);
|
|
else fs.writeFileSync(args[args.indexOf("-o") + 1], process.env.INSTALL_PAYLOAD);
|
|
`, { mode: 0o755 });
|
|
const env = {
|
|
...process.env,
|
|
HOME: home,
|
|
PREFIX: termux ? prefix : "",
|
|
TERMUX_VERSION: termux && !prefixOnly ? "test" : "",
|
|
MAGPIE_BIN_DIR: override ? bin : "",
|
|
MAGPIE_CLI: desktop ? "" : "1",
|
|
PATH: tools + ":" + process.env.PATH,
|
|
XDG_CONFIG_HOME: join(dir, "config"),
|
|
XDG_DATA_HOME: join(dir, "share"),
|
|
INSTALL_REQUESTS: requests,
|
|
INSTALL_FEED: JSON.stringify({ version: "test", assets }),
|
|
INSTALL_PAYLOAD: payload,
|
|
};
|
|
const result = spawnSync("sh", [installer], { env, encoding: "utf8" });
|
|
return { ...result, bin, file, payload, share: env.XDG_DATA_HOME, requests: readFileSync(requests, "utf8") };
|
|
}
|
|
|
|
test("Termux downloads Android arm64 into PREFIX/bin even with WebKit installed", (t) => {
|
|
const r = install(t, { desktop: true });
|
|
assert.equal(r.status, 0, r.stderr);
|
|
assert.equal(readFileSync(join(r.bin, "magpie"), "utf8"), r.payload);
|
|
assert.ok(statSync(join(r.bin, "magpie")).mode & 0o111);
|
|
assert.match(r.requests, /magpie-cli-android-arm64/);
|
|
assert.doesNotMatch(r.requests, /magpie-linux-|icon-256/);
|
|
assert.equal(existsSync(join(r.share, "applications/magpie.desktop")), false);
|
|
assert.match(r.stdout, /run it: magpie web/);
|
|
assert.doesNotMatch(r.stdout, /install WebKit/);
|
|
});
|
|
|
|
test("Termux prefix detection and amd64 target", (t) => {
|
|
const r = install(t, { prefixOnly: true, arch: "x86_64" });
|
|
assert.equal(r.status, 0, r.stderr);
|
|
assert.match(r.requests, /magpie-cli-android-amd64/);
|
|
});
|
|
|
|
test("Termux respects a custom bin directory containing spaces", (t) => {
|
|
const r = install(t, { override: true });
|
|
assert.equal(r.status, 0, r.stderr);
|
|
assert.equal(readFileSync(join(r.bin, "magpie"), "utf8"), r.payload);
|
|
});
|
|
|
|
test("missing Android release never falls back to Linux", (t) => {
|
|
const r = install(t, { missing: true });
|
|
assert.notEqual(r.status, 0);
|
|
assert.match(r.stderr, /no magpie-cli-android-arm64.*build in Termux/);
|
|
assert.equal(readFileSync(join(r.bin, "magpie"), "utf8"), "old installation");
|
|
assert.equal(r.requests.trim().split("\n").length, 1);
|
|
});
|
|
|
|
test("a checksum mismatch leaves the existing installation intact", (t) => {
|
|
const r = install(t, { corrupt: true });
|
|
assert.notEqual(r.status, 0);
|
|
assert.match(r.stderr, /does not match its checksum/);
|
|
assert.equal(readFileSync(join(r.bin, "magpie"), "utf8"), "old installation");
|
|
});
|
|
|
|
test("ordinary Linux still selects its CLI or desktop build", (t) => {
|
|
for (const desktop of [false, true]) {
|
|
const r = install(t, { termux: false, desktop });
|
|
assert.equal(r.status, 0, r.stderr);
|
|
assert.match(r.requests, desktop ? /magpie-linux-arm64/ : /magpie-cli-linux-arm64/);
|
|
assert.equal(existsSync(join(r.share, "applications/magpie.desktop")), desktop);
|
|
}
|
|
});
|