Agent Zero AI framework
Fix Desktop and Office package installation
Alessandro2d48c4c51d5d
diff --git a/docker/run/AGENTS.md b/docker/run/AGENTS.mdindex 6de0f7ddd..b043ed54e 100644--- a/docker/run/AGENTS.md+++ b/docker/run/AGENTS.md@@ -19,7 +19,7 @@- `BRANCH` is required for branch-based Docker builds.- Preserve exposed ports for SSH, HTTP, and tunneled services unless docs and workflows are updated together.- Keep the two-runtime Python model aligned with the root contract.-- Keep runtime desktop packages on `kali-last-snapshot`; carry the rolling base's matching ATK introspection package into that transaction, then pin the verified Python 3.13-compatible LibreOffice and complete Xpra runtime versions in `fs/ins/install_additional.sh` for both published architectures.+- Keep runtime desktop packages on `kali-last-snapshot`; align ATK's version-locked libraries and installed optional components with the pinned snapshot version, and pin the verified LibreOffice and complete Xpra runtime versions in `fs/ins/install_additional.sh` for both published architectures. Let those package dependencies constrain Python compatibility; do not depend on retired rolling package versions remaining downloadable.- Do not bake secrets, local `.env` values, or user data into the image.- Runtime startup must ensure `/a0/usr/uploads` exists before supervised services start.- Runtime startup raises the soft open-file limit toward `A0_NOFILE_LIMIT` (default `65535`) before supervisord starts, bounded by the container hard limit.diff --git a/docker/run/fs/ins/install_additional.sh b/docker/run/fs/ins/install_additional.shindex efdb0d084..bd48a447d 100644--- a/docker/run/fs/ins/install_additional.sh+++ b/docker/run/fs/ins/install_additional.sh@@ -13,6 +13,7 @@ if ! command -v apt-get >/dev/null 2>&1; thenfiKALI_SUITE="kali-last-snapshot"+ATK_VERSION="2.60.3-1"LIBREOFFICE_VERSION="4:26.2.4.2-1"XPRA_VERSION="6.5.2-r0-1"arch="$(dpkg --print-architecture)"@@ -22,6 +23,19 @@ if [ "$arch" = "arm64" ]; thenXPRA_HTML5_VERSION="21-r1-1"fi+ATK_PACKAGES=(+ "at-spi2-common=$ATK_VERSION"+ "libatk1.0-0t64=$ATK_VERSION"+ "libatk-bridge2.0-0t64=$ATK_VERSION"+ "libatspi2.0-0t64=$ATK_VERSION"+ "gir1.2-atk-1.0=$ATK_VERSION"+)+for package in at-spi2-core gir1.2-atspi-2.0; do+ if dpkg-query -W -f='${Status}' "$package" 2>/dev/null | grep -q 'install ok installed'; then+ ATK_PACKAGES+=("$package=$ATK_VERSION")+ fi+done+LIBREOFFICE_PACKAGES=("libreoffice-core=$LIBREOFFICE_VERSION""libreoffice-writer=$LIBREOFFICE_VERSION"@@ -39,11 +53,6 @@ XPRA_PACKAGES=("xpra-html5=$XPRA_HTML5_VERSION")-apt-get update-ATK_VERSION="$(dpkg-query -W -f='${Version}' libatk1.0-0t64)"-ATK_GIR_PACKAGE="/tmp/gir1.2-atk-1.0_${ATK_VERSION}_${arch}.deb"-(cd /tmp && apt-get download "gir1.2-atk-1.0=$ATK_VERSION")-for source in /etc/apt/sources.list /etc/apt/sources.list.d/kali.sources; do[ ! -f "$source" ] || sed -i "s/kali-rolling/$KALI_SUITE/g" "$source"done@@ -60,8 +69,8 @@ Signed-By: /usr/share/keyrings/xpra.ascArchitectures: $archEOFapt-get update-DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \- "$ATK_GIR_PACKAGE" \+DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --allow-downgrades \+ "${ATK_PACKAGES[@]}" \gir1.2-gtk-3.0 \"${LIBREOFFICE_PACKAGES[@]}" \"${XPRA_PACKAGES[@]}" \@@ -90,5 +99,4 @@ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \fonts-noto-cjk \fonts-noto-color-emoji-rm -f "$ATK_GIR_PACKAGE"rm -rf /var/lib/apt/lists/*diff --git a/helpers/system_packages.py b/helpers/system_packages.pyindex 7b4b979a0..f09d7e767 100644--- a/helpers/system_packages.py+++ b/helpers/system_packages.py@@ -1,17 +1,48 @@from __future__ import annotations+import os+import platformimport subprocessimport threadingimport time+from pathlib import Pathfrom typing import CallableAPT_LOCK_TIMEOUT_SECONDS = 240APT_LOCK_RETRY_SECONDS = 5+KALI_SUITE = "kali-last-snapshot"+KALI_SOURCE_FILES = (+ Path("/etc/apt/sources.list"),+ Path("/etc/apt/sources.list.d/kali.sources"),+)_apt_lock = threading.RLock()+def run_runtime_apt(command: list[str], *, timeout: int) -> subprocess.CompletedProcess[str]:+ """Run runtime repairs with the Docker build's Kali package sources."""+ with _apt_lock:+ if platform.freedesktop_os_release().get("ID") == "kali":+ for source in KALI_SOURCE_FILES:+ if source.is_file():+ original = source.read_text(encoding="utf-8")+ updated = original.replace("kali-rolling", KALI_SUITE)+ if updated != original:+ source.write_text(updated, encoding="utf-8")++ return run_apt_with_retries(+ lambda: subprocess.run(+ command,+ check=False,+ text=True,+ capture_output=True,+ timeout=timeout,+ env={**os.environ, "DEBIAN_FRONTEND": "noninteractive"},+ )+ )++def run_apt_with_retries(runner: Callable[[], subprocess.CompletedProcess[str]],*,diff --git a/helpers/system_packages.py.dox.md b/helpers/system_packages.py.dox.mdindex f1078d3b7..e40c69cfc 100644--- a/helpers/system_packages.py.dox.md+++ b/helpers/system_packages.py.dox.md@@ -3,7 +3,7 @@## Purpose- Own the `system_packages.py` helper module.-- This module runs apt operations with retry behavior.+- Run serialized APT operations with lock retries and the shared Desktop/Office repair policy.- Keep this file-level DOX profile synchronized with `system_packages.py` because this directory is intentionally flat.## Ownership@@ -11,16 +11,17 @@- `system_packages.py` owns the runtime implementation.- `system_packages.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation.- Top-level functions:+- `run_runtime_apt(command, timeout)`: Run a runtime repair command with the shared Kali compatibility policy. Migrate the two standard source files to `kali-last-snapshot`, preserving mirror/key/architecture settings. Commands pass through unchanged; source I/O failures propagate to the caller.- `run_apt_with_retries(runner: Callable[[], subprocess.CompletedProcess[str]], lock_timeout_seconds: int=..., retry_seconds: int=...) -> subprocess.CompletedProcess[str]`: Run an apt/dpkg command, serializing in-process callers and waiting out apt locks.- `is_apt_lock_error(result: subprocess.CompletedProcess[str]) -> bool`-- Notable constants/configuration names: `APT_LOCK_TIMEOUT_SECONDS`, `APT_LOCK_RETRY_SECONDS`.+- Notable constants/configuration names: `APT_LOCK_TIMEOUT_SECONDS`, `APT_LOCK_RETRY_SECONDS`, `KALI_SUITE`, `KALI_SOURCE_FILES`.## Runtime Contracts- Helper modules own reusable framework APIs and must preserve public callers unless all callers, tests, and docs are updated together.- Update this file whenever public functions, classes, persistence behavior, path/security assumptions, side effects, or cross-module contracts change.-- Observed side-effect areas: subprocess/runtime control.-- Imported dependency areas include: `__future__`, `subprocess`, `threading`, `time`, `typing`.+- Side effects: subprocess/runtime control and idempotent edits to `/etc/apt/sources.list` and `/etc/apt/sources.list.d/kali.sources` on Kali. Other distributions retain their existing package policy.+- Dependencies: standard-library `os`, `platform`, `pathlib`, `subprocess`, `threading`, `time`, and `typing`.## Key Concepts@@ -38,6 +39,7 @@- Run targeted tests for changed helper behavior; run security regressions for auth, filesystem, WebSocket, tunnel, upload, or secret-handling helpers.- Related tests observed by source search:- `tests/test_office_document_store.py`+ - `tests/test_system_packages.py`## Child DOX Indexdiff --git a/plugins/_desktop/AGENTS.md b/plugins/_desktop/AGENTS.mdindex 718707f5c..af10ecb2c 100644--- a/plugins/_desktop/AGENTS.md+++ b/plugins/_desktop/AGENTS.md@@ -15,6 +15,7 @@- Preserve session startup, cleanup, and route protection for desktop access.- Keep the Xpra server, client modules, and GTK introspection runtime present as one compatible stack; Xpra shadow sessions import all three even when users connect only through HTML5.+- Route APT commands through `system_packages.run_runtime_apt` so existing Kali containers repair from the build's snapshot. Preserve the installed Xpra component version. If GTK needs a missing ATK typelib, align ATK's version-locked libraries and any installed optional components with the build's pinned snapshot version; do not fetch dependencies from rolling.- Keep desktop state injected into prompts accurate and bounded.- Do not expose desktop routes without the expected auth protections.- Keep Desktop host visibility tied to an attached modal or canvas host; modal cleanup may preserve the iframe in keepalive, but must not leave stale modal mode behind.diff --git a/plugins/_desktop/hooks.py b/plugins/_desktop/hooks.pyindex 89a6390df..a23d26bcd 100644--- a/plugins/_desktop/hooks.py+++ b/plugins/_desktop/hooks.py@@ -3,7 +3,6 @@ from __future__ import annotationsimport osimport shutilimport subprocess-import tempfileimport threadingimport timeimport urllib.request@@ -25,7 +24,15 @@ XPRA_KEYRING_FILE = Path("/usr/share/keyrings/xpra.asc")XPRA_KEY_URL = "https://xpra.org/xpra.asc"XPRA_VERSION = "6.5.2-r0-1"GTK_RUNTIME_PACKAGE = "gir1.2-gtk-3.0"-KALI_ROLLING_SOURCE = "deb http://http.kali.org/kali kali-rolling main contrib non-free non-free-firmware\n"+ATK_VERSION = "2.60.3-1"+ATK_RUNTIME_PACKAGES = (+ "at-spi2-common",+ "libatk1.0-0t64",+ "libatk-bridge2.0-0t64",+ "libatspi2.0-0t64",+ "gir1.2-atk-1.0",+)+ATK_OPTIONAL_PACKAGES = ("at-spi2-core", "gir1.2-atspi-2.0")XPRA_VERSIONED_RUNTIME_PACKAGES = frozenset({"xpra-common",@@ -245,14 +252,15 @@ def _purge_packages(def _ensure_runtime_dependencies(installed: list[str], errors: list[str]) -> None:if os.geteuid() != 0 or not shutil.which("apt-get") or not shutil.which("dpkg-query"):return- if not _ensure_kali_gtk_runtime(installed, errors):- returnmissing = [package for package in RUNTIME_PACKAGES if not _package_installed(package)]if not missing:returnif not _apt_update(errors):return+ if not _ensure_kali_gtk_runtime(installed, errors):+ return+ missing = [package for package in missing if not _package_installed(package)]required_xpra_missing = [package for package in missing if package.startswith("xpra")]if required_xpra_missing and not _package_candidates_available(required_xpra_missing):@@ -273,36 +281,28 @@ def _ensure_kali_gtk_runtime(installed: list[str], errors: list[str]) -> bool:GTK_RUNTIME_PACKAGE not in RUNTIME_PACKAGESor _package_installed(GTK_RUNTIME_PACKAGE)or _read_os_release().get("ID") != "kali"+ or _package_installed("gir1.2-atk-1.0")):return True- with tempfile.TemporaryDirectory(prefix="a0-desktop-apt-") as directory:- source = Path(directory) / "kali-rolling.list"- source.write_text(KALI_ROLLING_SOURCE, encoding="utf-8")- options = [- "-o",- f"Dir::Etc::sourcelist={source}",- "-o",- "Dir::Etc::sourceparts=-",- ]- result = _run_apt_command(["apt-get", *options, "update"], timeout=300)- if result.returncode == 0:- result = _run_apt_command(- [- "apt-get",- *options,- "install",- "-y",- "--no-install-recommends",- GTK_RUNTIME_PACKAGE,- ],- timeout=900,- )- if result.returncode == 0:- installed.append(GTK_RUNTIME_PACKAGE)- return True- errors.append((result.stderr or result.stdout or "GTK runtime install failed").strip())- return False+ packages = [+ *ATK_RUNTIME_PACKAGES,+ *(package for package in ATK_OPTIONAL_PACKAGES if _package_installed(package)),+ ]+ # Keep ATK's version-locked libraries together when repairing older rolling bases.+ result = _run_apt_command(+ [+ "apt-get", "install", "-y", "--no-install-recommends", "--allow-downgrades",+ *(f"{package}={ATK_VERSION}" for package in packages),+ GTK_RUNTIME_PACKAGE,+ ],+ timeout=900,+ )+ if result.returncode == 0:+ installed.append(GTK_RUNTIME_PACKAGE)+ return True+ errors.append((result.stderr or result.stdout or "GTK runtime install failed").strip())+ return Falsedef _install_runtime_packages(@@ -389,16 +389,7 @@ def _download(url: str) -> bytes:def _run_apt_command(command: list[str], *, timeout: int) -> subprocess.CompletedProcess[str]:- return system_packages.run_apt_with_retries(- lambda: subprocess.run(- command,- check=False,- text=True,- capture_output=True,- timeout=timeout,- env={**os.environ, "DEBIAN_FRONTEND": "noninteractive"},- )- )+ return system_packages.run_runtime_apt(command, timeout=timeout)def _xpra_repository_source() -> str:diff --git a/plugins/_office/AGENTS.md b/plugins/_office/AGENTS.mdindex 7fba34633..0d9c5f2c6 100644--- a/plugins/_office/AGENTS.md+++ b/plugins/_office/AGENTS.md@@ -15,6 +15,7 @@- Preserve document storage integrity and live session synchronization.- Keep LibreOffice operations bounded to intended workspaces and artifact paths.+- Route APT commands through `system_packages.run_runtime_apt`; Kali repairs must use the build's snapshot when resolving LibreOffice/UNO dependencies.- Do not expose document contents or temporary files beyond intended UI/tool flows.- Editor text Save As storage helpers must preserve exact `.md` or `.txt` text and create a new registered document without mutating or deleting the source document.diff --git a/plugins/_office/hooks.py b/plugins/_office/hooks.pyindex 4d678192a..072149595 100644--- a/plugins/_office/hooks.py+++ b/plugins/_office/hooks.py@@ -479,13 +479,4 @@ def _apt_update(errors: list[str]) -> bool:def _run_apt_command(command: list[str], *, timeout: int) -> subprocess.CompletedProcess[str]:- return system_packages.run_apt_with_retries(- lambda: subprocess.run(- command,- check=False,- text=True,- capture_output=True,- timeout=timeout,- env={**os.environ, "DEBIAN_FRONTEND": "noninteractive"},- )- )+ return system_packages.run_runtime_apt(command, timeout=timeout)diff --git a/tests/test_browser_agent_regressions.py b/tests/test_browser_agent_regressions.pyindex 2428da83c..8ca7f845b 100644--- a/tests/test_browser_agent_regressions.py+++ b/tests/test_browser_agent_regressions.py@@ -2547,14 +2547,20 @@ def test_browser_docker_pins_python_313_compatible_desktop_packages():assert 'XPRA_HTML5_VERSION="19-r1-1"' in install_additionalassert 'XPRA_HTML5_VERSION="21-r1-1"' in install_additionalassert '"python3-uno=$LIBREOFFICE_VERSION"' in install_additional- assert 'apt-get download "gir1.2-atk-1.0=$ATK_VERSION"' in install_additional- assert ' "$ATK_GIR_PACKAGE" \\' in install_additional+ from plugins._desktop import hooks as desktop_hooks+ assert f'ATK_VERSION="{desktop_hooks.ATK_VERSION}"' in install_additional+ for package in desktop_hooks.ATK_RUNTIME_PACKAGES:+ assert f'"{package}=$ATK_VERSION"' in install_additional+ assert ' "${ATK_PACKAGES[@]}" \\' in install_additional+ assert "PYTHON_VERSION" not in install_additional+ assert '--allow-downgrades' in install_additionalassert " gir1.2-gtk-3.0 \\" in install_additionalassert '"xpra-client=$XPRA_VERSION"' in install_additionalassert '"xpra-client-gtk3=$XPRA_VERSION"' in install_additionalassert '"xpra-server=$XPRA_VERSION"' in install_additionalassert '"xpra-html5=$XPRA_HTML5_VERSION"' in install_additional- assert install_additional.index("apt-get download") < install_additional.index('s/kali-rolling/$KALI_SUITE')+ assert "apt-get download" not in install_additional+ assert install_additional.index('s/kali-rolling/$KALI_SUITE') < install_additional.index("apt-get update")assert "https://xpra.org/beta" not in install_additionaldiff --git a/tests/test_office_document_store.py b/tests/test_office_document_store.pyindex cdc421560..82f0de242 100644--- a/tests/test_office_document_store.py+++ b/tests/test_office_document_store.py@@ -34,6 +34,11 @@ from plugins._office.helpers import ()[email protected](autouse=True)+def runtime_package_os(monkeypatch):+ monkeypatch.setattr(system_packages.platform, "freedesktop_os_release", lambda: {"ID": "debian"})++@pytest.fixturedef office_state(tmp_path, monkeypatch):state = tmp_path / "state"@@ -1859,11 +1864,16 @@ def test_cleanup_hook_installs_matching_xpra_client_stack(monkeypatch):assert calls[-1][-2:] == ["xpra-client=6.5.2-r0-1", "xpra-client-gtk3=6.5.2-r0-1"]-def test_cleanup_hook_repairs_kali_gtk_from_rolling_source(monkeypatch):[email protected]("optional_installed", [False, True])[email protected]("install_fails", [False, True])+def test_cleanup_hook_repairs_kali_gtk_from_snapshot(tmp_path, monkeypatch, optional_installed, install_fails):calls = []- source_text = []- installed_state = {desktop_hooks.GTK_RUNTIME_PACKAGE: False}+ installed_state = {package: optional_installed for package in desktop_hooks.ATK_OPTIONAL_PACKAGES}+ source = tmp_path / "sources.list"+ source.write_text("deb http://http.kali.org/kali kali-rolling main\n", encoding="utf-8")+ monkeypatch.setattr(system_packages, "KALI_SOURCE_FILES", (source,))+ monkeypatch.setattr(system_packages.platform, "freedesktop_os_release", lambda: {"ID": "kali"})monkeypatch.setattr(desktop_hooks.os, "geteuid", lambda: 0)monkeypatch.setattr(desktop_hooks.shutil,@@ -1876,13 +1886,17 @@ def test_cleanup_hook_repairs_kali_gtk_from_rolling_source(monkeypatch):def fake_run(command, **kwargs):calls.append(command)- source_option = next(- (item for item in command if item.startswith("Dir::Etc::sourcelist=")),- "",- )- if source_option:- source_text.append(Path(source_option.split("=", 1)[1]).read_text(encoding="utf-8"))+ assert "kali-rolling" not in source.read_text(encoding="utf-8")+ assert not any(item.startswith("Dir::Etc::sourcelist=") for item in command)+ assert "download" not in commandif "install" in command:+ assert "--allow-downgrades" in command+ for package in desktop_hooks.ATK_RUNTIME_PACKAGES:+ assert f"{package}={desktop_hooks.ATK_VERSION}" in command+ for package in desktop_hooks.ATK_OPTIONAL_PACKAGES:+ assert (f"{package}={desktop_hooks.ATK_VERSION}" in command) == optional_installed+ if install_fails:+ return types.SimpleNamespace(returncode=100, stdout="", stderr="GTK dependency conflict")installed_state[desktop_hooks.GTK_RUNTIME_PACKAGE] = Truereturn types.SimpleNamespace(returncode=0, stdout="", stderr="")@@ -1892,11 +1906,13 @@ def test_cleanup_hook_repairs_kali_gtk_from_rolling_source(monkeypatch):desktop_hooks._ensure_runtime_dependencies(installed, errors)- assert installed == [desktop_hooks.GTK_RUNTIME_PACKAGE]- assert errors == []- assert source_text == [desktop_hooks.KALI_ROLLING_SOURCE, desktop_hooks.KALI_ROLLING_SOURCE]- assert calls[0][-1] == "update"- assert calls[1][-2:] == ["--no-install-recommends", desktop_hooks.GTK_RUNTIME_PACKAGE]+ if install_fails:+ assert installed == []+ assert errors == ["GTK dependency conflict"]+ else:+ assert installed == [desktop_hooks.GTK_RUNTIME_PACKAGE]+ assert errors == []+ assert calls[0] == ["apt-get", "update"]def test_cleanup_hook_reports_required_xpra_codec_conflict(monkeypatch):diff --git a/tests/test_system_packages.py b/tests/test_system_packages.pynew file mode 100644index 000000000..99ad9eed4--- /dev/null+++ b/tests/test_system_packages.py@@ -0,0 +1,95 @@+import os+from pathlib import Path+import subprocess++import pytest++from helpers import system_packages++[email protected]("os_id", ["kali", "debian", "ubuntu"])+def test_runtime_apt_preserves_command_and_source_settings(tmp_path, monkeypatch, os_id):+ sources = (tmp_path / "sources.list", tmp_path / "kali.sources")+ contents = (+ "# Local mirror\ndeb https://mirror.example/kali kali-rolling main contrib\n",+ "Types: deb\nURIs: https://mirror.example/kali\nSuites: kali-rolling\nComponents: main\nSigned-By: /keyring.gpg\n",+ )+ for source, content in zip(sources, contents):+ source.write_text(content)+ monkeypatch.setattr(system_packages, "KALI_SOURCE_FILES", sources)+ monkeypatch.setattr(system_packages.platform, "freedesktop_os_release", lambda: {"ID": os_id})+ commands = []++ def run(command, **kwargs):+ commands.append(command)+ return subprocess.CompletedProcess(command, 0, "", "")++ monkeypatch.setattr(system_packages.subprocess, "run", run)+ command = ["apt-get", "install", "-y", "python3-uno"]+ for _ in range(2):+ assert system_packages.run_runtime_apt(command, timeout=30).returncode == 0+ for source, content in zip(sources, contents):+ expected = content.replace("kali-rolling", "kali-last-snapshot") if os_id == "kali" else content+ assert source.read_text() == expected+ assert commands[-1] == command+ assert command == ["apt-get", "install", "-y", "python3-uno"]+++def test_runtime_apt_propagates_source_write_errors(tmp_path, monkeypatch):+ source = tmp_path / "sources.list"+ source.write_text("deb https://mirror.example/kali kali-rolling main\n")+ monkeypatch.setattr(system_packages, "KALI_SOURCE_FILES", (source,))+ monkeypatch.setattr(system_packages.platform, "freedesktop_os_release", lambda: {"ID": "kali"})++ def fail_write(*args, **kwargs):+ raise PermissionError("source is read-only")++ monkeypatch.setattr(Path, "write_text", fail_write)+ monkeypatch.setattr(system_packages.subprocess, "run", lambda *args, **kwargs: pytest.fail("APT must not run"))+ with pytest.raises(PermissionError, match="source is read-only"):+ system_packages.run_runtime_apt(["apt-get", "install", "python3-gi-cairo"], timeout=30)++[email protected]("arch", ["amd64", "arm64"])+def test_desktop_install_script_uses_compatible_architecture_packages(tmp_path, arch):+ script = (Path(__file__).resolve().parents[1] / "docker/run/fs/ins/install_additional.sh").read_text()+ for path in ("/etc/apt", "/usr/share/keyrings", "/var/lib/apt/lists"):+ (tmp_path / path.lstrip("/")).mkdir(parents=True)+ script = script.replace(path, str(tmp_path / path.lstrip("/")))+ sources = tmp_path / "etc/apt/sources.list"+ sources.write_text("deb https://mirror.example/kali kali-rolling main\n")+ (tmp_path / "etc/apt/sources.list.d").mkdir()+ log = tmp_path / "apt.log"+ stubs = r'''+apt-get() {+ [[ "$(<"$SIM_ROOT/etc/apt/sources.list")" != *kali-rolling* ]] || return 1+ printf '%s\0' "$@" >> "$SIM_ROOT/apt.log"+ printf '\0' >> "$SIM_ROOT/apt.log"+}+dpkg() { printf '%s\n' "$SIM_ARCH"; }+dpkg-query() {+ if [[ "$SIM_ARCH" == arm64 ]]; then+ printf 'install ok installed\n'+ else+ return 1+ fi+}+wget() { return 0; }+'''+ result = subprocess.run(+ ["bash", "-e", "-c", stubs + script], text=True, capture_output=True,+ env={**os.environ, "SIM_ROOT": str(tmp_path), "SIM_ARCH": arch},+ )+ assert result.returncode == 0, result.stderr+ commands = [command.split("\0") for command in log.read_text().split("\0\0") if command]+ installs = [command for command in commands if command[0] == "install"]+ assert len(installs) == 2+ for command in installs:+ assert not any(arg.startswith("python3=") for arg in command)+ assert f'xpra-html5={"19-r1-1" if arch == "amd64" else "21-r1-1"}' in installs[-1]+ assert "xpra-client=6.5.2-r0-1" in installs[-1]+ assert "python3-uno=4:26.2.4.2-1" in installs[-1]+ assert "--allow-downgrades" in installs[-1]+ assert "gir1.2-atk-1.0=2.60.3-1" in installs[-1]+ assert ("at-spi2-core=2.60.3-1" in installs[-1]) == (arch == "arm64")+ assert f"Architectures: {arch}\n" in (tmp_path / "etc/apt/sources.list.d/xpra.sources").read_text()