From: Tobias Ulmer Date: Tue, 20 Dec 2016 19:43:16 +0000 (+0100) Subject: project: add checksum selection to proj/config X-Git-Tag: e2factory-2.3.16rc1~20 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=3a7fa4187785ed186be9c71f4c1bceb3264ce0e3;p=e2factory.git project: add checksum selection to proj/config Signed-off-by: Tobias Ulmer --- diff --git a/Changelog b/Changelog index 78c40b1..8cee993 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ NEXT: + * Add selection of checksum algorithms to proj/config * Fix checksum verification of some file sources used by collect_project * Fix SourceID calculation in files plugin under artificial conditions * Remove error message when an optional tool isn't present diff --git a/local/project.lua b/local/project.lua index c34db31..2ef5f5b 100644 --- a/local/project.lua +++ b/local/project.lua @@ -64,7 +64,7 @@ local function load_prj_cfg(prj) rc, re = e2lib.vrfy_dict_exp_keys(prj, "e2project", { "name", "release_id", "deploy_results", - "default_results", "chroot_arch" }) + "default_results", "chroot_arch", "checksums" }) if not rc then return false, re end @@ -117,6 +117,37 @@ local function load_prj_cfg(prj) err.new("running on x86_32: switching to x86_64 mode is impossible.") end + -- checksums + if prj.checksums == nil then + prj.checksums = {} + end + + rc, re = e2lib.vrfy_dict_exp_keys(prj.checksums, "e2project.checksums", + { "sha1", "sha256" }) + if not rc then + return false, re + end + + if prj.checksums.sha1 ~= nil then + if type(prj.checksums.sha1) ~= "boolean" then + return false, err.new("e2project.checksums.sha1 is not a boolean") + end + else + prj.checksums.sha1 = true + end + + if prj.checksums.sha256 ~= nil then + if type(prj.checksums.sha256) ~= "boolean" then + return false, err.new("e2project.checksums.sha256 is not a boolean") + end + else + prj.checksums.sha256 = false + end + + if not (prj.checksums.sha1 or prj.checksums.sha256) then + return false, err.new("at least one checksum algorithm is required") + end + _prj = prj return true end @@ -266,6 +297,16 @@ function project.default_results_iter() end end +--- +function project.checksums_sha1() + return _prj.checksums.sha1 +end + +--- +function project.checksums_sha256() + return _prj.checksums.sha256 +end + --- Calculate the Project ID. The Project ID consists of files in proj/init -- as well as some keys from proj/config and buildconfig. Returns a cached -- value after the first call. @@ -302,6 +343,8 @@ function project.projid(info) hash.hash_append(hc, project.release_id()) hash.hash_append(hc, project.name()) hash.hash_append(hc, project.chroot_arch()) + hash.hash_append(hc, tostring(project.checksums_sha1())) + hash.hash_append(hc, tostring(project.checksums_sha256())) hash.hash_append(hc, buildconfig.VERSION) -- .e2/extensions