]> git.e2factory.org Git - e2factory.git/commitdiff
result: make the buildconfig table part of the result
authorTobias Ulmer <tu@emlix.com>
Thu, 8 Sep 2016 13:16:15 +0000 (15:16 +0200)
committerTobias Ulmer <tu@emlix.com>
Wed, 16 Nov 2016 14:41:18 +0000 (15:41 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
local/result.lua

index 19959ec2e5de8f8ab6a2434f39fb63ba82b324ed..5b8a406d6c1051892d198427785b886e8ff68e31 100644 (file)
@@ -20,6 +20,7 @@
 
 local result = {}
 
+local buildconfig = require("buildconfig")
 local chroot = require("chroot")
 local class = require("class")
 local e2lib = require("e2lib")
@@ -65,7 +66,6 @@ function result.basic_result:initialize(rawres)
     --
     -- e2build currently needs this stuff in every result.
     --
-    self._build_config = false
     self._build_mode = false
     self._build_process = false
     self._chroot_list = sl.sl:new(false, true)
@@ -139,21 +139,54 @@ function result.basic_result:merged_env()
         self._type, self._name))
 end
 
---- Set build_config table for result. XXX: better solution would be nice
-function result.basic_result:set_buildconfig(bc)
-    assertIsTable(bc)
-    assertIsNil(self.build_config)
-    self._build_config = bc
-end
-
---- Get build_config table if it was set
+--- Return locked buildconfig table
+-- XXX: This is more like "chroot-config"
+-- @return buildconfig table (locked) or false on error
+-- @return error object.
 function result.basic_result:buildconfig()
-    assertIsTable(self._build_config)
-    assertIsNil(self.build_config)
+    local rc, re, e, buildid, bc, tmpdir, builddir, info
+
+    info = e2tool.info()
+    assertIsTable(info)
+    e = err.new("preparing build config for %s failed", self:get_name())
+
+    buildid, re = self:buildid()
+    if not buildid then
+        return false, e:cat(re)
+    end
 
-    -- XXX: Returned table can be changed, and the current code relies on it
-    -- XXX: It would be nice if this could be fixed, but for now this has to do
-    return self._build_config
+    bc = {}
+    tmpdir = string.format("%s/e2factory-%s.%s.%s-build/%s",
+        e2lib.globals.tmpdir, buildconfig.MAJOR, buildconfig.MINOR,
+        buildconfig.PATCHLEVEL, e2lib.globals.osenv["USER"])
+    builddir = "tmp/e2"
+
+    bc.base = e2lib.join(tmpdir, project.name(), self:get_name())
+    bc.c = e2lib.join(bc.base, "chroot")
+    bc.chroot_marker = e2lib.join(bc.base, "e2factory-chroot")
+    bc.chroot_lock = e2lib.join(bc.base, "e2factory-chroot-lock")
+    bc.T = e2lib.join(tmpdir, project.name(), self:get_name(), "chroot", builddir)
+    bc.Tc = e2lib.join("/", builddir)
+    bc.r = self:get_name()
+    bc.chroot_call_prefix = project.chroot_call_prefix()
+    bc.buildlog = string.format("%s/log/build.%s.log", info.root, self:get_name())
+    bc.scriptdir = "script"
+    bc.build_driver_file = "build-driver"
+    bc.buildrc_file = "buildrc"
+    bc.buildrc_noinit_file = "buildrc-noinit"
+    bc.profile = "/tmp/bashrc"
+
+    bc.builtin_env = environment.new()
+    bc.builtin_env:set("E2_TMPDIR", bc.Tc)
+    bc.builtin_env:set("E2_RESULT", self:get_name())
+    bc.builtin_env:set("E2_RELEASE_ID", project.release_id())
+    bc.builtin_env:set("E2_PROJECT_NAME", project.name())
+    bc.builtin_env:set("E2_BUILDID", buildid)
+    bc.builtin_env:set("T", bc.Tc)
+    bc.builtin_env:set("r", self:get_name())
+    bc.builtin_env:set("R", self:get_name())
+
+    return strict.readonly(bc)
 end
 
 --- Set build_mode table for result: