From: Gordon Hecker Date: Thu, 29 Oct 2009 13:18:28 +0000 (+0100) Subject: chroot config: Switch to new file format, similar to source file X-Git-Tag: e2factory-2.3.2rc1~19 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=0260ad89c459958c486b8dece014008a7e0a97fb;p=e2factory.git chroot config: Switch to new file format, similar to source file configuration, require sha1 checksums to be configured for files located on servers other than "." Signed-off-by: Gordon Hecker --- diff --git a/doc/manual/chroot.text b/doc/manual/chroot.text index 0385e2d..fc60189 100644 --- a/doc/manual/chroot.text +++ b/doc/manual/chroot.text @@ -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", + }, }, }, } diff --git a/local/e2build.lua b/local/e2build.lua index 59f9a9b..183a756 100644 --- a/local/e2build.lua +++ b/local/e2build.lua @@ -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// diff --git a/local/e2tool.lua b/local/e2tool.lua index 02bcd20..cc3edde 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -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 diff --git a/local/ls-project.lua b/local/ls-project.lua index 869d57e..c9151f6 100755 --- a/local/ls-project.lua +++ b/local/ls-project.lua @@ -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