From 7856ecd518601a658ad238d63e3b2e590a14f350 Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Wed, 22 Jan 2014 21:06:07 +0100 Subject: [PATCH] Move collect_project resultid calculation out of e2tool Signed-off-by: Tobias Ulmer --- local/e2tool.lua | 19 ----------- plugins/collect_project.lua | 64 ++++++++++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 20 deletions(-) diff --git a/local/e2tool.lua b/local/e2tool.lua index 5f1fef3..f3d9b7f 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -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 diff --git a/plugins/collect_project.lua b/plugins/collect_project.lua index 0e3011a..cddaa1f 100644 --- a/plugins/collect_project.lua +++ b/plugins/collect_project.lua @@ -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") -- 2.39.5