From 54fe67ece58a4e17d7e5099aded5a84909fc66d7 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Thu, 8 Jul 2021 23:25:16 +0200 Subject: [PATCH] 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. ` --- osbuild/util/ostree.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/osbuild/util/ostree.py b/osbuild/util/ostree.py index 875d9b90..88e0501c 100644 --- a/osbuild/util/ostree.py +++ b/osbuild/util/ostree.py @@ -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