]> git.e2factory.org Git - e2factory.git/commitdiff
Simplify chroot setup by dropping build_config.groups
authorTobias Ulmer <tu@emlix.com>
Mon, 10 Feb 2014 18:29:10 +0000 (19:29 +0100)
committerTobias Ulmer <tu@emlix.com>
Wed, 16 Nov 2016 14:41:17 +0000 (15:41 +0100)
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 <tu@emlix.com>
local/e2build.lua
local/e2tool.lua

index 3d593881139648cc27bb85a341d3226c8e7334a3..a226a8e92503950b061c34a2a1e1e551fa166349 100644 (file)
@@ -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
index ebbd40bad07d254563c911a72dd16aa1729ba7e1..ecd693932f884e69f6f4d528c3de5e204c6b623d 100644 (file)
@@ -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")