]> git.e2factory.org Git - e2factory.git/commitdiff
e2tool: improve syntax and global version checks
authorTobias Ulmer <tu@emlix.com>
Fri, 20 Jan 2017 19:26:07 +0000 (20:26 +0100)
committerTobias Ulmer <tu@emlix.com>
Mon, 30 Jan 2017 13:33:34 +0000 (14:33 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
local/e2tool.lua

index 53432b9f4bdd8123bd0b950f24900af45ba20a4f..4466c6433d69252dc747b05d6e3b5b72d57cb72e 100644 (file)
@@ -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",