diff --git a/ansible-collection-redhat-rhel_mgmt.spec b/ansible-collection-redhat-rhel_mgmt.spec index 1ff32f0..043db07 100644 --- a/ansible-collection-redhat-rhel_mgmt.spec +++ b/ansible-collection-redhat-rhel_mgmt.spec @@ -21,7 +21,7 @@ Name: ansible-collection-%{collection_namespace}-%{collection_name} Url: https://github.com/pcahyna/fedora.linux_mgmt/ Summary: Ansible Collection of general system management and utility modules and other plugins Version: 1.0.0 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv3+ @@ -62,6 +62,12 @@ Requires: ansible >= 2.9.10 Source: https://github.com/pcahyna/fedora.linux_mgmt/archive/%{version}/%{archivename}.tar.gz +%if 0%{?rhel} +# Collection tarballs from Galaxy +# Not used on Fedora. +Source901: https://galaxy.ansible.com/download/community-general-5.4.0.tar.gz +%endif + BuildArch: noarch BuildRequires: python3 @@ -90,7 +96,34 @@ Collection artifact for %{name}. This package contains %{collection_namespace}-% %endif %prep -%autosetup -n %{extractdir} +%if 0%{?rhel} +%setup -T -a 901 -c -n .external/community/general +%endif +%setup -n %{extractdir} + +%if 0%{?rhel} +modules=( remote_management/redfish/redfish_{command,config,info}.py ) +module_utils=( redfish_utils.py ) + +mkdir -p plugins/modules +mkdir -p plugins/module_utils + +for dir in %{_builddir}/.external/*/*; do + name=$(basename "$dir") + ns=$(basename $(dirname "$dir")) + for module in "${modules[@]}"; do + cp -pL $dir/plugins/modules/$module plugins/modules/ + done + for module_util in "${module_utils[@]}"; do + cp -pL $dir/plugins/module_utils/$module_util plugins/module_utils/$module_util + done + # Replacing original collection name by downstream (vendored) name + if [ "${ns}" != "%{collection_namespace}" ] || [ "${name}" != "%{collection_name}" ] ; then + find -type f -exec \ + sed "s/${ns}[.]${name}/%{collection_namespace}.%{collection_name}/g" -i {} \; + fi +done +%endif # Replacing original (Galaxy) collection name by downstream (Automation Hub) name %if "%{collection_namespace_orig}" != "%{collection_namespace}" || "%{collection_name_orig}" != "%{collection_name}" @@ -105,10 +138,17 @@ find -type f ! -executable -type f -name '*.py' -print -exec sed -i -e '1{\@^#!. mv galaxy.yml.new galaxy.yml %build +mkdir -p .collections/ansible_collections/%{collection_namespace}/%{collection_name}/ +cp -a * .collections/ansible_collections/%{collection_namespace}/%{collection_name}/ + +pushd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/ %ansible_collection_build +popd %install +pushd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/ %ansible_collection_install +popd %if %{with collection_artifact} # Copy collection artifact to /usr/share/ansible/collections/ for collection-artifact