diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-03-30 12:46:22 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-03-30 12:46:22 +0530 |
commit | b2604317980b9cb26f1445dfb6ff82c84f9cbe65 (patch) | |
tree | a421c82bd63d07ae682a90f479ddfc08867926a3 /talerbuildconfig.py | |
parent | c4a6a98ed47a1a26083097ab3d74eb216169265a (diff) | |
download | build-common-b2604317980b9cb26f1445dfb6ff82c84f9cbe65.tar.gz build-common-b2604317980b9cb26f1445dfb6ff82c84f9cbe65.tar.bz2 build-common-b2604317980b9cb26f1445dfb6ff82c84f9cbe65.zip |
add version range checks
Diffstat (limited to 'talerbuildconfig.py')
-rw-r--r-- | talerbuildconfig.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/talerbuildconfig.py b/talerbuildconfig.py index e243a19..f28e1c2 100644 --- a/talerbuildconfig.py +++ b/talerbuildconfig.py @@ -35,6 +35,7 @@ import logging from distutils.spawn import find_executable import subprocess from dataclasses import dataclass +import semver """ This module aims to replicate a small GNU Coding Standards @@ -50,6 +51,9 @@ Makefile fragement, which is the processed by a Makefile (usually) in GNU Make format. """ +# Should be incremented each time we add some functionality +serialversion = 2 + # TODO: We need a smallest version argument. @@ -116,9 +120,17 @@ class BuildConfig: for tool in self.tools: res = tool.check(self) if not res: - print(f"Error: tool {tool.name} not available") + print(f"Error: tool '{tool.name}' not available") if hasattr(tool, "hint"): print(f"Hint: {tool.hint}") + sys.exit(1) + if hasattr(tool, "version_spec"): + sv = semver.SimpleSpec(tool.version_spec) + path, version = self.tool_results[tool.name] + if not sv.match(semver.Version(version)): + print(f"Error: Tool '{tool.name}' has version '{version}', but we require '{tool.version_spec}'") + sys.exit(1) + for tool in self.tools: path, version = self.tool_results[tool.name] @@ -413,6 +425,9 @@ class NodeJsTool(Tool): name = "node" hint = "If you are using Ubuntu Linux or Debian Linux, try installing the\nnode-legacy package or symlink node to nodejs." + def __init__(self, version_spec): + self.version_spec = version_spec + def args(self, parser): pass @@ -427,7 +442,7 @@ class NodeJsTool(Tool): ): buildconfig._warn("your node version is too old, use Node 4.x or newer") return False - node_version = tool_version("node --version") + node_version = tool_version("node --version").lstrip("v") buildconfig._set_tool("node", "node", version=node_version) return True |