]> git.e2factory.org Git - e2factory.git/commitdiff
Explicitly require and use the cache module
authorTobias Ulmer <tu@emlix.com>
Thu, 12 Dec 2013 16:02:29 +0000 (17:02 +0100)
committerTobias Ulmer <tu@emlix.com>
Wed, 16 Nov 2016 14:41:17 +0000 (15:41 +0100)
cache metatable is gone.

Signed-off-by: Tobias Ulmer <tu@emlix.com>
local/e2-build.lua
local/e2-fetch-sources.lua
local/e2-ls-project.lua
local/e2build.lua
local/e2tool.lua
local/policy.lua
plugins/cvs.lua
plugins/files.lua
plugins/git.lua
plugins/svn.lua

index 13ba36ca667ad928a6aec18039347ade1d76a084..7da84adbeea19e55096bc336ba6ed9c00d832a1f 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ]]
 
+local cache = require("cache")
 local console = require("console")
+local e2build = require("e2build")
 local e2lib = require("e2lib")
+local e2option = require("e2option")
 local e2tool = require("e2tool")
-local e2build = require("e2build")
 local err = require("err")
-local e2option = require("e2option")
-local scm = require("scm")
 local policy = require("policy")
+local scm = require("scm")
 
 local function e2_build(arg)
     local rc, re = e2lib.init()
@@ -74,14 +75,14 @@ local function e2_build(arg)
         for _,set in ipairs(writeback) do
             if set.set == "disable" then
                 e2lib.logf(3, disable_msg, set.server)
-                rc, re = info.cache:set_writeback(set.server, false)
+                rc, re = cache.set_writeback(info.cache, set.server, false)
                 if not rc then
                     local e = err.new(disable_msg, set.server)
                     return false, e:cat(re)
                 end
             elseif set.set == "enable" then
                 e2lib.logf(3, enable_msg, set.server)
-                rc, re = info.cache:set_writeback(set.server, true)
+                rc, re = cache.set_writeback(info.cache, set.server, true)
                 if not rc then
                     local e = err.new(enable_msg, set.server)
                     return false, e:cat(re)
index 7fa37b3a88466b93b10700cd064aea0a708c4fa9..04b2aeb1f54979fc88706b337e9885a825f3c1ea 100644 (file)
 
 -- fetch-sources - Retrieve sources for project -*- Lua -*-
 
+local cache = require("cache")
 local e2lib = require("e2lib")
+local e2option = require("e2option")
 local e2tool = require("e2tool")
 local err = require("err")
-local e2option = require("e2option")
 local scm = require("scm")
 
 local function e2_fetch_source(arg)
@@ -116,7 +117,8 @@ local function e2_fetch_source(arg)
     local function cache_chroot(info)
         for _,c in ipairs(info.chroot.groups_sorted) do
             for _,file in ipairs(info.chroot.groups_byname[c].files) do
-                local rc, e = info.cache:cache_file(file.server, file.location, {})
+                local rc, e = cache.cache_file(info.cache, file.server,
+                    file.location, {})
                 if not rc then
                     return false, err.new("caching file failed")
                 end
index 75874964ea3c25a79d90e5debe58aa11d87d9508..755451d58006fcb958cca8a9c37c6a7bb6efb0e7 100644 (file)
 
 -- ls-project - show project information -*- Lua -*-
 
+local cache = require("cache")
 local console = require("console")
 local e2lib = require("e2lib")
+local e2option = require("e2option")
 local e2tool = require("e2tool")
 local err = require("err")
-local e2option = require("e2option")
-local scm = require("scm")
 local policy = require("policy")
+local scm = require("scm")
 
 local function e2_ls_project(arg)
     local rc, re = e2lib.init()
@@ -212,9 +213,9 @@ local function e2_ls_project(arg)
     local s1 = "|"
     local s2 = "|"
     p1(s1, s2, "servers")
-    local servers_sorted = info.cache:servers()
+    local servers_sorted = cache.servers(info.cache)
     for i = 1, #servers_sorted, 1 do
-        local ce = info.cache:ce_by_server(servers_sorted[i])
+        local ce = cache.ce_by_server(info.cache, servers_sorted[i])
         if i < #servers_sorted then
             s2 = "|"
         else
index 9f26f1e3124762d8018670bcd4e8ad16ad26e69a..d9af4c46e082c88d5096fb71391db4755875528d 100644 (file)
 ]]
 
 local e2build = {}
+local buildconfig = require("buildconfig")
+local cache = require("cache")
 local digest = require("digest")
-local transport = require("transport")
-local tools = require("tools")
-local err = require("err")
 local e2lib = require("e2lib")
-local scm = require("scm")
-local environment = require("environment")
 local e2tool = require("e2tool")
-local strict = require("strict")
-local buildconfig = require("buildconfig")
 local eio = require("eio")
+local environment = require("environment")
+local err = require("err")
+local scm = require("scm")
+local strict = require("strict")
+local tools = require("tools")
+local transport = require("transport")
 
 -- Table driving the build process, see documentation at the bottom.
 local build_process = {}
@@ -60,13 +61,13 @@ local function linklast(info, r, return_flags)
     local cache_flags = {
         check_only = true
     }
-    local dst, re = info.cache:file_path(server, location1, cache_flags)
+    local dst, re = cache.file_path(info.cache, server, location1, cache_flags)
     if not dst then
         return false, e:cat(re)
     end
     -- create the last link
     local lnk_location = e2lib.join("out", r, "last")
-    local lnk, re = info.cache:file_path(info.root_server_name, lnk_location)
+    local lnk, re = cache.file_path(info.cache, info.root_server_name, lnk_location)
     if not lnk then
         return false, e:cat(re)
     end
@@ -130,13 +131,14 @@ local function result_available(info, r, return_flags)
     -- cache the result
     local result_location = e2lib.join(location, r, dep_set, "result.tar")
     local cache_flags = {}
-    rc, re = info.cache:cache_file(server, result_location, cache_flags)
+    rc, re = cache.cache_file(info.cache, server, result_location, cache_flags)
     if not rc then
         e2lib.log(3, "caching result failed")
         -- ignore
     end
     local cache_flags = {}
-    local path, re = info.cache:file_path(server, result_location, cache_flags)
+    local path, re = cache.file_path(info.cache, server, result_location,
+        cache_flags)
     rc = e2lib.isfile(path)
     if not rc then
         -- result is not available. Build.
@@ -313,11 +315,13 @@ local function setup_chroot(info, r, return_flags)
         if res.build_config.groups[grp.name] then
             for _, f in ipairs(grp.files) do
                 local flags = { cache = true }
-                local rc, re = info.cache:cache_file(f.server, f.location, flags)
+                local rc, re = cache.cache_file(info.cache, f.server,
+                    f.location, flags)
                 if not rc then
                     return false, e:cat(re)
                 end
-                local path, re = info.cache:file_path(f.server, f.location, flags)
+                local path, re = cache.file_path(info.cache, f.server,
+                    f.location, flags)
                 if not path then
                     return false, e:cat(re)
                 end
@@ -553,7 +557,7 @@ function e2build.unpack_result(info, r, dep, destdir)
     e2lib.logf(3, "searching for dependency %s in %s:%s", dep, server, location)
     local location1 = e2lib.join(location, dep, dep_set, "result.tar")
     local cache_flags = {}
-    local path, re = info.cache:file_path(server, location1, cache_flags)
+    local path, re = cache.file_path(info.cache, server, location1, cache_flags)
     if not path then
         return false, e:cat(re)
     end
@@ -907,7 +911,8 @@ local function deploy(info, r, tmpdir)
     local cache_flags = {
         cache = false,
     }
-    local rc, re = info.cache:fetch_file(server, location1, tmpdir, nil, cache_flags)
+    local rc, re = cache.fetch_file(info.cache, server, location1, tmpdir,
+        nil, cache_flags)
     if rc then
         e2lib.warnf("WOTHER",
             "Skipping deployment. This release was already deployed.")
@@ -919,7 +924,7 @@ local function deploy(info, r, tmpdir)
         local sourcefile = e2lib.join(resdir, f)
         local location1 = e2lib.join(location, r, f)
         local cache_flags = {}
-        local rc, re = info.cache:push_file(sourcefile, server, location1,
+        local rc, re = cache.push_file(info.cache, sourcefile, server, location1,
             cache_flags)
         if not rc then
             return false, re
@@ -1031,7 +1036,8 @@ local function store_result(info, r, return_flags)
     local cache_flags = {
         try_hardlink = true,
     }
-    rc, re = info.cache:push_file(sourcefile, server, location1, cache_flags)
+    rc, re = cache.push_file(info.cache, sourcefile, server,
+        location1, cache_flags)
     if not rc then
         return false, e:cat(re)
     end
@@ -1143,7 +1149,7 @@ local function collect_project(info, r, return_flags)
         local server = info.root_server_name
         local location = e2lib.join("proj/init", f)
         local cache_flags = {}
-        rc, re = info.cache:fetch_file(server, location,
+        rc, re = cache.fetch_file(info.cache, server, location,
             destdir, nil, cache_flags)
         if not rc then
             return false, e:cat(re)
@@ -1189,7 +1195,7 @@ local function collect_project(info, r, return_flags)
 
         for _,file in pairs(grp.files) do
             local cache_flags = {}
-            rc, re = info.cache:fetch_file(file.server,
+            rc, re = cache.fetch_file(info.cache, file.server,
             file.location, destdir, nil, cache_flags)
             if not rc then
                 return false, e:cat(re)
@@ -1242,9 +1248,8 @@ local function collect_project(info, r, return_flags)
                     return false, e:cat(re)
                 end
             end
-            rc, re = info.cache:fetch_file(file.server,
-            file.location, destdir, nil,
-            cache_flags)
+            rc, re = cache.fetch_file(file.server, file.location, destdir,
+                nil, cache_flags)
             if not rc then
                 return false, e:cat(re)
             end
@@ -1272,8 +1277,8 @@ local function collect_project(info, r, return_flags)
         for _,file in pairs(files) do
             local server = info.root_server_name
             local cache_flags = {}
-            rc, re = info.cache:fetch_file(server, file,
-                destdir, nil, cache_flags)
+            rc, re = cache.fetch_file(info.cache, server, file, destdir,
+                nil, cache_flags)
             if not rc then
                 return false, e:cat(re)
             end
@@ -1353,8 +1358,8 @@ local function collect_project(info, r, return_flags)
         ".e2/lib/make/detect_tool",
     }
     for _,location in ipairs(locations) do
-        rc, re = info.cache:fetch_file(server, location,
-        destdir, nil, cache_flags)
+        rc, re = cache.fetch_file(info.cache, server, location,
+            destdir, nil, cache_flags)
         if not rc then
             return false, e:cat(re)
         end
index ad0f44a6bad13afcd40f0af52f2a6caffa1016f7..1c0e71e23effd5a110bfa4966570d4188dd33bf2 100644 (file)
@@ -1432,10 +1432,10 @@ function e2tool.collect_project_info(info, skip_load_config)
     if not info.cache then
         return false, e:cat(re)
     end
-    rc = info.cache:new_cache_entry(info.root_server_name,
-    info.root_server, { writeback=true },  nil, nil )
-    rc = info.cache:new_cache_entry(info.proj_storage_server_name,
-    nil, nil, info.default_repo_server, info.project_location)
+    rc = cache.new_cache_entry(info.cache, info.root_server_name,
+        info.root_server, { writeback=true },  nil, nil )
+    rc = cache.new_cache_entry(info.cache, info.proj_storage_server_name,
+        nil, nil, info.default_repo_server, info.project_location)
 
     --e2tool.add_source_results(info)
 
@@ -1519,7 +1519,7 @@ local function check_chroot_config(info)
         if not grp.server then
             e:append("in group: %s", grp.name)
             e:append(" `server' attribute missing")
-        elseif not info.cache:valid_server(grp.server) then
+        elseif not cache.valid_server(info.cache, grp.server) then
             e:append("in group: %s", grp.name)
             e:append(" no such server: %s", grp.server)
         end
@@ -1891,13 +1891,13 @@ local function verify_remote_fileid(info, file, fileid)
     local rc, re, hc
     local e = err.new("error calculating remote file id for file: %s:%s",
     file.server, file.location)
-    if not info.cache:cache_enabled(file.server) or
+    if not cache.cache_enabled(info.cache, file.server) or
         not e2option.opts["check-remote"] then
         e2lib.logf(4, "checksum for remote file %s:%s skip verifying",
         file.server, file.location)
         return true, nil
     end
-    local surl, re = info.cache:remote_url(file.server, file.location)
+    local surl, re = cache.remote_url(info.cache, file.server, file.location)
     if not surl then
         return false, e:cat(re)
     end
@@ -1993,12 +1993,14 @@ function e2tool.fileid(info, file)
     if file.sha1 then
         fileid = file.sha1
     else
-        rc, re = info.cache:cache_file(file.server, file.location, cache_flags)
+        rc, re = cache.cache_file(info.cache, file.server,
+            file.location, cache_flags)
         if not rc then
             return false, e:cat(re)
         end
 
-        path, re = info.cache:file_path(file.server, file.location, cache_flags)
+        path, re = cache.file_path(info.cache, file.server,
+            file.location, cache_flags)
         if not path then
             return false, e:cat(re)
         end
index bb336653725e8ab98e843cee8c90f76639e331b6..762721a91bece32884dcfdce06e66cae1a3d7f12 100644 (file)
 ]]
 
 local policy = {}
+local cache = require("cache")
 local e2lib = require("e2lib")
-local err = require("err")
 local e2option = require("e2option")
+local err = require("err")
 local strict = require("strict")
 local hash = require("hash")
 
@@ -186,7 +187,7 @@ function policy.init(info)
         local release_id = "release-id"
         local server, location = s(location, release_id)
         local se = err.new("checking server configuration for '%s'", server)
-        local ce, re = info.cache:ce_by_server(server)
+        local ce, re = cache.ce_by_server(info.cache, server)
         if not ce then
             se:cat(re)
         elseif not ce.flags.writeback then
index 71d8918ed8b222cbbf75ff30b87a873564cf9b8e..5bc4be0c6ee75d9693bb328e336711a0df57f592 100644 (file)
 ]]
 
 local cvs = {}
+local cache = require("cache")
 local e2lib = require("e2lib")
 local eio = require("eio")
-local scm = require("scm")
-local hash = require("hash")
-local url = require("url")
-local tools = require("tools")
 local err = require("err")
+local hash = require("hash")
+local scm = require("scm")
 local strict = require("strict")
+local tools = require("tools")
+local url = require("url")
 
 plugin_descriptor = {
     description = "CVS SCM Plugin",
@@ -146,7 +147,7 @@ local function mkcvsroot(info, sourcename)
 
     src = info.sources[sourcename]
 
-    surl, re = info.cache:remote_url(src.server, src.cvsroot)
+    surl, re = cache.remote_url(info.cache, src.server, src.cvsroot)
     if not surl then
         return false, e:cat(re)
     end
index 1c47c802c4e7be7b00f2e52666373de63936f2a9..86fd2bc40331b8622e8a1bf611fb1bb04073800b 100644 (file)
 ]]
 
 local files = {}
-local scm = require("scm")
-local hash = require("hash")
-local err = require("err")
+local cache = require("cache")
 local e2lib = require("e2lib")
 local e2tool = require("e2tool")
 local eio = require("eio")
+local err = require("err")
+local hash = require("hash")
+local scm = require("scm")
 local strict = require("strict")
 local tools = require("tools")
 
@@ -88,7 +89,7 @@ function files.validate_source(info, sourcename)
             if not f.server then
                 e:append("source has file entry without `server' attribute")
             end
-            if f.server and (not info.cache:valid_server(f.server)) then
+            if f.server and (not cache.valid_server(info.cache, f.server)) then
                 e:append("invalid server: %s", f.server)
             end
             if not f.location then
@@ -134,7 +135,8 @@ function files.cache_source(info, sourcename)
             f.location)
         local flags = { cache = true }
         if f.server ~= info.root_server_name then
-            local rc, e = info.cache:cache_file(f.server, f.location, flags)
+            local rc, e = cache.cache_file(info.cache, f.server,
+                f.location, flags)
             if not rc then
                 return false, e
             end
@@ -348,13 +350,13 @@ function files.prepare_source(info, sourcename, sourceset, buildpath)
         end
         if file.unpack then
             local cache_flags = { cache = true }
-            local rc, re = info.cache:cache_file(file.server, file.location,
-            cache_flags)
+            local rc, re = cache.cache_file(info.cache, file.server,
+                file.location, cache_flags)
             if not rc then
                 return false, e:cat(re)
             end
-            local path, re = info.cache:file_path(file.server, file.location,
-            cache_flags)
+            local path, re = cache.file_path(info.cache, file.server,
+                file.location, cache_flags)
             if not path then
                 return false, e:cat(re)
             end
@@ -390,13 +392,13 @@ function files.prepare_source(info, sourcename, sourceset, buildpath)
             end
             if file.patch then
                 local cache_flags = { cache = true }
-                local rc, re = info.cache:cache_file(file.server, file.location,
-                cache_flags)
+                local rc, re = cache.cache_file(info.cache, file.server,
+                    file.location, cache_flags)
                 if not rc then
                     return false, e:cat(re)
                 end
-                local path, re = info.cache:file_path(file.server,
-                file.location, cache_flags)
+                local path, re = cache.file_path(info.cache, file.server,
+                    file.location, cache_flags)
                 if not path then
                     return false, e:append(re)
                 end
@@ -417,8 +419,8 @@ function files.prepare_source(info, sourcename, sourceset, buildpath)
                     return false, e:cat(re)
                 end
 
-                local rc, re = info.cache:fetch_file(file.server, file.location,
-                    destdir, destname, {})
+                local rc, re = cache.fetch_file(info.cache, file.server,
+                    file.location, destdir, destname, {})
                 if not rc then
                     return false, e:cat(re)
                 end
@@ -539,8 +541,8 @@ function files.toresult(info, sourcename, sourceset, directory)
         if not rc then
             return false, e:cat(re)
         end
-        rc, re = info.cache:fetch_file(file.server, file.location, destdir,
-            destname, {})
+        rc, re = cache.fetch_file(info.cache, file.server, file.location,
+            destdir, destname, {})
         if not rc then
             return false, e:cat(re)
         end
index ba2fe99758dcc9ed158029d85d3247409e7cdeb5..e6cb5789d50a958bc0e57101260c003da52e7bd0 100644 (file)
 ]]
 
 local git = {}
-local scm = require("scm")
-local hash = require("hash")
 local cache = require("cache")
-local generic_git = require("generic_git")
-local url = require("url")
-local err = require("err")
-local e2option = require("e2option")
 local e2lib = require("e2lib")
+local e2option = require("e2option")
 local e2tool = require("e2tool")
 local eio = require("eio")
+local err = require("err")
+local generic_git = require("generic_git")
+local hash = require("hash")
+local scm = require("scm")
 local strict = require("strict")
 local tools = require("tools")
+local url = require("url")
 
 --- Initialize git plugin.
 -- @param ctx Plugin context. See plugin module.
@@ -165,7 +165,7 @@ function git.validate_source(info, sourcename)
     if not src.server then
         e:append("source has no `server' attribute")
     end
-    if src.server and (not info.cache:valid_server(src.server)) then
+    if src.server and (not cache.valid_server(info.cache, src.server)) then
         e:append("invalid server: %s", src.server)
     end
     if not src.licences then
index d97124dad5742fedca8e9ec2a12fdaff169a1a30..db53536c208a6c93aecb20d4f77fcd703e0f960a 100644 (file)
 ]]
 
 local svn = {}
-local scm = require("scm")
-local hash = require("hash")
-local url = require("url")
-local tools = require("tools")
-local err = require("err")
+local cache = require("cache")
 local e2lib = require("e2lib")
 local eio = require("eio")
+local err = require("err")
+local hash = require("hash")
+local scm = require("scm")
 local strict = require("strict")
+local tools = require("tools")
+local url = require("url")
 
 plugin_descriptor = {
     description = "SVN SCM Plugin",
@@ -150,7 +151,7 @@ function svn.fetch_source(info, sourcename)
     local src = info.sources[sourcename]
     local location = src.location
     local server = src.server
-    local surl, re = info.cache:remote_url(server, location)
+    local surl, re = cache.remote_url(info.cache, server, location)
     if not surl then
         return false, e:cat(re)
     end
@@ -177,7 +178,7 @@ function svn.prepare_source(info, sourcename, source_set, build_path)
     local src = info.sources[ sourcename ]
     local location = src.location
     local server = src.server
-    local surl, re = info.cache:remote_url(server, location)
+    local surl, re = cache.remote_url(info.cache, server, location)
     if not surl then
         return false, e:cat(re)
     end
@@ -319,7 +320,7 @@ function svn.sourceid(info, sourcename, source_set)
     end
 
     -- svn specific
-    surl, re = info.cache:remote_url(src.server, src.location)
+    surl, re = cache.remote_url(info.cache, src.server, src.location)
     if not surl then
         return false, re
     end