From b2604317980b9cb26f1445dfb6ff82c84f9cbe65 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 30 Mar 2020 12:46:22 +0530 Subject: add version range checks --- talerbuildconfig.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'talerbuildconfig.py') 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 -- cgit v1.2.3