]> git.e2factory.org Git - e2factory.git/commitdiff
Stop accessing private hash context fields, call hash functions via module
authorTobias Ulmer <tu@emlix.com>
Tue, 12 Nov 2013 13:06:34 +0000 (14: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/digest.lua
local/e2tool.lua
local/environment.lua
plugins/cvs.lua
plugins/files.lua
plugins/git.lua

index 1710ae0477c76c72c008fb600f577991939d2edb..c386dbfb72099c2662fa75c2a18718f57d2d88d3 100644 (file)
@@ -189,12 +189,12 @@ local function compute_checksum_entry(pos, entry, directory, verify)
             return false, re
         end
 
-        rc, re = hc:hash_file(filename)
+        rc, re = hash.hash_file(hc, filename)
         if not rc then
             return false, re
         end
 
-        computedcs, re = hc:hash_finish()
+        computedcs, re = hash.hash_finish(hc)
         if not computedcs then
             return false, re
         end
index 72d2bf352e3a7e4458a402b978550d4f3ca50df9..4a4c231e36a9b028f041654de514aed828d13abd 100644 (file)
@@ -1854,12 +1854,12 @@ function e2tool.hash_path(path)
 
     local ctx = hash.hash_start()
 
-    local rc, re = ctx:hash_file(path)
+    local rc, re = hash.hash_file(ctx, path)
     if not rc then
         return nil, e:cat(re)
     end
 
-    return ctx:hash_finish()
+    return hash.hash_finish(ctx)
 end
 
 --- hash a file addressed by server name and location.
@@ -1929,15 +1929,15 @@ local function projid(info)
             if not fileid then
                 return false, e
             end
-            hc:hash_line(location)     -- the filename
-            hc:hash_line(fileid)       -- the file content
+            hash.hash_line(hc, location)       -- the filename
+            hash.hash_line(hc, fileid) -- the file content
         end
     end
-    hc:hash_line(info.project.release_id)
-    hc:hash_line(info.project.name)
-    hc:hash_line(info.project.chroot_arch)
-    hc:hash_line(buildconfig.VERSION)
-    info.projid = hc:hash_finish()
+    hash.hash_line(hc, info.project.release_id)
+    hash.hash_line(hc, info.project.name)
+    hash.hash_line(hc, info.project.chroot_arch)
+    hash.hash_line(hc, buildconfig.VERSION)
+    info.projid = hash.hash_finish(hc)
     return info.projid
 end
 
@@ -2157,17 +2157,17 @@ function e2tool.licenceid(info, licence)
         return lic.licenceid
     end
     local hc = hash.hash_start()
-    hc:hash_line(licence)                      -- licence name
+    hash.hash_line(hc, licence)                        -- licence name
     for _,f in ipairs(lic.files) do
-        hc:hash_line(f.server)
-        hc:hash_line(f.location)
+        hash.hash_line(hc, f.server)
+        hash.hash_line(hc, f.location)
         local fileid, re = e2tool.fileid(info, f)
         if not fileid then
             return false, e:cat(re)
         end
-        hc:hash_line(fileid)
+        hash.hash_line(hc, fileid)
     end
-    lic.licenceid, re = hc:hash_finish()
+    lic.licenceid, re = hash.hash_finish(hc)
     if not lic.licenceid then
         return nil, e:cat(re)
     end
@@ -2193,8 +2193,8 @@ function e2tool.buildid(info, resultname)
         return false, e
     end
     local hc = hash.hash_start()
-    hc:hash_line(r.pbuildid)
-    r.buildid = hc:hash_finish()
+    hash.hash_line(hc, r.pbuildid)
+    r.buildid = hash.hash_finish(hc)
     return r.build_mode.buildid(r.buildid)
 end
 
@@ -2207,18 +2207,17 @@ local function chrootgroupid(info, groupname)
         return g.groupid
     end
     local hc = hash.hash_start()
-    hc:hash_line(g.name)
+    hash.hash_line(hc, g.name)
     for _,f in ipairs(g.files) do
-        hc:hash_line(f.server)
-        hc:hash_line(f.location)
+        hash.hash_line(hc, f.server)
+        hash.hash_line(hc, f.location)
         local fileid, re = e2tool.fileid(info, f)
         if not fileid then
             return false, e:cat(re)
         end
-        hc:hash_line(fileid)
+        hash.hash_line(hc, fileid)
     end
-    e2lib.logf(4, "hash data for chroot group %s\n%s", groupname, hc.data)
-    g.groupid = hc:hash_finish()
+    g.groupid = hash.hash_finish(hc)
     return g.groupid
 end
 
@@ -2287,7 +2286,7 @@ function e2tool.pbuildid(info, resultname)
         end
     end
     r.envid = envid(info, resultname)
-    hc:hash_line(r.envid)
+    hash.hash_line(hc, r.envid)
     if not r.pseudo_result then
         local location = e2tool.resultbuildscript(info.results[resultname].directory)
         local f = {
@@ -2298,20 +2297,19 @@ function e2tool.pbuildid(info, resultname)
         if not fileid then
             return false, e:cat(re)
         end
-        hc:hash_line(fileid)                   -- build script hash
+        hash.hash_line(hc, fileid)                     -- build script hash
     end
     -- call the list of functions in info.ftab.resultid
     for _,f in ipairs(info.ftab.resultid) do
-        local hash, re = f(info, resultname)
+        local rhash, re = f(info, resultname)
         -- nil -> error
         -- false -> don't modify the hash
-        if hash == nil then
+        if rhash == nil then
             return false, e:cat(re)
-        elseif hash ~= false then
-            hc:hash_line(hash)
+        elseif rhash ~= false then
+            hash.hash_line(hc, rhash)
         end
     end
-    e2lib.logf(4, "hash data for resultid %s\n%s", resultname, hc.data)
     r.resultid = hash.hash_finish(hc)  -- result id (without deps)
 
     local projid, re = projid(info)
@@ -2319,7 +2317,7 @@ function e2tool.pbuildid(info, resultname)
         return false, e:cat(re)
     end
     hc = hash.hash_start()
-    hc:hash_line(projid)               -- project id
+    hash.hash_line(hc, projid)         -- project id
     hash.hash_line(hc, r.resultid)     -- result id
     for _,d in ipairs(r.depends) do
         local id, re = e2tool.pbuildid(info, d)
@@ -2339,16 +2337,15 @@ function e2tool.pbuildid(info, resultname)
     end
     -- call the list of functions in info.ftab.pbuildid
     for _,f in ipairs(info.ftab.pbuildid) do
-        local hash, re = f(info, resultname)
+        local rhash, re = f(info, resultname)
         -- nil -> error
         -- false -> don't modify the hash
-        if hash == nil then
+        if rhash == nil then
             return false, e:cat(re)
-        elseif hash ~= false then
-            hc:hash_line(hash)
+        elseif rhash ~= false then
+            hash.hash_line(hc, rhash)
         end
     end
-    e2lib.logf(4, "hash data for buildid %s\n%s", resultname, hc.data)
     r.pbuildid = hash.hash_finish(hc)  -- buildid (with deps)
     return r.build_mode.buildid(r.pbuildid)
 end
index 3d3c7791d5d4c8686434224c0ba16d22117fd307..97a0bf1be4db6409184ef3066245c85ab6afd4a7 100644 (file)
@@ -60,9 +60,9 @@ end
 function environment.id(env)
     local hc = hash.hash_start()
     for var, val in env:iter() do
-        hc:hash_append(string.format("%s=%s", var, val))
+        hash.hash_append(hc, string.format("%s=%s", var, val))
     end
-    return hc:hash_finish()
+    return hash.hash_finish(hc)
 end
 
 --- merge environment from merge into env.
index 9ef56935ea6de4b68b47e0450280bfb83d89a7e4..1ee9a72807cacf50d27155e716800d7b68147184 100644 (file)
@@ -372,7 +372,7 @@ function cvs.sourceid(info, sourcename, source_set)
     -- cvs specific
     if source_set == "tag" and src.tag ~= "^" then
         -- we rely on tags being unique with cvs
-        hc:hash_line(src.tag)
+        hash.hash_line(hc, src.tag)
     else
         -- the old function took a hash of the CVS/Entries file, but
         -- forgot the subdirecties' CVS/Entries files. We might
@@ -385,7 +385,6 @@ function cvs.sourceid(info, sourcename, source_set)
     hash.hash_line(hc, src.cvsroot)
     hash.hash_line(hc, src.module)
     -- skip src.working
-    e2lib.logf(4, "hash data for source %s\n%s", src.name, hc.data)
     src.sourceid[source_set] = hash.hash_finish(hc)
     return true, nil, src.sourceid[source_set]
 end
index 7f230da27c350fd4297e03693edbb445832fa660..d307edef98c1ff695cf9302203943735c97b6417 100644 (file)
@@ -497,7 +497,6 @@ function files.sourceid(info, sourcename, sourceset)
         hash.hash_line(hc, tostring(f.patch))
         hash.hash_line(hc, tostring(f.copy))
     end
-    e2lib.logf(4, "hash data for source %s\n%s", src.name, hc.data)
     src.sourceid = hash.hash_finish(hc)
     return true, nil, src.sourceid
 end
index 12ee85f9c32a082246863d6f65bfceea916576c0..634f998940e97f05894058db2c9769101451cb21 100644 (file)
@@ -540,7 +540,6 @@ function git.sourceid(info, sourcename, sourceset)
     hash.hash_line(hc, src.location)
     hash.hash_line(hc, src.working)
     hash.hash_line(hc, src.commitid[sourceset])
-    e2lib.logf(4, "hash data for source %s\n%s", src.name, hc.data)
     src.sourceid[sourceset] = hash.hash_finish(hc)
     return true, nil, src.sourceid[sourceset]
 end