Files
moonmix/tools/install-container.py
T
nandi b1f0965e02
CI / check (push) Successful in 8s
CI / native (push) Successful in 1m17s
Add OCI image and container desktop launcher
Build a release OCI image with runtime dependencies and a rootless Podman launcher for Wayland and PipeWire. Install the runner, app-menu entry, and icons per user without replacing the native executable.

Use Ubuntu 26.04 and GTK 4.22 for linux-dmabuf v6 compatibility. Allow an explicit icon-theme override so the container uses its bundled Adwaita assets. Document installation and add runner/desktop regression tests.
2026-11-22 20:56:43 -08:00

51 lines
2.0 KiB
Python
Executable File

#!/usr/bin/env python3
"""Install the container runner, app-menu entry and icons for the current user."""
import os
from pathlib import Path
import shutil
def desktop_exec(path):
"""Quote one Exec argument at both desktop-entry escaping layers."""
value = str(path).replace("%", "%%")
value = "".join("\\" + char if char in '\\"`$' else char for char in value)
return ('"' + value + '"').replace("\\", "\\\\")
def main():
root = Path(__file__).resolve().parent.parent
runner = Path.home() / ".local/bin/moonmix-container"
data_home = Path(os.environ.get("XDG_DATA_HOME") or Path.home() / ".local/share")
runner.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(root / "tools/moonmix-container", runner)
runner.chmod(0o755)
# Reuse the native entry's app id and metadata so Wayland associates the
# container window with this launcher. An absolute Exec avoids GUI PATH issues.
desktop = data_home / "applications/org.latha.moonmix.desktop"
desktop.parent.mkdir(parents=True, exist_ok=True)
template = (root / "data/org.latha.moonmix.desktop").read_text()
# GIO checks the executable before expanding %% field codes. Using env
# also supports a literal percent sign in the runner's absolute path.
desktop.write_text("".join(
f"Exec=/usr/bin/env {desktop_exec(runner)}\n" if line.startswith("Exec=") else line
for line in template.splitlines(keepends=True)
))
desktop.chmod(0o644)
for variant in ("scalable", "symbolic"):
name = "org.latha.moonmix" + ("-symbolic" if variant == "symbolic" else "") + ".svg"
relative = Path("icons/hicolor") / variant / "apps" / name
destination = data_home / relative
destination.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(root / "data" / relative, destination)
destination.chmod(0o644)
print(f"Installed runner: {runner}")
print(f"Installed desktop launcher: {desktop}")
if __name__ == "__main__":
main()