]> git.e2factory.org Git - e2factory.git/commitdiff
chroot config: Switch to new file format, similar to source file
authorGordon Hecker <gh@emlix.com>
Thu, 29 Oct 2009 13:18:28 +0000 (14:18 +0100)
committerGordon Hecker <gh@emlix.com>
Mon, 2 Nov 2009 11:57:08 +0000 (12:57 +0100)
configuration, require sha1 checksums to be configured for files located
on servers other than "."

Signed-off-by: Gordon Hecker <gh@emlix.com>
doc/manual/chroot.text
local/e2build.lua
local/e2tool.lua
local/ls-project.lua

index 0385e2d623f13188dc177f1667dbe914c86bea33..fc601890101b5c5b908df3219c15559863ecdd3c 100644 (file)
@@ -33,14 +33,25 @@ Example:
         { name = "base",
           server = "chroot",
           files = {
-              "chroot/20080916/base.tar.gz",
+            {
+              location = "chroot/20080916/base.tar.gz",
+              sha1 = "adc83b19e793491b1c6ea0fd8b46cd9f32e592fc",
+            },
           },
         },
         { name = "host-gcc",
           server = "chroot",
           files = {
-            "chroot/20080916/binutils.tar.gz",
-            "chroot/20080916/gcc34.tar.gz",
+            {
+              -- server is inherited from the group if not configured here
+              server = "chroot",
+              location = "chroot/20080916/binutils.tar.gz",
+              sha1 = "55b6aaa6f91b7cd6bf7e47dbb7af548ef8bb85e8",
+            },
+            {
+              location = "chroot/20080916/gcc34.tar.gz",
+              sha1 = "7f69da1b33b39f124cc37331711de8e12bbbc758",
+            },
           },
         },
       }
index 59f9a9b034387f39b731e95ea8379425c7eed62a..183a7560e5db5892f7775f01ee27d593cc9ddd17 100644 (file)
@@ -262,11 +262,13 @@ function e2build.setup_chroot(info, r, return_flags)
     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, grp.server, f, flags)
+        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, grp.server, f, flags)
+        local path, re = cache.file_path(info.cache, f.server, f.location,
+                                                               flags)
        if not path then
          return false, e:cat(re)
        end
@@ -1017,12 +1019,13 @@ function e2build.collect_project(info, r, return_flags)
                e2lib.mkdir(destdir, "-p")
                for _,file in pairs(grp.files) do
                        local cache_flags = {}
-                       local server = grp.server
-                       rc, re = cache.fetch_file(info.cache, server, file,
-                                               destdir, nil, cache_flags)
+                       rc, re = cache.fetch_file(info.cache, file.server,
+                               file.location, destdir, nil, cache_flags)
                        if not rc then
                                return false, e:cat(re)
                        end
+                       -- XXX organize for checksum checking when building
+                       -- XXX the project out of the collect_project result
                end
        end
        -- project/licences/<licence>/<files>
index 02bcd20842ddc5098c88109b896e17e72a677979..cc3edde2aa0526898a522316ffa515dc115c5b4f 100644 (file)
@@ -1448,7 +1448,10 @@ function e2tool.pbuildid(info, resultname)
                end
                hash.hash_line(hc, lid)         -- licence id
        end
-       local groupid = e2tool.chrootgroupid(info, "base")
+       local groupid, re = e2tool.chrootgroupid(info, "base")
+       if not groupid then
+               return nil, e:cat(re)
+       end
        hc:hash_line(groupid)
        if r.chroot then
                for _,g in ipairs(r.chroot) do
@@ -1520,16 +1523,27 @@ function e2tool.flush_buildids(info)
 end
 
 function e2tool.chrootgroupid(info, groupname)
+       local e = new_error("calculating chroot group id failed for group %s",
+                                                               groupname)
        local g = info.chroot.groups_byname[groupname]
        if g.groupid then
                return g.groupid
        end
        local hc = hash.hash_start()
        hc:hash_line(g.name)
-       hc:hash_line(g.server)
        for _,f in ipairs(g.files) do
-               hc:hash_line(f)
-               -- XXX  hash each file?
+               hc:hash_line(f.server)
+               hc:hash_line(f.location)
+               if f.sha1 then
+                       hc:hash_line(f.sha1)
+               else
+                       local h, re = e2tool.hash_file(info, f.server,
+                                                               f.location)
+                       if not h then
+                               return false, e:cat(re)
+                       end
+                       hc:hash_line(h)
+               end
        end
        e2lib.log(4, string.format("hash data for chroot group %s\n%s", 
                                                        groupname, hc.data))
@@ -2398,11 +2412,36 @@ function e2tool.check_chroot_config(info)
       e:append("in group: %s", grp.name)
       e:append(" list of files is empty")
     else
-      for _,l in ipairs(grp.files) do
-        if type(l) ~= "string" then
-          e:append("in group: %s", grp.name)
-          e:append(" file list contains non-string element")
-        end
+      for _,f in ipairs(grp.files) do
+       local inherit = {
+         server = grp.server,
+       }
+       local keys = {
+         server = {
+           mandatory = true,
+           type = "string",
+           inherit = true,
+         },
+         location = {
+           mandatory = true,
+           type = "string",
+           inherit = false,
+         },
+         sha1 = {
+           mandatory = false,
+           type = "string",
+           inherit = false,
+         },
+       }
+       local rc, re = check_tab(f, keys, inherit)
+       if not rc then
+         e:append("in group: %s", grp.name)
+         e:cat(re)
+       end
+       if f.server ~= info.root_server_name and not f.sha1 then
+         e:append("in group: %s", grp.name)
+         e:append("file entry for remote file without `sha1` attribute")
+       end
       end
     end
   end
index 869d57ea77b0a50afdcc43eef82b4c0391e60600..c9151f6e6843347a4b760a6f60b744bca7d5d259 100755 (executable)
@@ -292,8 +292,9 @@ for _,g in ipairs(info.chroot.groups_sorted) do
                s2 = " "
        end
        p2(s1, s2, grp.name, grp.name)
-       p3(s1, s2, "server", grp.server)
-       p3t(s1, s2, "files", grp.files)
+       for _,f in ipairs(grp.files) do
+               p3(s1, s2, "file", string.format("%s:%s", f.server, f.location))
+       end
        if grp.groupid then
                p3(s1, s2, "groupid", grp.groupid)
        end