aboutsummaryrefslogtreecommitdiff
path: root/tools/binman/state.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-11-23 11:03:42 -0700
committerSimon Glass <sjg@chromium.org>2021-12-02 09:16:30 -0700
commitc475decf59a6460bbd706199d8157f2fd2c4f4fc (patch)
tree144b0e99f9493e18c23a081397b624812af6e6db /tools/binman/state.py
parent650e5de7d407a3a9d2a9cc693eb8b1290a768d65 (diff)
downloadu-boot-c475decf59a6460bbd706199d8157f2fd2c4f4fc.zip
u-boot-c475decf59a6460bbd706199d8157f2fd2c4f4fc.tar.gz
u-boot-c475decf59a6460bbd706199d8157f2fd2c4f4fc.tar.bz2
binman: Add a way to obtain the version
Add a -V option which shows the version number of binman. For now this just uses a local 'version' file. Once the tool is packaged in some way we can figure out an approach that suits. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/state.py')
-rw-r--r--tools/binman/state.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/binman/state.py b/tools/binman/state.py
index 9e5b8a3..af0a65e 100644
--- a/tools/binman/state.py
+++ b/tools/binman/state.py
@@ -16,6 +16,8 @@ import os
from patman import tools
from patman import tout
+OUR_PATH = os.path.dirname(os.path.realpath(__file__))
+
# Map an dtb etype to its expected filename
DTB_TYPE_FNAME = {
'u-boot-spl-dtb': 'spl/u-boot-spl.dtb',
@@ -515,3 +517,19 @@ def TimingShow():
for name, seconds in duration.items():
print('%10s: %10.1fms' % (name, seconds * 1000))
+
+def GetVersion(path=OUR_PATH):
+ """Get the version string for binman
+
+ Args:
+ path: Path to 'version' file
+
+ Returns:
+ str: String version, e.g. 'v2021.10'
+ """
+ version_fname = os.path.join(path, 'version')
+ if os.path.exists(version_fname):
+ version = tools.ReadFile(version_fname, binary=False)
+ else:
+ version = '(unreleased)'
+ return version