From 031963c2845d24ac891be5541af447d6690cc147 Mon Sep 17 00:00:00 2001 From: Noriko Hosoi Date: Tue, 16 Mar 2021 17:39:28 -0700 Subject: [PATCH] Building the collection artifact subpackage Description: If "--with collection_artifact" is added to rh/fedpkg build, rhel/linux-system-roles-collection-package is created. Notes: - have collection_artifact build always disabled by default - if building --with collection_artifact and without Ansible, fedpkg fails due to missing collection artifact (tarball). - copr build will specify --with collection_artifact explicitly. For %{without ansible}, ansible_collection_build generates tar at the collection top and ansible_collection_install untar from the tarball. Related: rhbz#1961404 --- linux-system-roles.spec | 84 +++++++++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 29 deletions(-) diff --git a/linux-system-roles.spec b/linux-system-roles.spec index fce47e9..c3abf28 100644 --- a/linux-system-roles.spec +++ b/linux-system-roles.spec @@ -4,6 +4,8 @@ %bcond_without ansible %endif +%bcond_with collection_artifact + %if 0%{?rhel} Name: rhel-system-roles %else @@ -12,7 +14,7 @@ Name: linux-system-roles Url: https://github.com/linux-system-roles/ Summary: Set of interfaces for unified system management Version: 1.0.1 -Release: 1%{?dist} +Release: 2%{?dist} #Group: Development/Libraries License: GPLv3+ and MIT and BSD @@ -51,23 +53,19 @@ License: GPLv3+ and MIT and BSD BuildRequires: ansible >= 2.9.10 %endif -%if %{undefined ansible_collection_build} %if %{without ansible} # Empty command. We don't have ansible-galaxy. -%define ansible_collection_build() : +%define ansible_collection_build() tar -cf %{_tmppath}/%{collection_namespace}-%{collection_name}-%{version}.tar.gz . %else %define ansible_collection_build() ansible-galaxy collection build %endif -%endif -%if %{undefined ansible_collection_install} %if %{without ansible} # Simply copy everything instead of galaxy-installing the built artifact. -%define ansible_collection_install() mkdir -p %{buildroot}%{ansible_collection_files}; cp -a . %{buildroot}%{ansible_collection_files}/%{collection_name}/ +%define ansible_collection_install() 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 %define ansible_collection_install() ansible-galaxy collection install -n -p %{buildroot}%{_datadir}/ansible/collections %{collection_namespace}-%{collection_name}-%{version}.tar.gz %endif -%endif # For each role, call either defcommit() or deftag(). The other macros # (%%id and %%shortid) can be then used in the same way in both cases. @@ -256,6 +254,14 @@ consistent configuration interface for managing multiple versions of Fedora, Red Hat Enterprise Linux & CentOS. %endif +%if %{with collection_artifact} +%package collection-artifact +Summary: Collection artifact to import to Automation Hub / Ansible Galaxy + +%description collection-artifact +Collection artifact for %{name}. This package contains %{collection_namespace}-%{collection_name}-%{version}.tar.gz +%endif + %prep %setup -q -a1 -a2 -a3 -a4 -a5 -a6 -a7 -a8 -a9 -a10 -a11 -a12 -a13 -a14 -a15 -a16 -a17 -n %{getarchivedir 0} @@ -384,30 +390,32 @@ rm -r .collections/ansible_collections/%{collection_namespace}/%{collection_name cp -p galaxy.yml lsr_role2collection/.ansible-lint \ .collections/ansible_collections/%{collection_namespace}/%{collection_name} -# converting README.md to README.html -sh md2html.sh -l \ - .collections/ansible_collections/%{collection_namespace}/%{collection_name}/README.md \ - .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/%{rolename1}/README.md \ - .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/%{rolename2}/README.md \ - .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/%{rolename3}/README.md \ - .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/%{rolename4}/README.md \ - .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/%{rolename5}/README.md \ - .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/%{rolename6}/README.md \ - .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/%{rolename7}/README.md \ - .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/%{rolename8}/README.md \ - .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/%{rolename9}/README.md \ - .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/%{rolename10}/README.md \ - .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/%{rolename11}/README.md \ - .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/%{rolename12}/README.md \ - .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/%{rolename13}/README.md \ - .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/%{rolename14}/README.md \ - .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/%{rolename15}/README.md \ - .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/%{rolename16}/README.md \ - .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/%{rolename17}/README.md +pushd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/ -cd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/ +# converting README.md to README.html +sh ../../../../md2html.sh -l \ + README.md \ + roles/%{rolename1}/README.md \ + roles/%{rolename2}/README.md \ + roles/%{rolename3}/README.md \ + roles/%{rolename4}/README.md \ + roles/%{rolename5}/README.md \ + roles/%{rolename6}/README.md \ + roles/%{rolename7}/README.md \ + roles/%{rolename8}/README.md \ + roles/%{rolename9}/README.md \ + roles/%{rolename10}/README.md \ + roles/%{rolename11}/README.md \ + roles/%{rolename12}/README.md \ + roles/%{rolename13}/README.md \ + roles/%{rolename14}/README.md \ + roles/%{rolename15}/README.md \ + roles/%{rolename16}/README.md \ + roles/%{rolename17}/README.md %ansible_collection_build +popd + %install mkdir -p $RPM_BUILD_ROOT%{installbase} mkdir -p $RPM_BUILD_ROOT%{_datadir}/ansible/roles @@ -638,7 +646,7 @@ mv $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}ha_cluster/examples/sim $RPM_BUILD_ROOT%{_pkgdocdir}/ha_cluster/example-simple-playbook.yml rmdir $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}ha_cluster/examples -cd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/ +pushd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/ %ansible_collection_install mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/collection @@ -657,6 +665,14 @@ for rolename in %{rolenames}; do fi done +%if %{with collection_artifact} +# Copy collection artifact to /usr/share/ansible/collections/ for collection-artifact +if [ -f %{collection_namespace}-%{collection_name}-%{version}.tar.gz ]; then + mv %{collection_namespace}-%{collection_name}-%{version}.tar.gz \ + $RPM_BUILD_ROOT%{_datadir}/ansible/collections/ +fi +%endif +popd %files %if %{without ansible} @@ -756,7 +772,17 @@ done %{ansible_collection_files} +%if %{with collection_artifact} +%files collection-artifact +%{_datadir}/ansible/collections/%{collection_namespace}-%{collection_name}-%{version}.tar.gz +%endif + %changelog +* Tue Apr 13 2021 Noriko Hosoi - 1.0.1-2 +- Adding the -collection-artifact subpackage, enabled using + "--with collection_artifact". It is used for importing to + ansible galaxy/automation hub. + * Tue Apr 6 2021 Pavel Cahyna - 1.0.1-1 - Sync with RHEL version 1.0.1-1.el8 Fix description field in galaxy.yml