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

Daniel P. Berrangé berrange at redhat.com
Thu Feb 21 16:33:52 UTC 2019


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

Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
---
 guests/lcitool | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/guests/lcitool b/guests/lcitool
index 5c2b785..2af6878 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -548,8 +548,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
@@ -557,21 +556,15 @@ 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 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




More information about the libvir-list mailing list