cache metatable is gone.
Signed-off-by: Tobias Ulmer <tu@emlix.com>
    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()
         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)
 
 
 -- 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)
     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
 
 
 -- 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()
     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
 
 ]]
 
 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 = {}
     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
     -- 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.
         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
     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
     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.")
         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
     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
         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)
 
         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)
                     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
         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
         ".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
 
     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)
 
         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
     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
     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
 
 ]]
 
 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")
 
         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
 
 ]]
 
 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",
 
     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
 
 ]]
 
 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")
 
             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
             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
         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
             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
                     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
         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
 
 ]]
 
 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.
     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
 
 ]]
 
 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",
     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
     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
     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