]> git.e2factory.org Git - e2factory.git/commitdiff
Unbreak --wc-mode and make it work with intermediary deps
authorTobias Ulmer <tu@emlix.com>
Tue, 25 Mar 2014 16:47:06 +0000 (17:47 +0100)
committerTobias Ulmer <tu@emlix.com>
Tue, 25 Mar 2014 17:07:54 +0000 (18:07 +0100)
Adds a partially random buildid to scratch results, triggering a rebuild
of any result that has a scratch result in its dependency chain.

Signed-off-by: Tobias Ulmer <tu@emlix.com>
Changelog
local/e2build.lua
local/policy.lua

index ee6892a1004cf2410153c0110f084fa0bd720db4..318cf53e76fc0af3692cfa7394723efe463c14b5 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,7 @@
 NEXT:
+ * Unbreak --wc-mode and allow specifying multiple results, including
+   intermediary dependencies. Beware this changes wc-mode buildid from "scratch"
+   to "scratch-<buildid>".
  * Include revision ID in SVN sourceid calculation, fixing various issue with
    moving tags and branch mode. Also fix licenceid calculation for svn sources.
  * Fix error message for unknown chroot tarball extension.
index 9e81c5a15f2b788e5792a419c54c36c43b0f444b..2bd525c8e4a1220c61bb18a3136b76405b24b217 100644 (file)
@@ -50,7 +50,7 @@ local function linklast(info, r, return_flags)
     local server, location = res.build_mode.storage(info.project_location,
     info.release_id)
     local location1 = string.format("%s/%s/%s", location, r,
-    res.build_mode.buildid(res.buildid))
+        e2tool.buildid(info, r))
     local cache_flags = {
         check_only = true
     }
@@ -91,7 +91,7 @@ local function result_available(info, r, return_flags)
     e2lib.log(4, string.format("result_available(%s)", tostring(r)))
     local res = info.results[r]
     local mode = res.build_mode
-    local buildid = res.build_mode.buildid(e2tool.buildid(info, r))
+    local buildid = e2tool.buildid(info, r)
     local sbid = e2tool.bid_display(buildid)
     local rc, re
     local e = err.new("error while checking if result is available: %s", r)
@@ -476,8 +476,8 @@ function e2build.unpack_result(info, r, dep, destdir)
     local d = info.results[dep]
     local buildid = e2tool.buildid(info, dep)
 
-    local dep_set = res.build_mode.dep_set(buildid)
-    local server, location = res.build_mode.storage(info.project_location,
+    local dep_set = d.build_mode.dep_set(buildid)
+    local server, location = d.build_mode.storage(info.project_location,
     info.release_id)
     e2lib.log(3, string.format("searching for dependency %s in %s:%s",
     dep, server, location))
@@ -917,7 +917,7 @@ local function store_result(info, r, return_flags)
     end
     local server, location = res.build_mode.storage(info.project_location,
     info.release_id)
-    local buildid = res.build_mode.buildid(e2tool.buildid(info, r))
+    local buildid = e2tool.buildid(info, r)
     local sourcefile = string.format("%s/result.tar", tmpdir)
     local location1 = string.format("%s/%s/%s/result.tar", location, r, buildid)
     local cache_flags = {
index e9dc427edf90a0573ee6e6d22c70f819c1f48148..eef4f41c981598b69b0280020affce9b33ef0951 100644 (file)
@@ -33,6 +33,7 @@ local e2lib = require("e2lib")
 local err = require("err")
 local e2option = require("e2option")
 local strict = require("strict")
+local hash = require("hash")
 
 --- source_set_* get the source set identifier
 -- @class function
@@ -113,8 +114,51 @@ local function buildid_buildid(buildid)
     return buildid
 end
 
+local buildid_scratch_cache = {}
+
 local function buildid_scratch(buildid)
-    return "scratch"
+    --- XXX: Always returning a fixed buildid string does not work when
+    -- the scratch results gets used by results not in scratch mode.
+    -- eg. if we have a result graph like this: root->tag->wc-mode->tag
+    -- the final tag would only be built once and then cached globally.
+    --
+    -- Ideally we would use the hash of the wc-mode result.tar (and making sure
+    -- that its checksum is stable), but getting it requires some bigger
+    -- changes that are currently not possible.
+    --
+    -- Next best thing is to generate a random buildid. However, since
+    -- buildid_scratch() is called multiple times, we need to cache the result
+    -- to make the new buildid stable.
+
+    -- calculate buildid only once to make stable.
+    if buildid_scratch_cache[buildid] then
+        return buildid_scratch_cache[buildid]
+    end
+
+    local rfile, msg, rstr
+    local hc, newbuildid
+
+    rfile, msg = io.open("/dev/urandom")
+    if not rfile then
+        e2lib.abort(msg)
+    end
+
+    rstr = rfile:read(16)
+    if not rstr or string.len(rstr) ~= 16 then
+        e2lib.abort("could not get 16 bytes of entrophy")
+    end
+
+    rfile:close()
+
+    hc = hash.hash_start()
+    hash.hash_append(hc, buildid)
+    hash.hash_append(hc, rstr)
+
+    newbuildid = hash.hash_finish(hc)
+    newbuildid = "scratch-" .. newbuildid
+    buildid_scratch_cache[buildid] = newbuildid
+
+    return buildid_scratch_cache[buildid]
 end
 
 function policy.init(info)