From 1e62a126b26cb542ce3fa7c531c98e48e16c6c5e Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Mon, 20 Aug 2012 12:45:12 +0200 Subject: [PATCH] Fix indentation Signed-off-by: Tobias Ulmer --- global/e2-create-project.lua | 154 ++++++++++++------------- global/e2-fetch-project.lua | 91 +++++++-------- global/e2-install-e2.lua | 126 ++++++++++---------- global/e2-root.lua.in | 215 ++++++++++++++++++----------------- global/e2.lua.in | 78 ++++++------- 5 files changed, 336 insertions(+), 328 deletions(-) diff --git a/global/e2-create-project.lua b/global/e2-create-project.lua index 2c78449..f8b7ad4 100644 --- a/global/e2-create-project.lua +++ b/global/e2-create-project.lua @@ -41,55 +41,55 @@ Create a new project and store it on in . defaults to '%s'. ]] e2option.documentation = string.format(doc, - e2lib.globals.default_projects_server) +e2lib.globals.default_projects_server) local opts, arguments = e2option.parse(arg) local rc, e = e2lib.read_global_config() if not rc then - e2lib.abort(e) + e2lib.abort(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)) + e2lib.abort(e:cat(re)) end local scache, re = e2lib.setup_cache() if not scache then - e2lib.abort(e:cat(re)) + e2lib.abort(e:cat(re)) end -- standard global tool setup finished if e2lib.globals.osenv["E2_LOCAL_TAG"] and e2lib.globals.osenv["E2_LOCAL_BRANCH"] then - e2lib.globals.local_e2_branch = e2lib.globals.osenv["E2_LOCAL_BRANCH"] - e2lib.globals.local_e2_tag = e2lib.globals.osenv["E2_LOCAL_TAG"] + e2lib.globals.local_e2_branch = e2lib.globals.osenv["E2_LOCAL_BRANCH"] + e2lib.globals.local_e2_tag = e2lib.globals.osenv["E2_LOCAL_TAG"] elseif e2lib.globals.osenv["E2_LOCAL_TAG"] then - e2lib.globals.local_e2_branch = "-" - e2lib.globals.local_e2_tag = e2lib.globals.osenv["E2_LOCAL_TAG"] + e2lib.globals.local_e2_branch = "-" + e2lib.globals.local_e2_tag = e2lib.globals.osenv["E2_LOCAL_TAG"] elseif e2lib.globals.osenv["E2_LOCAL_BRANCH"] then - e2lib.globals.local_e2_branch = e2lib.globals.osenv["E2_LOCAL_BRANCH"] - e2lib.globals.local_e2_tag = "^" + e2lib.globals.local_e2_branch = e2lib.globals.osenv["E2_LOCAL_BRANCH"] + e2lib.globals.local_e2_tag = "^" else - e2lib.globals.local_e2_branch = config.site.e2_branch - e2lib.globals.local_e2_tag = config.site.e2_tag + e2lib.globals.local_e2_branch = config.site.e2_branch + e2lib.globals.local_e2_tag = config.site.e2_tag end if #arguments ~= 1 then - e2option.usage(1) + e2option.usage(1) end local sl, re = e2lib.parse_server_location(arguments[1], - e2lib.globals.default_projects_server) +e2lib.globals.default_projects_server) if not sl then - e2lib.abort(e:cat(re)) + e2lib.abort(e:cat(re)) end local p = {} p.version = buildconfig.GLOBAL_INTERFACE_VERSION[1] -- the project version p.e2version = string.format("%s %s", e2lib.globals.local_e2_branch, - e2lib.globals.local_e2_tag) +e2lib.globals.local_e2_tag) p.server = sl.server -- the server p.location = sl.location -- the project location p.name = e2lib.basename(sl.location) -- the project basename @@ -102,31 +102,31 @@ e2lib.chdir(tmpdir) local version = string.format("%d\n", p.version) local empty = "" files = { - { filename = "version", content=version }, - { filename = "proj/.keep", content=empty }, - { filename = "git/.keep", content=empty }, - { filename = "files/.keep", content=empty }, - { filename = "cvs/.keep", content=empty }, - { filename = "svn/.keep", content=empty }, + { filename = "version", content=version }, + { filename = "proj/.keep", content=empty }, + { filename = "git/.keep", content=empty }, + { filename = "files/.keep", content=empty }, + { filename = "cvs/.keep", content=empty }, + { filename = "svn/.keep", content=empty }, } for _,f in ipairs(files) do - local dir = e2lib.dirname(f.filename) - rc, re = e2lib.mkdir(dir, "-p") - if not rc then - e2lib.abort(e:cat(re)) - end - rc, re = e2lib.write_file(f.filename, f.content) - if not rc then - e2lib.abort(e:cat(re)) - end - local sourcefile = string.format("%s/%s", tmpdir, f.filename) - local flocation = string.format("%s/%s", p.location, f.filename) - local cache_flags = {} - rc, re = cache.push_file(scache, sourcefile, p.server, flocation, - cache_flags) - if not rc then - e2lib.abort(e:cat(re)) - end + local dir = e2lib.dirname(f.filename) + rc, re = e2lib.mkdir(dir, "-p") + if not rc then + e2lib.abort(e:cat(re)) + end + rc, re = e2lib.write_file(f.filename, f.content) + if not rc then + e2lib.abort(e:cat(re)) + end + local sourcefile = string.format("%s/%s", tmpdir, f.filename) + local flocation = string.format("%s/%s", p.location, f.filename) + local cache_flags = {} + rc, re = cache.push_file(scache, sourcefile, p.server, flocation, + cache_flags) + if not rc then + e2lib.abort(e:cat(re)) + end end e2lib.chdir("/") e2lib.rmtempdir(tmpdir) @@ -138,7 +138,7 @@ e2lib.chdir(tmpdir) 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)) + e2lib.abort(e:cat(re)) end -- works up to this point @@ -147,28 +147,28 @@ end local url = string.format("file://%s/.git", tmpdir) rc, re = e2lib.git(nil, "init-db") if not rc then - e2lib.abort(e:cat(re)) + e2lib.abort(e:cat(re)) end local gitignore = e2lib.read_template("gitignore") if not gitignore then - e2lib.abort(re) + e2lib.abort(re) end local chroot, re = e2lib.read_template("proj/chroot") if not chroot then - e2lib.abort(re) + e2lib.abort(re) end local licences, re = e2lib.read_template("proj/licences") if not licences then - e2lib.abort(re) + e2lib.abort(re) end local env, re = e2lib.read_template("proj/env") if not env then - e2lib.abort(re) + e2lib.abort(re) end local pconfig, re = e2lib.read_template("proj/config") if not pconfig then - e2lib.abort(re) + e2lib.abort(re) end pconfig = pconfig:gsub("<>", p.name) pconfig = pconfig:gsub("<>", p.name) @@ -179,55 +179,57 @@ local e2version = string.format("%s\n", p.e2version) local syntax = string.format("%s\n", buildconfig.SYNTAX[1]) local empty = "" files = { - { filename = ".e2/.keep", content=empty }, - { filename = "in/.keep", content=empty }, - { filename = "log/.keep", content=empty }, - { filename = "proj/init/.keep", content=empty }, - { filename = "res/.keep", content=empty }, - { filename = "src/.keep", content=empty }, - { filename = "proj/chroot", content=chroot }, - { filename = "proj/licences", content=licences }, - { filename = "proj/env", content=env }, - { filename = "proj/config", content=pconfig }, - { filename = ".e2/syntax", content=syntax }, - { filename = ".e2/e2version", content=e2version }, - { filename = ".gitignore", content=gitignore }, + { filename = ".e2/.keep", content=empty }, + { filename = "in/.keep", content=empty }, + { filename = "log/.keep", content=empty }, + { filename = "proj/init/.keep", content=empty }, + { filename = "res/.keep", content=empty }, + { filename = "src/.keep", content=empty }, + { filename = "proj/chroot", content=chroot }, + { filename = "proj/licences", content=licences }, + { filename = "proj/env", content=env }, + { filename = "proj/config", content=pconfig }, + { filename = ".e2/syntax", content=syntax }, + { filename = ".e2/e2version", content=e2version }, + { filename = ".gitignore", content=gitignore }, } for _,f in ipairs(files) do - local dir = e2lib.dirname(f.filename) - rc, re = e2lib.mkdir(dir, "-p") - if not rc then - e2lib.abort(e:cat(re)) - end - rc, re = e2lib.write_file(f.filename, f.content) - if not rc then - e2lib.abort(e:cat(re)) - end - rc, re = e2lib.git(nil, "add", f.filename) - if not rc then - e2lib.abort(e:cat(re)) - end + local dir = e2lib.dirname(f.filename) + rc, re = e2lib.mkdir(dir, "-p") + if not rc then + e2lib.abort(e:cat(re)) + end + rc, re = e2lib.write_file(f.filename, f.content) + if not rc then + e2lib.abort(e:cat(re)) + end + rc, re = e2lib.git(nil, "add", f.filename) + if not rc then + e2lib.abort(e:cat(re)) + end end rc, re = e2lib.write_extension_config(config.site.default_extensions) if not rc then - e2lib.abort(e:cat(re)) + e2lib.abort(e:cat(re)) end rc, re = e2lib.git(nil, "add", e2lib.globals.extension_config) if not rc then - e2lib.abort(e:cat(re)) + e2lib.abort(e:cat(re)) end rc, re = e2lib.git(nil, "commit", "-m \"project setup\"") if not rc then - e2lib.abort(e:cat(re)) + e2lib.abort(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)) + e2lib.abort(e:cat(re)) end e2lib.chdir("/") e2lib.rmtempdir(tmpdir) e2lib.finish() + +-- vim:sw=4:sts=4:et: diff --git a/global/e2-fetch-project.lua b/global/e2-fetch-project.lua index 005c69b..b378813 100644 --- a/global/e2-fetch-project.lua +++ b/global/e2-fetch-project.lua @@ -42,7 +42,7 @@ fetch the project located in server:location to a directory given in defaults to '%s'. ]] e2option.documentation = string.format(doc, - e2lib.globals.default_projects_server) +e2lib.globals.default_projects_server) e2option.option("branch", "retrieve a specific project branch") e2option.option("tag", "retrieve a specific project tag") @@ -50,7 +50,7 @@ e2option.option("tag", "retrieve a specific project tag") local opts, arguments = e2option.parse(arg) local rc, re = e2lib.read_global_config() if not rc then - e2lib.abort(e:cat(re)) + e2lib.abort(e:cat(re)) end e2lib.init2() @@ -60,22 +60,22 @@ local config = e2lib.get_global_config() -- setup cache local scache, re = e2lib.setup_cache() if not scache then - e2lib.abort(e:cat(re)) + e2lib.abort(e:cat(re)) end -- standard global tool setup finished if #arguments < 1 then - e2lib.abort("specify path to a project to fetch") + e2lib.abort("specify path to a project to fetch") end if #arguments > 2 then - e2lib.abort("too many arguments") + e2lib.abort("too many arguments") end local sl, re = e2lib.parse_server_location(arguments[1], - e2lib.globals.default_projects_server) +e2lib.globals.default_projects_server) if not sl then - e2lib.abort(e:cat(re)) + e2lib.abort(e:cat(re)) end local p = {} @@ -83,41 +83,41 @@ p.server = sl.server p.location = sl.location p.name = e2lib.basename(p.location) if arguments[2] then - p.destdir = arguments[2] + p.destdir = arguments[2] else - p.destdir = p.name + p.destdir = p.name end if opts["branch"] then - p.branch = opts["branch"] + p.branch = opts["branch"] else - p.branch = nil + p.branch = nil end if opts["tag"] then - p.tag = opts["tag"] + p.tag = opts["tag"] else - p.tag = nil + p.tag = nil end -- fetch project descriptor file local tmpdir = e2lib.mktempdir() local location = string.format("%s/version", p.location) local rc, re = cache.fetch_file(scache, p.server, location, tmpdir, nil, - { cache = false }) +{ cache = false }) if not rc then - e2lib.abort(e:cat(re)) + e2lib.abort(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)) + e2lib.abort(e:cat(re)) end e2lib.rmtempdir() v = tonumber(line:match("[0-9]+")) if not v or v < 1 or v > 2 then - e2lib.abort(e:append("unhandled project version")) + e2lib.abort(e:append("unhandled project version")) end -- version is 1 or 2 @@ -127,43 +127,43 @@ local location = string.format("%s/proj/%s.git", p.location, p.name) local skip_checkout = false local destdir = p.destdir local rc, re = generic_git.git_clone_from_server(scache, p.server, location, - p.destdir, skip_checkout) +p.destdir, skip_checkout) if not rc then - e2lib.abort(e:cat(re)) + e2lib.abort(e:cat(re)) end e2lib.chdir(p.destdir) -- checkout the desired branch, if a branch was given if p.branch then - local e = e:append("checking out branch failed: %s", p.branch) - local args = string.format("-n1 refs/heads/%s", p.branch) - local rc, re = e2lib.git(nil, "rev-list", args) - if not rc then - local args = string.format( - "--track -b '%s' 'origin/%s'", p.branch, p.branch) - local rc, re = e2lib.git(nil, "checkout", args) + local e = e:append("checking out branch failed: %s", p.branch) + local args = string.format("-n1 refs/heads/%s", p.branch) + local rc, re = e2lib.git(nil, "rev-list", args) if not rc then - e2lib.abort(e:cat(re)) + local args = string.format( + "--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)) + end end - end end -- checkout the desired tag, if a tag was given if p.tag then - local e = e:append("checking out tag failed: %s", p.tag) - if p.branch then - -- branch and tag were specified. The working branch was created above. - -- Warn and go on checking out the tag... - e2lib.warnf("WOTHER", - "switching to tag '%s' after checking out branch '%s'", - p.tag, p.branch) - 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)) - end + local e = e:append("checking out tag failed: %s", p.tag) + if p.branch then + -- branch and tag were specified. The working branch was created above. + -- Warn and go on checking out the tag... + e2lib.warnf("WOTHER", + "switching to tag '%s' after checking out branch '%s'", + p.tag, p.branch) + 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)) + end end -- write project location file @@ -171,19 +171,20 @@ local file = ".e2/project-location" 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)) + e2lib.abort(e:cat(re)) end -- write version file local rc, re = e2lib.write_file(e2lib.globals.global_interface_version_file, - string.format("%d\n", v)) +string.format("%d\n", v)) -- call e2-install-e2 e2_install_e2 = string.format("%s %s/e2-install-e2", - e2lib.shquote(buildconfig.LUA), e2lib.shquote(buildconfig.TOOLDIR)) +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")) + e2lib.abort(err.new("installing local e2 failed")) end e2lib.finish() +-- vim:sw=4:sts=4:et: diff --git a/global/e2-install-e2.lua b/global/e2-install-e2.lua index 1f24195..9b4f3ec 100644 --- a/global/e2-install-e2.lua +++ b/global/e2-install-e2.lua @@ -43,7 +43,7 @@ local opts, arguments = e2option.parse(arg) local root = e2lib.locate_project_root() if not root then - e2lib.abort("can't locate project root.") + e2lib.abort("can't locate project root.") end -- try to get project specific config file paht @@ -53,7 +53,7 @@ local config_file = e2lib.read_line(config_file_config) local rc, e = e2lib.read_global_config(config_file) if not rc then - e2lib.abort(e) + e2lib.abort(e) end e2lib.init2() local e = err.new("e2-install-e2 failed") @@ -61,18 +61,18 @@ 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") + e2lib.abort("no servers configured in global config") end local scache, re = e2lib.setup_cache() if not scache then - e2lib.abort(e:cat(re)) + e2lib.abort(e:cat(re)) end -- standard global tool setup finished if #arguments > 0 then - e2option.usage(1) + e2option.usage(1) end local rc, re @@ -80,18 +80,18 @@ local rc, re -- change to the project root directory rc, re = e2lib.chdir(root) if not rc then - e2lib.abort(e:cat(re)) + e2lib.abort(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)) + e2lib.abort(e:cat(re)) end v = tonumber(line:match("[0-9]+")) if not v or v < 1 or v > 2 then - e2lib.abort(e:append("unhandled project version")) + e2lib.abort(e:append("unhandled project version")) end -- version is 1 or 2 @@ -99,42 +99,42 @@ end -- 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)) + e2lib.abort(e:cat(re)) end e2lib.logf(2, "installing local tools") local extensions if e2util.exists(e2lib.globals.extension_config) then - extensions, re = e2lib.read_extension_config() - if not extensions then - e2lib.abort(e:cat(re)) - end + extensions, re = e2lib.read_extension_config() + if not extensions then + e2lib.abort(e:cat(re)) + end else - e2lib.warnf("WOTHER", "extension configuration not available") - extensions = {} -- empty list + e2lib.warnf("WOTHER", "extension configuration not available") + extensions = {} -- empty list end 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")) + e2lib.abort(e:append("cannot parse e2 version")) end local ref if tag == "^" then - e2lib.warnf("WOTHER", "using e2 version by branch") - if branch:match("/") then - ref = branch - else - ref = string.format("remotes/origin/%s", branch) - end + e2lib.warnf("WOTHER", "using e2 version by branch") + if branch:match("/") then + ref = branch + else + ref = string.format("remotes/origin/%s", branch) + end else - ref = string.format("refs/tags/%s", tag) + ref = string.format("refs/tags/%s", tag) end rc, re = e2lib.chdir(".e2") if not rc then - e2lib.abort(e:cat(re)) + e2lib.abort(e:cat(re)) end -- checkout e2factory itself @@ -144,9 +144,9 @@ local destdir = "e2" local skip_checkout = false e2lib.logf(2, "fetching e2factory (ref %s)", ref) rc, re = generic_git.git_clone_from_server(scache, server, location, - destdir, skip_checkout) +destdir, skip_checkout) if not rc then - e2lib.abort(e:cat(re)) + e2lib.abort(e:cat(re)) end e2lib.chdir(destdir) @@ -154,55 +154,57 @@ 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)) + e2lib.abort(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)) - end - local ref - if ex.ref:match("/") then - ref = ex.ref - else - ref = string.format("refs/tags/%s", ex.ref) - end - e2lib.logf(2, "fetching extension: %s (%s)", ex.name, ref) - local server = config.site.e2_server - 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.abort(e:cat(re)) - end - rc, re = generic_git.git_clone_from_server(scache, server, location, - destdir, skip_checkout) - if not rc then - e2lib.abort(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)) - end + -- change to the e2factory extensions directory + rc, re = e2lib.chdir(root .. "/.e2/e2/extensions") + if not rc then + e2lib.abort(e:cat(re)) + end + local ref + if ex.ref:match("/") then + ref = ex.ref + else + ref = string.format("refs/tags/%s", ex.ref) + end + e2lib.logf(2, "fetching extension: %s (%s)", ex.name, ref) + local server = config.site.e2_server + 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.abort(e:cat(re)) + end + rc, re = generic_git.git_clone_from_server(scache, server, location, + destdir, skip_checkout) + if not rc then + e2lib.abort(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)) + end end -- build and install e2lib.logf(2, "building e2factory") rc, re = e2lib.chdir(root .. "/.e2/e2") if not rc then - e2lib.abort(e:cat(re)) + e2lib.abort(e:cat(re)) end local cmd = string.format("make PREFIX=%s BINDIR=%s local install-local", - e2lib.shquote(buildconfig.PREFIX), e2lib.shquote(buildconfig.BINDIR)) +e2lib.shquote(buildconfig.PREFIX), e2lib.shquote(buildconfig.BINDIR)) rc, re = e2lib.callcmd_capture(cmd) if rc ~= 0 then - e2lib.abort(e:cat(re)) + e2lib.abort(e:cat(re)) end e2lib.finish() + +-- vim:sw=4:sts=4:et: diff --git a/global/e2-root.lua.in b/global/e2-root.lua.in index d72dae8..8d6e4c7 100644 --- a/global/e2-root.lua.in +++ b/global/e2-root.lua.in @@ -37,156 +37,157 @@ rm_tool = "@RM_TOOL@" compat_2_1 = true -- be compatible with e2-2.1? function assert_chroot_environment(path) - local fname = string.format("%s/emlix-chroot", path) - local f = io.open(fname, "r") - if not f then - print("not a chroot environment") - os.exit(99) - end - f:close() - return true + local fname = string.format("%s/emlix-chroot", path) + local f = io.open(fname, "r") + if not f then + print("not a chroot environment") + os.exit(99) + end + f:close() + return true end -- e2-root ... if arg[1] == "chroot_2_2" then - -- 2_2_chroot - local path = arg[2] - local command = arg[3] - if (not path) or (not command) or #arg ~= 3 then - print("wrong arguments") - os.exit(99) - end - assert_chroot_environment(path) - local cmd = string.format("%s -i %s '%s' %s", env_tool, chroot_tool, path, - command) - local rc = os.execute(cmd) - os.exit(rc/256) + -- 2_2_chroot + local path = arg[2] + local command = arg[3] + if (not path) or (not command) or #arg ~= 3 then + print("wrong arguments") + os.exit(99) + end + assert_chroot_environment(path) + local cmd = string.format("%s -i %s '%s' %s", env_tool, chroot_tool, path, + command) + local rc = os.execute(cmd) + os.exit(rc/256) elseif arg[1] == "extract_tar_2_2" then - -- extract_tar_2_2 - local path = arg[2] - local tartype = arg[3] - local file = arg[4] - if (not path) or (not tartype) or (not file) or #arg ~= 4 then - print("wrong arguments") - os.exit(99) - end - assert_chroot_environment(path) - if tartype == "tar.gz" then - tarflags = "-z" - elseif tartype == "tar.bz2" then - tarflags = "-j" - elseif tartype == "tar" then - tarflags = "" - end - local cmd = string.format("%s -i %s %s -C '%s' -xf '%s'", - env_tool, tar_tool, tarflags, path, file) - local rc = os.execute(cmd) - os.exit(rc/256) + -- extract_tar_2_2 + local path = arg[2] + local tartype = arg[3] + local file = arg[4] + if (not path) or (not tartype) or (not file) or #arg ~= 4 then + print("wrong arguments") + os.exit(99) + end + assert_chroot_environment(path) + if tartype == "tar.gz" then + tarflags = "-z" + elseif tartype == "tar.bz2" then + tarflags = "-j" + elseif tartype == "tar" then + tarflags = "" + end + local cmd = string.format("%s -i %s %s -C '%s' -xf '%s'", + env_tool, tar_tool, tarflags, path, file) + local rc = os.execute(cmd) + os.exit(rc/256) elseif arg[1] == "set_permissions_2_2" then - -- set_permissions_2_2 - local path = arg[2] - if (not path) then - print("wrong arguments") - os.exit(99) - end - assert_chroot_environment(path) - local cmd = string.format("%s -i %s root:root '%s'", env_tool, chown_tool, - path) - local rc = os.execute(cmd) - os.exit(rc/256) + -- set_permissions_2_2 + local path = arg[2] + if (not path) then + print("wrong arguments") + os.exit(99) + end + assert_chroot_environment(path) + local cmd = string.format("%s -i %s root:root '%s'", env_tool, chown_tool, + path) + local rc = os.execute(cmd) + os.exit(rc/256) elseif arg[1] == "remove_chroot_2_2" then - -- remove_chroot_2_2 - local path = arg[2] - if (not path) then - print("wrong arguments") - os.exit(99) - end - assert_chroot_environment(path) - local cmd = string.format("%s -i %s -fr '%s'", env_tool, rm_tool, path) - local rc = os.execute(cmd) - os.exit(rc/256) + -- remove_chroot_2_2 + local path = arg[2] + if (not path) then + print("wrong arguments") + os.exit(99) + end + assert_chroot_environment(path) + local cmd = string.format("%s -i %s -fr '%s'", env_tool, rm_tool, path) + local rc = os.execute(cmd) + os.exit(rc/256) end -- e2-root <...> if not compat_2_1 then - print("unknown command") - os.exit(3) + print("unknown command") + os.exit(3) end if #arg < 4 then - print("too few arguments") - os.exit(3) + print("too few arguments") + os.exit(3) end local call = {} call.username = os.getenv("USER") if not call.username then - print("can't get USER environment variable") - os.exit(3) + print("can't get USER environment variable") + os.exit(3) end call.cmd = arg[1] call.tmpdir = arg[2] .. "/e2build" call.proj = arg[3] call.result = arg[4] call.chroot_path = call.tmpdir .. "/" .. call.username .. "/" .. - call.proj .. "/" .. call.result .. "/chroot" +call.proj .. "/" .. call.result .. "/chroot" local rc = 1 if call.cmd == "setup-chroot" then - rc = os.execute("mkdir -p " .. call.chroot_path .. - " && touch \"" .. call.chroot_path .. "/emlix-chroot\"") - os.exit(rc/256) + rc = os.execute("mkdir -p " .. call.chroot_path .. + " && touch \"" .. call.chroot_path .. "/emlix-chroot\"") + os.exit(rc/256) elseif call.cmd == "extract-tar" then - call.file = arg[5] - local opts = "-xzf" - if string.match(call.file, ".bz2$") then - opts = "-xjf" - elseif string.match(call.file, ".tar$") then - opts = "-xf" - end - rc = os.execute("tar -C \"" .. call.chroot_path .. + call.file = arg[5] + local opts = "-xzf" + if string.match(call.file, ".bz2$") then + opts = "-xjf" + elseif string.match(call.file, ".tar$") then + opts = "-xf" + end + rc = os.execute("tar -C \"" .. call.chroot_path .. "\" " .. opts .. " \"" .. call.file .. "\"") - os.exit(rc/256) + os.exit(rc/256) elseif call.cmd == "prepare" then - rc = os.execute("PATH=/usr/sbin:/sbin:$PATH " .. - "T=\"/tmp/e2\" " .. - "r=\"" .. call.result .. "\" " .. - "chroot " .. call.chroot_path .. " " .. - "/bin/bash -e -x \"/tmp/e2/script/e2-runbuild-unpack-source\"") - os.exit(rc/256) + rc = os.execute("PATH=/usr/sbin:/sbin:$PATH " .. + "T=\"/tmp/e2\" " .. + "r=\"" .. call.result .. "\" " .. + "chroot " .. call.chroot_path .. " " .. + "/bin/bash -e -x \"/tmp/e2/script/e2-runbuild-unpack-source\"") + os.exit(rc/256) elseif call.cmd == "runbuild" then - rc = os.execute("PATH=/usr/sbin:/sbin:$PATH " .. - "T=\"/tmp/e2\" " .. - "r=\"" .. call.result .. "\" " .. - "chroot " .. call.chroot_path .. " " .. - "/bin/bash -e -x \"/tmp/e2/script/e2-runbuild-build\"") - os.exit(rc/256) + rc = os.execute("PATH=/usr/sbin:/sbin:$PATH " .. + "T=\"/tmp/e2\" " .. + "r=\"" .. call.result .. "\" " .. + "chroot " .. call.chroot_path .. " " .. + "/bin/bash -e -x \"/tmp/e2/script/e2-runbuild-build\"") + os.exit(rc/256) elseif call.cmd == "enter" then - local cmd = arg[5] - if cmd then - command = string.format(" -c \"%s\"", cmd) - else - command = "" - end - rc = os.execute("PATH=/usr/sbin:/sbin:$PATH " .. - "T=\"/tmp/e2\" " .. - "r=\"" .. call.result .. "\" " .. - "chroot " .. call.chroot_path .. " " .. - "/bin/bash --rcfile \"/tmp/e2/script/e2-runbuildrc\"" .. - command) - os.exit(rc/256) + local cmd = arg[5] + if cmd then + command = string.format(" -c \"%s\"", cmd) + else + command = "" + end + rc = os.execute("PATH=/usr/sbin:/sbin:$PATH " .. + "T=\"/tmp/e2\" " .. + "r=\"" .. call.result .. "\" " .. + "chroot " .. call.chroot_path .. " " .. + "/bin/bash --rcfile \"/tmp/e2/script/e2-runbuildrc\"" .. + command) + os.exit(rc/256) elseif call.cmd == "rm-chroot" then - rc = os.execute("rm -fr \"" .. call.chroot_path .. "\"") - os.exit(rc/256) + rc = os.execute("rm -fr \"" .. call.chroot_path .. "\"") + os.exit(rc/256) end print("unknown command") os.exit(3) +-- vim:sw=4:sts=4:et: diff --git a/global/e2.lua.in b/global/e2.lua.in index 957b3b1..ea9dd3d 100644 --- a/global/e2.lua.in +++ b/global/e2.lua.in @@ -37,7 +37,7 @@ e2lib.init() e2option.documentation = [[ usage: e2 OPTION ... - e2 COMMAND ARGUMENT ... +e2 COMMAND ARGUMENT ... "e2" is a wrapper script for invoking e2 commands. Any e2 commands called will be redirected either to the project-local or the global installation, depend‐ @@ -45,10 +45,10 @@ ing on whether the invocation took place inside or outside a project tree. ]] e2option.flag("prefix", "print installation prefix", - function() - print(buildconfig.PREFIX) - os.exit(0) - end) +function() + print(buildconfig.PREFIX) + os.exit(0) +end) local root = e2lib.locate_project_root() @@ -56,57 +56,57 @@ e2call = {} e2call.basename = e2lib.basename(arg[0]) local function quoteargs(argstr) -- probably has to do escaping? - if #argstr == 0 then return "" - else return "'" .. argstr .. "'" end + if #argstr == 0 then return "" + else return "'" .. argstr .. "'" end end if e2call.basename == "e2" and arg[1] and string.sub(arg[1], 1, 1) ~= "-" then - e2call.toolname = "e2-" .. arg[1] - e2call.arg_string = quoteargs(table.concat(arg, "' '", 2)) + e2call.toolname = "e2-" .. arg[1] + e2call.arg_string = quoteargs(table.concat(arg, "' '", 2)) elseif e2call.basename == "e2" then - e2call.toolname = "e2" - local opts = e2option.parse(arg) - if #opts == 0 then - e2option.usage() - end - e2lib.finish(0) + e2call.toolname = "e2" + local opts = e2option.parse(arg) + if #opts == 0 then + e2option.usage() + end + e2lib.finish(0) else - e2call.toolname = e2call.basename - e2call.arg_string = quoteargs(table.concat(arg, "' '", 1)) + e2call.toolname = e2call.basename + e2call.arg_string = quoteargs(table.concat(arg, "' '", 1)) end e2call.globaltool = buildconfig.TOOLDIR .. "/" .. e2call.toolname if root then - e2call.localtool = root .. "/.e2/bin/" .. e2call.toolname + e2call.localtool = root .. "/.e2/bin/" .. e2call.toolname end if e2util.stat(e2call.globaltool) then - e2call.tool = e2call.globaltool - env = string.format("LUA_PATH='%s/?.lua' LUA_CPATH='%s/?.so'", - buildconfig.LIBDIR, buildconfig.LIBDIR) - lua = buildconfig.LUA - cmd = string.format("%s %s %s %s", env, lua, e2call.tool, e2call.arg_string) + e2call.tool = e2call.globaltool + env = string.format("LUA_PATH='%s/?.lua' LUA_CPATH='%s/?.so'", + buildconfig.LIBDIR, buildconfig.LIBDIR) + lua = buildconfig.LUA + cmd = string.format("%s %s %s %s", env, 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") + e2lib.abort(e2call.toolname .. + " is not a global tool and we're not in a project environment") 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 - env = "LUA_PATH='" .. root .. "/.e2/lib/e2/?.lc;" .. - root .. "/.e2/lib/e2/?.lua' " .. - "LUA_CPATH=" .. root .. "/.e2/lib/e2/?.so" - cmd = env .. " " .. - root .. "/.e2/bin/e2-lua " .. - e2call.tool .. " " .. e2call.arg_string + e2call.tool = e2call.localtool + -- Search for .lc files, the local e2 may be of an older version + env = "LUA_PATH='" .. root .. "/.e2/lib/e2/?.lc;" .. + root .. "/.e2/lib/e2/?.lua' " .. + "LUA_CPATH=" .. root .. "/.e2/lib/e2/?.so" + cmd = env .. " " .. + root .. "/.e2/bin/e2-lua " .. + e2call.tool .. " " .. e2call.arg_string else - e2lib.abort(e2call.toolname .. " is neither local nor global tool") + e2lib.abort(e2call.toolname .. " is neither local nor global tool") end function table_log(loglevel, t) - e2lib.log(loglevel, tostring(t)) - for k,v in pairs(t) do - e2lib.log(loglevel, k .. "\t->\t" .. v) - end + e2lib.log(loglevel, tostring(t)) + for k,v in pairs(t) do + e2lib.log(loglevel, k .. "\t->\t" .. v) + end end table_log(3, e2call) @@ -115,3 +115,5 @@ e2lib.log(3, "calling " .. e2call.tool) e2lib.log(4, cmd) local rc = os.execute(cmd) e2lib.finish(rc/256) + +-- vim:sw=4:sts=4:et: -- 2.39.5