#!/usr/bin/env python3 """Host test for the WebKitGTK GSettings schema build wiring in Geminux.""" import os import pathlib import shutil import subprocess import tempfile BASE = pathlib.Path(__file__).resolve().parent.parent HELPER = BASE / "scripts/compile-gsettings-schemas.sh" PACKAGES = BASE / "scripts/rootfs-packages.txt" OVERLAY = BASE / "scripts/apply-geminux-overlay.sh" BOOTSTRAP = BASE / "scripts/bootstrap-rootfs-container.sh" REBUILD = BASE / "rebuild-image.sh" SCHEMA_XML = """ true """ def read(path): return path.read_text(encoding="utf-8") def main(): for tool in ("glib-compile-schemas", "gsettings"): if not shutil.which(tool): raise SystemExit("missing required host tool: %s" % tool) if not HELPER.is_file() or not os.access(HELPER, os.X_OK): raise SystemExit("missing executable scripts/compile-gsettings-schemas.sh") helper = read(HELPER) if "glib-compile-schemas --strict --targetdir" not in helper: raise SystemExit("compile helper lost its strict targetdir compilation") if "gschemas.compiled" not in helper: raise SystemExit("compile helper no longer validates gschemas.compiled") packages = { line.strip() for line in read(PACKAGES).splitlines() if line.strip() and not line.lstrip().startswith("#") } for package in ("glib", "gsettings-desktop-schemas", "webkit2gtk-4.1", "gst-plugins-good"): if package not in packages: raise SystemExit("rootfs package set is missing %s" % package) overlay = read(OVERLAY) if "scripts/compile-gsettings-schemas.sh" not in overlay: raise SystemExit("overlay application no longer compiles GSettings schemas") bootstrap = read(BOOTSTRAP) if "apk add --no-cache python3 kmod openssl glib" not in bootstrap: raise SystemExit("bootstrap container no longer installs glib host tools") rebuild = read(REBUILD) if " glib " not in rebuild: raise SystemExit("image build container no longer installs glib host tools") print("[ok] WebKit GSettings package and build wiring") with tempfile.TemporaryDirectory(prefix="geminux-gsettings-") as tmp: root = pathlib.Path(tmp) schema_dir = root / "usr/share/glib-2.0/schemas" schema_dir.mkdir(parents=True) (schema_dir / "org.geminux.webkit.probe.gschema.xml").write_text( SCHEMA_XML, encoding="utf-8") result = subprocess.run( [str(HELPER), str(root)], capture_output=True, text=True) if result.returncode != 0: raise SystemExit("schema compile failed:\n%s" % result.stderr.strip()) compiled = schema_dir / "gschemas.compiled" if not compiled.is_file() or compiled.stat().st_size == 0: raise SystemExit("helper did not produce gschemas.compiled") env = os.environ.copy() env["GSETTINGS_SCHEMA_DIR"] = str(schema_dir) listed = subprocess.run( ["gsettings", "list-schemas"], env=env, capture_output=True, text=True) if listed.returncode != 0 or \ "org.geminux.webkit.probe" not in listed.stdout: raise SystemExit("compiled schema database is not readable by gsettings") print("[ok] WebKit GSettings schema compilation") if __name__ == "__main__": main()