"""Exercise a target-built XBPS repository entirely within the build directory.""" from pathlib import Path import os import subprocess here = Path.cwd() prefix = here / "checked/usr" work = here / "repository-test" work.mkdir() os.chdir(work) (work / "payload/usr/share").mkdir(parents=True) (work / "payload/usr/share/message").write_text("Vinix package round trip\n") (work / "client").mkdir() (work / "config").mkdir() def xbps(tool, *args): return subprocess.check_output(["vinix-run", "--library-path", str(prefix / "lib"), str(prefix / "bin" / ("xbps-" + tool)), *args], text=True) machine = os.environ.get("VPAC_TARGET_ARCH", os.uname().machine) arch = xbps("uhelper", "arch").strip() if arch != machine + "-musl": raise SystemExit(f"target XBPS reports {arch!r} for {machine}-musl") version = "vinix-test-1.0_1" xbps("create", "-A", arch, "-n", version, "-s", "Vinix package fixture", "payload") xbps("rindex", "-a", f"{version}.{arch}.xbps") found = xbps("query", "-r", "client", "-C", str(work / "config"), "--repository=" + str(work), "-R", "-p", "pkgver", "vinix-test") if found.strip() != version: raise SystemExit(f"wrong repository result: {found!r}")