[jenkins-ci PATCH v6 1/4] mappings: extend mapping to allow per-arch entries

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

 



For example to prevent Xen being installed on any s390x

  xen:
    deb: libxen-dev
    Fedora: xen-devel
    s390x-default:

Or the inverse to only install Xen on x86_64 on Debian, but allow
it on all archs on Fedora

  xen:
    Fedora: xen-devel
    x86_64-deb: libxen-dev

Note that the architecture specific matches are considered after
all the non-architcture matches.

The dockerfile generator is updated to apply arch filtering based
on the host arch.

The ansible playbook is not actually implementing support for
non-x86_64 architectures in this commit. It is just hardcoding
x86_64, which is enough to ensure the changes in the mappings.yml
file are a no-op initially.

Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 guests/lcitool                             | 16 +++++++++-
 guests/playbooks/update/tasks/packages.yml | 32 +++++++++++++++++++
 guests/vars/mappings.yml                   | 37 ++++++++++++++++++++--
 3 files changed, 81 insertions(+), 4 deletions(-)

diff --git a/guests/lcitool b/guests/lcitool
index 88bc945..d762721 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -20,6 +20,7 @@ import argparse
 import fnmatch
 import json
 import os
+import platform
 import random
 import string
 import subprocess
@@ -79,6 +80,16 @@ class Util:
 
         return sorted(set(matches))
 
+    @staticmethod
+    def get_native_arch():
+        # Same canonicalization as libvirt virArchFromHost
+        arch = platform.machine()
+        if arch in ["i386", "i486", "i586"]:
+            arch = "i686"
+        if arch == "amd64":
+            arch = "x86_64"
+        return arch
+
 
 class Config:
 
@@ -302,6 +313,8 @@ class Application:
         self._inventory = Inventory()
         self._projects = Projects()
 
+        self._native_arch = Util.get_native_arch()
+
         self._parser = argparse.ArgumentParser(
             conflict_handler="resolve",
             description="libvirt CI guest management tool",
@@ -540,7 +553,8 @@ class Application:
                 )
 
         pkgs = {}
-        keys = ["default", package_format, os_name, os_full]
+        base_keys = ["default", package_format, os_name, os_full]
+        keys = base_keys + [self._native_arch + "-" + k for k in base_keys]
         # We need to add the base project manually here: the standard
         # machinery hides it because it's an implementation detail
         for project in projects + ["base"]:
diff --git a/guests/playbooks/update/tasks/packages.yml b/guests/playbooks/update/tasks/packages.yml
index 7fdfc45..01d4616 100644
--- a/guests/playbooks/update/tasks/packages.yml
+++ b/guests/playbooks/update/tasks/packages.yml
@@ -52,6 +52,38 @@
   when:
     - mappings[item][os_name + os_version] is defined
 
+- name: '{{ project }}: Look up mappings (default with arch)'
+  set_fact:
+    temp: '{{ temp|combine({ item: mappings[item]["x86_64" + "-" + "default"] }) }}'
+  with_items:
+    '{{ packages }}'
+  when:
+    - mappings[item]["x86_64" + "-" + "default"] is defined
+
+- name: '{{ project }}: Look up mappings (package format with arch)'
+  set_fact:
+    temp: '{{ temp|combine({ item: mappings[item]["x86_64" + "-" + package_format] }) }}'
+  with_items:
+    '{{ packages }}'
+  when:
+    - mappings[item]["x86_64" + "-" + package_format] is defined
+
+- name: '{{ project }}: Look up mappings (OS name with arch)'
+  set_fact:
+    temp: '{{ temp|combine({ item: mappings[item]["x86_64" + "-" + os_name] }) }}'
+  with_items:
+    '{{ packages }}'
+  when:
+    - mappings[item]["x86_64" + "-" + os_name] is defined
+
+- name: '{{ project }}: Look up mappings (OS version with arch)'
+  set_fact:
+    temp: '{{ temp|combine({ item: mappings[item]["x86_64" + "-" + os_name + os_version] }) }}'
+  with_items:
+    '{{ packages }}'
+  when:
+    - mappings[item]["x86_64" + "-" + os_name + os_version] is defined
+
 - set_fact:
     flattened: []
 
diff --git a/guests/vars/mappings.yml b/guests/vars/mappings.yml
index 8ff2f34..f856cda 100644
--- a/guests/vars/mappings.yml
+++ b/guests/vars/mappings.yml
@@ -7,9 +7,25 @@
 # priority:
 #
 #   - default
-#   - package format (deb, pkg, rpm)
-#   - OS name (CentOS, Debian, Fedora, FreeBSD, Ubuntu)
-#   - OS version (CentOS7, Debian9, FedoraRawhide, Ubuntu18 and so on)
+#   - package format
+#   - OS name
+#   - OS version
+#   - arch with default
+#   - arch with package format
+#   - arch with OS name
+#   - arch with OS version
+#
+# Valid package formats are
+#   - deb, pkg, rpm
+#
+# Valid OS names are:
+#   - CentOS, Debian, Fedora, FreeBSD, Ubuntu
+#
+# Valid OS versions are:
+#   - CentOS7, Debian9, FedoraRawhide, Ubuntu18 and so on
+#
+# The arch specific rules use a prefix "$ARCH-" where  $ARCH
+# is a libvirt arch name.
 #
 # So something like
 #
@@ -27,6 +43,21 @@
 #
 # will result in the 'ccache' package being installed everywhere except
 # for CentOS, where nothing will be installed.
+#
+# For example to prevent Xen being installed on any s390x
+#
+#  xen:
+#    deb: libxen-dev
+#    Fedora: xen-devel
+#    s390x-default:
+#
+# Or the inverse to only install Xen on x86_64 only on debian
+# based distros or Fedora
+#
+#  xen:
+#    x86_64-deb: libxen-dev
+#    x86_64-Fedora: xen-devel
+#
 
 mappings:
 
-- 
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