Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(desktop): sign the prepared Cua Driver helper ad hoc, so an x86_64 TEST build can sign the app (#2507)

Call White38573c691879
diff --git a/desktop/scripts/prepare-cua-driver.py b/desktop/scripts/prepare-cua-driver.py
index 5ecb523d0..42ccdfab3 100644
--- a/desktop/scripts/prepare-cua-driver.py
+++ b/desktop/scripts/prepare-cua-driver.py
@@ -250,6 +250,17 @@ def verify_built_contract(binary: Path) -> None:
raise ValueError("patched Cua Driver click.click_mode contract is unexpected")
+def sign_adhoc(binary: Path) -> None:
+ """Sign the built helper ad hoc, as Apple's linker already does for arm64 output.
+
+ The linker leaves x86_64 output unsigned, and a gh-v TEST build has Tauri sign
+ the app ad hoc while bundling, which codesign refuses while a nested helper is
+ unsigned. The packaging workflow still re-signs the helper from the inside out.
+ """
+ subprocess.run(["codesign", "--force", "--sign", "-", str(binary)], check=True)
+ subprocess.run(["codesign", "--verify", "--strict", str(binary)], check=True)
+
+
def prepare(
target: str,
*,
@@ -271,6 +282,7 @@ def prepare(
source_root = extract_driver_source(manifest, resolved_archive, work / "source")
patch = apply_driver_patch(manifest, source_root)
prepared = build_driver(manifest, source_root, target)
+ sign_adhoc(prepared)
verify_built_contract(prepared)
temporary_output = destination / f".{output.name}.{os.getpid()}.tmp"
shutil.copyfile(prepared, temporary_output)
diff --git a/tests/test_cua_driver_packaging.py b/tests/test_cua_driver_packaging.py
index b5f19a01a..c83c78fd2 100644
--- a/tests/test_cua_driver_packaging.py
+++ b/tests/test_cua_driver_packaging.py
@@ -5,10 +5,14 @@ import io
import json
from pathlib import Path
from runpy import run_path
+import shutil
+import subprocess
import tarfile
import pytest
+from scripts import desktop_release
+
_SCRIPT = run_path(
str(Path(__file__).parents[1] / "desktop/scripts/prepare-cua-driver.py")
@@ -99,6 +103,61 @@ def test_built_contract_rejects_snapshot_input_schema_shape(
_SCRIPT["verify_built_contract"](tmp_path / "cua-driver")
+ shutil.which("codesign") is None,
+ reason="codesign exists only on macOS, where the helper is prepared; nothing to sign elsewhere",
+)
+def test_prepared_helper_is_a_signed_code_object(
+ monkeypatch: pytest.MonkeyPatch, tmp_path: Path
+) -> None:
+ """An x86_64 build leaves the linker's output unsigned; the prepared helper never is."""
+
+ built = tmp_path / "build" / "cua-driver"
+ built.parent.mkdir()
+ shutil.copyfile("/usr/bin/true", built)
+ built.chmod(0o755)
+ subprocess.run(["codesign", "--remove-signature", str(built)], check=True)
+ unsigned = subprocess.run(
+ ["codesign", "-dv", str(built)], capture_output=True, text=True
+ )
+ assert "not signed at all" in unsigned.stderr
+
+ contract_checked: list[str] = []
+
+ def verify_contract(binary: Path) -> None:
+ subprocess.run(["codesign", "--verify", "--strict", str(binary)], check=True)
+ contract_checked.append(str(binary))
+
+ script = _SCRIPT["prepare"].__globals__
+ patch = Path("desktop/cua-driver") / _SCRIPT["load_manifest"]()["driver"]["patch"]["file"]
+ monkeypatch.setitem(script, "extract_driver_source", lambda *_args: tmp_path / "source")
+ monkeypatch.setitem(script, "apply_driver_patch", lambda *_args: patch.resolve())
+ monkeypatch.setitem(script, "build_driver", lambda *_args: built)
+ monkeypatch.setitem(script, "verify_built_contract", verify_contract)
+
+ output = _SCRIPT["prepare"](
+ "x86_64-apple-darwin",
+ source_archive=tmp_path / "source.tar.gz",
+ output_dir=tmp_path / "binaries",
+ )
+
+ assert contract_checked == [str(built)]
+ subprocess.run(["codesign", "--verify", "--strict", str(output)], check=True)
+ details = subprocess.run(
+ ["codesign", "-dv", str(output)], capture_output=True, text=True, check=True
+ )
+ assert "Signature=adhoc" in details.stderr
+ provenance = json.loads(
+ output.with_name(f"{output.name}.provenance.json").read_text(encoding="utf-8")
+ )
+ assert provenance["prepared_binary_sha256"] == _SCRIPT["digest"](output)
+ desktop_release.driver_provenance(
+ "x86_64-apple-darwin",
+ output,
+ output.with_name(f"{output.name}.provenance.json"),
+ )
+
+
def test_source_extraction_is_scoped_to_the_driver_subtree(tmp_path: Path) -> None:
archive = tmp_path / "source.tar.gz"
root = "cua-fixture"