local opts, arguments = e2option.parse(arg)
local rc, e = e2lib.read_global_config()
if not rc then
- e2lib.abort(e)
+ return false, e
end
e2lib.init2()
local e = err.new("creating project failed")
local config, re = e2lib.get_global_config()
if not config then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
local scache, re = e2lib.setup_cache()
if not scache then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
-- standard global tool setup finished
local sl, re = e2lib.parse_server_location(arguments[1],
e2lib.globals.default_projects_server)
if not sl then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
local p = {}
local dir = e2lib.dirname(f.filename)
rc, re = e2lib.mkdir(dir, "-p")
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
rc, re = e2lib.write_file(f.filename, f.content)
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
local sourcefile = string.format("%s/%s", tmpdir, f.filename)
local flocation = string.format("%s/%s", p.location, f.filename)
rc, re = cache.push_file(scache, sourcefile, p.server, flocation,
cache_flags)
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
end
e2lib.chdir("/")
local rlocation = string.format("%s/proj/%s.git", p.location, p.name)
local rc, re = generic_git.git_init_db(scache, p.server, rlocation)
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
-- works up to this point
local url = string.format("file://%s/.git", tmpdir)
rc, re = e2lib.git(nil, "init-db")
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
local gitignore = e2lib.read_template("gitignore")
if not gitignore then
- e2lib.abort(re)
+ return false, re
end
local chroot, re = e2lib.read_template("proj/chroot")
if not chroot then
- e2lib.abort(re)
+ return false, re
end
local licences, re = e2lib.read_template("proj/licences")
if not licences then
- e2lib.abort(re)
+ return false, re
end
local env, re = e2lib.read_template("proj/env")
if not env then
- e2lib.abort(re)
+ return false, re
end
local pconfig, re = e2lib.read_template("proj/config")
if not pconfig then
- e2lib.abort(re)
+ return false, re
end
pconfig = pconfig:gsub("<<release_id>>", p.name)
pconfig = pconfig:gsub("<<name>>", p.name)
local dir = e2lib.dirname(f.filename)
rc, re = e2lib.mkdir(dir, "-p")
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
rc, re = e2lib.write_file(f.filename, f.content)
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
rc, re = e2lib.git(nil, "add", f.filename)
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
end
rc, re = e2lib.write_extension_config(config.site.default_extensions)
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
rc, re = e2lib.git(nil, "add", e2lib.globals.extension_config)
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
rc, re = e2lib.git(nil, "commit", "-m \"project setup\"")
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
local refspec = "master:refs/heads/master"
local rlocation = string.format("%s/proj/%s.git", p.location, p.name)
rc, re = generic_git.git_push(scache, ".git", p.server, rlocation, refspec)
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
e2lib.chdir("/")
e2lib.rmtempdir(tmpdir)
- e2lib.finish()
+
+ return true
end
local rc, re = e2_create_project(arg)
e2lib.abort(re)
end
+e2lib.finish(0)
+
-- vim:sw=4:sts=4:et:
local opts, arguments = e2option.parse(arg)
local rc, re = e2lib.read_global_config()
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
e2lib.init2()
-- setup cache
local scache, re = e2lib.setup_cache()
if not scache then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
-- standard global tool setup finished
if #arguments < 1 then
- e2lib.abort("specify path to a project to fetch")
+ return false, err.new("specify path to a project to fetch")
end
if #arguments > 2 then
- e2lib.abort("too many arguments")
+ return false, err.new("too many arguments")
end
local sl, re = e2lib.parse_server_location(arguments[1],
e2lib.globals.default_projects_server)
if not sl then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
local p = {}
local rc, re = cache.fetch_file(scache, p.server, location, tmpdir, nil,
{ cache = false })
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
-- read the version from the first line
local version_file = string.format("%s/version", tmpdir)
local line, re = e2lib.read_line(version_file)
if not line then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
e2lib.rmtempdir()
local v = tonumber(line:match("[0-9]+"))
if not v or v < 1 or v > 2 then
- e2lib.abort(e:append("unhandled project version"))
+ return false, e:append("unhandled project version")
end
-- version is 1 or 2
local rc, re = generic_git.git_clone_from_server(scache, p.server, location,
p.destdir, skip_checkout)
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
e2lib.chdir(p.destdir)
"--track -b '%s' 'origin/%s'", p.branch, p.branch)
local rc, re = e2lib.git(nil, "checkout", args)
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
end
end
local args = string.format("'refs/tags/%s'", p.tag)
local rc, re = e2lib.git(nil, "checkout", args)
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
end
local data = string.format("%s\n", p.location)
local rc, re = e2lib.write_file(file, data)
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
-- write version file
e2lib.shquote(buildconfig.LUA), e2lib.shquote(buildconfig.TOOLDIR))
rc, re = e2lib.callcmd_log(e2_install_e2)
if rc ~= 0 then
- e2lib.abort(err.new("installing local e2 failed"))
+ return false, err.new("installing local e2 failed")
end
- e2lib.finish()
return true
end
e2lib.abort(re)
end
+e2lib.finish(0)
+
-- vim:sw=4:sts=4:et:
local root = e2lib.locate_project_root()
if not root then
- e2lib.abort("can't locate project root.")
+ return false, err.new("can't locate project root.")
end
-- try to get project specific config file paht
local rc, e = e2lib.read_global_config(config_file)
if not rc then
- e2lib.abort(e)
+ return false, e
end
e2lib.init2()
local e = err.new("e2-install-e2 failed")
local config = e2lib.get_global_config()
local servers = config.servers
if not servers then
- e2lib.abort("no servers configured in global config")
+ return false, err.new("no servers configured in global config")
end
local scache, re = e2lib.setup_cache()
if not scache then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
-- standard global tool setup finished
-- change to the project root directory
rc, re = e2lib.chdir(root)
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
-- read the version from the first line
local line, re = e2lib.read_line(e2lib.globals.global_interface_version_file)
if not line then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
local v = tonumber(line:match("[0-9]+"))
if not v or v < 1 or v > 2 then
- e2lib.abort(e:append("unhandled project version"))
+ return false, e:append("unhandled project version")
end
-- version is 1 or 2
-- remove the old e2 source, installation and plugins, if it exists
rc, re = e2lib.rm(".e2/e2 .e2/bin .e2/lib .e2/plugins", "-fr")
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
e2lib.logf(2, "installing local tools")
if e2util.exists(e2lib.globals.extension_config) then
extensions, re = e2lib.read_extension_config()
if not extensions then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
else
e2lib.warnf("WOTHER", "extension configuration not available")
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"))
+ return false, e:append("cannot parse e2 version")
end
local ref
if tag == "^" then
rc, re = e2lib.chdir(".e2")
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
-- checkout e2factory itself
rc, re = generic_git.git_clone_from_server(scache, server, location,
destdir, false)
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
e2lib.chdir(destdir)
local args = string.format("%s --", ref)
rc, re = e2lib.git(nil, "checkout", args)
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
for _,ex in ipairs(extensions) do
-- change to the e2factory extensions directory
rc, re = e2lib.chdir(root .. "/.e2/e2/extensions")
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
local ref
if ex.ref:match("/") then
local destdir = ex.name
rc, re = e2lib.rm(destdir, "-fr")
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
rc, re = generic_git.git_clone_from_server(scache, server, location,
destdir, false)
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
e2lib.chdir(destdir)
-- checkout ref
rc, re = e2lib.git(nil, "checkout", ref)
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
end
e2lib.logf(2, "building e2factory")
rc, re = e2lib.chdir(root .. "/.e2/e2")
if not rc then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
local cmd = string.format("make PREFIX=%s BINDIR=%s local install-local",
e2lib.shquote(buildconfig.PREFIX), e2lib.shquote(buildconfig.BINDIR))
rc, re = e2lib.callcmd_capture(cmd)
if rc ~= 0 then
- e2lib.abort(e:cat(re))
+ return false, e:cat(re)
end
- e2lib.finish()
+ return true
end
local rc, re = e2_install_e2(arg)
e2lib.abort(re)
end
+e2lib.finish(0)
+
-- vim:sw=4:sts=4:et:
local e2lib = require("e2lib")
local e2option = require("e2option")
+local err = require("err")
require("buildconfig")
require("e2util")
if #opts == 0 then
e2option.usage(1)
end
- e2lib.finish(0)
+ return 0
else
e2call.toolname = e2call.basename
e2call.arg_string = quoteargs(table.concat(arg, "' '", 1))
cmd = string.format("%s %s %s %s", env, buildconfig.LUA, e2call.tool,
e2call.arg_string)
elseif not root then
- e2lib.abort(e2call.toolname ..
- " is not a global tool and we're not in a project environment")
+ return false, err.new("%s is not a global tool and we're not in a project environment", e2call.toolname)
elseif root and e2util.stat(e2call.localtool) then
e2call.tool = e2call.localtool
-- Search for .lc files, the local e2 may be of an older version
root .. "/.e2/bin/e2-lua " ..
e2call.tool .. " " .. e2call.arg_string
else
- e2lib.abort(e2call.toolname .. " is neither local nor global tool")
+ return false,
+ err.new("%s is neither local nor global tool", e2call.toolname)
end
local function table_log(loglevel, t)
e2lib.log(3, "calling " .. e2call.tool)
e2lib.log(4, cmd)
local rc = os.execute(cmd)
- e2lib.finish(rc/256)
+
+ return rc/256
end
local rc, re = e2(arg)
e2lib.abort(re)
end
+e2lib.finish(rc)
+
-- vim:sw=4:sts=4:et: