[jenkins-ci PATCH v5 3/5] lcitool: avoid intermediate list of packages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We can purge any packages which expand to None straight away, and
simply convert to a set to get rid of duplicates.

Reviewed-by: Andrea Bolognani <abologna@xxxxxxxxxx>
Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 guests/lcitool | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/guests/lcitool b/guests/lcitool
index 46af92b..88bc945 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -539,8 +539,7 @@ class Application:
                     )
                 )
 
-        temp = {}
-
+        pkgs = {}
         keys = ["default", package_format, os_name, os_full]
         # We need to add the base project manually here: the standard
         # machinery hides it because it's an implementation detail
@@ -548,21 +547,17 @@ class Application:
             for package in self._projects.get_packages(project):
                 for key in keys:
                     if key in mappings[package]:
-                        temp[package] = mappings[package][key]
+                        pkgs[package] = mappings[package][key]
 
-        pkgs = []
-        for item in temp:
-            pkgname = temp[item]
-            if pkgname is None:
-                continue
-            if pkgname in pkgs:
-                continue
-            pkgs.append(pkgname)
+                if package not in pkgs:
+                    continue
+                if pkgs[package] is None:
+                    del pkgs[package]
 
         print("FROM {}".format(facts["docker_base"]))
 
         varmap = {}
-        varmap["pkgs"] = " \\\n            ".join(sorted(pkgs))
+        varmap["pkgs"] = " \\\n            ".join(sorted(set(pkgs.values())))
         if package_format == "deb":
             sys.stdout.write(textwrap.dedent("""
                 RUN export DEBIAN_FRONTEND=noninteractive && \\
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux