]> git.e2factory.org Git - e2factory.git/commitdiff
project: add checksum selection to proj/config
authorTobias Ulmer <tu@emlix.com>
Tue, 20 Dec 2016 19:43:16 +0000 (20:43 +0100)
committerTobias Ulmer <tu@emlix.com>
Tue, 20 Dec 2016 19:43:16 +0000 (20:43 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
Changelog
local/project.lua

index 78c40b19e1b067a99b76a58be3a6488bb2d81b73..8cee993c304e3b43605e0ed4890ef1f23cfe90c3 100644 (file)
--- 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
index c34db318a7a957954817c34599556fbaf8ffd29e..2ef5f5b2d9a53b38d3cc65bb8db7a7777d708e86 100644 (file)
@@ -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