From 88466e8ab4a4875865f99530a52c15891e9ac964 Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Thu, 8 Sep 2016 15:16:15 +0200 Subject: [PATCH] result: make the buildconfig table part of the result Signed-off-by: Tobias Ulmer --- local/result.lua | 61 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 14 deletions(-) diff --git a/local/result.lua b/local/result.lua index 19959ec..5b8a406 100644 --- a/local/result.lua +++ b/local/result.lua @@ -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: -- 2.39.5