| 1 | """Exercise a target-built XBPS repository entirely within the build directory.""" |
| 2 | from pathlib import Path |
| 3 | import os |
| 4 | import subprocess |
| 5 | |
| 6 | here = Path.cwd() |
| 7 | prefix = here / "checked/usr" |
| 8 | work = here / "repository-test" |
| 9 | work.mkdir() |
| 10 | os.chdir(work) |
| 11 | (work / "payload/usr/share").mkdir(parents=True) |
| 12 | (work / "payload/usr/share/message").write_text("Vinix package round trip\n") |
| 13 | (work / "client").mkdir() |
| 14 | (work / "config").mkdir() |
| 15 | |
| 16 | def xbps(tool, *args): |
| 17 | return subprocess.check_output(["vinix-run", "--library-path", str(prefix / "lib"), |
| 18 | str(prefix / "bin" / ("xbps-" + tool)), *args], text=True) |
| 19 | |
| 20 | machine = os.environ.get("VPAC_TARGET_ARCH", os.uname().machine) |
| 21 | arch = xbps("uhelper", "arch").strip() |
| 22 | if arch != machine + "-musl": |
| 23 | raise SystemExit(f"target XBPS reports {arch!r} for {machine}-musl") |
| 24 | version = "vinix-test-1.0_1" |
| 25 | xbps("create", "-A", arch, "-n", version, "-s", "Vinix package fixture", "payload") |
| 26 | xbps("rindex", "-a", f"{version}.{arch}.xbps") |
| 27 | found = xbps("query", "-r", "client", "-C", str(work / "config"), "--repository=" + str(work), |
| 28 | "-R", "-p", "pkgver", "vinix-test") |
| 29 | if found.strip() != version: |
| 30 | raise SystemExit(f"wrong repository result: {found!r}") |
| 31 | |