]> git.e2factory.org Git - e2factory.git/commitdiff
e2tool: buildid() now returns error instead of calling abort()
authorTobias Ulmer <tu@emlix.com>
Wed, 17 Apr 2013 13:24:42 +0000 (15:24 +0200)
committerTobias Ulmer <tu@emlix.com>
Wed, 16 Nov 2016 13:58:55 +0000 (14:58 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
local/e2-build.lua
local/e2build.lua
local/e2tool.lua

index f62a03ba05a77ac653db2a44e7f70a309012d406..a7e90f386d442dca3d622ab33911063f0dcfa094 100644 (file)
@@ -204,7 +204,11 @@ local function e2_build(arg)
 
     if opts["buildid"] then
         for _,r in ipairs(sel_res) do
-            print(string.format("%-20s [%s]", r, e2tool.buildid(info, r)))
+            local bid, re = e2tool.buildid(info, r)
+            if not bid then
+                return false, re
+            end
+            print(string.format("%-20s [%s]", r, bid))
         end
 
         return true
index 38065804495d2781e26218e62da19f4cc3b72fc0..edceb048d55ba47f46ff0841989855bdeba9c172 100644 (file)
@@ -89,12 +89,18 @@ end
 -- @return an error object on failure
 local function result_available(info, r, return_flags)
     local res = info.results[r]
-    local mode = res.build_mode
-    local buildid = e2tool.buildid(info, r)
-    local sbid = e2tool.bid_display(buildid)
     local rc, re
+    local buildid, sbid
     local e = err.new("error while checking if result is available: %s", r)
     local columns = tonumber(e2lib.globals.osenv["COLUMNS"])
+
+    buildid, re = e2tool.buildid(info, r)
+    if not buildid then
+        return false, e:cat(re)
+    end
+
+    sbid = e2tool.bid_display(buildid)
+
     if res.playground then
         return_flags.message = e2lib.align(columns,
         0, string.format("building %-20s", r),
@@ -110,11 +116,13 @@ local function result_available(info, r, return_flags)
         return_flags.stop = false
         return true, nil
     end
-    local server, location = mode.storage(info.project_location, info.release_id)
-    local dep_set = mode.buildid(e2tool.buildid(info, r))
+    local server, location =
+        res.build_mode.storage(info.project_location, info.release_id)
+    local dep_set = res.build_mode.dep_set(buildid)
+
     -- cache the result
     local result_location = string.format("%s/%s/%s/result.tar", location, r,
-    dep_set)
+        dep_set)
     local cache_flags = {}
     rc, re = info.cache:cache_file(server, result_location, cache_flags)
     if not rc then
@@ -480,7 +488,11 @@ function e2build.unpack_result(info, r, dep, destdir)
     local tmpdir = e2lib.mktempdir()
     local e = err.new("unpacking result failed: %s", dep)
     local d = info.results[dep]
-    local buildid = e2tool.buildid(info, dep)
+
+    local buildid, re = e2tool.buildid(info, dep)
+    if not buildid then
+        return false, re
+    end
 
     local dep_set = d.build_mode.dep_set(buildid)
     local server, location = d.build_mode.storage(info.project_location,
@@ -917,13 +929,18 @@ local function store_result(info, r, return_flags)
     end
     local server, location = res.build_mode.storage(info.project_location,
     info.release_id)
-    local buildid = e2tool.buildid(info, r)
+
+    local buildid, re = e2tool.buildid(info, r)
+    if not buildid then
+        return false, re
+    end
+
     local sourcefile = string.format("%s/result.tar", tmpdir)
     local location1 = string.format("%s/%s/%s/result.tar", location, r, buildid)
     local cache_flags = {
         try_hardlink = true,
     }
-    local rc, re = info.cache:push_file(sourcefile, server, location1,
+    rc, re = info.cache:push_file(sourcefile, server, location1,
     cache_flags)
     if not rc then
         return false, e:cat(re)
index 1052a0ece2fbf84738604c5e1cf96412d410024f..3d3798f1c5245bdb6d03725649a2032ebeaef8b5 100644 (file)
@@ -2129,16 +2129,16 @@ function e2tool.bid_display(buildid)
     return string.format("%s...", string.sub(buildid, 1, 8))
 end
 
---- get the buildid for a result, calculating it if required
--- XXX this function always succeeds or aborts
--- @param info
--- @param resultname
--- @return the buildid
+--- Get the buildid for a result, calculating it if required.
+-- @param Info table.
+-- @param Result name.
+-- @return Build ID or false on error
+-- @return Error object on failure
 function e2tool.buildid(info, resultname)
     local r = info.results[resultname]
     local id, e = e2tool.pbuildid(info, resultname)
     if not id then
-        e2lib.abort(e)
+        return false, e
     end
     local hc = hash.hash_start()
     hc:hash_line(r.buildno)