From: Tobias Ulmer Date: Mon, 10 Feb 2014 18:29:10 +0000 (+0100) Subject: Simplify chroot setup by dropping build_config.groups X-Git-Tag: e2factory-2.3.15rc1~224 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=813d16950d160bc742ce79ef20444b58f986e5ea;p=e2factory.git Simplify chroot setup by dropping build_config.groups Use chroot groups of the result instead of going through build_config.groups. Make sure res.chroot is sorted independent of proj/chroot. Previously we did a complicated dance adding all required groups to a build_config dict and then iterated over the entire chroot table. The order in which chroot groups were untared did depend on the order of appearance in proj/chroot. Signed-off-by: Tobias Ulmer --- diff --git a/local/e2build.lua b/local/e2build.lua index 3d59388..a226a8e 100644 --- a/local/e2build.lua +++ b/local/e2build.lua @@ -188,7 +188,6 @@ end -- @field buildrc_file XXX -- @field buildrc_noinit_file XXX -- @field profile Configuration file passed to the shell (string). --- @field groups table of strings: chroot groups -- @field builtin_env Environment that's built in like E2_TMPDIR. --- Generate build_config and store in res.build_config. @@ -236,12 +235,6 @@ function e2build.build_config(info, r) bc.buildrc_file = "buildrc" bc.buildrc_noinit_file = "buildrc-noinit" bc.profile = "/tmp/bashrc" - - bc.groups = {} - for _,g in ipairs(res.chroot) do - bc.groups[g] = true - end - bc.builtin_env = environment.new() bc.builtin_env:set("E2_TMPDIR", bc.Tc) bc.builtin_env:set("E2_RESULT", r) @@ -315,40 +308,42 @@ local function setup_chroot(info, r, return_flags) if not rc then return false, e:cat(re) end - for _,grp in ipairs(info.chroot.groups) do - if res.build_config.groups[grp.name] then - for _, f in ipairs(grp.files) do - local flags = { cache = true } - local rc, re = cache.cache_file(info.cache, f.server, - f.location, flags) - if not rc then - return false, e:cat(re) - end - local path, re = cache.file_path(info.cache, f.server, - f.location, flags) - if not path then - return false, e:cat(re) - end - if f.sha1 then - rc, re = e2tool.verify_hash(info, f.server, f.location, f.sha1) - if not rc then - return false, e:cat(re) - end - end - local tartype - tartype, re = e2lib.tartype_by_suffix(path) - if not tartype then - return false, e:cat(re) - end - e2tool.set_umask(info) - local argv = { "extract_tar_2_3", res.build_config.base, tartype, path } - local rc, re = e2lib.e2_su_2_2(argv) - e2tool.reset_umask(info) + local grp + for _,cgrpnm in ipairs(res.chroot) do + grp = info.chroot.groups_byname[cgrpnm] + + for _, f in ipairs(grp.files) do + local flags = { cache = true } + local rc, re = cache.cache_file(info.cache, f.server, + f.location, flags) + if not rc then + return false, e:cat(re) + end + local path, re = cache.file_path(info.cache, f.server, + f.location, flags) + if not path then + return false, e:cat(re) + end + if f.sha1 then + rc, re = e2tool.verify_hash(info, f.server, f.location, f.sha1) if not rc then return false, e:cat(re) end end + local tartype + tartype, re = e2lib.tartype_by_suffix(path) + if not tartype then + return false, e:cat(re) + end + + e2tool.set_umask(info) + local argv = { "extract_tar_2_3", res.build_config.base, tartype, path } + local rc, re = e2lib.e2_su_2_2(argv) + e2tool.reset_umask(info) + if not rc then + return false, e:cat(re) + end end end return true, nil diff --git a/local/e2tool.lua b/local/e2tool.lua index ebbd40b..ecd6939 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -366,11 +366,12 @@ local function check_result(info, resultname) e:append("chroot attribute:") e:cat(re) end - for i,g in pairs(res.chroot) do + for _,g in ipairs(res.chroot) do if not info.chroot.groups_byname[g] then e:append("chroot group does not exist: %s", g) end end + table.sort(res.chroot) end if res.env and type(res.env) ~= "table" then e:append("result has invalid `env' attribute")