From: Tobias Ulmer Date: Mon, 17 Sep 2012 12:03:36 +0000 (+0200) Subject: Remove dead code from e2tool X-Git-Tag: e2factory-2.3.13rc1~101 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=740c7d69096218149d7369e65fa3f5b82ee7c964;p=e2factory.git Remove dead code from e2tool Signed-off-by: Tobias Ulmer --- diff --git a/local/e2tool.lua b/local/e2tool.lua index 9a601aa..2d426a5 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -158,19 +158,6 @@ local strict = require("strict") -- @name env -- @class table --- --- e2tool.load_user_config(INFO, PATH, DEST, INDEX, VAR) --> OK? --- --- from the file at PATH, load a configuration named VAR. --- the resulting data is fixated and stored as DEST[INDEX]. --- fixating is done by the local function tablefixate, --- which keeps a list of all array member names in the specific --- array member ".fix". furthermore, the type of the configuration --- is memorized at ".e2". when storing the configuration back --- to permanent memory, only those table entries which are listed --- in the ".fix" array will be stored to the configuration file. --- storing details are described with e2tool.save_user_config below. - --- check if a table is a list of strings -- @param l table -- @param unique bool: require strings to be unique @@ -1616,85 +1603,6 @@ function e2tool.check_project_info(info, all, access, verbose) return true, nil end - --- Save user configuration file --- --- e2tool.save_user_config(PATH, CFG) --- --- Save a partial project configuration (source or result) --- into a file named PATH --- CFG is one of info.sources[s], info.results[r], info.chroot, --- info.licences --- --- e2tool.config_create(CONFIGTYPE) -> CGF --- --- Create and return an empty configuration. --- CONFIGTYPE is one of "e2source", "e2result", "e2chroot", --- "e2licence". --- --- e2tool.config_insert(CFG, KEY, VALUE) --- --- Add a new field to a source/result configuration entry. - -local function save_user_config(path, entry) - local function save_field(file, indent, key, value, ender) - file:write(ender .. "\n" .. string.rep(" ", indent)) - if type(key) ~= "number" then file:write(key .. " = ") end - if type(value) == "string" then - file:write("\"" .. value .. "\"") - elseif type(value) == "number" or type(value) == "boolean" then - file:write(tostring(value)) - elseif type(value) == "table" then - local e = "{" - for k, v in pairs(value) do - save_field(file, indent+1, k, v, e) - e = "," - end - if e == "," then - file:write("\n" .. string.rep(" ", indent) .. "}") - else - file:write("{}") - end - else - e2lib.bomb("unexpected data type in info field entry: " - .. type(value) .. " at " .. key) - end - end - local x = entry[".fix"] - if not x then e2lib.abort("fixature missing: " .. path) end - local f, msg = io.open(path, "w") - if not f then e2lib.abort("cannot write config " .. path .. ":" .. msg) end - f:write("-- config -*- Lua -*-\n\n") - f:write(x[".e2"] .. " ") - local e = "{" - for _, k in ipairs(x) do - save_field(f, 1, k, entry[k], e) - e = "," - end - f:write("\n}\n") - f:close() -end - -local function config_create(configtype) - if configtype ~= "e2source" and - configtype ~= "e2result" and - configtype ~= "e2chroot" and - configtype ~= "e2licence" then - e2lib.abort("unknown configuration type: " .. configtype) - end - local f = {} - f[".e2"] = configtype - local c = {} - c[".fix"] = f - return c -end - -local function config_insert(entry, key, value) - local k = key or (#entry + 1) - entry[k] = value - table.insert(entry[".fix"], k) -end - -- Dependency management -- -- e2tool.dsort(INFO) -> ARRAY @@ -1905,136 +1813,6 @@ function e2tool.e2_has_fixed_tag(info) return true end --- Check if a tag exists on the e2 tool repository --- --- e2tool.e2_tag_exists(tag) --- --- return true if the tag exists and false if not. - -local function e2_tag_exists(tag) - local rc = e2scm["git"].tag_available(tag, nil) - if rc then - e2lib.log(1, "Fatal: Tag exists in the local repository. FIXME") - return true - end - return false -end - --- Check if there are sources which are "on pseudo tags" --- --- e2tool.has_pseudotags(info) --- --- Return true if there is at least one source on a pseudo --- tag. - -local function has_pseudotags(info) - local rc=false - local l={} - e2lib.log(2, "Checking for pseudo tagged sources.") - for _,s in pairs(info.sources) do - if s.tag and s.tag == "^" then - e2lib.log(1, "Fatal: source " .. s.name .. " has pseudo tag.") - rc=true - table.insert(l, s.name) - end - end - return rc, l -end - --- Check if tags are available for all sources --- --- e2tool.tag_available(info, check_local, check_remote) --- --- Return true if the tags are available, false if not. --- Choose local and remote checking by setting check_local and --- check_remote. --- --- TODO: works with the null project. Use and/or write scm specific --- code to make it usable for projects that use non-git scms. - -local function tag_available(info, check_local, check_remote) - local missing_local = {} - local missing_remote = {} - local rc = true - --*** this code is basically broken and git-version specific - e2lib.log(2, "Checking for tag availability.") - for _,s in pairs(info.sources) do - if s.tag and check_local then - local cmd = string.format("GIT_DIR=in/%s/.git git rev-list " .. - "--max-count=1 refs/tags/%s --", e2lib.shquote(s.name), - e2lib.shquote(s.tag)) - rc = e2lib.callcmd_capture(cmd) - if rc ~= 0 then - e2lib.log(1, "Fatal: source " .. s.name - .. ": local tag not available: " .. s.tag) - rc = false - end - end - if s.tag and check_remote then - local server = lookup_server(info, s.server) - local cmd = string.format("GIT_DIR=%s/%s git rev-list --max-count=1 " .. - "refs/tags/%s --", e2lib.shquote(server), e2lib.shquote(s.remote), - e2lib.shquote(s.tag)) - rc = e2lib.callcmd_capture(cmd) - if rc ~= 0 then - e2lib.log(1, "Fatal: " .. s.name .. ": remote tag not available: " - .. s.tag) - rc = false - end - end - end -end - --- Do all checks required before tagging a project --- --- e2tool.pre_tag_check(info, check_local, check_remote) --- --- Return true if all checks succeed and false if not. --- For offline usage local and remote checking can be turned on --- as needed. - -local function pre_tag_check(info, tag, check_local, check_remote) - -- do all checks first - local e2_has_fixed_tag_flag, has_pseudotags_flag, has_pseudotags_list - local tag_unavailable_flag, e2_tag_exists_flag - e2_has_fixed_tag_flag = e2tool.e2_has_fixed_tag(info) - has_pseudotags_flag, has_pseudotags_list = has_pseudotags(info) - tag_unavailable_flag = tag_available(info, check_local, check_remote) - if tag then - e2_tag_exists_flag = e2_tag_exists(tag) - else - e2_tag_exists_flag = false - end - - -- return false if any fatal errors occured - if not e2_has_fixed_tag_flag or - has_pseudotags_flag or - tag_unavailable_flag or - e2_tag_exists_flag then - return false - end - return true -end - ---- calculate sourceids for all sources --- @param info --- @param sourceset --- @return bool --- @return an error object on failure -local function calc_sourceids(info, sourceset) - local e = err.new("calculating sourceids failed") - for _,src in pairs(info.sources) do - local sourceid, re = scm.sourceid(info, src.name, sourceset) - if not sourceid then - e:cat(re) - end - end - if e.getcount() > 1 then - return false, e - end - return true, nil -end - local function hashcache_write(info) local e = err.new("writing hash cache file") local f, msg = io.open(info.hashcache_file, "w") @@ -2220,24 +1998,6 @@ local function licenceid(info, licence) return lic.licenceid end ---- calculate licenceids for all licences --- @param info --- @return bool --- @return an error object on failure -local function calc_licenceids(info) - local e = err.new("calculating licenceids failed") - for l,_ in pairs(info.licences) do - local licenceid, re = licenceid(info, l) - if not licenceid then - e:cat(re) - end - end - if e.getcount() > 1 then - return false, e - end - return true, nil -end - --- return the first eight digits of buildid hash -- @param buildid string: hash value -- @return string: a short representation of the hash value