From 783912e31e26d66a7c0afeda7ce53ca94864cc40 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Sat, 19 Nov 2022 14:18:19 -0600 Subject: [PATCH] Fix inverted conditionals and BR: ansible-packaging Fix and simply inverted conditionals and build/install the collection using ansible-galaxy. Previously, the conditionals were inverted and the %ansible_collection_* macros weren't used on Fedora, instead using the tar hack meant for RHEL 8. BR: ansible-packaging is needed for these macros. --- ansible-pcp.spec | 53 +++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/ansible-pcp.spec b/ansible-pcp.spec index 604e55e..98e46c9 100644 --- a/ansible-pcp.spec +++ b/ansible-pcp.spec @@ -8,9 +8,10 @@ Source: https://github.com/performancecopilot/ansible-pcp/archive/v%{v Patch0: 0001-build_ignore-unnecessary-files.patch BuildArch: noarch -%if 0%{?rhel} +%if %{defined rhel} %global collection_namespace redhat %global collection_name rhel_metrics +%global ansible_collection_files %{_datadir}/ansible/collections/ansible_collections/%{collection_namespace} %else %global collection_namespace performancecopilot %global collection_name metrics @@ -20,36 +21,17 @@ BuildArch: noarch Requires: (ansible-core >= 2.11.0 or ansible >= 2.9.0) %endif -# NOTE: Even though ansible-core is in 8.6, it is only available -# at *runtime*, not at *buildtime* - so we can't have -# ansible-core as a build_dep on RHEL8 -%if 0%{?fedora} || 0%{?rhel} >= 9 -%global have_ansible 0 -%global ansible_build_dep ansible-core >= 2.11.0 -%else -%if 0%{?rhel} && ! 0%{?epel} -%global have_ansible 1 -%else -%global have_ansible 0 -%global ansible_build_dep ansible >= 2.9.10 -%endif -%endif - -%if %{have_ansible} -BuildRequires: %{ansible_build_dep} -# package has been removed from RHEL9 %if 0%{?rhel} >= 9 -%global have_ansible_lint 0 -%else -%global have_ansible_lint 1 -%endif -%else -%global have_ansible_lint 0 -%global ansible_collection_files %{_datadir}/ansible/collections/ansible_collections/%{collection_namespace} +BuildRequires: ansible-core +%global ansible_collection_build ansible-galaxy collection build . +%global ansible_collection_install ansible-galaxy collection install -n -p %{buildroot}%{_datadir}/ansible/collections %{collection_namespace}-%{collection_name}-%{version}.tar.gz %endif -%if %{have_ansible_lint} -BuildRequires: python3-ansible-lint +%if %{defined fedora} +BuildRequires: ansible-packaging +BuildRequires: ansible-packaging-tests +# There's ansible-lint errors that need to be addressed +# BuildRequires: python3-ansible-lint %endif %description @@ -103,19 +85,22 @@ find . -name \*.yml -o -name \*.md | while read file; do done %build -%if %{have_ansible} -%ansible_collection_build -%else +# NOTE: Even though ansible-core is in 8.6, it is only available +# at *runtime*, not at *buildtime* - so we can't have +# ansible-core as a build_dep on RHEL8 +%if %{defined rhel} && 0%{?rhel} <= 8 tar -cf %{_tmppath}/%{collection_namespace}-%{collection_name}-%{version}.tar.gz . +%else +%ansible_collection_build %endif %install -%if %{have_ansible} -%ansible_collection_install -%else +%if %{defined rhel} && 0%{?rhel} <= 8 mkdir -p %{buildroot}%{ansible_collection_files}/%{collection_name} cd %{buildroot}%{ansible_collection_files}/%{collection_name} tar -xf %{_tmppath}/%{collection_namespace}-%{collection_name}-%{version}.tar.gz +%else +%ansible_collection_install %endif %check