From: Tobias Ulmer Date: Thu, 12 Dec 2013 16:02:29 +0000 (+0100) Subject: Explicitly require and use the cache module X-Git-Tag: e2factory-2.3.15rc1~281 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=d13d290051167f704220797c14dd0c9911d102ac;p=e2factory.git Explicitly require and use the cache module cache metatable is gone. Signed-off-by: Tobias Ulmer --- diff --git a/local/e2-build.lua b/local/e2-build.lua index 13ba36c..7da84ad 100644 --- a/local/e2-build.lua +++ b/local/e2-build.lua @@ -28,14 +28,15 @@ along with this program. If not, see . ]] +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) diff --git a/local/e2-fetch-sources.lua b/local/e2-fetch-sources.lua index 7fa37b3..04b2aeb 100644 --- a/local/e2-fetch-sources.lua +++ b/local/e2-fetch-sources.lua @@ -30,10 +30,11 @@ -- 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 diff --git a/local/e2-ls-project.lua b/local/e2-ls-project.lua index 7587496..755451d 100644 --- a/local/e2-ls-project.lua +++ b/local/e2-ls-project.lua @@ -30,13 +30,14 @@ -- 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 diff --git a/local/e2build.lua b/local/e2build.lua index 9f26f1e..d9af4c4 100644 --- a/local/e2build.lua +++ b/local/e2build.lua @@ -29,17 +29,18 @@ ]] 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 diff --git a/local/e2tool.lua b/local/e2tool.lua index ad0f44a..1c0e71e 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -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 diff --git a/local/policy.lua b/local/policy.lua index bb33665..762721a 100644 --- a/local/policy.lua +++ b/local/policy.lua @@ -29,9 +29,10 @@ ]] 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 diff --git a/plugins/cvs.lua b/plugins/cvs.lua index 71d8918..5bc4be0 100644 --- a/plugins/cvs.lua +++ b/plugins/cvs.lua @@ -29,14 +29,15 @@ ]] 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 diff --git a/plugins/files.lua b/plugins/files.lua index 1c47c80..86fd2bc 100644 --- a/plugins/files.lua +++ b/plugins/files.lua @@ -29,12 +29,13 @@ ]] 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 diff --git a/plugins/git.lua b/plugins/git.lua index ba2fe99..e6cb578 100644 --- a/plugins/git.lua +++ b/plugins/git.lua @@ -29,18 +29,18 @@ ]] 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 diff --git a/plugins/svn.lua b/plugins/svn.lua index d97124d..db53536 100644 --- a/plugins/svn.lua +++ b/plugins/svn.lua @@ -29,14 +29,15 @@ ]] 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