Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

Mac in-app update: sign-and-notarize.sh --updater-archive packs the notarised app; feed_tool set-app-platform verifies the Tauri signature and writes the update entry

Niko1221935407d88332
diff --git a/packaging/UPDATES.md b/packaging/UPDATES.md
index 1d676bf99..00c8c9198 100644
--- a/packaging/UPDATES.md
+++ b/packaging/UPDATES.md
@@ -117,10 +117,34 @@ A key rotation is a release that carries both public keys; the old private key s
python packaging/feed_tool.py pack-control <control bundle folder> --version V --platform P --out RELEASE/control
# the app installers carry the engine out of the box: fill apps/desktop/src-tauri/resources/engine-bundle/<package folder> with the signed
# engine packages first (the tester builds do the same); tauri.conf.json lists that folder as a resource for every build
- TAURI_SIGNING_PRIVATE_KEY=<path to tauri-updater.key> npx tauri build --config src-tauri/tauri.release.conf.json # signed installers + latest.json inputs
- python packaging/feed_tool.py build-feed --out RELEASE --sequence N --key <feed-key.json> --engine RELEASE/engine --control RELEASE/control --app-json <tauri latest.json>
+ TAURI_SIGNING_PRIVATE_KEY=<path to tauri-updater.key> npx tauri build --config src-tauri/tauri.release.conf.json # installers + their .sig files (one build per OS)
+ # Mac only, on the Mac that holds the Developer ID certificate (see "The Mac app" below); the .app.tar.gz that tauri build made is NOT used:
+ bash packaging/mac/sign-and-notarize.sh <Strata.dmg> --updater-archive # writes signed/Strata.dmg (notarised) and signed/Strata.app.tar.gz
+ # on the release PC, per app installer (this is also the step that makes the Tauri updater json; tauri build does not write latest.json):
+ npx tauri signer sign -f <path to tauri-updater.key> signed/Strata.app.tar.gz # asks for the key password; writes Strata.app.tar.gz.sig
+ python packaging/feed_tool.py set-app-platform --app-json RELEASE/tauri-latest.json --target darwin-aarch64 --version V --archive signed/Strata.app.tar.gz --sig signed/Strata.app.tar.gz.sig
+ python packaging/feed_tool.py set-app-platform --app-json RELEASE/tauri-latest.json --target windows-x86_64 --version V --archive <setup .exe> --sig <setup .exe.sig>
+ python packaging/feed_tool.py set-app-platform --app-json RELEASE/tauri-latest.json --target linux-x86_64 --version V --archive <.AppImage> --sig <.AppImage.sig>
+ python packaging/feed_tool.py build-feed --out RELEASE --sequence N --key <feed-key.json> --engine RELEASE/engine --control RELEASE/control --app-json RELEASE/tauri-latest.json
python packaging/feed_tool.py verify-feed RELEASE --pub <feed-key.pub.json>
+### The Mac app
+
+`tauri build` signs its installers with the Tauri key before anything else touches them. On a Mac that is too early: `sign-and-notarize.sh` then re-signs every
+Mach-O in the app with the Developer ID and notarises and staples it, which changes the bytes. The `Strata.app.tar.gz` and `.sig` that `tauri build` wrote hold the
+**unsigned, un-notarised** app, and the updater would install exactly that on a user's Mac. So the in-app Mac update is built from the finished app instead:
+
+1. `sign-and-notarize.sh <dmg> --updater-archive` (on the Mac) packs the signed, notarised, stapled `.app` into `Strata.app.tar.gz` (the app folder at the root, the layout
+ Tauri's bundler makes), unpacks it again and checks `codesign`, the staple and `spctl`. It never reads the Tauri key.
+2. Move the `.tar.gz` to the release PC and sign it there with `npx tauri signer sign -f <key> Strata.app.tar.gz` (or `TAURI_SIGNING_PRIVATE_KEY_PATH` and the password variable).
+ The key stays on the PC and in the owner's safe storage; nothing in this tree reads or stores it, and the Mac needs no node and no key.
+3. `feed_tool.py set-app-platform` checks that signature against the public key in `tauri.conf.json` over the exact archive bytes, checks the archive holds `<Name>.app` at its root,
+ and writes `url`, `signature`, `sha256` and `size` of the darwin entry. A signature that was made for the pre-notarisation file does not verify, so it cannot be published by mistake.
+4. `build-feed --app-json` and `verify-feed` as above. Upload the notarised `Strata.dmg`, `Strata.app.tar.gz`, and the `latest.json` from the feed folder (`app/latest.json`).
+
+The Windows installer and the Linux AppImage need no extra step: their `.sig` files from `tauri build` are the ones to pass to `set-app-platform`. Re-signing the Mac app after the archive
+was made (a second `sign-and-notarize.sh` run) makes a new archive: sign and add it again.
+
The feed is hosted as the files of a GitHub release of `Niko1221/Strata`. The built-in address is
`https://github.com/Niko1221/Strata/releases/latest/download` (`strata_cli/update_cmd.py` `DEFAULT_FEED` adds `/strata-feed.json`; `install.sh`
and `install.ps1` use the folder). GitHub assets are flat, so build the packages with `--url-prefix ""` and upload every file of the release folder
diff --git a/packaging/feed_tool.py b/packaging/feed_tool.py
index 21fdfc142..837b1fa40 100644
--- a/packaging/feed_tool.py
+++ b/packaging/feed_tool.py
@@ -208,6 +208,68 @@ def build_feed(out: Path, *, key: dict, sequence: int, channel: str = "stable",
return document
+TAURI_TARGET_NAMES = tuple(feedmod.TAURI_TARGETS.values()) + ("linux-aarch64",)
+
+
+def _default_app_pubkey() -> str:
+ conf = Path(__file__).resolve().parents[1] / "apps" / "desktop" / "src-tauri" / "tauri.conf.json"
+ return json.loads(conf.read_text(encoding="utf-8"))["plugins"]["updater"]["pubkey"]
+
+
+def _check_mac_archive(archive: Path) -> None:
+ """A Mac updater archive is a gzip tar with exactly one top-level ``<Name>.app`` folder (what Tauri's bundler makes)."""
+ try:
+ with tarfile.open(archive, "r:gz") as tar:
+ tops = {m.name.lstrip("./").split("/", 1)[0] for m in tar.getmembers() if m.name.lstrip("./")}
+ names = set(tar.getnames())
+ except (tarfile.TarError, OSError) as exc:
+ raise SystemExit(f"{archive.name} is not a readable .tar.gz ({exc})")
+ if len(tops) != 1 or not next(iter(tops)).endswith(".app"):
+ raise SystemExit(f"{archive.name} must hold one <Name>.app folder at its root; found {sorted(tops)[:5]}")
+ app = next(iter(tops))
+ if not any(n.lstrip("./") == f"{app}/Contents/Info.plist" for n in names):
+ raise SystemExit(f"{archive.name} has no {app}/Contents/Info.plist")
+
+
+def set_app_platform(app_json: Path, *, target: str, archive: Path, signature_file: Path, url: str, version: str | None = None,
+ notes: str | None = None, pub_date: str | None = None, pubkey: str | None = None,
+ now: dt.datetime | None = None) -> dict:
+ """Add or replace one platform in the Tauri updater JSON (the file ``build-feed --app-json`` takes; it becomes ``latest.json``).
+
+ The ``.sig`` is made by ``npx tauri signer sign`` (or by ``tauri build`` for the Windows / Linux installers) and is only READ here;
+ this tool never touches the Tauri private key. It is checked against the public key in ``tauri.conf.json`` (or ``pubkey``) over the
+ exact archive bytes, so a signature of an older or unsigned file, or one from another key, is refused before it can be published.
+ ``sha256`` and ``size`` are taken from the archive."""
+ if target not in TAURI_TARGET_NAMES:
+ raise SystemExit(f"unknown target {target!r}; use one of {', '.join(TAURI_TARGET_NAMES)}")
+ archive, signature_file = Path(archive), Path(signature_file)
+ if target.startswith("darwin-"):
+ _check_mac_archive(archive)
+ signature = signature_file.read_text(encoding="utf-8").strip()
+ try:
+ with archive.open("rb") as stream:
+ signing.minisign_verify(pubkey or _default_app_pubkey(), signature, iter(lambda: stream.read(1 << 20), b""))
+ except signing.SignatureError as exc:
+ raise SystemExit(f"{signature_file.name} does not verify for {archive.name}: {exc}")
+ document: dict = {}
+ if Path(app_json).exists():
+ document = json.loads(Path(app_json).read_text(encoding="utf-8"))
+ if version:
+ if document.get("version") not in (None, version):
+ raise SystemExit(f"{app_json} is for version {document['version']}, not {version}")
+ document["version"] = version
+ if not document.get("version"):
+ raise SystemExit("a new app json needs --version")
+ document.setdefault("notes", notes or "")
+ if notes:
+ document["notes"] = notes
+ document["pub_date"] = pub_date or document.get("pub_date") or (now or dt.datetime.now(dt.timezone.utc)).strftime("%Y-%m-%dT%H:%M:%SZ")
+ document.setdefault("platforms", {})[target] = {"url": url, "signature": signature, "sha256": _sha256(archive),
+ "size": archive.stat().st_size}
+ Path(app_json).write_text(json.dumps(document, indent=1) + "\n", encoding="utf-8")
+ return document["platforms"][target]
+
+
def main(argv: list[str] | None = None) -> int:
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
sub = ap.add_subparsers(dest="cmd", required=True)
@@ -237,6 +299,16 @@ def main(argv: list[str] | None = None) -> int:
bf.add_argument("--control", type=Path)
bf.add_argument("--app-json", type=Path)
bf.add_argument("--expires-days", type=int)
+ sa = sub.add_parser("set-app-platform", help="add one signed app installer to the Tauri updater json")
+ sa.add_argument("--app-json", type=Path, required=True, help="the file to create or patch (what build-feed --app-json takes)")
+ sa.add_argument("--target", required=True, help="darwin-aarch64, darwin-x86_64, windows-x86_64 or linux-x86_64")
+ sa.add_argument("--archive", type=Path, required=True)
+ sa.add_argument("--sig", type=Path, required=True, help="the .sig file made by tauri signer sign")
+ sa.add_argument("--url", help="where the archive is published (default: the latest GitHub release)")
+ sa.add_argument("--version")
+ sa.add_argument("--notes")
+ sa.add_argument("--pub-date")
+ sa.add_argument("--pubkey", help="the Tauri public key (default: tauri.conf.json plugins.updater.pubkey)")
vf = sub.add_parser("verify-feed")
vf.add_argument("source")
vf.add_argument("--pub", type=Path, required=True)
@@ -258,6 +330,11 @@ def main(argv: list[str] | None = None) -> int:
control_dir=a.control, app_json=a.app_json, expires_days=a.expires_days)
print(f"wrote {a.out / feedmod.FEED_NAME} (+ .sig); engines {len((doc.get('engine') or {}).get('packages', []))}, "
f"control {'yes' if 'control' in doc else 'no'}, app {'yes' if 'app' in doc else 'no'}")
+ elif a.cmd == "set-app-platform":
+ url = a.url or f"https://github.com/Niko1221/Strata/releases/latest/download/{a.archive.name}"
+ entry = set_app_platform(a.app_json, target=a.target, archive=a.archive, signature_file=a.sig, url=url, version=a.version,
+ notes=a.notes, pub_date=a.pub_date, pubkey=a.pubkey)
+ print(f"{a.app_json}: {a.target} -> {entry['url']} ({entry['size']} bytes, sha256 {entry['sha256'][:16]}..., signature verified)")
elif a.cmd == "verify-feed":
trusted = signing.load_trusted_keys(a.pub, environ={})
loaded = feedmod.fetch(a.source, trusted)
diff --git a/packaging/mac/README.md b/packaging/mac/README.md
index 7cfbf3746..cedaa7415 100644
--- a/packaging/mac/README.md
+++ b/packaging/mac/README.md
@@ -31,6 +31,22 @@ and the notarytool profile (`strata-notary`); `SIGN_ID` and `NOTARY_PROFILE` ove
A trial run that signs ad-hoc and sends nothing to Apple: add `--dry-run` (no certificate needed).
+## The in-app update file (release builds only)
+
+The app updates itself on a Mac from `Strata.app.tar.gz`, not from the dmg. The one `tauri build` makes holds the app before this script signs it, so it must
+not be published. For a release build add `--updater-archive`:
+
+ bash sign-and-notarize.sh Strata.dmg --updater-archive
+
+After the app is signed, notarised and stapled, the script packs it into `signed/Strata.app.tar.gz` (the `.app` folder at the root of a gzip tar, like Tauri's own),
+unpacks it again in a scratch folder and runs `codesign --verify --deep --strict`, `stapler validate` and `spctl` on the unpacked copy. The archive is **not signed with the Tauri
+updater key** here: that key never goes near the Mac, and the Mac needs no node. Copy `Strata.app.tar.gz` to the release PC and, there:
+
+ npx tauri signer sign -f <path to tauri-updater.key> Strata.app.tar.gz
+ python packaging/feed_tool.py set-app-platform --app-json RELEASE/tauri-latest.json --target darwin-aarch64 --version V --archive Strata.app.tar.gz --sig Strata.app.tar.gz.sig
+
+`set-app-platform` refuses a signature that does not verify for these exact bytes, then records the url, signature, SHA-256 and size. Full release order: `packaging/UPDATES.md`, "Releasing".
+
## What it does
1. Copies the `.app` out of the dmg into a temporary folder (the original is never changed).
diff --git a/packaging/mac/sign-and-notarize.sh b/packaging/mac/sign-and-notarize.sh
index 8b1188f99..2de20ea77 100755
--- a/packaging/mac/sign-and-notarize.sh
+++ b/packaging/mac/sign-and-notarize.sh
@@ -2,7 +2,7 @@
# Sign the Strata Mac app (dmg or .app) and, optionally, the Mac Terminal archive with the owner's Developer ID, then notarise
# them with Apple, so macOS opens them without the "damaged" / "unidentified developer" warning.
#
-# bash sign-and-notarize.sh <Strata-tester-mac.dmg | Strata.app> [--terminal <Strata-Terminal-Mac.zip>] [--out DIR] [--dry-run]
+# bash sign-and-notarize.sh <Strata-tester-mac.dmg | Strata.app> [--terminal <Strata-Terminal-Mac.zip>] [--updater-archive] [--out DIR] [--dry-run]
# bash sign-and-notarize.sh --terminal <Strata-Terminal-Mac.zip> # the Terminal archive alone
#
# This script runs on the OWNER'S Mac, where the certificate "Developer ID Application: Niko Veit (79LR4R7RSC)" is in the Keychain and the
@@ -30,6 +30,11 @@
# 6. notarises the .app, staples it, rebuilds the dmg (same layout as apps/desktop/scripts/make-dmg.sh), signs the dmg, notarises the dmg,
# staples it, spctl -a -t open --context context:primary-signature -vv;
# 7. Terminal archive: signs every Mach-O inside, re-zips, notarises the zip (a zip cannot be stapled: see the note at the end).
+# 8. --updater-archive (opt-in, needs the app input): packs the signed, notarised, stapled .app into Strata.app.tar.gz, the file Tauri's in-app
+# updater downloads on a Mac (Strata.app at the root of the archive), and checks it by unpacking it again. The archive is NOT signed with the
+# Tauri updater key here: this script never touches that key. Sign it on the PC (npx tauri signer sign) and put it in the update file with
+# packaging/feed_tool.py set-app-platform (see packaging/UPDATES.md). Any Strata.app.tar.gz / .sig that `tauri build` made earlier holds the
+# UNSIGNED app and must not be published.
set -u
set -o pipefail
@@ -38,7 +43,7 @@ NOTARY_PROFILE="${NOTARY_PROFILE:-strata-notary}"
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ENT_NODE_SRC="$HERE/entitlements-node.plist"
-INPUT=""; TERMINAL=""; OUT=""; DRY=0; KEEP=0; SIGN_NESTED=0
+INPUT=""; TERMINAL=""; OUT=""; DRY=0; KEEP=0; SIGN_NESTED=0; UPDATER_ARCHIVE=0
WORK=""
LOG=""
declare -a RESULTS=()
@@ -58,12 +63,14 @@ while [ $# -gt 0 ]; do
--dry-run) DRY=1; shift ;;
--keep-work) KEEP=1; shift ;;
--sign-nested) SIGN_NESTED=1; shift ;;
+ --updater-archive) UPDATER_ARCHIVE=1; shift ;;
-h|--help) usage 0 ;;
-*) echo "unknown option: $1" >&2; usage ;;
*) if [ -z "$INPUT" ]; then INPUT="$1"; shift; else echo "unexpected argument: $1" >&2; usage; fi ;;
esac
done
[ -n "$INPUT" ] || [ -n "$TERMINAL" ] || usage
+if [ "$UPDATER_ARCHIVE" -eq 1 ] && [ -z "$INPUT" ]; then echo "--updater-archive needs the app (a .dmg or .app) as the input" >&2; usage; fi
# ----------------------------------------------------------------------------------------------------------------- output helpers
say() { printf '%s\n' "$*"; [ -z "$LOG" ] || printf '%s\n' "$*" >>"$LOG"; }
@@ -552,6 +559,34 @@ process_app() {
hdiutil detach "$mnt" >/dev/null 2>&1 || hdiutil detach "$mnt" -force >/dev/null 2>&1
fi
deliver "$out_dmg" "$INPUT"
+ if [ "$UPDATER_ARCHIVE" -eq 1 ]; then make_updater_archive "$bundle_real"; fi
+}
+
+make_updater_archive() { # the finished (signed, stapled) .app
+ local app=$1 name chk top out
+ name="$(basename "$app" .app).app.tar.gz"
+ out="$WORK/final/$name"
+ rm -f "$out"
+ # the layout Tauri's bundler makes and its updater unpacks: the .app folder at the root of a gzip tar, nothing else
+ # (COPYFILE_DISABLE keeps AppleDouble "._" files out; tar keeps symlinks and permissions)
+ ( cd "$(dirname "$app")" && COPYFILE_DISABLE=1 tar -czf "$out" "$(basename "$app")" ) || fail "pack the updater archive" "tar failed"
+ chk="$WORK/updater-check"; rm -rf "$chk"; mkdir -p "$chk"
+ tar -xzf "$out" -C "$chk" || fail "check the updater archive" "tar cannot unpack it"
+ top="$(ls -A "$chk")"
+ [ "$top" = "$(basename "$app")" ] || fail "check the updater archive" "the archive root holds '$top', not just $(basename "$app")"
+ find "$chk" -name '._*' | grep -q . && fail "check the updater archive" "AppleDouble files in the archive"
+ if logged codesign --verify --deep --strict "$chk/$top"; then rec OK "updater archive: the unpacked app verifies"
+ else fail "updater archive" "codesign --verify failed on the unpacked app"; fi
+ if [ "$DRY" -eq 0 ]; then
+ logged xcrun stapler validate "$chk/$top" || fail "updater archive" "the unpacked app has no valid notarisation ticket"
+ if spctl -a -vvv -t exec "$chk/$top" >>"$LOG" 2>&1; then rec OK "updater archive: spctl accepts the unpacked app" "Notarized Developer ID"
+ else fail "updater archive" "Gatekeeper rejects the unpacked app"; fi
+ else
+ rec INFO "updater archive: notarisation checks" "skipped in a dry run"
+ fi
+ rm -rf "$chk"
+ rec OK "pack the updater archive" "$name"
+ deliver "$out" "$INPUT"
}
build_dmg() { # app out.dmg volname
diff --git a/tests/terminal/test_update_feed.py b/tests/terminal/test_update_feed.py
index c029b4237..072c4b970 100644
--- a/tests/terminal/test_update_feed.py
+++ b/tests/terminal/test_update_feed.py
@@ -289,5 +289,91 @@ class FeedTool(unittest.TestCase):
main(["verify-feed", str(release), "--pub", str(Path(folder) / "keys" / "feed-key.pub.json")])
+class AppPlatform(unittest.TestCase):
+ """`feed_tool.py set-app-platform`: the signed Mac archive goes into the Tauri updater json, and only if it verifies."""
+
+ def setUp(self):
+ import io
+ import tarfile
+ self.temp = tempfile.TemporaryDirectory()
+ self.addCleanup(self.temp.cleanup)
+ self.root = Path(self.temp.name)
+ self.public, self.secret = fx.minisign_pair()
+ self.archive = self.root / "Strata.app.tar.gz"
+ with tarfile.open(self.archive, "w:gz") as tar:
+ for name, data in (("Strata.app/Contents/Info.plist", b"<plist/>"), ("Strata.app/Contents/MacOS/strata-desktop", b"bin")):
+ info = tarfile.TarInfo(name)
+ info.size = len(data)
+ tar.addfile(info, io.BytesIO(data))
+ self.sig = self.root / "Strata.app.tar.gz.sig"
+ self.sig.write_text(fx.minisign_sign(self.archive.read_bytes(), self.secret) + "\n")
+ self.app_json = self.root / "latest.json"
+
+ def run_tool(self, **extra):
+ from feed_tool import set_app_platform
+ args = dict(target="darwin-aarch64", archive=self.archive, signature_file=self.sig, url="https://example.invalid/Strata.app.tar.gz",
+ version="0.2.0", pubkey=self.public)
+ args.update(extra)
+ return set_app_platform(self.app_json, **args)
+
+ def test_a_signed_mac_archive_is_added_with_its_hash_and_size(self):
+ import hashlib
+ entry = self.run_tool()
+ document = json.loads(self.app_json.read_text())
+ self.assertEqual(document["version"], "0.2.0")
+ self.assertEqual(document["platforms"]["darwin-aarch64"], entry)
+ self.assertEqual(entry["sha256"], hashlib.sha256(self.archive.read_bytes()).hexdigest())
+ self.assertEqual(entry["size"], self.archive.stat().st_size)
+ self.assertEqual(entry["signature"], self.sig.read_text().strip())
+
+ def test_the_result_is_a_feed_app_member_control_accepts(self):
+ from feed_tool import build_feed, keygen
+ self.run_tool()
+ keygen(self.root / "keys")
+ key = json.loads((self.root / "keys" / "feed-key.json").read_text())
+ document = build_feed(self.root / "release", key=key, sequence=1, app_json=self.app_json)
+ self.assertIn("darwin-aarch64", document["app"]["platforms"])
+ self.assertTrue((self.root / "release" / "app" / "latest.json").exists())
+
+ def test_a_second_platform_is_added_beside_the_first(self):
+ self.run_tool()
+ self.run_tool(target="windows-x86_64")
+ self.assertEqual(sorted(json.loads(self.app_json.read_text())["platforms"]), ["darwin-aarch64", "windows-x86_64"])
+
+ def test_a_signature_of_a_different_file_is_refused_and_nothing_is_written(self):
+ """What `tauri build` left behind (the unsigned app) signs different bytes than the notarised archive we upload."""
+ self.archive.write_bytes(self.archive.read_bytes() + b"x")
+ with self.assertRaises(SystemExit) as caught:
+ self.run_tool()
+ self.assertIn("does not verify", str(caught.exception))
+ self.assertFalse(self.app_json.exists())
+
+ def test_a_signature_from_another_key_is_refused(self):
+ other_public, _ = fx.minisign_pair()
+ with self.assertRaises(SystemExit):
+ self.run_tool(pubkey=other_public)
+
+ def test_a_mac_archive_must_hold_the_app_at_its_root(self):
+ import io
+ import tarfile
+ with tarfile.open(self.archive, "w:gz") as tar:
+ info = tarfile.TarInfo("build/Strata.app/Contents/Info.plist")
+ info.size = 1
+ tar.addfile(info, io.BytesIO(b"x"))
+ self.sig.write_text(fx.minisign_sign(self.archive.read_bytes(), self.secret))
+ with self.assertRaises(SystemExit) as caught:
+ self.run_tool()
+ self.assertIn("root", str(caught.exception))
+
+ def test_the_default_key_is_the_one_in_tauri_conf(self):
+ from feed_tool import _default_app_pubkey
+ self.assertEqual(_default_app_pubkey(), json.loads((fx.ROOT / "apps/desktop/src-tauri/tauri.conf.json").read_text())["plugins"]["updater"]["pubkey"])
+
+ def test_a_version_mismatch_is_refused(self):
+ self.run_tool()
+ with self.assertRaises(SystemExit):
+ self.run_tool(version="0.2.1")
+
+
if __name__ == "__main__":
unittest.main()