return false, e:cat(re)
end
end
+
+ -- It would make sense to check for the required global servers here.
+ -- Required meaning servers to fetch a project.
+
return c
end
+--- Add local servers to the cache configuration. As the name implies,
+-- this function should not be called from a global context.
+-- @param c cache object
+-- @param project_root path to the local project root
+-- @param project_location location of the project relative to "upstream".
+-- @return True on success, false on error
+-- @return Error object on failure.
+function cache.setup_cache_local(c, project_root, project_location)
+ assertIsTable(c)
+ assertIsStringN(project_root)
+ assertIsString(project_location)
+
+ local rc, re
+ local servers
+
+ servers = cache.server_names()
+
+ rc, re = cache.new_cache_entry(c, servers.root_server,
+ "file://" .. project_root, { writeback=true }, nil, nil)
+ if not rc then
+ return false, re
+ end
+
+ rc, re = cache.new_cache_entry(c, servers.proj_storage,
+ nil, nil, servers.default_repo, project_location)
+ if not rc then
+ return false, re
+ end
+
+ -- Check for required local servers here. These tests are currently
+ -- spread out, but mainly live in policy.init()
+
+ return true
+end
+
+local _server_names = strict.lock({
+ -- XXX: inconsistent, confusing naming scheme
+ root_server = ".",
+ -- the proj_storage server is equivalent to
+ -- default_repo_server:info.project-locaton
+ proj_storage = "proj-storage",
+ default_repo = "projects",
+ default_files = "upstream",
+ result_server = "results",
+ releases = "releases",
+})
+
+--- Return a table of fixed server names whose existence we rely on
+-- throughout the program. The table is locked.
+-- @return Locked dictionary with fixed server names.
+function cache.server_names()
+ return _server_names
+end
+
--- get a sorted list of servers
-- @param c a cache table
-- @return table: a list of servers
return false, e
end
- if f.server ~= info.root_server_name and not f.sha1 then
+ if f.server ~= cache.server_names().root_server and not f.sha1 then
e:append("in group: %s", grp.name)
e:append("file entry for remote file without `sha1` attribute")
return false, e
error(err.new("<name> argument required"))
end
-- remote
- local rserver = info.default_repo_server
+ local rserver = cache.server_names().default_repo
if opts["server"] then
rserver = opts["server"]
end
local name = arguments[1]
local rlocation = string.format("%s/git/%s.git", info.project_location, name)
-- local
- local lserver = info.root_server_name
+ local lserver = cache.server_names().root_server
local llocation = string.format("in/%s/.git", name)
local rc, re = generic_git.new_repository(info.cache, lserver, llocation,
rserver, rlocation)
end
local location = arguments[1]
- local sl, re = e2lib.parse_server_location(location, info.default_files_server)
+ local sl, re = e2lib.parse_server_location(location,
+ cache.server_names().default_files)
if not sl then
error(re)
end
destdir = e2lib.join(bc.T, "script")
info = e2tool.info()
- rc, re = cache.fetch_file(info.cache, info.root_server_name,
+ rc, re = cache.fetch_file(info.cache, cache.server_names().root_server,
location, destdir)
if not rc then
e = err.new("installing build script")
abslocation)
end
- rc, re = cache.fetch_file(info.cache, info.root_server_name,
- location, destdir)
+ rc, re = cache.fetch_file(info.cache,
+ cache.server_names().root_server, location, destdir)
if not rc then
return false, e:cat(re)
end
-- @field chroot_umask Umask setting for chroot (decimal number).
-- @field host_umask Default umask of the process (decimal number).
-- @field root Project root directory (string).
--- @field root_server string: url pointing to the project root
--- @field root_server_name string: name of the root server (".")
--- @field default_repo_server string: name of the default scm repo server
--- @field default_files_server string: name of the default files server
--- @field result_storage (deprecated)
-- @field project_location string: project location relative to the servers
-- @field local_template_path Path to the local templates (string).
local _info = false
e2lib.logf(4, "VERSION: %s", buildconfig.VERSION)
e2lib.logf(4, "VERSIONSTRING: %s", buildconfig.VERSIONSTRING)
- hash.hcache_load(e2lib.join(info.root, ".e2/hashcache"))
-- no error check required
-
- --XXX create some policy module where the following policy settings
- --XXX and functions reside (server names, paths, etc.)
-
- -- the '.' server as url
- info.root_server = "file://" .. info.root
- info.root_server_name = "."
-
- -- the proj_storage server is equivalent to
- -- info.default_repo_server:info.project-locaton
- info.proj_storage_server_name = "proj-storage"
-
- -- need to configure the results server in the configuration, named 'results'
- info.result_server_name = "results"
-
- info.default_repo_server = "projects"
- info.default_files_server = "upstream"
+ hash.hcache_load(e2lib.join(info.root, ".e2/hashcache"))
-- read .e2/proj-location
local plf = e2lib.join(info.root, e2lib.globals.project_location_file)
if not info.cache then
return false, e:cat(re)
end
- 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)
+
+ rc, re = cache.setup_cache_local(info.cache, info.root, info.project_location)
+ if not rc then
+ return false, e:cat(re)
+ end
local f = e2lib.join(info.root, e2lib.globals.e2version_file)
local v, re = e2lib.parse_e2versionfile(f)
local licence = {}
package.loaded["licence"] = licence
+local cache = require("cache")
local class = require("class")
local e2lib = require("e2lib")
local e2tool = require("e2tool")
if not rc then
return false, e:cat(re)
end
- if file.server ~= info.root_server_name and not file.sha1 then
+ if file.server ~= cache.server_names().root_server and not file.sha1 then
return false, e:append(
"file entry for remote file without sha1 attribute")
end
-- @return Server name (string).
-- @return Location path to store results in (string).
local function storage_release(location, release_id)
- return "results", string.format("%s/release/%s", location, release_id)
+ return cache.server_names().result_server,
+ string.format("%s/release/%s", location, release_id)
end
--- Get results server and location.
-- @return Server name (string).
-- @return Location path to store results in (string).
local function storage_default(location, release_id)
- return "results", string.format("%s/shared", location)
+ return cache.server_names().result_server,
+ string.format("%s/shared", location)
end
--- Get local server and location.
-- @return Server name (string).
-- @return Location path to store results in (string).
local function storage_local(location, release_id)
- return "." , string.format("out")
+ return cache.server_names().root_server , string.format("out")
end
--- Get deploy server and location.
-- @return Server name (string).
-- @return Location path to store results in (string).
local function deploy_storage_default(location, release_id)
- return "releases", string.format("%s/archive/%s", location, release_id)
+ return cache.server_names().releases,
+ string.format("%s/archive/%s", location, release_id)
end
--- Get the buildid for a build
package.loaded["project"] = project
local buildconfig = require("buildconfig")
+local cache = require("cache")
local e2lib = require("e2lib")
local e2tool = require("e2tool")
local err = require("err")
if not e2lib.is_backup_file(f) then
location = e2lib.join("proj/init", f)
file = {
- server = info.root_server_name,
+ server = cache.server_names().root_server,
location = location,
}
package.loaded["result"] = result
local buildconfig = require("buildconfig")
+local cache = require("cache")
local chroot = require("chroot")
local class = require("class")
local e2build = require("e2build")
-- buildscript
local file = {
- server = info.root_server_name,
+ server = cache.server_names().root_server,
location = e2tool.resultbuildscript(self:get_name_as_path()),
}
-- buildscript
local file = {
- server = info.root_server_name,
+ server = cache.server_names().root_server,
location = e2tool.resultbuildscript(self:get_name_as_path()),
}
end
e2lib.logf(3, "init file: %s", f)
- local server = info.root_server_name
+ local server = cache.server_names().root_server
local location = e2lib.join("proj/init", f)
local cache_flags = {}
rc, re = cache.fetch_file(info.cache, server, location,
e2tool.resultbuildscript(dep:get_name_as_path())
}
for _,file in pairs(files) do
- local server = info.root_server_name
+ local server = cache.server_names().root_server
local cache_flags = {}
rc, re = cache.fetch_file(info.cache, server, file, destdir,
nil, cache_flags)
return false, e:cat(re)
end
-- install the global Makefiles
- local server = info.root_server_name
+ local server = cache.server_names().root_server
local destdir = e2lib.join(bc.T, "project")
local cache_flags = {}
local locations = {
if not f.location then
error(e:append("file entry without `location' attribute"))
end
- if f.server ~= info.root_server_name and not f.sha1 then
+ if f.server ~= cache.server_names().root_server and not f.sha1 then
error(e:append("file entry for remote file without "..
"`sha1` attribute"))
end