[libvirt-jenkins-ci PATCH 5/7] lcitool: Use commands[] for deb-based distros

Andrea Bolognani abologna at redhat.com
Fri Mar 27 19:34:57 UTC 2020


It's nicer to use, and will make further changes easier.

This commit is better viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 guests/lcitool | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/guests/lcitool b/guests/lcitool
index 98ef2a0..fb0219b 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -797,20 +797,20 @@ class Application:
 
         print("FROM {}".format(facts["docker_base"]))
 
+        commands = []
+
         if package_format == "deb":
-            sys.stdout.write(textwrap.dedent("""
-                RUN export DEBIAN_FRONTEND=noninteractive && \\
-                    {package_manager} update && \\
-                    {package_manager} dist-upgrade -y && \\
-                    {package_manager} install --no-install-recommends -y {pkgs} && \\
-                    {package_manager} autoremove -y && \\
-                    {package_manager} autoclean -y && \\
-                    sed -Ei 's,^# (en_US\\.UTF-8 .*)$,\\1,' /etc/locale.gen && \\
-                    dpkg-reconfigure locales
-            """).format(**varmap))
+            commands.extend([
+                "export DEBIAN_FRONTEND=noninteractive",
+                "{package_manager} update",
+                "{package_manager} dist-upgrade -y",
+                "{package_manager} install --no-install-recommends -y {pkgs}",
+                "{package_manager} autoremove -y",
+                "{package_manager} autoclean -y",
+                "sed -Ei 's,^# (en_US\\.UTF-8 .*)$,\\1,' /etc/locale.gen",
+                "dpkg-reconfigure locales",
+            ])
         elif package_format == "rpm":
-            commands = []
-
             # Rawhide needs this because the keys used to sign packages are
             # cycled from time to time
             if os_name == "Fedora" and os_version == "Rawhide":
@@ -864,9 +864,8 @@ class Application:
                     "{package_manager} clean all -y",
                 ])
 
-            script = "\nRUN " + (" && \\\n    ".join(commands)) + "\n"
-
-            sys.stdout.write(script.format(**varmap))
+        script = "\nRUN " + (" && \\\n    ".join(commands)) + "\n"
+        sys.stdout.write(script.format(**varmap))
 
         if cross_arch:
             # Intentionally a separate RUN command from the above
-- 
2.25.1




More information about the libvir-list mailing list