vinix-ports / ports / xbps / check.py
30 lines · 27 sloc · 1.2 KB · c33d8afc2906b8dd9a8b905224eccd49a44f7ad5
Raw
1"""Exercise a target-built XBPS repository entirely within the build directory."""
2from pathlib import Path
3import os
4import subprocess
5
6here = Path.cwd()
7prefix = here / "checked/usr"
8work = here / "repository-test"
9work.mkdir()
10os.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
16def 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
20machine = os.environ.get("VPAC_TARGET_ARCH", os.uname().machine)
21arch = xbps("uhelper", "arch").strip()
22if arch != machine + "-musl":
23 raise SystemExit(f"target XBPS reports {arch!r} for {machine}-musl")
24version = "vinix-test-1.0_1"
25xbps("create", "-A", arch, "-n", version, "-s", "Vinix package fixture", "payload")
26xbps("rindex", "-a", f"{version}.{arch}.xbps")
27found = xbps("query", "-r", "client", "-C", str(work / "config"), "--repository=" + str(work),
28 "-R", "-p", "pkgver", "vinix-test")
29if found.strip() != version:
30 raise SystemExit(f"wrong repository result: {found!r}")
31