git_skip_checkout = true,
buildnumber_server_url = nil,
template_path = "/etc/e2/templates",
+ extension_config = ".e2/extensions",
}
-- Interrupt handling
return false, "no config file available"
end
+function e2lib.write_extension_config(extensions)
+ local e = new_error("writing extensions config: %s", e2lib.extension_config)
+ local f, re = io.open(e2lib.extension_config, "w")
+ if not f then
+ return false, e:cat(re)
+ end
+ f:write(string.format("extensions {\n"))
+ for _,ex in ipairs(extensions) do
+ f:write(string.format(" {\n"))
+ for k,v in pairs(ex) do
+ f:write(string.format(" %s=\"%s\",\n", k, v))
+ end
+ f:write(string.format(" },\n"))
+ end
+ f:write(string.format("}\n"))
+ f:close()
+ return true, nil
+end
+
+--- read the local extension configuration
+-- This function must run while being located in the projects root directory
+-- @param root string: path to project
+-- @return the extension configuration table
+-- @return an error object on failure
+function e2lib.read_extension_config()
+ if e2util.exists(".e2/e2version") then
+ return false, new_error(
+ "Deprecated configuration file .e2/e2version exists.\n"..
+ "Move configuration to .e2/extensions")
+ end
+ local e = new_error("reading extension config file: %s",
+ e2lib.extension_config)
+
+ local rc = e2util.exists(e2lib.extension_config)
+ if not rc then
+ return false, e:append("config file does not exist")
+ end
+ e2lib.logf(3, "reading extension file: %s", e2lib.extension_config)
+ local c = {}
+ c.extensions = function(x)
+ c.data = x
+ end
+ local rc, re = e2lib.dofile_protected(e2lib.extension_config, c, true)
+ if not rc then
+ return false, e:cat(re)
+ end
+ local extension = c.data
+ if not extension then
+ return false, e:append("invalid extension configuration")
+ end
+ return extension, nil
+end
+
--- use the global parameters from the global configuration
-- this function always succeeds or aborts
-- @return nothing
end
end
while true do
- if e2util.exists(".e2/e2version") then
+ if e2util.exists(".e2") then
e2lib.logf(3, "project is located in: %s", path)
e2lib.chdir(save_path)
return path
{ filename = "proj/licences", content=licences },
{ filename = "proj/env", content=env },
{ filename = "proj/config", content=pconfig },
- { filename = ".e2/e2version", content=e2version },
{ filename = ".e2/version", content=version },
{ filename = ".e2/syntax", content=syntax },
{ filename = ".gitignore", content=gitignore },
e2lib.abort(e:cat(re))
end
end
+rc, re = e2lib.write_extension_config(extensions)
+if not rc then
+ e2lib.abort(e:cat(re))
+end
+rc, re = e2lib.git(nil, "add", e2lib.extension_config)
+if not rc then
+ e2lib.abort(e:cat(re))
+end
rc, re = e2lib.git(nil, "commit", "-m \"project setup\"")
if not rc then
e2lib.abort(e:cat(re))
]]
require("e2global")
+
+install_prefix = getinstallpath("PREFIX")
+
e2lib.init()
e2option.documentation = [[
e2lib.abort(e:cat(re))
end
--- get e2 version
-local s = e2lib.read_line(".e2/e2version")
-local branch, tag = s:match("(%S+) (%S+)")
-if not branch or not tag then
- e2lib.abort(e:append("cannot parse e2 version"))
-end
-local ref
-if tag == "^" then
- e2lib.warnf("WOTHER", "using e2 version by branch")
- ref = string.format("refs/heads/%s", branch)
+e2lib.logf(2, "installing local tools")
+
+local extensions
+if e2util.exists(e2lib.extension_config) then
+ extensions, re = e2lib.read_extension_config()
+ if not extensions then
+ e2lib.abort(e:cat(re))
+ end
else
- ref = string.format("refs/tags/%s", tag)
+ -- parse .e2/e2version for compatibility to e2factory versions without
+ -- extension support (e2factory-2.3.0)
+ local s = e2lib.read_line(".e2/e2version")
+ local branch, tag = s:match("(%S+) (%S+)")
+ if not branch or not tag then
+ e2lib.abort(e:append("cannot parse e2 version"))
+ end
+ local ref
+ if tag == "^" then
+ e2lib.warnf("WOTHER", "using e2 version by branch")
+ ref = string.format("refs/heads/%s", branch)
+ else
+ ref = string.format("refs/tags/%s", tag)
+ end
+ -- build an extension table pointing to e2factory core only
+ extensions = {
+ {
+ name = "e2factory",
+ ref=ref,
+ }
+ }
end
-e2lib.logf(2, "installing tool version: %s", ref)
-
rc, re = e2lib.chdir(".e2")
if not rc then
e2lib.abort(e:cat(re))
end
-local _ext = {}
-local extensions = {}
--- 'e2factory' is handled like any other extension, but enabled by default
-_ext["e2factory"] = true
-exf = io.open("extensions", "r")
-if exf then
- for ex in exf:lines() do
- _ext[ex] = true
- end
- exf:close()
-end
-for ex,_ in pairs(_ext) do
- table.insert(extensions, ex)
-end
-
for _,ex in ipairs(extensions) do
-- change to the project root directory
rc, re = e2lib.chdir(root .. "/.e2")
if not rc then
e2lib.abort(e:cat(re))
end
- print("installing extension: " .. ex)
+ print(string.format("installing extension: %s (tag %s)", ex.name, ex.ref))
local server = config.site.e2_server
- local location = string.format("%s/%s.git", config.site.e2_base, ex)
- local destdir = ex
+ local location = string.format("%s/%s.git", config.site.e2_base, ex.name)
+ local destdir = ex.name
local skip_checkout = false
rc, re = e2lib.rm(destdir, "-fr")
if not rc then
e2lib.chdir(destdir)
-- checkout ref
- local args = string.format("--track -b tmp '%s'", ref)
+ local args = string.format("--track -b tmp '%s'", ex.ref)
rc, re = e2lib.git(nil, "checkout", args)
if not rc then
e2lib.abort(e:cat(re))
#!/bin/sh
export LC_ALL=C
-while [ '!' -f .e2/e2version ] ; do
+while [ '!' -d .e2 ] ; do
if [ "$PWD" = "/" ] ; then
echo >&2 \
"e2-locate-project-root: Not in a project environment."