Agent Zero AI framework
Handle optional Xpra codec gaps on ARM64
Alessandro3df27ccec363
diff --git a/docker/run/fs/ins/install_additional.sh b/docker/run/fs/ins/install_additional.shindex 6237d649c..31546deaa 100644--- a/docker/run/fs/ins/install_additional.sh+++ b/docker/run/fs/ins/install_additional.sh@@ -48,7 +48,7 @@ install_xpra_repo() {if ! xpra_install_check; thenif [ "$arch" != "amd64" ]; thenecho "xpra packages are not installable from ${uri} ${suite} for ${arch}; falling back to https://xpra.org trixie"- XPRA_PACKAGES=(xpra-server xpra-client xpra-client-gtk3 xpra-x11 xpra-html5)+ XPRA_PACKAGES=(xpra-server xpra-x11 xpra-html5)configure_xpra_repo "https://xpra.org" "trixie" "$arch"apt-get updateif ! xpra_install_check; thendiff --git a/plugins/_office/hooks.py b/plugins/_office/hooks.pyindex 9bcac0140..cae79008f 100644--- a/plugins/_office/hooks.py+++ b/plugins/_office/hooks.py@@ -71,6 +71,13 @@ RUNTIME_PACKAGES = ("fonts-noto-cjk","fonts-noto-color-emoji",)+# The browser-hosted Desktop needs the server, X11, and html5 pieces. Local+# Xpra GUI clients are useful extras, but can pull codec packages that are not+# consistently available across architectures.+OPTIONAL_RUNTIME_PACKAGES = (+ "xpra-client",+ "xpra-client-gtk3",+)RETIRED_RUNTIME_PACKAGES = ("firefox-esr",)@@ -269,8 +276,9 @@ def _ensure_runtime_dependencies(installed: list[str], errors: list[str]) -> Nonif not _apt_update(errors):return- xpra_missing = [package for package in missing if package.startswith("xpra")]- if xpra_missing and not _package_candidates_available(xpra_missing):+ required_missing, optional_missing = _split_runtime_packages(missing)+ required_xpra_missing = [package for package in required_missing if package.startswith("xpra")]+ if required_xpra_missing and not _package_candidates_available(required_xpra_missing):previous_error_count = len(errors)_ensure_xpra_repository(installed, errors)if len(errors) > previous_error_count or not _apt_update(errors):@@ -278,9 +286,33 @@ def _ensure_runtime_dependencies(installed: list[str], errors: list[str]) -> Nonmissing = [package for package in RUNTIME_PACKAGES if not _package_installed(package)]if not missing:return+ required_missing, optional_missing = _split_runtime_packages(missing)++ if required_missing and not _install_runtime_packages(required_missing, installed, errors):+ return++ if optional_missing:+ optional_xpra_missing = [package for package in optional_missing if package.startswith("xpra")]+ if optional_xpra_missing and not _package_candidates_available(optional_xpra_missing):+ return+ _install_runtime_packages(optional_missing, installed, errors, optional=True)+++def _split_runtime_packages(packages: list[str]) -> tuple[list[str], list[str]]:+ optional = [package for package in packages if package in OPTIONAL_RUNTIME_PACKAGES]+ required = [package for package in packages if package not in OPTIONAL_RUNTIME_PACKAGES]+ return required, optional++def _install_runtime_packages(+ packages: list[str],+ installed: list[str],+ errors: list[str],+ *,+ optional: bool = False,+) -> bool:result = subprocess.run(- ["apt-get", "install", "-y", "--no-install-recommends", *missing],+ ["apt-get", "install", "-y", "--no-install-recommends", *packages],check=False,text=True,capture_output=True,@@ -288,9 +320,18 @@ def _ensure_runtime_dependencies(installed: list[str], errors: list[str]) -> Nonenv={**os.environ, "DEBIAN_FRONTEND": "noninteractive"},)if result.returncode == 0:- installed.extend(missing)- return- errors.append((result.stderr or result.stdout or "apt-get install failed").strip())+ installed.extend(packages)+ return True+ output = (result.stderr or result.stdout or "apt-get install failed").strip()+ if optional and _is_xpra_codec_dependency_gap(output):+ return False+ errors.append(output)+ return False+++def _is_xpra_codec_dependency_gap(output: str) -> bool:+ normalized = output.lower()+ return "xpra-codecs" in normalized and "libvpx9" in normalizeddef _apt_update(errors: list[str]) -> bool:diff --git a/tests/test_office_document_store.py b/tests/test_office_document_store.pyindex 9e8f83d65..0c3ca81f5 100644--- a/tests/test_office_document_store.py+++ b/tests/test_office_document_store.py@@ -899,6 +899,88 @@ def test_cleanup_hook_uses_trixie_xpra_components_for_kali_arm64(tmp_path, monkeassert calls[-1][-3:] == ["xpra-server", "xpra-x11", "xpra-html5"]+def test_cleanup_hook_skips_optional_xpra_client_codec_conflict(monkeypatch):+ calls = []+ installed_state = {+ "xpra-server": True,+ "xpra-client": False,+ "xpra-client-gtk3": False,+ "xpra-x11": True,+ "xpra-html5": True,+ }+ codec_error = (+ "E: Unable to satisfy dependencies. Reached two conflicting assignments:\n"+ " 1. xpra-codecs:arm64=6.4.3-r0-1 is selected for install\n"+ " 2. xpra-codecs:arm64 Depends libvpx9 (>= 1.12.0)\n"+ " but none of the choices are installable: [no choices]"+ )++ monkeypatch.setattr(hooks.os, "geteuid", lambda: 0)+ monkeypatch.setattr(+ hooks.shutil,+ "which",+ lambda name: f"/usr/bin/{name}" if name in {"apt-get", "dpkg-query", "apt-cache"} else "",+ )+ monkeypatch.setattr(+ hooks,+ "RUNTIME_PACKAGES",+ ("xpra-server", "xpra-client", "xpra-client-gtk3", "xpra-x11", "xpra-html5"),+ )+ monkeypatch.setattr(hooks, "_package_installed", lambda package: installed_state.get(package, False))++ def fake_run(command, **kwargs):+ calls.append(command)+ if command[:2] == ["apt-cache", "policy"]:+ return types.SimpleNamespace(returncode=0, stdout="Candidate: 6.4.3-r0-1\n", stderr="")+ if command[:2] == ["apt-get", "install"]:+ return types.SimpleNamespace(returncode=100, stdout="", stderr=codec_error)+ return types.SimpleNamespace(returncode=0, stdout="", stderr="")++ monkeypatch.setattr(hooks.subprocess, "run", fake_run)+ installed = []+ errors = []++ hooks._ensure_runtime_dependencies(installed, errors)++ assert installed == []+ assert errors == []+ assert calls[-1][-2:] == ["xpra-client", "xpra-client-gtk3"]+++def test_cleanup_hook_reports_required_xpra_codec_conflict(monkeypatch):+ codec_error = (+ "E: Unable to satisfy dependencies. Reached two conflicting assignments:\n"+ " 1. xpra-codecs:arm64=6.4.3-r0-1 is selected for install\n"+ " 2. xpra-codecs:arm64 Depends libvpx9 (>= 1.12.0)\n"+ " but none of the choices are installable: [no choices]"+ )++ monkeypatch.setattr(hooks.os, "geteuid", lambda: 0)+ monkeypatch.setattr(+ hooks.shutil,+ "which",+ lambda name: f"/usr/bin/{name}" if name in {"apt-get", "dpkg-query", "apt-cache"} else "",+ )+ monkeypatch.setattr(hooks, "RUNTIME_PACKAGES", ("xpra-server",))+ monkeypatch.setattr(hooks, "_package_installed", lambda package: False)++ def fake_run(command, **kwargs):+ if command[:2] == ["apt-cache", "policy"]:+ return types.SimpleNamespace(returncode=0, stdout="Candidate: 6.4.3-r0-1\n", stderr="")+ if command[:2] == ["apt-get", "install"]:+ return types.SimpleNamespace(returncode=100, stdout="", stderr=codec_error)+ return types.SimpleNamespace(returncode=0, stdout="", stderr="")++ monkeypatch.setattr(hooks.subprocess, "run", fake_run)+ installed = []+ errors = []++ hooks._ensure_runtime_dependencies(installed, errors)++ assert installed == []+ assert errors == [codec_error]++def test_self_update_launch_invokes_office_cleanup(monkeypatch, tmp_path):manager = load_self_update_manager()calls = []