From b3698d3324b3989501e336745c203eb7d97e3f79 Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Fri, 3 Mar 2017 18:49:35 +0100 Subject: [PATCH] files: fix sub-licences default assignment 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 --- Changelog | 1 + plugins/files.lua | 26 ++++++++++++-------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Changelog b/Changelog index 15a18ce..0364b1f 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ NEXT: + * fixed sub-licences handling for file sources * ls-project add --unused option * ls-project only shows chroot groups used by listed results * ls-project only shows licences used by the listed sources diff --git a/plugins/files.lua b/plugins/files.lua index ca83423..e30c488 100644 --- a/plugins/files.lua +++ b/plugins/files.lua @@ -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()) -- 2.39.5