]> git.e2factory.org Git - e2factory.git/commitdiff
ls-project: only show licences for listed sources
authorTobias Ulmer <tu@emlix.com>
Tue, 28 Feb 2017 18:59:07 +0000 (19:59 +0100)
committerTobias Ulmer <tu@emlix.com>
Tue, 28 Feb 2017 19:17:32 +0000 (20:17 +0100)
--all continues to show all licences, including unused ones

Signed-off-by: Tobias Ulmer <tu@emlix.com>
Changelog
local/e2-ls-project.lua

index 600ca25d312f9ff0ed5d27792db2081129f3f905..48ef83caf6107574d41f87a5c726d0b86c49caad 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,5 @@
 NEXT:
+ * ls-project <result> only shows licences used by the listed sources
  * Add new source type "licence", providing licence info to build environment
  * Removed lazytag build mode, it was deprecated for a long time
  * Fix error in cvs source if cvsroot unset
index 7b33a0b57d0713d58cec58926dc779081732e71f..92670112a58ea9708036c26b745619de76723f18 100644 (file)
@@ -113,6 +113,26 @@ local function e2_ls_project(arg)
     end
     table.sort(sources)
 
+    local licences = {}
+    if opts.all then
+        for licencename,_ in pairs(licence.licences) do
+            table.insert(licences, licencename)
+        end
+    else
+        local seen = {}
+        for _,sourcename in ipairs(sources) do
+            local src = source.sources[sourcename]
+
+            for licencename in src:get_licences():iter() do
+                if not seen[licencename] then
+                    table.insert(licences, licencename)
+                    seen[licencename] = true
+                end
+            end
+        end
+    end
+    table.sort(licences)
+
     local function pempty(s1, s2, s3)
         console.infof("   %s  %s  %s\n", s1, s2, s3)
     end
@@ -291,10 +311,12 @@ local function e2_ls_project(arg)
     pempty(s1, s2, s3)
     s2 = "|"
     p1(s1, s2, "licences")
-    local llen = #licence.licences_sorted
-    for _,lic in ipairs(licence.licences_sorted) do
-        llen = llen - 1
-        if llen == 0 then
+
+    local len = #licences
+    for _,licencename in ipairs(licences) do
+        local lic = licence.licences[licencename]
+        len = len - 1
+        if len == 0 then
             s2 = " "
         end
         p2(s1, s2, lic:get_name())