]> git.e2factory.org Git - e2factory.git/commitdiff
Require err module, change new_error() to err.new()
authorTobias Ulmer <tu@emlix.com>
Wed, 8 Aug 2012 12:39:34 +0000 (14:39 +0200)
committerTobias Ulmer <tu@emlix.com>
Mon, 13 Aug 2012 10:22:07 +0000 (12:22 +0200)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
25 files changed:
generic/cache.lua
generic/e2lib.lua
generic/e2option.lua
generic/generic_git.lua
generic/hash.lua
generic/lock.lua
generic/plugin.lua
generic/transport.lua
global/e2-create-project.lua
global/e2-fetch-project.lua
global/e2-install-e2.lua
local/build.lua
local/cf.lua
local/cvs.lua
local/e2build.lua
local/e2tool.lua
local/fetch-sources.lua
local/files.lua
local/git.lua
local/ls-project.lua
local/new-source.lua
local/playground.lua
local/policy.lua
local/scm.lua
local/svn.lua

index 61b35cc63a67d2a86e852d54b7945f3451fb2d5a..ead3ba4fd38f0dbbfc88467f64b0ab348adabb14 100644 (file)
@@ -29,6 +29,7 @@ local cache = {}
 require("e2lib")
 local transport = require("transport")
 local url = require("url")
+local err = require("err")
 
 --- cache
 -- @class table
@@ -99,7 +100,7 @@ function cache.new_cache_entry(c, server, remote_url, flags, alias_server,
     ((remote_url and flags) and (alias_server and alias_location)))
     local ru, cu
     local rc, re
-    local e = new_error("error setting up cache entry")
+    local e = err.new("error setting up cache entry")
     local ce = {}
     local cache_url = nil
     if not remote_url then
@@ -165,7 +166,7 @@ function cache.ce_by_url(c, url)
             return ce, nil
         end
     end
-    return nil, new_error("no cache entry for url: %s", url)
+    return nil, err.new("no cache entry for url: %s", url)
 end
 
 --- get cache entry by server
@@ -179,7 +180,7 @@ function cache.ce_by_server(c, server)
             return ce, nil
         end
     end
-    return nil, new_error("no cache entry for server: %s", server)
+    return nil, err.new("no cache entry for server: %s", server)
 end
 
 --- check if server is valid
@@ -191,7 +192,7 @@ function cache.valid_server(c, server)
     if cache.ce_by_server(c, server) then
         return true
     else
-        return false, new_error("not a valid server: %s", server)
+        return false, err.new("not a valid server: %s", server)
     end
 end
 
@@ -294,7 +295,7 @@ end
 -- @return an error object on failure
 function cache.fetch_file(c, server, location, destdir, destname, flags)
     local rc, re
-    local e = new_error("cache: fetching file failed")
+    local e = err.new("cache: fetching file failed")
     local ce, re = cache.ce_by_server(c, server)
     if not ce then
         return false, e:cat(re)
@@ -344,7 +345,7 @@ end
 -- @return an error object on failure
 function cache.push_file(c, sourcefile, server, location, flags)
     local rc, re
-    local e = new_error("error pushing file to cache/server")
+    local e = err.new("error pushing file to cache/server")
     local ce, re = cache.ce_by_server(c, server)
     if not ce then
         return false, e:cat(re)
@@ -382,7 +383,7 @@ end
 -- @return bool
 -- @return an error object on failure
 function cache.writeback(c, server, location, flags)
-    local e = new_error("writeback failed")
+    local e = err.new("writeback failed")
     local rc, re
     local ce, re = cache.ce_by_server(c, server)
     if not ce then
@@ -413,7 +414,7 @@ end
 -- @return bool
 -- @return an error object on failure
 function cache.cache_file(c, server, location, flags)
-    local e = new_error("caching file failed: %s:%s", server, location)
+    local e = err.new("caching file failed: %s:%s", server, location)
     local rc, re
     local ce, re = cache.ce_by_server(c, server)
     if not ce then
@@ -454,7 +455,7 @@ end
 -- @return an error object on failure
 function cache.file_path(c, server, location, flags)
     local rc, re
-    local e = new_error("providing file path failed")
+    local e = err.new("providing file path failed")
     -- get the cache entry
     local ce, re = cache.ce_by_server(c, server)
     if not ce then
@@ -486,7 +487,7 @@ end
 -- @return an error object on failure
 function cache.set_writeback(c, server, value)
     if type(value) ~= "boolean" then
-        return false, new_error(
+        return false, err.new(
         "cache.set_writeback(): value is not boolean")
     end
     local rc, re = cache.valid_server(c, server)
index c083a1a86adbd64ac00c7c82a21f490341d9074d..72abbbaf5759486ade5950fe91eb5bc278c50a3b 100644 (file)
@@ -29,7 +29,7 @@ module("e2lib", package.seeall)
 require("strict")
 require("buildconfig")
 local lock = require("lock")
-require("err")
+local err = require("err")
 require("plugin")
 local tools = require("tools")
 local cache = require("cache")
@@ -176,7 +176,7 @@ end
 
 function init2()
   local rc, re
-  local e = new_error("initializing globals (step2)")
+  local e = err.new("initializing globals (step2)")
 
   -- get the global configuration
   local config = get_global_config()
@@ -552,7 +552,7 @@ function log(level, msg)
 end
 
 function rotate_log(file)
-  local e = new_error("rotating logfile: %s", file)
+  local e = err.new("rotating logfile: %s", file)
   local rc, re
   local logdir = dirname(file)
   local logfile = basename(file)
@@ -730,7 +730,7 @@ function tartype_by_suffix(filename)
        elseif filename:match("tar$") then
                tartype = "tar"
        else
-               e = new_error("unknown suffix for filename: %s", filename)
+               e = err.new("unknown suffix for filename: %s", filename)
                return false, e
        end
        return tartype
@@ -765,11 +765,11 @@ end
 function read_line(path)
   local f, msg = io.open(path)
   if not f then
-    return nil, new_error("%s", msg)
+    return nil, err.new("%s", msg)
   end
   local l, msg = f:read("*l")
   if not l then
-    return nil, new_error("%s", msg)
+    return nil, err.new("%s", msg)
   end
   f:close()
   return l
@@ -885,7 +885,7 @@ function read_global_config(e2_config_file)
 end
 
 function write_extension_config(extensions)
-  local e = new_error("writing extensions config: %s", globals.extension_config)
+  local e = err.new("writing extensions config: %s", globals.extension_config)
   local f, re = io.open(globals.extension_config, "w")
   if not f then
     return false, e:cat(re)
@@ -909,7 +909,7 @@ end
 -- @return the extension configuration table
 -- @return an error object on failure
 function read_extension_config()
-  local e = new_error("reading extension config file: %s",
+  local e = err.new("reading extension config file: %s",
                                                globals.extension_config)
   local rc = e2util.exists(globals.extension_config)
   if not rc then
@@ -1243,7 +1243,7 @@ function dofile_protected(path, gtable, allownewdefs)
 end
 
 function dofile2(path, gtable)
-  local e = new_error("error loading config file: %s", path)
+  local e = err.new("error loading config file: %s", path)
   local chunk, msg = loadfile(path)
   if not chunk then
     return false, e:cat(msg)
@@ -1265,7 +1265,7 @@ end
 
 function locate_project_root(path)
   local rc, re
-  local e = new_error("checking for project directory failed")
+  local e = err.new("checking for project directory failed")
   local save_path = e2util.cwd()
   if not save_path then
     return nil, e:append("cannot get current working directory")
@@ -1304,7 +1304,7 @@ function locate_project_root(path)
     end
   end
   chdir(save_path)
-  return nil, new_error("not in a project directory")
+  return nil, err.new("not in a project directory")
 end
 
 -- parse version files:
@@ -1570,7 +1570,7 @@ end
 -- @return an error object on failure
 function git(gitdir, subtool, args)
        local rc, re
-       local e = new_error("calling git failed")
+       local e = err.new("calling git failed")
        if not gitdir then
                gitdir = ".git"
        end
@@ -1745,7 +1745,7 @@ end
 function sha1sum(path)
   assert(type(path) == "string")
 
-  local e = new_error("calculating SHA1 checksum failed")
+  local e = err.new("calculating SHA1 checksum failed")
 
   local sha1sum, re = tools.get_tool("sha1sum")
   if not sha1sum then
@@ -1808,7 +1808,7 @@ end
 -- @return an error object on failure
 function get_sys_arch()
   local rc, re
-  local e = new_error("getting host system architecture failed")
+  local e = err.new("getting host system architecture failed")
   local uname = tools.get_tool("uname")
   local cmd = string.format("%s -m", e2lib.shquote(uname))
   local p, msg = io.popen(cmd, "r")
@@ -1876,11 +1876,11 @@ end
 function read_file(file)
   local f, msg = io.open(file, "r")
   if not f then
-    return nil, new_error("%s", msg)
+    return nil, err.new("%s", msg)
   end
   local s, msg = f:read("*a")
   if not s then
-    return nil, new_error("%s", msg)
+    return nil, err.new("%s", msg)
   end
   f:close()
   return s, nil
@@ -1891,7 +1891,7 @@ end
 -- @return string: the file content
 -- @return an error object on failure
 function read_template(file)
-  local e = new_error("error reading template file")
+  local e = err.new("error reading template file")
   local filename = string.format("%s/%s", globals.template_path, file)
   local template, re = read_file(filename)
   if not template then
@@ -1926,7 +1926,7 @@ end
 -- @return a cache object
 -- @return an error object on failure
 function setup_cache()
-  local e = new_error("setting up cache failed")
+  local e = err.new("setting up cache failed")
   local config = get_global_config()
   if type(config.cache) ~= "table" or type(config.cache.path) ~= "string" then
     return false, e:append("invalid cache configuration: config.cache.path")
@@ -1999,7 +1999,7 @@ function chdir(path)
   local rc, re
   rc, re = e2util.cd(path)
   if not rc then
-    return false, new_error("chdir %s failed: %s", path, re)
+    return false, err.new("chdir %s failed: %s", path, re)
   end
   return true, nil
 end
index c616b3218599d96c6c200f85147b44c2bca7f41a..1ebcbd67f8226bd570cfb60f343cdf715edf837d 100644 (file)
@@ -30,6 +30,7 @@ require("e2lib")
 require("e2util")
 require("collection")
 require("plugin")
+local err = require("err")
 
 -- Parsing of command-line options
 
@@ -73,7 +74,7 @@ aliases = {}
 -- @return nil
 function flag(name, doc, func, category)
   if options[ name ] then
-    return false, new_error("option exists: %s", name)
+    return false, err.new("option exists: %s", name)
   end
   options[ name ] = {type = "flag", documentation = doc or "", name = name,
     proc=func, default = true,
@@ -90,7 +91,7 @@ end
 -- @return nil
 function option(name, doc, default, func, argname)
   if options[ name ] then
-    return false, new_error("option exists: %s", name)
+    return false, err.new("option exists: %s", name)
   end
   options[ name ] = {type = "option", documentation = doc or "", name = name,
     proc=func, default=default or true,
index 1660963672610cfa0d309287d7f0b0062ed58a72..b226076d5608fec3ba55334c1a39d1b9d987e3e9 100644 (file)
@@ -32,6 +32,7 @@ local generic_git = {}
 local cache = require("cache")
 local url = require("url")
 local tools = require("tools")
+local err = require("err")
 
 --- clone a git repository
 -- @param surl url to the server
@@ -44,7 +45,7 @@ function generic_git.git_clone_url1(surl, location, destdir, skip_checkout)
         e2lib.abort("git_clone_url1(): missing parameter")
     end
     local rc, re
-    local e = new_error("cloning git repository")
+    local e = err.new("cloning git repository")
     local full_url = string.format("%s/%s", surl, location)
     local u, re = url.parse(full_url)
     if not u then
@@ -87,7 +88,7 @@ function generic_git.git_branch_new1(gitwc, track, branch, start_point)
     e2lib.shquote(start_point))
     local rc = e2lib.callcmd_capture(cmd)
     if rc ~= 0 then
-        return false, new_error("creating new branch failed")
+        return false, err.new("creating new branch failed")
     end
     return true, nil
 end
@@ -104,7 +105,7 @@ function generic_git.git_checkout1(gitwc, branch)
     e2lib.shquote(branch))
     local rc = e2lib.callcmd_capture(cmd)
     if rc ~= 0 then
-        return false, new_error("git checkout failed")
+        return false, err.new("git checkout failed")
     end
     return true, nil
 end
@@ -117,7 +118,7 @@ end
 function generic_git.git_rev_list1(gitdir, ref)
     e2lib.log(4, string.format("git_rev_list(): %s %s",
     tostring(gitdir), tostring(ref)))
-    local e = new_error("git rev-list failed")
+    local e = err.new("git rev-list failed")
     local rc, re
     local tmpfile = e2lib.mktempfile()
     local args = string.format("--max-count=1 '%s' -- >'%s'", ref, tmpfile)
@@ -133,7 +134,7 @@ function generic_git.git_rev_list1(gitdir, ref)
     f:close()
     e2lib.rmtempfile(tmpfile)
     if (not rev) or (not rev:match("^%S+$")) then
-        return nil, new_error("can't parse git rev-list output")
+        return nil, err.new("can't parse git rev-list output")
     end
     if rev then
         e2lib.log(4, string.format("git_rev_list: %s", rev))
@@ -151,7 +152,7 @@ function generic_git.git_init_db1(rurl)
     if (not rurl) then
         e2lib.abort("git_init_db1(): missing parameter")
     end
-    local e = new_error("running git_init_db")
+    local e = err.new("running git_init_db")
     local rc, re
     local u, re = url.parse(rurl)
     if not u then
@@ -190,7 +191,7 @@ function generic_git.git_push1(gitdir, rurl, refspec)
         e2lib.abort("git_push1(): missing parameter")
     end
     local rc, re
-    local e = new_error("git push failed")
+    local e = err.new("git push failed")
     local u, re = url.parse(rurl)
     if not u then
         return false, e:cat(re)
@@ -220,7 +221,7 @@ function generic_git.git_remote_add1(lurl, rurl, name)
         e2lib.abort("missing parameter")
     end
     local rc, re
-    local e = new_error("git remote-add failed")
+    local e = err.new("git remote-add failed")
     local lrepo, re = url.parse(lurl)
     if not lrepo then
         return false, e:cat(re)
@@ -256,7 +257,7 @@ function generic_git.git_url1(u)
     elseif u.transport == "file" then
         giturl = string.format("/%s", u.path)
     else
-        return nil, new_error("transport not supported: %s", u.transport)
+        return nil, err.new("transport not supported: %s", u.transport)
     end
     return giturl, nil
 end
@@ -272,7 +273,7 @@ end
 function generic_git.git_clone_from_server(c, server, location, destdir,
     skip_checkout)
     local rc, re
-    local e = new_error("cloning git repository")
+    local e = err.new("cloning git repository")
     local surl, re = cache.remote_url(c, server, location)
     if not surl then
         return false, e:cat(re)
@@ -292,7 +293,7 @@ end
 -- @return an error object on failure
 function generic_git.git_init_db(c, server, location)
     local rc, re
-    local e = new_error("initializing git repository")
+    local e = err.new("initializing git repository")
     local rurl, re = cache.remote_url(c, server, location)
     if not rurl then
         return false, e:cat(re)
@@ -314,7 +315,7 @@ end
 -- @return an error object on failure
 function generic_git.git_push(c, gitdir, server, location, refspec)
     local rc, re
-    local e = new_error("git push failed")
+    local e = err.new("git push failed")
     local rurl, re = cache.remote_url(c, server, location)
     if not rurl then
         return false, e:cat(re)
@@ -329,7 +330,7 @@ end
 -- @return an error object on failure
 function generic_git.git_config(gitdir, query)
     local rc, re
-    local e = new_error("running git config")
+    local e = err.new("running git config")
     local tmpfile = e2lib.mktempfile()
     local cmd = string.format("GIT_DIR=%s git config %s > %s",
     e2lib.shquote(gitdir), e2lib.shquote(query), e2lib.shquote(tmpfile))
@@ -353,7 +354,7 @@ end
 -- @return an error object on failure
 function generic_git.git_add(gitdir, args)
     local rc, re
-    local e = new_error("running git add")
+    local e = err.new("running git add")
     if not gitdir then
         gitdir = ".git"
     end
@@ -373,7 +374,7 @@ end
 -- @return an error object on failure
 function generic_git.git_commit(gitdir, args)
     local rc, re
-    local e = new_error("git commit failed")
+    local e = err.new("git commit failed")
     return e2lib.git("commit", gitdir, args)
 end
 
@@ -385,7 +386,7 @@ end
 function generic_git.verify_remote_tag(gitdir, tag)
     e2lib.logf(4, "generic_git.verify_remote_tag(%s, %s)", tostring(gitdir),
     tostring(tag))
-    local e = new_error("verifying remote tag")
+    local e = err.new("verifying remote tag")
     local rc, re
 
     -- fetch the remote tag
@@ -395,7 +396,7 @@ function generic_git.verify_remote_tag(gitdir, tag)
     tag, rtag)
     rc, re = e2lib.git(gitdir, "fetch", args)
     if not rc then
-        return false, new_error("remote tag is not available: %s", tag)
+        return false, err.new("remote tag is not available: %s", tag)
     end
 
     -- store commit ids for use in the error message, if any
@@ -436,7 +437,7 @@ end
 function generic_git.verify_clean_repository(gitwc)
     e2lib.logf(4, "generic_git.verify_clean_repository(%s)", tostring(gitwc))
     gitwc = gitwc or "."
-    local e = new_error("verifying that repository is clean")
+    local e = err.new("verifying that repository is clean")
     local rc, re
     local tmp = e2lib.mktempfile()
     rc, re = e2lib.chdir(gitwc)
@@ -459,7 +460,7 @@ function generic_git.verify_clean_repository(gitwc)
     if #files > 0 then
         local msg = "the following files are not checked into the repository:\n"
         msg = msg .. files
-        return false, new_error("%s", msg)
+        return false, err.new("%s", msg)
     end
     -- verify that the working copy matches HEAD
     local args = string.format("--name-only HEAD >%s", tmp)
@@ -476,7 +477,7 @@ function generic_git.verify_clean_repository(gitwc)
     if #files > 0 then
         msg = "the following files are modified:\n"
         msg = msg..files
-        return false, new_error("%s", msg)
+        return false, err.new("%s", msg)
     end
     -- verify that the index matches HEAD
     local args = string.format("--name-only --cached HEAD >%s", tmp)
@@ -493,7 +494,7 @@ function generic_git.verify_clean_repository(gitwc)
     if #files > 0 then
         msg = "the following files in index are modified:\n"
         msg = msg..files
-        return false, new_error("%s", msg)
+        return false, err.new("%s", msg)
     end
     return true
 end
@@ -508,7 +509,7 @@ function generic_git.verify_head_match_tag(gitwc, verify_tag)
     tostring(verify_tag))
     assert(verify_tag)
     gitwc = gitwc or "."
-    local e = new_error("verifying that HEAD matches 'refs/tags/%s'", verify_tag)
+    local e = err.new("verifying that HEAD matches 'refs/tags/%s'", verify_tag)
     local rc, re
     local tmp = e2lib.mktempfile()
     local args = string.format("--tags --match '%s' >%s", verify_tag, tmp)
@@ -557,7 +558,7 @@ end
 -- @return nil, or an error string on error
 function generic_git.new_repository(c, lserver, llocation, rserver, rlocation, flags)
     local rc, re
-    local e = new_error("setting up new git repository failed")
+    local e = err.new("setting up new git repository failed")
     local lserver_url, re = cache.remote_url(c, lserver, llocation)
     if not lserver_url then
         return false, e:cat(re)
index 9b0a4bae60ab5a4905c6d8a24558efc6a20cac75..df1be7948edd6d726eb264d499d51cafb23a7395 100644 (file)
@@ -28,6 +28,7 @@
 
 local hash = {}
 require("sha1")
+local err = require("err")
 
 --- create a hash context
 -- @return a hash context object, or nil on error
@@ -82,7 +83,7 @@ function hash.hash_file(hc, path)
 
     local fd = io.open(path, "r")
     if not fd then
-        return nil, new_error("could not open file '%s'", path)
+        return nil, err.new("could not open file '%s'", path)
     end
 
     local buf = ""
index 43064dcf0ca3b5d25b1e5ce8c2c554f717894a1c..c03845a62aceb908326fe2ca1654e834f6d25d5d 100644 (file)
@@ -30,6 +30,7 @@
 -- Remaining lock directories can be removed by calling the cleanup
 -- method.
 local lock = {}
+local err = require("err")
 
 --- create a new lock context
 -- @return table: the lock context
@@ -50,7 +51,7 @@ end
 -- @param dir string: lock directory
 -- @return boolean
 function lock.lock(l, dir)
-    local e = new_error("locking failed")
+    local e = err.new("locking failed")
 
     local rc, re = e2lib.mkdir(dir)
     if not rc then
@@ -66,7 +67,7 @@ end
 -- @param dir string: lock directory
 -- @return boolean
 function lock.unlock(l, dir)
-    local e = new_error("unlocking failed")
+    local e = err.new("unlocking failed")
     local rc, re
 
     for i,x in ipairs(l.locks) do
@@ -94,7 +95,7 @@ end
 local test=false
 if test then
     -- some dummy functions to test without context...
-    function new_error(x)
+    function err.new(x)
         return true
     end
     e2lib = {}
index 5377a64c7ac8359ab616a156a8612c133673fac4..2c018cc8e83b6029cf4b5e9875ef94248399d42c 100644 (file)
@@ -1,4 +1,5 @@
 module("plugin", package.seeall)
+local err = require("err")
 
 --- plugin descriptor
 -- @class table
@@ -50,7 +51,7 @@ plugins = {}
 -- @return bool
 -- @return an error object on failure
 local function load_plugin(dir, p, ctx)
-       local e = new_error("loading plugin failed: %s", p)
+       local e = err.new("loading plugin failed: %s", p)
        local plugin_file = string.format("%s/%s", dir, p)
        local chunk, msg = loadfile(plugin_file)
        if not chunk then
@@ -103,7 +104,7 @@ end
 -- @return bool
 -- @return an error object on failure
 function load_plugins(dir, ctx)
-  local e = new_error("loading plugins failed")
+  local e = err.new("loading plugins failed")
   e2lib.logf(4, "loading plugins from: %s", dir)
   for p in e2lib.directory(dir) do
     local rc, re = load_plugin(dir, p, ctx)
@@ -119,7 +120,7 @@ end
 -- @return bool
 -- @return an error object on failure
 function init_plugins()
-  local e = new_error("initializing plugins failed")
+  local e = err.new("initializing plugins failed")
   for _, pd in ipairs(plugins) do
     local rc, re = init_plugin(pd)
     if not rc then
@@ -133,7 +134,7 @@ end
 -- @return bool
 -- @return an error object on failure
 function exit_plugins()
-  local e = new_error("deinitializing plugins failed")
+  local e = err.new("deinitializing plugins failed")
   for _, pd in ipairs(plugins) do
     local rc, re = exit_plugin(pd)
     if not rc then
index ee467bf07dad24688bb2762d7a181bf17317edd3..c6ed4058b6ca073f55ed72c750a33002ad1620bb 100644 (file)
@@ -28,6 +28,7 @@
 local transport = {}
 local url = require("url")
 local tools = require("tools")
+local err = require("err")
 
 --- call rsync with appropriate rsh argument according to the tools
 -- configuration
@@ -119,7 +120,7 @@ local function rsync_ssh_mkdir(opts, user, server, dir)
         local rc, re = rsync_ssh(argv, emptydir .. "/", dest)
         if not rc then
             e2lib.rmtempdir(emptydir)
-            local e = new_error("could not create remote directory")
+            local e = err.new("could not create remote directory")
             return false, e:cat(re)
         end
     end
@@ -141,7 +142,7 @@ function transport.fetch_file(surl, location, destdir, destname)
         destname = e2lib.basename(location)
     end
     local rc, re
-    local e = new_error("transport: fetching file failed")
+    local e = err.new("transport: fetching file failed")
     local u, re = url.parse(surl)
     if not u then
         return false, e:cat(re)
@@ -228,7 +229,7 @@ function transport.push_file(sourcefile, durl, location, push_permissions, try_h
     e2lib.log(4, string.format("%s: %s %s %s %s", "transport.push_file()",
     sourcefile, durl, location, tostring(push_permissions)))
     local rc, e
-    e = new_error("error pushing file to server")
+    e = err.new("error pushing file to server")
     durl = string.format("%s/%s", durl, location)
     local u, re = url.parse(durl)
     if not u then
@@ -346,7 +347,7 @@ end
 function transport.file_path(surl, location)
     e2lib.log(4, string.format("%s: %s %s", "file_path()", surl,
     location))
-    local e = new_error("can't get path to file")
+    local e = err.new("can't get path to file")
     local u, re = url.parse(surl)
     if not u then
         return nil, e:cat(re)
index fe8b3b21652fbf46ce5395dd9cde6f2244349277..61550ef57f9c62029596e7262c875fab5f0891c5 100644 (file)
@@ -30,6 +30,7 @@ require("e2lib")
 require("e2option")
 local cache = require("cache")
 local generic_git = require("generic_git")
+local err = require("err")
 
 e2lib.init()
 
@@ -48,7 +49,7 @@ if not rc then
   e2lib.abort(e)
 end
 e2lib.init2()
-local e = new_error("creating project failed")
+local e = err.new("creating project failed")
 
 local config, re = e2lib.get_global_config()
 if not config then
index 2426cd5c0e0d66cb68c046e26bc7a5e85d15d8ff..01b75106eca83a1020826c9e764eee86e7ff5f41 100644 (file)
@@ -30,9 +30,10 @@ require("e2lib")
 require("e2option")
 local generic_git = require("generic_git")
 local cache = require("cache")
+local err = require("err")
 
 e2lib.init()
-local e = new_error("fetching project failed")
+local e = err.new("fetching project failed")
 local doc = [[
 usage: e2-fetch-project [<option> ...] [<server>:]<location> [<destination>]
 
@@ -184,7 +185,7 @@ e2_install_e2 = string.format("%s %s/e2-install-e2",
   e2lib.shquote(buildconfig.LUA), e2lib.shquote(buildconfig.TOOLDIR))
 rc, re = e2lib.callcmd_log(e2_install_e2)
 if rc ~= 0 then
-       e2lib.abort(new_error("installing local e2 failed"))
+       e2lib.abort(err.new("installing local e2 failed"))
 end
 e2lib.finish()
 
index 324ac9be271c1b707a26c4ad6295be148e12d63d..3f0df8c45efc91250dc71a48b4973770b24f4cb0 100644 (file)
@@ -29,6 +29,7 @@ require("buildconfig")
 require("e2lib")
 require("e2option")
 local generic_git = require("generic_git")
+local err = require("err")
 
 e2lib.init()
 
@@ -55,7 +56,7 @@ if not rc then
   e2lib.abort(e)
 end
 e2lib.init2()
-local e = new_error("e2-install-e2 failed")
+local e = err.new("e2-install-e2 failed")
 
 local config = e2lib.get_global_config()
 local servers = config.servers
index c05633e721d9bbb22a05e5ae23d9e85e791b6a0a..1719d27161e403b0877e34226261794c01a88184 100644 (file)
@@ -30,6 +30,8 @@
 require("e2local")
 require("e2tool")
 require("e2build")
+local err = require("err")
+
 e2lib.init()
 local info, re = e2tool.local_init(nil, "build")
 if not info then
@@ -71,14 +73,14 @@ local function perform_writeback_settings(writeback)
                        e2lib.logf(3, disable_msg, set.server)
                        rc, re = info.cache:set_writeback(set.server, false)
                        if not rc then
-                               local e = new_error(disable_msg, set.server)
+                               local e = err.new(disable_msg, set.server)
                                e2lib.abort(e:cat(re))
                        end
                elseif set.set == "enable" then
                        e2lib.logf(3, enable_msg, set.server)
                        rc, re = info.cache:set_writeback(set.server, true)
                        if not rc then
-                               local e = new_error(enable_msg, set.server)
+                               local e = err.new(enable_msg, set.server)
                                e2lib.abort(e:cat(re))
                        end
                end
@@ -127,7 +129,7 @@ end
 -- handle command line flags
 local build_mode = nil
 if opts["branch-mode"] and opts["wc-mode"] then
-       e = new_error("--branch-mode and --wc-mode are mutually exclusive")
+       e = err.new("--branch-mode and --wc-mode are mutually exclusive")
        e2lib.abort(e)
 end
 if opts["branch-mode"] then
index 073e684a2448443bd563256c24a208c2ec7c58d8..ca36a312d76d3e90ead4fadb46bbaaffd7b21222 100644 (file)
@@ -29,6 +29,8 @@
 
 require("e2local")
 require("e2tool")
+local err = require("err")
+
 e2lib.init()
 local info, re = e2tool.local_init(nil, "cf")
 if not info then
@@ -73,7 +75,7 @@ local editor = e2lib.globals.osenv["EDITOR"]
 local commands = {}
 
 local function newsource(info, ...)
-  local e = new_error("newsource")
+  local e = err.new("newsource")
   local t = ...
   local name = t[2]
   local scm = t[3]
@@ -111,7 +113,7 @@ local function newsource(info, ...)
 end
 
 local function editsource(info, ...)
-  local e = new_error("editsource")
+  local e = err.new("editsource")
   local t = ...
   local name = t[2]
   if not name then
@@ -126,7 +128,7 @@ local function editsource(info, ...)
 end
 
 local function newresult(info, ...)
-  local e = new_error("newresult")
+  local e = err.new("newresult")
   local t = ...
   local name = t[2]
   if not name then
@@ -167,7 +169,7 @@ local function newresult(info, ...)
 end
 
 local function editresult(info, ...)
-  local e = new_error("editresult")
+  local e = err.new("editresult")
   local t = ...
   local name = t[2]
   if not name then
@@ -182,7 +184,7 @@ local function editresult(info, ...)
 end
 
 local function editbuildscript(info, ...)
-  local e = new_error("editbuildscript")
+  local e = err.new("editbuildscript")
   local t = ...
   local name = t[2]
   if not name then
index 5c24749603655e7e64911f79fd18abdb18954b8d..36d56981215c06de22ce7d0b62c24f0f10ed15d6 100644 (file)
@@ -32,6 +32,7 @@ require("scm")
 local hash = require("hash")
 local url = require("url")
 local tools = require("tools")
+local err = require("err")
 
 --- validate source configuration, log errors to the debug log
 -- @param info the info table
@@ -47,7 +48,7 @@ function cvs.validate_source(info, sourcename)
   if not src.sourceid then
     src.sourceid = {}
   end
-  local e = new_error("in source %s:", sourcename)
+  local e = err.new("in source %s:", sourcename)
   rc, re = git.source_apply_default_working(info, sourcename)
   if not rc then
     return false, e:cat(re)
@@ -108,7 +109,7 @@ local function mkcvsroot(u)
   elseif u.transport == "cvspserver" then
     cvsroot = string.format(":pserver:%s:/%s", u.server, u.path)
   else
-    return nil, new_error("cvs: transport not supported")
+    return nil, err.new("cvs: transport not supported")
   end
   return cvsroot, nil
 end
@@ -128,7 +129,7 @@ local function mkrev(src, source_set)
     rev = src.tag
   end
   if not rev then
-    return nil, new_error("source set not allowed")
+    return nil, err.new("source set not allowed")
   end
   return rev, nil
 end
@@ -138,7 +139,7 @@ function cvs.fetch_source(info, sourcename)
   if not rc then
     return false, re
   end
-  local e = new_error("fetching source failed: %s", sourcename)
+  local e = err.new("fetching source failed: %s", sourcename)
   local src = info.sources[ sourcename ]
   local location = src.cvsroot
   local server = src.server
@@ -188,7 +189,7 @@ function cvs.prepare_source(info, sourcename, source_set, buildpath)
   if not rc then
     return false, re
   end
-  local e = new_error("cvs.prepare_source failed")
+  local e = err.new("cvs.prepare_source failed")
   local src = info.sources[ sourcename ]
   local location = src.cvsroot
   local server = src.server
@@ -236,7 +237,7 @@ function cvs.update(info, sourcename)
   if not rc then
     e2lib.abort(re)
   end
-  local e = new_error("updating cvs source failed")
+  local e = err.new("updating cvs source failed")
   local src = info.sources[ sourcename ]
   local working = string.format("%s/%s", info.root, src.working)
   local rsh = tools.get_tool("ssh")
@@ -315,7 +316,7 @@ function cvs.sourceid(info, sourcename, source_set)
        if src.sourceid[source_set] then
                return true, nil, src.sourceid[source_set]
        end
-       local e = new_error("calculating sourceid failed for source %s",
+       local e = err.new("calculating sourceid failed for source %s",
                                                                sourcename)
        local hc = hash.hash_start()
        hash.hash_line(hc, src.name)
@@ -355,7 +356,7 @@ function cvs.toresult(info, sourcename, sourceset, directory)
        -- <directory>/makefile
        -- <directory>/licences
        local rc, re
-       local e = new_error("converting result")
+       local e = err.new("converting result")
        rc, re = git.check(info, sourcename, true)
        if not rc then
                return false, e:cat(re)
@@ -413,7 +414,7 @@ end
 
 function cvs.check_workingcopy(info, sourcename)
        local rc, re
-       local e = new_error("checking working copy failed")
+       local e = err.new("checking working copy failed")
        e:append("in source %s (cvs configuration):", sourcename)
        e:setcount(0)
        rc, re = cvs.validate_source(info, sourcename)
index c419ffbcfa1cdddd2542862f6c63ca1483493bb1..8a60a36bda30aaf0b038ac592d17a8e89e3f0c03 100644 (file)
@@ -30,6 +30,7 @@
 module("e2build", package.seeall)
 local transport = require("transport")
 local tools = require("tools")
+local err = require("err")
 
 --- cache a result
 -- @param info
@@ -56,7 +57,7 @@ function result_available(info, r, return_flags)
   local buildid = res.build_mode.buildid(e2tool.buildid(info, r))
   local sbid = e2tool.bid_display(buildid)
   local rc, re
-  local e = new_error("error while checking if result is available: %s", r)
+  local e = err.new("error while checking if result is available: %s", r)
   local columns = tonumber(e2lib.globals.osenv["COLUMNS"])
   if res.playground then
     return_flags.message = e2lib.align(columns,
@@ -153,7 +154,7 @@ end
 function build_config(info, r)
   e2lib.log(4, string.format("build_config(%s, %s)",
                                                tostring(info), tostring(r)))
-  local e = new_error("setting up build configuration for result `%s' failed",
+  local e = err.new("setting up build configuration for result `%s' failed",
                                                                        r)
   local res = info.results[r]
   if not res then
@@ -215,7 +216,7 @@ end
 function chroot_lock(info, r, return_flags)
   local res = info.results[r]
   local rc, re
-  local e = new_error("error locking chroot")
+  local e = err.new("error locking chroot")
   rc, re = e2lib.mkdir(res.build_config.c, "-p")
   if not rc then
     return false, e:cat(re)
@@ -230,7 +231,7 @@ end
 function chroot_unlock(info, r, return_flags)
   local res = info.results[r]
   local rc, re
-  local e = new_error("error unlocking chroot")
+  local e = err.new("error unlocking chroot")
   rc, re = e2lib.globals.lock:unlock(res.build_config.chroot_lock)
   if not rc then
     return false, e:cat(re)
@@ -241,7 +242,7 @@ end
 function setup_chroot(info, r, return_flags)
   local res = info.results[r]
   local rc, re
-  local e = new_error("error setting up chroot")
+  local e = err.new("error setting up chroot")
   -- create the chroot path and create the chroot marker file without root
   -- permissions. That makes sure we have write permissions here.
   rc, re = e2lib.mkdir(res.build_config.c, "-p")
@@ -302,7 +303,7 @@ function enter_playground(info, r, chroot_command)
   end
   local res = info.results[r]
   local rc, re
-  local e = new_error("entering playground")
+  local e = err.new("entering playground")
   e2lib.log(4, "entering playground for " .. r .. " ...")
   local term = e2lib.globals.terminal
   local e2_su = tools.get_tool("e2-su-2.2")
@@ -319,7 +320,7 @@ end
 function fix_permissions(info, r, return_flags)
   local res = info.results[r]
   local rc, re
-  local e = new_error("fixing permissions failed")
+  local e = err.new("fixing permissions failed")
   e2lib.log(3, "fix permissions")
   e2tool.set_umask(info)
   local argv = { "chroot_2_3", res.build_config.base, "chown", "-R",
@@ -354,7 +355,7 @@ end
 function runbuild(info, r, return_flags)
   local res = info.results[r]
   local rc, re
-  local e = new_error("build failed")
+  local e = err.new("build failed")
   e2lib.log(3, "building " .. r .. " ...")
   local runbuild = string.format("/bin/bash -e -x %s/%s/%s",
     e2lib.shquote(res.build_config.Tc),
@@ -384,7 +385,7 @@ function runbuild(info, r, return_flags)
   e2tool.reset_umask(info)
   out:close()
   if rc ~= 0 then
-    e = new_error("build script for %s failed with exit status %d", r, rc)
+    e = err.new("build script for %s failed with exit status %d", r, rc)
     e:append("see %s for more information", res.build_config.buildlog)
     return false, e
   end
@@ -402,7 +403,7 @@ end
 
 function chroot_remove(info, r, return_flags)
   local res = info.results[r]
-  local e = new_error("removing chroot failed")
+  local e = err.new("removing chroot failed")
   e2tool.set_umask(info)
   local rc, re = e2lib.e2_su_2_2({"remove_chroot_2_3", res.build_config.base})
   e2tool.reset_umask(info)
@@ -445,7 +446,7 @@ function unpack_result(info, r, dep, destdir)
   local res = info.results[r]
   local rc, re
   local tmpdir = e2lib.mktempdir()
-  local e = new_error("unpacking result failed: %s", dep)
+  local e = err.new("unpacking result failed: %s", dep)
   local d = info.results[dep]
   local buildid = e2tool.buildid(info, dep)
 
@@ -505,7 +506,7 @@ function unpack_result(info, r, dep, destdir)
 end
 
 function sources(info, r, return_flags)
-  local e = new_error("installing sources")
+  local e = err.new("installing sources")
   local i, k, l, source, cp
 
   -- the development build case
@@ -528,7 +529,7 @@ function sources(info, r, return_flags)
   local function install_directory_structure(info, r, return_flags)
     local res = info.results[r]
     local rc, re
-    local e = new_error("installing directory structure")
+    local e = err.new("installing directory structure")
     local dirs = {"out", "init", "script", "build", "root", "env", "dep"}
     for _, v in pairs(dirs) do
       local d = string.format("%s/%s", res.build_config.T, v)
@@ -543,7 +544,7 @@ function sources(info, r, return_flags)
   local function install_build_script(info, r, return_flags)
     local res = info.results[r]
     local rc, re
-    local e = new_error("installing build script")
+    local e = err.new("installing build script")
     local location = e2tool.resultbuildscript(info.results[r].directory)
     local destdir = string.format("%s/script", res.build_config.T)
     rc, re = transport.fetch_file(info.root_server, location, destdir, nil)
@@ -556,7 +557,7 @@ function sources(info, r, return_flags)
   local function install_env(info, r, return_flags)
     local res = info.results[r]
     local rc, re
-    local e = new_error("installing environment files failed")
+    local e = err.new("installing environment files failed")
     -- install builtin environment variables
     local file = string.format("%s/env/builtin", res.build_config.T)
     rc, re = write_environment_script(res.build_config.builtin_env, file)
@@ -579,7 +580,7 @@ function sources(info, r, return_flags)
   local function install_init_files(info, r, return_flags)
     local res = info.results[r]
     local rc, re
-    local e = new_error("installing init files")
+    local e = err.new("installing init files")
     for x in e2lib.directory(info.root .. "/proj/init") do
       if not e2lib.is_backup_file(x) then
        local location = string.format("proj/init/%s", x)
@@ -598,7 +599,7 @@ function sources(info, r, return_flags)
   local function install_build_driver(info, r, return_flags)
     local res = info.results[r]
     local rc, re
-    local e = new_error("writing build driver script failed")
+    local e = err.new("writing build driver script failed")
     local bc = res.build_config
     local destdir = string.format("%s/%s", bc.T, bc.scriptdir)
     rc, re = write_build_driver(info, r, destdir)
@@ -611,7 +612,7 @@ function sources(info, r, return_flags)
   local function install_build_time_dependencies(info, r, return_flags)
     local res = info.results[r]
     local rc, re
-    local e = new_error("installing build time dependencies")
+    local e = err.new("installing build time dependencies")
     e2lib.log(3, string.format("install_build_time_dependencies"))
     local deps
     deps = e2tool.get_depends(info, r)
@@ -628,10 +629,10 @@ function sources(info, r, return_flags)
   local function install_sources(info, r, return_flags)
     local res = info.results[r]
     local rc, re
-    local e = new_error("installing sources")
+    local e = err.new("installing sources")
     e2lib.log(3, "install sources")
     for i, source in pairs(res.sources) do
-      local e = new_error("installing source failed: %s", source)
+      local e = err.new("installing source failed: %s", source)
       local destdir = string.format("%s/build", res.build_config.T)
       local source_set = res.build_mode.source_set()
       local rc, re = scm.prepare_source(info, source, source_set,
@@ -665,7 +666,7 @@ end
 function linklast(info, r, return_flags)
   local res = info.results[r]
   local rc, re
-  local e = new_error("creating link to last results")
+  local e = err.new("creating link to last results")
   -- calculate the path to the result
   local server, location = res.build_mode.storage(info.project_location,
                                                        info.release_id)
@@ -710,7 +711,7 @@ function store_result(info, r, return_flags)
     tostring(return_flags))
   local res = info.results[r]
   local rc, re
-  local e = new_error("fetching build results from chroot")
+  local e = err.new("fetching build results from chroot")
   e2lib.log(4, string.format("store_result"))
 
   -- create a temporary directory to build up the result
@@ -808,7 +809,7 @@ end
 function build_results_default(info, results)
   e2lib.logf(3, "building results")
   for _, r in ipairs(results) do
-    local e = new_error("building result failed: %s", r)
+    local e = err.new("building result failed: %s", r)
     local flags = {}
     local t1 = os.time()
     local rc, re = build_result(info, r, flags)
@@ -852,7 +853,7 @@ function register_build_results(func, position, post)
       end
     end
   end
-  return false, new_error("registering build_results function failed")
+  return false, err.new("registering build_results function failed")
 end
 
 --- build a result
@@ -900,7 +901,7 @@ function write_build_driver(info, r, destdir)
   e2lib.log(4, "writing build driver")
   local res = info.results[r]
   local rc, re
-  local e = new_error("generating build driver script failed")
+  local e = err.new("generating build driver script failed")
   local buildrc_file = string.format("%s/%s", destdir,
                                                res.build_config.buildrc_file)
   local buildrc_noinit_file = string.format("%s/%s", destdir,
@@ -951,7 +952,7 @@ end
 -- @return bool
 -- @return an error object on failure
 function write_environment_script(env, file)
-       local e = new_error("writing environment script")
+       local e = err.new("writing environment script")
        local f, msg = io.open(file, "w")
        if not f then
                e:append("%s: %s", file, msg)
@@ -981,7 +982,7 @@ function collect_project(info, r, return_flags)
        end
        e2lib.log(3, "providing project data to this build")
        local rc, re
-       local e = new_error("providing project data to this build failed")
+       local e = err.new("providing project data to this build failed")
        -- project/proj/init/<files>
        local destdir = string.format("%s/project/proj/init",
                                                        res.build_config.T)
@@ -1136,7 +1137,7 @@ function collect_project(info, r, return_flags)
                local config = string.format("%s/config", destdir)
                local f, msg = io.open(config, "w")
                if not f then
-                       e:cat(new_error("%s: %s", config, msg))
+                       e:cat(err.new("%s: %s", config, msg))
                        return false, e
                end
                f:write(string.format(
@@ -1281,7 +1282,7 @@ end
 -- @return bool
 -- @return an error object on failure
 function register_build_function(info, name, func, pos)
-  local e = new_error("register build function")
+  local e = err.new("register build function")
   local ipos = nil
   for i=1, #build_process, 1 do
     if build_process[i].name == pos then
index 60c0c76db40c5bace21e148d1bd4c916df878fe0..52688b4d0d2cf4aa6ec2411b33b5194a7107c38c 100644 (file)
@@ -33,7 +33,7 @@ module("e2tool", package.seeall)
 require("e2lib")
 require("strict")
 require("collection")
-require("err")
+local err = require("err")
 require("scm")
 require("files")
 require("git")
@@ -184,19 +184,19 @@ require("policy")
 -- @return bool
 local function listofstrings(l, unique, unify)
   if type(l) ~= "table" then
-    return false, new_error("not a table")
+    return false, err.new("not a table")
   end
   local values = {}
   local unified = {}
   for i,s in pairs(l) do
     if type(i) ~= "number" then
-      return false, new_error("found non-numeric index")
+      return false, err.new("found non-numeric index")
     end
     if type(s) ~= "string" then
-      return false, new_error("found non-string value")
+      return false, err.new("found non-string value")
     end
     if unique and values[s] then
-      return false, new_error("found non-unique value: '%s'", s)
+      return false, err.new("found non-unique value: '%s'", s)
     end
     if unify and not values[s] then
       table.insert(unified, s)
@@ -221,7 +221,7 @@ end
 -- @return bool
 -- @return an error object on failure
 local function check_tab(tab, keys, inherit)
-       local e = new_error("checking file configuration")
+       local e = err.new("checking file configuration")
 
        if type(tab) ~= "table" then
                return false, e:append("not a table")
@@ -263,14 +263,14 @@ end
 function opendebuglogfile(info)
   local rc, re = e2lib.mkdir(info.root .. "/log", "-p")
   if not rc then
-    local e = new_error("error making log directory")
+    local e = err.new("error making log directory")
     return false, e:cat(re)
   end
   local logfile = info.root .. "/log/debug.log"
   local rc, re = e2lib.rotate_log(logfile)
   local debuglogfile, msg = io.open(logfile, "w")
   if not debuglogfile then
-    local e = new_error("error opening debug logfile")
+    local e = err.new("error opening debug logfile")
     return false, e:append(msg)
   end
   e2lib.globals.debuglogfile = debuglogfile
@@ -287,7 +287,7 @@ end
 -- @return an error object on failure
 function load_user_config(info, path, dest, index, var)
   local rc, re
-  local e = new_error("loading configuration failed")
+  local e = err.new("loading configuration failed")
   e2lib.log(3, "loading " .. path)
   if not e2util.exists(path) then
     return false, e:append("file does not exist: %s", path)
@@ -318,7 +318,7 @@ end
 -- @return list of config items
 -- @return an error object on failure
 function load_user_config2(info, path, types)
-  local e = new_error("loading configuration file failed")
+  local e = err.new("loading configuration file failed")
   local rc, re
   local list = {}
 
@@ -381,7 +381,7 @@ end
 -- @return an error object on failure
 function local_init(path, tool)
   local rc, re
-  local e = new_error("initializing")
+  local e = err.new("initializing")
   local info = {}
 
   -- provide the current tool name to allow conditionals in plugin
@@ -440,7 +440,7 @@ end
 
 function collect_project_info(info, skip_load_config)
   local rc, re
-  local e = new_error("reading project configuration")
+  local e = err.new("reading project configuration")
 
   -- check for configuration compatibility
   info.config_syntax_compat = buildconfig.SYNTAX
@@ -559,7 +559,7 @@ function collect_project_info(info, skip_load_config)
     return false, e:cat(re)
   end
   info.project[".fix"] = nil
-  local e = new_error("in project configuration:")
+  local e = err.new("in project configuration:")
   if not info.project.release_id then
     e:append("key is not set: release_id")
   end
@@ -750,7 +750,7 @@ function collect_project_info(info, skip_load_config)
       e2lib.abort(e:cat(re))
     end
     if not rc then
-      e = new_error("project repository is not clean")
+      e = err.new("project repository is not clean")
       e2lib.abort(e:cat(re))
     end
   end
@@ -783,7 +783,7 @@ end
 
 function check_project_info(info, all, access, verbose)
   local rc, re
-  local e = new_error("error in project configuration")
+  local e = err.new("error in project configuration")
   rc, re = check_chroot_config(info)
   if not rc then
     return false, e:cat(re)
@@ -949,7 +949,7 @@ function dlist_recursive(info, result)
   local t = {}
   local function visit(res)
     if had[res] then
-      return false, new_error("cyclic dependency: %s", table.concat(path, " "))
+      return false, err.new("cyclic dependency: %s", table.concat(path, " "))
     elseif t and not col[res] then
       table.insert(path, res)
       had[res] = true
@@ -981,7 +981,7 @@ function dsort(info)
 end
 
 function read_hash_file(info, server, location)
-  local e = new_error("error reading hash file")
+  local e = err.new("error reading hash file")
   local cs = nil
   local cache_flags = { cache = true }
   local rc, re = info.cache:cache_file(server, location, cache_flags)
@@ -1006,7 +1006,7 @@ function hash_path(path)
   assert(type(path) == "string")
   assert(string.len(path) > 0)
 
-  local e = new_error("error hashing path")
+  local e = err.new("error hashing path")
 
   local ctx = hash.hash_start()
 
@@ -1025,7 +1025,7 @@ end
 -- @return string the hash value, nil on error
 -- @return nil, an error string on error
 function hash_file(info, server, location)
-  local e = new_error("error hashing file")
+  local e = err.new("error hashing file")
   local cache_flags = { cache = true }
   local rc, re = info.cache:cache_file(server, location, cache_flags)
   if not rc then
@@ -1050,13 +1050,13 @@ function verify_hash(info, server, location, sha1)
   e2lib.logf(4, "verify_hash %s %s %s %s", tostring(info), tostring(server),
                                        tostring(location), tostring(sha1))
   local rc, re
-  local e = new_error("error verifying checksum")
+  local e = err.new("error verifying checksum")
   local is_sha1, re = hash_file(info, server, location)
   if not is_sha1 then
     return false, e:cat(re)
   end
   if is_sha1 ~= sha1 then
-    e = new_error("checksum mismatch in file:")
+    e = err.new("checksum mismatch in file:")
     return false, e:append("%s:%s", server, location)
   end
   e2lib.logf(4, "checksum matches: %s:%s", server, location)
@@ -1226,7 +1226,7 @@ end
 -- @return bool
 -- @return an error object on failure
 function calc_sourceids(info, sourceset)
-       local e = new_error("calculating sourceids failed")
+       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
@@ -1240,7 +1240,7 @@ function calc_sourceids(info, sourceset)
 end
 
 function hashcache_setup(info)
-       local e = new_error("reading hash cache")
+       local e = err.new("reading hash cache")
        local rc, re
        e2lib.logf(4, "loading hashcache from file: %s", info.hashcache_file)
        info.hashcache = {}
@@ -1273,7 +1273,7 @@ function hashcache_setup(info)
 end
 
 function hashcache_write(info)
-       local e = new_error("writing hash cache file")
+       local e = err.new("writing hash cache file")
        local f, msg = io.open(info.hashcache_file, "w")
        if not f then
                return false, e:append(msg)
@@ -1290,7 +1290,7 @@ function hashcache_write(info)
 end
 
 function hashcache(info, file)
-       local e = new_error("getting fileid from hash cache failed")
+       local e = err.new("getting fileid from hash cache failed")
        local rc, re, fileid
        local p, re = info.cache:file_path(file.server, file.location, {})
        if not p then
@@ -1298,7 +1298,7 @@ function hashcache(info, file)
        end
        local s, msg = e2util.stat(p)
        if not s then
-               return nil, new_error("%s: %s", p, msg)
+               return nil, err.new("%s: %s", p, msg)
        end
        local id = string.format("%s:%s", file.server, file.location)
        local fileid
@@ -1334,7 +1334,7 @@ end
 -- @return an error object on failure
 function verify_remote_fileid(info, file, fileid)
        local rc, re
-       local e = new_error("error calculating remote file id for file: %s:%s",
+       local e = err.new("error calculating remote file id for file: %s:%s",
                                                file.server, file.location)
        if not info.cache:cache_enabled(file.server) or
           not e2option.opts["check-remote"] then
@@ -1386,11 +1386,11 @@ function verify_remote_fileid(info, file, fileid)
                   return false, e:cat(re)
                 end
        else
-               return false, new_error("transport not supported: %s",
+               return false, err.new("transport not supported: %s",
                   u.transport)
        end
        if fileid ~= remote_fileid then
-               return false, new_error(
+               return false, err.new(
                        "checksum for remote file %s:%s (%s) does not match" ..
                         " configured checksum (%s)",
                        file.server, file.location, remote_fileid, fileid)
@@ -1408,7 +1408,7 @@ end
 function fileid(info, file)
        local fileid
        local re
-       local e = new_error("error calculating file id for file: %s:%s",
+       local e = err.new("error calculating file id for file: %s:%s",
                                                file.server, file.location)
        if file.sha1 then
                fileid = file.sha1
@@ -1432,7 +1432,7 @@ end
 -- @return an error object on failure
 function licenceid(info, licence)
        local rc, re
-       local e = new_error("calculating licence id failed for licence: %s",
+       local e = err.new("calculating licence id failed for licence: %s",
                                                                licence)
        local lic = info.licences[licence]
        if lic.licenceid then
@@ -1461,7 +1461,7 @@ end
 -- @return bool
 -- @return an error object on failure
 function calc_licenceids(info)
-       local e = new_error("calculating licenceids failed")
+       local e = err.new("calculating licenceids failed")
        for l,_ in pairs(info.licences) do
                local licenceid, re = licenceid(info, l)
                if not licenceid then
@@ -1508,7 +1508,7 @@ end
 -- @return the buildid
 function pbuildid(info, resultname)
        e2lib.log(4, string.format("get pbuildid for %s", resultname))
-       local e = new_error("error calculating result id for result: %s",
+       local e = err.new("error calculating result id for result: %s",
                                                                resultname)
        local r = info.results[resultname]
        if r.pbuildid then
@@ -1648,7 +1648,7 @@ function flush_buildids(info)
 end
 
 function chrootgroupid(info, groupname)
-       local e = new_error("calculating chroot group id failed for group %s",
+       local e = err.new("calculating chroot group id failed for group %s",
                                                                groupname)
        local g = info.chroot.groups_byname[groupname]
        if g.groupid then
@@ -1725,10 +1725,10 @@ function check_source(info, sourcename)
        local src = info.sources[sourcename]
        local rc, e, re
        if not src then
-               e = new_error("no source by that name: %s", sourcename)
+               e = err.new("no source by that name: %s", sourcename)
                return false, e
        end
-       local e = new_error("in source: %s", sourcename)
+       local e = err.new("in source: %s", sourcename)
        if not src.type then
                e2lib.warnf("WDEFAULT", "in source %s", sourcename)
                e2lib.warnf("WDEFAULT", " type attribute defaults to `files'")
@@ -1742,7 +1742,7 @@ function check_source(info, sourcename)
 end
 
 function check_sources(info)
-       local e = new_error("Error while checking sources")
+       local e = err.new("Error while checking sources")
        local rc, re
        for n,s in pairs(info.sources) do
                rc, re = check_source(info, n)
@@ -1757,7 +1757,7 @@ function check_sources(info)
 end
 
 function check_licence(info, l)
-       local e = new_error("in licence: %s", l)
+       local e = err.new("in licence: %s", l)
        local lic = info.licences[l]
        if not lic.server then
                e:append("no server attribute")
@@ -1805,7 +1805,7 @@ function check_licence(info, l)
 end
 
 function check_licences(info)
-       local e = new_error("Error while checking licences")
+       local e = err.new("Error while checking licences")
        local rc, re
        for l, lic in pairs(info.licences) do
                rc, re = check_licence(info, l)
@@ -1820,7 +1820,7 @@ function check_licences(info)
 end
 
 function check_workingcopies(info)
-       local e = new_error("Error while checking working copies")
+       local e = err.new("Error while checking working copies")
        local rc, re
        for n,s in pairs(info.sources) do
                rc, re = scm.check_workingcopy(info, n)
@@ -1835,7 +1835,7 @@ function check_workingcopies(info)
 end
 
 function check_results(info)
-       local e = new_error("Error while checking results")
+       local e = err.new("Error while checking results")
        local rc, re
        for _,f in ipairs(info.ftab.check_result) do
                for r,_ in pairs(info.results) do
@@ -1865,7 +1865,7 @@ end
 -- @param resultname string: the result to check
 function check_result(info, resultname)
        local res = info.results[resultname]
-       local e = new_error("in result %s:", resultname)
+       local e = err.new("in result %s:", resultname)
        if not res then
                e:append("result does not exist: %s", resultname)
                return false, e
@@ -2003,7 +2003,7 @@ end
 -- @param resultname string: the result to check
 function check_collect_project(info, resultname)
        local res = info.results[resultname]
-       local e = new_error("in result %s:", resultname)
+       local e = err.new("in result %s:", resultname)
        local rc, re
        if not res.collect_project then
                -- insert empty tables, to avoid some conditionals in the code
@@ -2088,7 +2088,7 @@ function string2bn(info, s, build_numbers)
                build_numbers = info.build_numbers
        end
        local rc
-       local re = new_error("error parsing build numbers:")
+       local re = err.new("error parsing build numbers:")
        e2lib.log(3, "parsing build numbers")
        local line = 0
        for l in s:gmatch("[^\n]+") do
@@ -2147,7 +2147,7 @@ function buildnumber_write(info, file, build_numbers)
        if not build_numbers then
                build_numbers = info.build_numbers
        end
-       local e = new_error("error writing build number file:")
+       local e = err.new("error writing build number file:")
        e2lib.logf(3, "writing build numbers to %s", file)
        local s, re = bn2string(info)
        if not s then
@@ -2177,7 +2177,7 @@ function buildnumber_read(info, file, build_numbers)
        if not build_numbers then
                build_numbers = info.build_numbers
        end
-       local e = new_error("error reading build number file:")
+       local e = err.new("error reading build number file:")
        e2lib.logf(3, "reading build-numbers from %s", file)
        local s, re = e2lib.read_file(file)
        if not s and e2lib.isfile(file) then
@@ -2201,7 +2201,7 @@ end
 -- @return nil, an error object on failure
 function buildnumber_mergetoresults(info)
        e2lib.log(3, string.format("merging build numbers to results"))
-       local e = new_error("merging build numbers to results:")
+       local e = err.new("merging build numbers to results:")
        for r, res in pairs(info.results) do
                local bn = info.build_numbers[r]
                if not bn then
@@ -2274,11 +2274,11 @@ function buildnumber_request(info)
        e2lib.log(3, "requesting build numbers from server")
 
         if e2lib.globals.buildnumber_server_url == nil then
-          return false, new_error("no build number server configured")
+          return false, err.new("no build number server configured")
         end
 
        local rc, re
-       local e = new_error("error requesting build numbers")
+       local e = err.new("error requesting build numbers")
        local tmpdir = e2lib.mktempdir()
        local tmpreq = string.format("%s/build-number.req.tmp", tmpdir)
        local tmpres = string.format("%s/build-number.res.tmp", tmpdir)
@@ -2323,7 +2323,7 @@ function buildnumber_request_local(info)
        local req  -- the request
        local sta  -- the state
        local res  -- the response
-       local e = new_error("error in local buildnumber request")
+       local e = err.new("error in local buildnumber request")
        -- compose the request
        req = info.build_numbers
        -- compose the state
@@ -2442,7 +2442,7 @@ end
 -- @return an error object on failure
 function print_selection(info, results)
        for _,r in ipairs(results) do
-               local e = new_error("error printing selected results")
+               local e = err.new("error printing selected results")
                local res = info.results[r]
                if not res then
                        return false, e:append("no such result: %s", r)
@@ -2465,7 +2465,7 @@ end
 -- @return bool
 -- @return an error object on failure
 function lcd(info, dir)
-  local e = new_error("chdir failed")
+  local e = err.new("chdir failed")
   local abspath = string.format("%s/%s", info.root, dir)
   local rc, re = e2lib.chdir(abspath)
   if not rc then
@@ -2481,7 +2481,7 @@ end
 -- @return bool
 -- @return an error object on failure
 function check_config_syntax_compat(info)
-  local e = new_error("checking configuration syntax compatibilitly failed")
+  local e = err.new("checking configuration syntax compatibilitly failed")
   local l, re = e2lib.read_line(info.config_syntax_file)
   if not l then
     return false, e:cat(re)
@@ -2511,7 +2511,7 @@ end
 -- @return bool
 -- @return an error object on failure
 function read_chroot_config(info)
-  local e = new_error("reading chroot config failed")
+  local e = err.new("reading chroot config failed")
   local t = {}
   local rc, re = load_user_config(info, info.chroot_config_file,
                                                t, "chroot", "e2chroot")
@@ -2564,7 +2564,7 @@ end
 -- @return bool
 -- @return an error object on failure
 function check_chroot_config(info)
-  local e = new_error("error validating chroot configuration")
+  local e = err.new("error validating chroot configuration")
   for g,grp in pairs(info.chroot.groups) do
     if not grp.server then
       e:append("in group: %s", grp.name)
@@ -2675,7 +2675,7 @@ local function checkFilenameInvalidCharacters(str)
   local msg = "only digits, alphabetic characters, and '-_./' " ..
                 "are allowed"
   if not str:match("^[-_0-9a-zA-Z/.]+$") then
-    return false, new_error(msg)
+    return false, err.new(msg)
   else
     return true
   end
@@ -2686,7 +2686,7 @@ local function checkNameInvalidCharacters(str)
   local msg = "only digits, alphabetic characters, and '-_.' " ..
                 "are allowed"
   if not str:match("^[-_0-9a-zA-Z.]+$") then
-    return false, new_error(msg)
+    return false, err.new(msg)
   else
     return true
   end
@@ -2698,7 +2698,7 @@ local function slashToDot(str)
 end
 
 function load_source_config(info)
-  local e = new_error("error loading source configuration")
+  local e = err.new("error loading source configuration")
   info.sources = {}
 
   for _,src in ipairs(gather_source_paths(info)) do
@@ -2751,7 +2751,7 @@ function load_source_config(info)
 end
 
 function load_result_config(info)
-  local e = new_error("error loading result configuration")
+  local e = err.new("error loading result configuration")
   info.results = {}
 
   for _,res in ipairs(gather_result_paths(info)) do
@@ -2883,7 +2883,7 @@ end
 
 function register_collect_project_info(info, func)
   if type(info) ~= "table" or type(func) ~= "function" then
-    return false, new_error("register_collect_project_info: invalid argument")
+    return false, err.new("register_collect_project_info: invalid argument")
   end
   table.insert(info.ftab.collect_project_info, func)
   return true, nil
@@ -2891,7 +2891,7 @@ end
 
 function register_check_result(info, func)
   if type(info) ~= "table" or type(func) ~= "function" then
-    return false, new_error("register_check_result: invalid argument")
+    return false, err.new("register_check_result: invalid argument")
   end
   table.insert(info.ftab.check_result, func)
   return true, nil
@@ -2899,7 +2899,7 @@ end
 
 function register_resultid(info, func)
   if type(info) ~= "table" or type(func) ~= "function" then
-    return false, new_error("register_resultid: invalid argument")
+    return false, err.new("register_resultid: invalid argument")
   end
   table.insert(info.ftab.resultid, func)
   return true, nil
@@ -2907,7 +2907,7 @@ end
 
 function register_pbuildid(info, func)
   if type(info) ~= "table" or type(func) ~= "function" then
-    return false, new_error("register_pbuildid: invalid argument")
+    return false, err.new("register_pbuildid: invalid argument")
   end
   table.insert(info.ftab.pbuildid, func)
   return true, nil
@@ -2915,7 +2915,7 @@ end
 
 function register_dlist(info, func)
   if type(info) ~= "table" or type(func) ~= "function" then
-    return false, new_error("register_dlist: invalid argument")
+    return false, err.new("register_dlist: invalid argument")
   end
   table.insert(info.ftab.dlist, func)
   return true, nil
@@ -2923,7 +2923,7 @@ end
 
 function load_env_config(info, file)
   e2lib.logf(4, "loading environment: %s", file)
-  local e = new_error("loading environment: %s", file)
+  local e = err.new("loading environment: %s", file)
   local rc, re
 
   local info = info
@@ -2945,7 +2945,7 @@ function load_env_config(info, file)
       for var, val in pairs(data) do
         if type(var) ~= "string" or
          (type(val) ~= "string" and type(val) ~= "table") then
-         merge_error = new_error("invalid environment entry in %s: %s=%s",
+         merge_error = err.new("invalid environment entry in %s: %s=%s",
                                        file, tostring(var), tostring(val))
          return nil
        end
@@ -2957,7 +2957,7 @@ function load_env_config(info, file)
          for var1, val1 in pairs(val) do
             if type(var1) ~= "string" or
               (type(val1) ~= "string" and type(val1) ~= "table") then
-             merge_error = new_error(
+             merge_error = err.new(
                                "invalid environment entry in %s [%s]: %s=%s",
                                file, var, tostring(var1), tostring(val1))
              return nil
index a64974cdbb93b8d0d9abaf8699096b002d1a86b2..c82a5241adc6372d411b18d260419fa43e0f3e86 100644 (file)
@@ -30,6 +30,8 @@
 require("e2local")
 require("e2tool")
 require("e2build")
+local err = require("err")
+
 e2lib.init()
 local info, re = e2tool.local_init(nil, "fetch-sources")
 if not info then
@@ -56,7 +58,7 @@ up-to-dateness is not checked for sources which are already fetched.
 -- --fetch, --cache  fetch selected sources
 -- --update          update selected sources
 
-local e = new_error()
+local e = err.new()
 
 e2option.flag("all", "select all sources, even files sources")
 e2option.flag("chroot", "select chroot files")
@@ -139,7 +141,7 @@ end
 function fetch_sources(info, opts, sel)
   local rc1 = true    -- global return code
   local nfail = 0     -- failure counter
-  local e = new_error()  -- no message yet, append the summary later on
+  local e = err.new()  -- no message yet, append the summary later on
 
   -- fetch
   for _, s in pairs(info.sources) do
index edede203b15f0da766b5913b17659708c691721b..eb13dbd7f7b70ee0c15b3e963026c565fece5cca 100644 (file)
@@ -32,6 +32,7 @@
 module("files", package.seeall)
 require("scm")
 local hash = require("hash")
+local err = require("err")
 
 --- validate source configuration, log errors to the debug log
 -- @param info the info table
@@ -43,7 +44,7 @@ function files.validate_source(info, sourcename)
   if not rc then
     return false, e
   end
-  e = new_error("in source %s:", sourcename)
+  e = err.new("in source %s:", sourcename)
   e:setcount(0)
   local src = info.sources[ sourcename ]
   if not src.file then
@@ -137,7 +138,7 @@ end
 
 function files.fetch_source(info, sourcename)
   local rc, re
-  local e = new_error("fetching source failed: %s", sourcename)
+  local e = err.new("fetching source failed: %s", sourcename)
   rc, re = files.validate_source(info, sourcename)
   if not rc then
     return false, e:cat(re)
@@ -172,7 +173,7 @@ end
 -- @return nil, maybe an error string on error
 function files.prepare_source(info, sourcename, sourceset, buildpath)
   local rc, re
-  local e = new_error("error preparing source: %s", sourcename)
+  local e = err.new("error preparing source: %s", sourcename)
   rc, re = files.validate_source(info, sourcename)
   if not rc then
     return false, e:cat(re)
@@ -311,7 +312,7 @@ end
 -- @return an error string on error
 function files.sourceid(info, sourcename, sourceset)
        local rc, re
-       local e = new_error("error calculating sourceid for source: %s",
+       local e = err.new("error calculating sourceid for source: %s",
                                                                sourcename)
        rc, re = files.validate_source(info, sourcename)
        if not rc then
@@ -355,7 +356,7 @@ end
 -- export the source to a result structure
 function files.toresult(info, sourcename, sourceset, directory)
        local rc, re
-       local e = new_error("converting result failed")
+       local e = err.new("converting result failed")
        rc, re = files.validate_source(info, sourcename)
        if not rc then
                return false, e:cat(re)
index 9eaffd6a36759bdff7e44246bbf414cc5b5adce1..1d3e6e2d6e91e9f5c82adc7b46726f0749ffcf1e 100644 (file)
@@ -35,6 +35,7 @@ local hash = require("hash")
 local cache = require("cache")
 local generic_git = require("generic_git")
 local url = require("url")
+local err = require("err")
 
 --- git branch wrapper
 -- get the current branch
@@ -75,7 +76,7 @@ end
 function git.get_revision_id(info, source, sourceset, check_remote)
   local sourcename = source
   local rc, re
-  local e = new_error("getting revision id failed for source: %s", source)
+  local e = err.new("getting revision id failed for source: %s", source)
   local s = info.sources[source]
   rc, re = git.validate_source(info, sourcename)
   if not rc then
@@ -133,7 +134,7 @@ end
 -- @return bool
 -- @return an error object on failure
 function source_apply_default_licences(info, sourcename)
-  local e = new_error("applying default licences failed.")
+  local e = err.new("applying default licences failed.")
   local src = info.sources[ sourcename ]
   if src.licences_default_applied then
     return true
@@ -182,9 +183,9 @@ function generic_validate_source(info, sourcename)
   local rc, re
   local e
   if not src then
-    return false, new_error("invalid source: %s", sourcename)
+    return false, err.new("invalid source: %s", sourcename)
   end
-  e = new_error("in source %s:", sourcename)
+  e = err.new("in source %s:", sourcename)
   rc, re = source_apply_default_licences(info, sourcename)
   if not rc then
     return false, e:cat(re)
@@ -231,7 +232,7 @@ function check(info, sourcename, require_workingcopy)
   end
   rc, re = scm.working_copy_available(info, sourcename)
   if (not rc) and require_workingcopy then
-    return false, new_error("working copy is not available")
+    return false, err.new("working copy is not available")
   end
   rc, re = scm.check_workingcopy(info, sourcename)
   if not rc then
@@ -280,7 +281,7 @@ function git.validate_source(info, sourcename)
     return false, re
   end
   local src = info.sources[ sourcename ]
-  local e = new_error("in source %s:", sourcename)
+  local e = err.new("in source %s:", sourcename)
   rc, re = source_apply_default_working(info, sourcename)
   if not rc then
     return false, e:cat(re)
@@ -325,7 +326,7 @@ end
 function git.update(info, sourcename)
   local src = info.sources[ sourcename ]
   local rc, re
-  local e = new_error("updating source failed")
+  local e = err.new("updating source failed")
   rc, re = scm.working_copy_available(info, sourcename)
   if not rc then
     return false, e:cat(re)
@@ -378,7 +379,7 @@ end
 function git.fetch_source(info, sourcename)
   local src = info.sources[ sourcename ]
   local rc, re
-  local e = new_error("fetching source failed: %s", sourcename)
+  local e = err.new("fetching source failed: %s", sourcename)
   rc, re = git.validate_source(info, sourcename)
   if not rc then
     return false, e:cat(re)
@@ -420,7 +421,7 @@ end
 function git.prepare_source(info, sourcename, sourceset, buildpath)
   local src = info.sources[ sourcename ]
   local rc, re, e
-  local e = new_error("preparing git sources failed")
+  local e = err.new("preparing git sources failed")
   rc, re = check(info, sourcename, true)
   if not rc then
     return false, e:cat(re)
@@ -492,7 +493,7 @@ end
 function git.working_copy_available(info, sourcename)
   local src = info.sources[sourcename]
   local rc, re
-  local e = new_error("checking if working copy is available for source %s",
+  local e = err.new("checking if working copy is available for source %s",
                                                                sourcename)
   rc, re = git.validate_source(info, sourcename)
   if not rc then
@@ -530,7 +531,7 @@ end
 -- @return string: the git url, or nil
 -- @return an error object on failure
 function git.git_url(c, server, location)
-  local e = new_error("translating server:location to git url")
+  local e = err.new("translating server:location to git url")
   local rurl, re = cache.remote_url(c, server, location)
   if not rurl then
     return nil, e:cat(re)
@@ -573,7 +574,7 @@ end
 function git.display(info, sourcename)
   local src = info.sources[sourcename]
   local rc, re
-  local e = new_error("display source information failed")
+  local e = err.new("display source information failed")
   rc, re = git.validate_source(info, sourcename)
   if not rc then
     return nil, e:cat(re)
@@ -662,7 +663,7 @@ end
 
 function git.toresult(info, sourcename, sourceset, directory)
        local rc, re
-       local e = new_error("converting result")
+       local e = err.new("converting result")
        rc, re = check(info, sourcename, true)
        if not rc then
                return false, e:cat(re)
@@ -727,7 +728,7 @@ end
 
 function git.check_workingcopy(info, sourcename)
        local rc, re
-       local e = new_error("checking working copy failed")
+       local e = err.new("checking working copy failed")
        e:append("in source %s (git configuration):", sourcename)
        e:setcount(0)
        rc, re = git.validate_source(info, sourcename)
index 4d2d374a1f77c07d4e5446f8fc50db05c0178758..60a372ec8b72837b557837fe1d5a82152bde7300 100644 (file)
@@ -29,6 +29,8 @@
 
 require("e2local")
 require("e2tool")
+local err = require("err")
+
 e2lib.init()
 local info, re = e2tool.local_init(nil, "ls-project")
 if not info then
@@ -68,7 +70,7 @@ elseif #opts.arguments > 0 then
     if info.results[r] then
       table.insert(results, r)
     else
-      e2lib.abort(new_error("not a result: %s", r))
+      e2lib.abort(err.new("not a result: %s", r))
     end
   end
 end
index 40983021ba16c352c24046ac396c85cc90a8c3de..c3e47801b9ebceb57d2c7e2847be90e147e52a56 100644 (file)
@@ -32,6 +32,7 @@ require("e2local")
 require("e2tool")
 local generic_git = require("generic_git")
 local cache = require("cache")
+local err = require("err")
 
 e2lib.init()
 local info, re = e2tool.local_init(nil, "new-source")
@@ -79,7 +80,7 @@ function read_checksum(checksum_file, filename)
                return nil, e
        end
        local rc = nil
-       local e = new_error("no checksum available")
+       local e = err.new("no checksum available")
        while true do
                local line = f:read()
                if not line then
@@ -136,7 +137,7 @@ function download(f)
           e2lib.shquote(f), e2lib.shquote(name))
        local rc = e2lib.callcmd_capture(cmd)
        if rc ~= 0 then
-               return false, new_error("download failed: %s", f)
+               return false, err.new("download failed: %s", f)
        end
        return true, nil
 end
index 319c330579ad2485243d40fe97b8859512e81970..9e7b90034a596e21557ee2b7c4f3e1c79833baa1 100644 (file)
 require("e2local")
 require("e2tool")
 require("e2build")
+local err = require("err")
+
 e2lib.init()
 local info, re = e2tool.local_init(nil, "playground")
 if not info then
   e2lib.abort(re)
 end
 
-local e = new_error("entering playground failed")
+local e = err.new("entering playground failed")
 local rc, re
 
 e2option.documentation = [[
index 38c983db705a911bd36221328e469d1549830dc3..7a7b876534845de3cef9a8f7bd9918216049fb07 100644 (file)
@@ -26,6 +26,7 @@
 ]]
 
 module("policy", package.seeall)
+local err = require("err")
 
 function source_set_lazytag()
        return "lazytag"
@@ -133,7 +134,7 @@ end
 -- @return the buildid
 
 function init(info)
-       local e = new_error("checking policy")
+       local e = err.new("checking policy")
        -- check if all required servers exist
        local storage = {
                storage_release,
@@ -145,7 +146,7 @@ function init(info)
                local location = "test/test"
                local release_id = "release-id"
                local server, location = s(location, release_id)
-               local se = new_error("checking server configuration for '%s'",
+               local se = err.new("checking server configuration for '%s'",
                                                                        server)
                local ce, re = info.cache:ce_by_server(server)
                if not ce then
index 8e188acf04f2fb39b8f20db46fb41f5d50888bfa..8fc4d03a1fc05af96d7dac7f81e887632de89004 100644 (file)
@@ -26,6 +26,7 @@
 ]]
 
 scm = module("scm", package.seeall)
+local err = require("err")
 
 -- scm modules
 local scms = {}
@@ -39,7 +40,7 @@ local intf = {}
 -- @return bool
 -- @return an error object on failure
 function register(scmname, mod)
-  local e = new_error("error registering scm")
+  local e = err.new("error registering scm")
   if scms[scmname] then
     return false, e:append("scm with that name exists")
   end
@@ -58,7 +59,7 @@ end
 -- @return bool
 -- @return an error object on failure
 function register_interface(name)
-  local e = new_error("registering scm interface failed")
+  local e = err.new("registering scm interface failed")
   if intf[name] then
     return false, e:append(
                "interface with that name exists: %s", name)
@@ -68,7 +69,7 @@ function register_interface(name)
   local function func(info, sourcename, ...)
     local src = info.sources[sourcename]
     local rc, re, e
-    e = new_error("calling scm operation failed")
+    e = err.new("calling scm operation failed")
     if not scms[src.type] then
       return false, e:append("no such source type: %s", src.type)
     end
@@ -95,7 +96,7 @@ end
 -- @return bool
 -- @return an error object on failure
 function register_function(type, name, func)
-  local e = new_error("registering scm function failed")
+  local e = err.new("registering scm function failed")
   if not scms[type] then
     return false, e:append("no scm type by that name: %s", type)
   end
index 2b38a90ed8f415a319b8ae6ec94d81e8cfc705d5..c95bd93b342abc3c8fffbc1f562ff190905efb8d 100644 (file)
@@ -32,6 +32,7 @@ require("scm")
 local hash = require("hash")
 local url = require("url")
 local tools = require("tools")
+local err = require("err")
 
 --- translate url into subversion url
 -- @param u table: url table
@@ -39,7 +40,7 @@ local tools = require("tools")
 -- @return an error object on failure
 function mksvnurl(surl)
   local rc, re
-  local e = new_error("cannot translate url into subversion url:")
+  local e = err.new("cannot translate url into subversion url:")
   e:append("%s", surl)
   local u, re = url.parse(surl)
   if not u then
@@ -68,7 +69,7 @@ function svn.fetch_source(info, sourcename)
   if not rc then
     return false, re
   end
-  local e = new_error("fetching source failed: %s", sourcename)
+  local e = err.new("fetching source failed: %s", sourcename)
   local src = info.sources[sourcename]
   local location = src.location
   local server = src.server
@@ -95,7 +96,7 @@ function svn.prepare_source(info, sourcename, source_set, build_path) --OK
   if not rc then
     return false, re
   end
-  local e = new_error("svn.prepare_source failed")
+  local e = err.new("svn.prepare_source failed")
   local src = info.sources[ sourcename ]
   local location = src.location
   local server = src.server
@@ -148,7 +149,7 @@ end
 
 function svn.check_workingcopy(info, sourcename) --OK
        local rc, re
-       local e = new_error("checking working copy failed")
+       local e = err.new("checking working copy failed")
        e:append("in source %s (svn configuration):", sourcename)
        e:setcount(0)
        rc, re = svn.validate_source(info, sourcename)
@@ -246,7 +247,7 @@ function svn.toresult(info, sourcename, sourceset, directory) --OK
        -- <directory>/makefile
        -- <directory>/licences
        local rc, re
-       local e = new_error("converting result")
+       local e = err.new("converting result")
        rc, re = git.check(info, sourcename, true)
        if not rc then
                return false, e:cat(re)
@@ -307,7 +308,7 @@ function svn.update(info, sourcename)
   if not rc then
     e2lib.abort(re)
   end
-  local e = new_error("updating svn source failed")
+  local e = err.new("updating svn source failed")
   local src = info.sources[ sourcename ]
   local working = string.format("%s/%s", info.root, src.working)
   rc, re = e2lib.chdir(working)
@@ -335,7 +336,7 @@ function svn.validate_source(info, sourcename) --OK
   if not src.sourceid then
     src.sourceid = {}
   end
-  local e = new_error("in source %s:", sourcename)
+  local e = err.new("in source %s:", sourcename)
   rc, re = git.source_apply_default_working(info, sourcename)
   if not rc then
     return false, e:cat(re)