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(a)redhat.com>
---
guests/lcitool | 17 +++++++++++
guests/playbooks/update/tasks/packages.yml | 35 ++++++++++++++++++++++
guests/vars/mappings.yml | 6 ++++
3 files changed, 58 insertions(+)
diff --git a/guests/lcitool b/guests/lcitool
index 5b5b622..6a15c0c 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,27 @@ 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 install
"))
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)
@@ -714,6 +726,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..5724c28 100644
--- a/guests/playbooks/update/tasks/packages.yml
+++ b/guests/playbooks/update/tasks/packages.yml
@@ -100,3 +100,38 @@
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 and 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_executable: pip3
+
+- name: '{{ project }}: Install packages from pip'
+ pip:
+ name: '{{ pip_temp[item] }}'
+ executable: '{{ pip_executable }}'
+ 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 ec9e771..3907db4 100644
--- a/guests/vars/mappings.yml
+++ b/guests/vars/mappings.yml
@@ -1007,3 +1007,9 @@ mappings:
deb: zlib1g-dev
rpm: zlib-static
cross-policy-deb: foreign
+
+
+pip_mappings:
+
+ meson:
+ default: meson==0.49.0
--
2.23.0