]> git.e2factory.org Git - e2factory.git/commitdiff
licence config: Switch to new file format, similar to source file
authorGordon Hecker <gh@emlix.com>
Wed, 28 Oct 2009 15:40:49 +0000 (16:40 +0100)
committerGordon Hecker <gh@emlix.com>
Mon, 2 Nov 2009 12:44:10 +0000 (13:44 +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/licences.text
local/e2build.lua
local/e2tool.lua
local/ls-project.lua

index 2fa10465bb505e4eb9c039f53687ef5d347a7d46..1fc663be3f9a84d90e5db437a245be51bdb826a1 100644 (file)
@@ -17,9 +17,15 @@ Example:
 
     e2licence {
         gpl_2 = {
-            server = "upstream",
+            server = ".",
             files = {
-                "licence/gpl-2/COPYING",
+                {
+                    -- server is inherited if not given here
+                    server = ".",
+                    location = "licence/gpl-2/COPYING",
+                    -- sha1 is required when the server is not "."
+                    -- sha1 = "bd3c28b6df9c950cc68d5141c65acfc661779f5e",
+                },
             }
         }
     }
index fd68a4350bb7178e7888479d8d22e32f89ffc9c5..4929980738a05005ee588ea5973c7782251c746e 100644 (file)
@@ -1067,9 +1067,16 @@ function e2build.collect_project(info, r, return_flags)
                e2lib.mkdir(destdir, "-p")
                for _,file in ipairs(lic.files) do
                        local cache_flags = {}
-                       local server = lic.server
-                       rc, re = cache.fetch_file(info.cache, server, file,
-                                               destdir, nil, cache_flags)
+                       if file.sha1 then
+                               rc, re = e2tool.verify_hash(info, file.server,
+                                               file.location, file.sha1)
+                               if not rc then
+                                       return false, e:cat(re)
+                               end
+                       end
+                       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
index cc3edde2aa0526898a522316ffa515dc115c5b4f..f1fbc566f84aabfad6fe89ddd8c60647d1336fee 100644 (file)
@@ -1341,14 +1341,19 @@ function e2tool.licenceid(info, licence)
        end
        local hc = hash.hash_start()
        hc:hash_line(licence)                   -- licence name
-       hc:hash_line(lic.server)                -- server name
-       for _,file in ipairs(lic.files) do
-               local h, re = e2tool.hash_file(info, lic.server, file)
-                if not h then
-                       return nil, e:cat(re)
-                end
-               hc:hash_line(file)              -- licence file name
-               hc:hash_line(h)                 -- licence file content
+       for _,f in ipairs(lic.files) do
+               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
        lic.licenceid, re = hc:hash_finish()
        if not lic.licenceid then
@@ -1667,9 +1672,34 @@ function e2tool.check_licence(info, l)
        elseif not type(lic.files) == "table" then
                e:append("files attribute is not a table")
        else
-               for _,file in ipairs(lic.files) do
-                       if not type(file) == "string" then
-                               e:append("file list holds non-string element")
+               for _,f in ipairs(lic.files) do
+                       local inherit = {
+                         server = lic.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:cat(re)
+                       elseif f.server ~= info.root_server_name and
+                              not f.sha1 then
+                               e:append("file entry for remote file without"..
+                                                       " `sha1` attribute")
                        end
                end
        end
index c9151f6e6843347a4b760a6f60b744bca7d5d259..c2f8a276dfa2ae4c5c31d5cf8e992a9985d3d58d 100755 (executable)
@@ -270,9 +270,8 @@ for _,l in pairs(info.licences_sorted) do
     s2 = " "
   end
   p2(s1, s2, l)
-  p3(s1, s2, "server", lic.server)
-  for _,file in ipairs(lic.files) do
-    p3(s1, s2, "file", file)
+  for _,f in ipairs(lic.files) do
+    p3(s1, s2, "file", string.format("%s:%s", f.server, f.location))
   end
 end