From deee147c9518bb49974d96436ca11ce60345be17 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Fri, 23 Sep 2022 18:39:23 -0500 Subject: [PATCH] Refactor %ansible_collection_install This change removes %ansible_collection_install's dependence on the %collection_namespace and %collection_name macros. Now, the macro uses the new helper script which extracts this information from galaxy.yml. Parsing the galaxy.yml instead of using %{version} to determine the collection version also lends another benefit: it allows us to package pre-releases. Previously, discrepancies between %{version} and the upstream version (eg. "3.0.0~rc1" vs "3.0.0-rc1") broke the macro. --- macros.ansible | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/macros.ansible b/macros.ansible index 5e2bc06..856688e 100644 --- a/macros.ansible +++ b/macros.ansible @@ -1,9 +1,18 @@ +# Stores ephemeral data that's created by %%ansible_collection_install +# and used by other macros. +%__ansible_builddir %{_builddir}/%{?buildsubdir:%{buildsubdir}/}.ansible-packaging + %ansible_roles_dir %{_datadir}/ansible/roles %ansible_collections_dir %{_datadir}/ansible/collections/ansible_collections %ansible_collection_build() ansible-galaxy collection build -%ansible_collection_install() ansible-galaxy collection install -n -p %{buildroot}%{_datadir}/ansible/collections %{collection_namespace}-%{collection_name}-%{version}.tar.gz +%ansible_collection_install() %{shrink: +%{_rpmconfigdir}/ansible_collection.py install +--collections-dir %{buildroot}%{ansible_collections_dir} +--filelist %{ansible_collection_filelist} +} + %ansible_test_unit() %{expand:\\\ mkdir -p ../ansible_collections/%{collection_namespace}