utils/ostree: deployment path helper

Add a simple helper method that returns the path for a deployment,
given the sysroot, the osname, the reference or commit and the
deployment serial. Path might not exist.
`
This commit is contained in:
Christian Kellner 2021-07-08 23:25:16 +02:00
parent dc201d45fd
commit 54fe67ece5

View file

@ -125,3 +125,17 @@ def rev_parse(repo: PathLike, ref: str) -> str:
raise RuntimeError(msg)
return msg
def deployment_path(root: PathLike, osname: str, ref: str, serial: int):
"""Return the path to a deployment given the parameters"""
base = os.path.join(root, "ostree")
repo = os.path.join(base, "repo")
stateroot = os.path.join(base, "deploy", osname)
commit = rev_parse(repo, ref)
sysroot = f"{stateroot}/deploy/{commit}.{serial}"
return sysroot