From: Tobias Ulmer Date: Fri, 20 Jan 2017 19:26:07 +0000 (+0100) Subject: e2tool: improve syntax and global version checks X-Git-Tag: e2factory-2.3.17~51 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=a89c88a53f3dc4b7a5e585937f9bb1c7b905d882;p=e2factory.git e2tool: improve syntax and global version checks Signed-off-by: Tobias Ulmer --- diff --git a/local/e2tool.lua b/local/e2tool.lua index 53432b9..4466c64 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -796,18 +796,54 @@ local function check_config_syntax_compat() end end - local s = [[ + e:cat([[ Your configuration syntax is incompatible with this tool version. Please read the configuration Changelog, update your project configuration and finally insert the new configuration syntax version into %s -Configuration syntax versions supported by this version of the tools are:]] - e2lib.logf(2, s, sf) +Configuration syntax versions supported by this version of the tools are:]]) + for _,m in ipairs(buildconfig.SYNTAX) do - e2lib.logf(2, "%s", m) + e:append("%s", m) + end + e:append("Currently configured configuration syntax is: %q", l) + return false, e +end + +--- Compare global interface version and complain if we're not compatible. +-- @return True on success, false on error. +-- @Error object on failure. +local function check_global_interface_version() + local rc, re, e + local givf, line, supported + + -- read global interface version and check if this version of the local + -- tools supports the version used for the project + + e = err.new("global interface version check failed") + + givf = e2lib.join(e2tool.root(), e2lib.globals.global_interface_version_file) + line, re = eio.file_read_line(givf) + if not line then + return false, e:cat(re) + end + + line = line:match("^%s*(%d+)%s*$") + supported = false + for _,v in ipairs(buildconfig.GLOBAL_INTERFACE_VERSION) do + if v == line then + supported = true + end + end + if not supported then + e:cat("%s: Invalid global interface version", + e2lib.globals.global_interface_version_file) + e:append("supported global interface versions are: %s", + table.concat(buildconfig.GLOBAL_INTERFACE_VERSION), " ") + return false, e end - e2lib.logf(2, "Currently configured configuration syntax is: %q", l) - return false, e:append("configuration syntax mismatch") + + return true end --- Verify that a result or source file pathname in the form @@ -935,7 +971,12 @@ function e2tool.collect_project_info(info, skip_load_config) -- check for configuration compatibility rc, re = check_config_syntax_compat() if not rc then - e2lib.finish(1) + e2lib.abort(re) + end + + rc, re = check_global_interface_version() + if not rc then + e2lib.abort(re) end info.local_template_path = e2lib.join(e2tool.root(), ".e2/lib/e2/templates") @@ -1055,28 +1096,6 @@ function e2tool.collect_project_info(info, skip_load_config) return false, e end - -- read global interface version and check if this version of the local - -- tools supports the version used for the project - local givf = e2lib.join(e2tool.root(), e2lib.globals.global_interface_version_file) - local line, re = eio.file_read_line(givf) - if not line then - return false, e:cat(re) - end - info.global_interface_version = line:match("^%s*(%d+)%s*$") - local supported = false - for _,v in ipairs(buildconfig.GLOBAL_INTERFACE_VERSION) do - if v == info.global_interface_version then - supported = true - end - end - if not supported then - e:append("%s: Invalid global interface version", - e2lib.globals.global_interface_version_file) - e:append("supported global interface versions are: %s", - table.concat(buildconfig.GLOBAL_INTERFACE_VERSION), " ") - return false, e - end - -- warn if deprecated config files still exist local deprecated_files = { "proj/servers",