]> git.e2factory.org Git - e2factory.git/commitdiff
Move collect_project resultid calculation out of e2tool
authorTobias Ulmer <tu@emlix.com>
Wed, 22 Jan 2014 20:06:07 +0000 (21:06 +0100)
committerTobias Ulmer <tu@emlix.com>
Wed, 16 Nov 2016 14:41:17 +0000 (15:41 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
local/e2tool.lua
plugins/collect_project.lua

index 5f1fef36e09298c7b582e9d1fe1ad7ad78dabf1a..f3d9b7f6f9e68aa1fdd8c70b828efafdd44ac95e 100644 (file)
@@ -2038,25 +2038,6 @@ function e2tool.pbuildid(info, resultname)
     for _,d in ipairs(r.depends) do
         hash.hash_line(hc, d)                  -- dependency name
     end
-    for _,c in ipairs(r.collect_project_results) do
-        hash.hash_line(hc, c)          -- name
-    end
-    for _,s in ipairs(r.collect_project_sources) do
-        hash.hash_line(hc, s)          -- name
-    end
-    for _,g in ipairs(r.collect_project_chroot_groups) do
-        hash.hash_line(hc, g)          -- name
-    end
-    for _,l in ipairs(r.collect_project_licences) do
-        hash.hash_line(hc, l)          -- name
-        -- We collect all licences. So we cannot be sure to catch
-        -- them via results/sources. Include them explicitly here.
-        local lid, re = e2tool.licenceid(info, l)
-        if not lid then
-            return false, e:cat(re)
-        end
-        hash.hash_line(hc, lid)                -- licence id
-    end
 
     if r.chroot then
         for _,g in ipairs(r.chroot) do
index 0e3011a09d9af0e12987647ffad2572151656521..cddaa1fd41d6541a717a188ae8d619d21a6e2ebe 100644 (file)
@@ -26,6 +26,7 @@ local e2tool = require("e2tool")
 local eio = require("eio")
 local environment = require("environment")
 local err = require("err")
+local hash = require("hash")
 local scm = require("scm")
 
 --- check collect_project configuration
@@ -106,6 +107,59 @@ local function check_collect_project(info, resultname)
     return true, nil
 end
 
+--- Calculate part of the resultid for collect_project results.
+-- @param info Info table.
+-- @param resultname Result name.
+-- @return ResultID string, false to skip, nil on error.
+-- @return Error object on failure.
+local function collect_project_resultid(info, resultname)
+    local rc, re, res, hc, id
+
+    res = info.results[resultname]
+
+    if not res.collect_project then
+        return false
+    end
+
+    -- Warning: nil is used to signal error to the caller.
+
+    hc, re = hash.hash_start()
+    if not hc then return nil, re end
+
+
+    for _,c in ipairs(res.collect_project_results) do
+        rc, re = hash.hash_line(hc, c)
+        if not rc then return nil, re end
+    end
+    for _,s in ipairs(res.collect_project_sources) do
+        rc, re = hash.hash_line(hc, s)
+        if not rc then return nil, re end
+    end
+    for _,g in ipairs(res.collect_project_chroot_groups) do
+        rc, re = hash.hash_line(hc, g)
+        if not rc then return nil, re end
+    end
+    for _,l in ipairs(res.collect_project_licences) do
+        rc, re = hash.hash_line(hc, l)
+        if not rc then return nil, re end
+
+        -- We collect all licences. So we cannot be sure to catch
+        -- them via results/sources. Include them explicitly here.
+        local lid, re = e2tool.licenceid(info, l)
+        if not lid then
+            return nil, e:cat(re)
+        end
+
+        rc, re = hash.hash_line(hc, lid)
+        if not rc then return nil, re end
+    end
+
+    id, re = hash.hash_finish(hc)
+    if not id then return nil, re end
+
+    return id
+end
+
 --- collect all data required to build the project.
 -- skip results that depend on this result
 -- example: toolchain, busybox, sources, iso,
@@ -374,7 +428,15 @@ end
 local function collect_project_init(ctx)
     local rc, re
 
-    e2tool.register_check_result(ctx.info, check_collect_project)
+    rc, re = e2tool.register_check_result(ctx.info, check_collect_project)
+    if not rc then
+        return false, re
+    end
+
+    rc, re = e2tool.register_resultid(ctx.info, collect_project_resultid)
+    if not rc then
+        return false, re
+    end
 
     rc, re = e2build.register_build_function(ctx.info, "collect_project",
         build_collect_project, "fix_permissions")