Let's install meson via pip whenever meson is not available at all or
does not match the minimum required version.
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
---
guests/lcitool | 25 ++++++++++++
guests/playbooks/update/tasks/packages.yml | 44 ++++++++++++++++++++++
guests/vars/mappings.yml | 17 +++++++++
3 files changed, 86 insertions(+)
diff --git a/guests/lcitool b/guests/lcitool
index 5b5b622..2c08455 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -303,6 +303,7 @@ class Projects:
with open(mappings_path, "r") as infile:
mappings = yaml.safe_load(infile)
self._mappings = mappings["mappings"]
+ self._pip_mappings = mappings["pip_mappings"]
except Exception as ex:
raise Exception("Can't load mappings: {}".format(ex))
@@ -340,6 +341,9 @@ class Projects:
def get_mappings(self):
return self._mappings
+ def get_pip_mappings(self):
+ return self._pip_mappings
+
def get_packages(self, project):
return self._packages[project]
@@ -583,6 +587,7 @@ class Application:
def _action_dockerfile(self, args):
mappings = self._projects.get_mappings()
+ pip_mappings = self._projects.get_pip_mappings()
hosts = self._inventory.expand_pattern(args.hosts)
if len(hosts) > 1:
@@ -617,6 +622,7 @@ class Application:
pkgs = {}
cross_pkgs = {}
+ pip_pkgs = {}
base_keys = ["default", package_format, os_name, os_full]
cross_keys = []
if args.cross_arch:
@@ -641,21 +647,28 @@ class Application:
for key in keys:
if key in mappings[package]:
pkgs[package] = mappings[package][key]
+ if package in pip_mappings and key in pip_mappings[package]:
+ pip_pkgs[package] = pip_mappings[package][key]
if package not in pkgs:
continue
+ if package in pip_pkgs and pkgs[package] is not None:
+ del pip_pkgs[package]
if cross_policy == "foreign" and pkgs[package] is not None:
cross_pkgs[package] = pkgs[package]
if pkgs[package] is None or cross_policy in ["skip", "foreign"]:
del pkgs[package]
pkg_align = " \\\n" + (" " * len("RUN " + package_manager + " "))
+ pip_pkg_align = " \\\n" + (" " * len("RUN pip3 "))
print("FROM {}".format(facts["docker_base"]))
varmap = {}
varmap["package_manager"] = package_manager
varmap["pkgs"] = pkg_align[1:] + pkg_align.join(sorted(set(pkgs.values())))
+ varmap["pip_pkgs"] = pip_pkg_align[1:] + pip_pkg_align.join(sorted(set(pip_pkgs.values())))
+
if package_format == "deb":
if args.cross_arch:
deb_arch = Util.native_arch_to_deb_arch(args.cross_arch)
@@ -691,7 +704,14 @@ class Application:
{package_manager} install --no-install-recommends -y {cross_pkgs} && \\
{package_manager} autoremove -y && \\
{package_manager} autoclean -y
+ """).format(**varmap))
+
+ if pip_pkgs:
+ sys.stdout.write(textwrap.dedent("""
+ RUN pip3 install {pip_pkgs}
+ """).format(**varmap))
+ sys.stdout.write(textwrap.dedent("""
ENV ABI "{cross_abi}"
ENV CONFIGURE_OPTS "--host={cross_abi} \\
--target={cross_abi}"
@@ -714,6 +734,11 @@ class Application:
{package_manager} clean all -y
""").format(**varmap))
+ if pip_pkgs:
+ sys.stdout.write(textwrap.dedent("""
+ RUN pip3 install {pip_pkgs}
+ """).format(**varmap))
+
def run(self):
args = self._parser.parse_args()
if args.debug:
diff --git a/guests/playbooks/update/tasks/packages.yml b/guests/playbooks/update/tasks/packages.yml
index ec8a4c4..c041eab 100644
--- a/guests/playbooks/update/tasks/packages.yml
+++ b/guests/playbooks/update/tasks/packages.yml
@@ -100,3 +100,47 @@
package:
name: '{{ flattened|sort }}'
state: '{{ state }}'
+
+- set_fact:
+ pip_temp: {}
+
+- name: '{{ project }}: Verify pip mappings'
+ fail:
+ msg: 'No mappings defined for {{ item }}'
+ with_items:
+ '{{ packages }}'
+ when:
+ - pip_mappings[item] is undefined
+
+- name: '{{ project }}: Look up pip mappings (default)'
+ set_fact:
+ pip_temp: '{{ pip_temp|combine({ item: pip_mappings[item]["default"] }) }}'
+ with_items:
+ '{{ packages }}'
+ when:
+ - pip_mappings[item]["default"] is defined
+
+- set_fact:
+ pip_flattened: []
+
+- name: '{{ project }}: Flatten pip package list'
+ set_fact:
+ pip_flattened: '{{ pip_flattened }} + [ "{{ pip_temp[item] }}" ]'
+ with_items:
+ '{{ temp }}'
+ when:
+ - pip_temp[item] != None
+ - pip_temp[item] not in pip_flattened
+
+- name: '{{ project }}: Install packages from pip (state={{ state }})'
+ pip:
+ name: '{{ pip_flattened|sort }}'
+ executable: pip3
+ state: '{{ state }}'
+ with_items:
+ '{{ packages }}'
+ when:
+ - temp[item] is defined
+ - temp[item] == None
+ - pip_temp[item] is defined
+ - pip_temp[item] != None
diff --git a/guests/vars/mappings.yml b/guests/vars/mappings.yml
index 524cff2..ba0f1cf 100644
--- a/guests/vars/mappings.yml
+++ b/guests/vars/mappings.yml
@@ -1007,3 +1007,20 @@ mappings:
deb: zlib1g-dev
rpm: zlib-static
cross-policy-deb: foreign
+
+
+# Pip mappings are used to map the generic packages name used to define
+# projects to the specific package name and version which will be used when
+# installing them via pip.
+#
+# pip packages' name are not different between different OSes, thus only
+# the default "priority" is taken into account.
+#
+# In case we need to stick to a specific version of a pip package, it can
+# be represented by adding "==$version" to the pip package name, as done
+# with the meson package.
+
+pip_mappings:
+
+ meson:
+ default: meson==0.49.0
--
2.23.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list