]> git.e2factory.org Git - e2factory.git/commitdiff
files: fix sub-licences default assignment
authorTobias Ulmer <tu@emlix.com>
Fri, 3 Mar 2017 17:49:35 +0000 (18:49 +0100)
committerTobias Ulmer <tu@emlix.com>
Fri, 3 Mar 2017 17:49:38 +0000 (18:49 +0100)
During the initialization of file entries, new licences were added to
the "outer" file licences list.

This lead to file entries without a licences list getting additional
licence entries that shouldn't have been there.

Signed-off-by: Tobias Ulmer <tu@emlix.com>
Changelog
plugins/files.lua

index 15a18ce68bf1d9e65ac0f7b44fe25406ddee71b5..0364b1f1da3a7c1e0063fdbf38834d06abd014bb 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,5 @@
 NEXT:
+ * fixed sub-licences handling for file sources
  * ls-project add --unused option
  * ls-project <result> only shows chroot groups used by listed results
  * ls-project <result> only shows licences used by the listed sources
index ca83423c299da1152ffa1846ffd2368ca709b2e3..e30c488374510fa70bbb1b9ece04a527b7d2e0f3 100644 (file)
@@ -199,6 +199,7 @@ function files.files_source:initialize(rawsrc)
 
     self._files = {}
     self._sourceid = false
+    self._orig_licences = false
 
     rc, re = e2lib.vrfy_dict_exp_keys(rawsrc, "e2source config", {
         "env",
@@ -231,6 +232,10 @@ function files.files_source:initialize(rawsrc)
         error(err.new("`file' attribute must be a table"))
     end
 
+    -- We extend licences() later as more sub-licences are discovered.
+    -- Keep a copy of the original "outer" licences
+    self._orig_licences = self:licences():copy()
+
     e = err.new("error in file list of source")
     for _,f in ipairs(rawsrc.file) do
         local file
@@ -297,21 +302,19 @@ function files.files_source:initialize(rawsrc)
         file:patch(f.patch)
 
         -- per file licences --
+        file:licences(sl.sl:new())
+
         local laerr = string.format("%s:%s licences attribute",
             f.server, f.location)
-        local llist, licences
 
         if f.licences == nil then
-            f.licences = self:get_licences()
+            file:licences():insert_sl(self._orig_licences)
         elseif type(f.licences == "table") then
             rc, re = e2lib.vrfy_listofstrings(f.licences, laerr, true, false)
             if not rc then
                 error(e:cat(re))
             end
 
-            licences = self:get_licences()
-            llist = sl.sl:new()
-
             for _,licencename in ipairs(f.licences) do
                 if not licence.licences[licencename] then
                     error(e:append("%s has unknown licence: %q",
@@ -320,18 +323,13 @@ function files.files_source:initialize(rawsrc)
 
                 -- Make sure the main licences list contains every licence in
                 -- the entire source.
-                licences:insert(licencename)
-                llist:insert(licencename)
+                self:licences():insert(licencename)
+                file:licences():insert(licencename)
             end
-
-            self:set_licences(licences)
-            f.licences = llist
         else
             error(e:append("%s must be a table", laerr))
         end
 
-        file:licences(f.licences)
-
         table.insert(self._files, file)
     end
 end
@@ -365,7 +363,7 @@ function files.files_source:sourceid(sourceset)
     hash.hash_append(hc, self._env:envid())
 
     -- all licences
-    for licencename in self:get_licences():iter() do
+    for licencename in self:licences():iter() do
         local lid, re = licence.licences[licencename]:licenceid()
         if not lid then
             return false, re
@@ -398,7 +396,7 @@ function files.files_source:display(sourceset)
     d = {}
     table.insert(d, string.format("type       = %s", self:get_type()))
     table.insert(d, string.format("licences   = %s",
-        self:get_licences():concat(" ")))
+        self:licences():concat(" ")))
 
     for file in self:file_iter() do
         s = string.format("file       = %s", file:servloc())