dynamically generate %files

Generate the content of the %files section dynamically. (1943679)

Related: rhbz#1952889
This commit is contained in:
Rich Megginson 2021-04-02 00:19:15 +02:00 committed by Noriko Hosoi
parent bc131831ba
commit f018f16e50

View File

@ -62,7 +62,7 @@ BuildRequires: ansible >= 2.9.10
%if %{without ansible} %if %{without ansible}
# Simply copy everything instead of galaxy-installing the built artifact. # Simply copy everything instead of galaxy-installing the built artifact.
%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) %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 %else
%define ansible_collection_install() ansible-galaxy collection install -n -p %{buildroot}%{_datadir}/ansible/collections %{collection_namespace}-%{collection_name}-%{version}.tar.gz %define ansible_collection_install() ansible-galaxy collection install -n -p %{buildroot}%{_datadir}/ansible/collections %{collection_namespace}-%{collection_name}-%{version}.tar.gz
%endif %endif
@ -306,24 +306,11 @@ find -type f -executable -name '*.py' -exec \
sed -i -r -e '1s@^(#! */usr/bin/env python)(\s|$)@#\13\2@' '{}' + sed -i -r -e '1s@^(#! */usr/bin/env python)(\s|$)@#\13\2@' '{}' +
%build %build
sh md2html.sh \ readmes=""
%{rolename1}/README.md \ for role in %{rolenames}; do
%{rolename2}/README.md \ readmes="${readmes} $role/README.md"
%{rolename3}/README.md \ done
%{rolename4}/README.md \ sh md2html.sh $readmes
%{rolename5}/README.md \
%{rolename6}/README.md \
%{rolename7}/README.md \
%{rolename8}/README.md \
%{rolename9}/README.md \
%{rolename10}/README.md \
%{rolename11}/README.md \
%{rolename12}/README.md \
%{rolename13}/README.md \
%{rolename14}/README.md \
%{rolename15}/README.md \
%{rolename16}/README.md \
%{rolename17}/README.md
mkdir .collections mkdir .collections
%if 0%{?rhel} %if 0%{?rhel}
@ -358,194 +345,69 @@ rm -r .collections/ansible_collections/%{collection_namespace}/%{collection_name
cp -p galaxy.yml lsr_role2collection/.ansible-lint \ cp -p galaxy.yml lsr_role2collection/.ansible-lint \
.collections/ansible_collections/%{collection_namespace}/%{collection_name} .collections/ansible_collections/%{collection_namespace}/%{collection_name}
# converting README.md to README.html for collection
readmes=".collections/ansible_collections/%{collection_namespace}/%{collection_name}/README.md"
for role in %{rolenames}; do
readmes="${readmes} .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/$role/README.md"
done
sh md2html.sh $readmes
pushd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/ pushd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/
%ansible_collection_build %ansible_collection_build
# 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
tar -cf - README.html \
roles/%{rolename1}/README.html \
roles/%{rolename2}/README.html \
roles/%{rolename3}/README.html \
roles/%{rolename4}/README.html \
roles/%{rolename5}/README.html \
roles/%{rolename6}/README.html \
roles/%{rolename7}/README.html \
roles/%{rolename8}/README.html \
roles/%{rolename9}/README.html \
roles/%{rolename10}/README.html \
roles/%{rolename11}/README.html \
roles/%{rolename12}/README.html \
roles/%{rolename13}/README.html \
roles/%{rolename14}/README.html \
roles/%{rolename15}/README.html \
roles/%{rolename16}/README.html \
roles/%{rolename17}/README.html | \
(cd ../../../..; tar -xf -)
popd popd
%install %install
mkdir -p $RPM_BUILD_ROOT%{installbase} mkdir -p $RPM_BUILD_ROOT%{installbase}
mkdir -p $RPM_BUILD_ROOT%{_datadir}/ansible/roles mkdir -p $RPM_BUILD_ROOT%{_datadir}/ansible/roles
cp -pR %{rolename1} $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}%{rolename1} for role in %{rolenames}; do
cp -pR %{rolename2} $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}%{rolename2} cp -pR "$role" "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role"
cp -pR %{rolename3} $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}%{rolename3} done
cp -pR %{rolename4} $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}%{rolename4}
cp -pR %{rolename5} $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}%{rolename5}
cp -pR %{rolename6} $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}%{rolename6}
cp -pR %{rolename7} $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}%{rolename7}
cp -pR %{rolename8} $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}%{rolename8}
cp -pR %{rolename9} $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}%{rolename9}
cp -pR %{rolename10} $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}%{rolename10}
cp -pR %{rolename11} $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}%{rolename11}
cp -pR %{rolename12} $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}%{rolename12}
cp -pR %{rolename13} $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}%{rolename13}
cp -pR %{rolename14} $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}%{rolename14}
cp -pR %{rolename15} $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}%{rolename15}
cp -pR %{rolename16} $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}%{rolename16}
cp -pR %{rolename17} $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}%{rolename17}
%if 0%{?rolealtprefix:1} %if 0%{?rolealtprefix:1}
ln -s %{rolealtrelpath}%{roleinstprefix}%{rolename1} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename1} for role in %{rolenames}; do
ln -s %{rolealtrelpath}%{roleinstprefix}%{rolename2} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename2} ln -s "%{rolealtrelpath}%{roleinstprefix}$role" "$RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}$role"
ln -s %{rolealtrelpath}%{roleinstprefix}%{rolename3} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename3} done
ln -s %{rolealtrelpath}%{roleinstprefix}%{rolename4} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename4}
ln -s %{rolealtrelpath}%{roleinstprefix}%{rolename5} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename5}
ln -s %{rolealtrelpath}%{roleinstprefix}%{rolename6} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename6}
ln -s %{rolealtrelpath}%{roleinstprefix}%{rolename7} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename7}
ln -s %{rolealtrelpath}%{roleinstprefix}%{rolename8} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename8}
ln -s %{rolealtrelpath}%{roleinstprefix}%{rolename9} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename9}
ln -s %{rolealtrelpath}%{roleinstprefix}%{rolename10} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename10}
ln -s %{rolealtrelpath}%{roleinstprefix}%{rolename11} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename11}
ln -s %{rolealtrelpath}%{roleinstprefix}%{rolename12} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename12}
ln -s %{rolealtrelpath}%{roleinstprefix}%{rolename13} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename13}
ln -s %{rolealtrelpath}%{roleinstprefix}%{rolename14} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename14}
ln -s %{rolealtrelpath}%{roleinstprefix}%{rolename15} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename15}
ln -s %{rolealtrelpath}%{roleinstprefix}%{rolename16} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename16}
ln -s %{rolealtrelpath}%{roleinstprefix}%{rolename17} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename17}
%endif %endif
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/kdump
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/postfix
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/selinux
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/timesync
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/network
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/storage
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/metrics
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/tlog
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/kernel_settings
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/logging
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/nbde_server
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/nbde_client
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/certificate
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/crypto_policies
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/sshd
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/ssh
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/ha_cluster
mkdir -p $RPM_BUILD_ROOT%{_pkglicensedir} mkdir -p $RPM_BUILD_ROOT%{_pkglicensedir}
rm $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/roles
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}kdump/README.md \ for role in %{rolenames}; do
$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}kdump/README.html \ mkdir -p "$RPM_BUILD_ROOT%{_pkgdocdir}/$role"
$RPM_BUILD_ROOT%{_pkgdocdir}/kdump cp -p "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/README.md" \
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}kdump/COPYING \ "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/README.html" \
$RPM_BUILD_ROOT%{_pkglicensedir}/kdump.COPYING "$RPM_BUILD_ROOT%{_pkgdocdir}/$role"
if [ -f "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/COPYING" ]; then
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}postfix/README.md \ cp -p "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/COPYING" \
$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}postfix/README.html \ "$RPM_BUILD_ROOT%{_pkglicensedir}/$role.COPYING"
$RPM_BUILD_ROOT%{_pkgdocdir}/postfix fi
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}postfix/COPYING \ if [ -f "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/LICENSE" ]; then
$RPM_BUILD_ROOT%{_pkglicensedir}/postfix.COPYING cp -p "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/LICENSE" \
"$RPM_BUILD_ROOT%{_pkglicensedir}/$role.LICENSE"
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}selinux/README.md \ fi
$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}selinux/README.html \ if [ -d "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/examples" ]; then
$RPM_BUILD_ROOT%{_pkgdocdir}/selinux for file in "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/examples/"*.yml ; do
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}selinux/COPYING \ basename=$(basename "$file" .yml)
$RPM_BUILD_ROOT%{_pkglicensedir}/selinux.COPYING newname="$basename"
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}selinux/selinux-playbook.yml \ if [[ "$newname" != example-* ]]; then
$RPM_BUILD_ROOT%{_pkgdocdir}/selinux/example-selinux-playbook.yml newname="example-$newname"
fi
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}timesync/README.md \ if [[ "$newname" != *-playbook ]]; then
$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}timesync/README.html \ newname="${newname}-playbook"
$RPM_BUILD_ROOT%{_pkgdocdir}/timesync fi
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}timesync/COPYING \ cp "$file" "$RPM_BUILD_ROOT%{_pkgdocdir}/$role/${newname}.yml"
$RPM_BUILD_ROOT%{_pkglicensedir}/timesync.COPYING rm "$file"
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}timesync/examples/multiple-ntp-servers.yml \ done
$RPM_BUILD_ROOT%{_pkgdocdir}/timesync/example-timesync-playbook.yml if [ -f "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/examples/inventory" ]; then
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}timesync/examples/single-pool.yml \ cp "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/examples/inventory" \
$RPM_BUILD_ROOT%{_pkgdocdir}/timesync/example-timesync-pool-playbook.yml "$RPM_BUILD_ROOT%{_pkgdocdir}/$role/example-inventory"
rm "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/examples/inventory"
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/README.md \ fi
$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/README.html \ # special case for network
$RPM_BUILD_ROOT%{_pkgdocdir}/network # this will error if the directory is unexpectedly empty
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/LICENSE \ rmdir "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/examples"
$RPM_BUILD_ROOT%{_pkglicensedir}/network.LICENSE fi
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/bond_with_vlan.yml \ done
$RPM_BUILD_ROOT%{_pkgdocdir}/network/example-bond_with_vlan-playbook.yml
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/bridge_with_vlan.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/network/example-bridge_with_vlan-playbook.yml
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/eth_simple_auto.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/network/example-eth_simple_auto-playbook.yml
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/eth_with_vlan.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/network/example-eth_with_vlan-playbook.yml
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/infiniband.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/network/example-infiniband-playbook.yml
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/macvlan.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/network/example-macvlan-playbook.yml
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/remove_profile.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/network/example-remove_profile-playbook.yml
rm $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/remove_profile.yml
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/down_profile.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/network/example-down_profile-playbook.yml
rm $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/down_profile.yml
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/inventory \
$RPM_BUILD_ROOT%{_pkgdocdir}/network/example-inventory
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/ethtool_features.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/network/example-ethtool_features-playbook.yml
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/ethtool_features_default.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/network/example-ethtool_features_default-playbook.yml
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/bond_simple.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/network/example-bond_simple-playbook.yml
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/eth_with_802_1x.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/network/example-eth_with_802_1x-playbook.yml
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/wireless_wpa_psk.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/network/example-wireless_wpa_psk-playbook.yml
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/remove+down_profile.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/network/example-remove+down_profile-playbook.yml
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/dummy_simple.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/network/example-dummy_simple-playbook.yml
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/ethtool_coalesce.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/network/example-ethtool_coalesce-playbook.yml
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/team_simple.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/network/example-team_simple-playbook.yml
mv $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}network/examples/eth_dns_support.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/network/example-eth_dns_support-playbook.yml
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}storage/README.md \
$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}storage/README.html \
$RPM_BUILD_ROOT%{_pkgdocdir}/storage
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}storage/LICENSE \
$RPM_BUILD_ROOT%{_pkglicensedir}/storage.LICENSE
rm $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}*/semaphore rm $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}*/semaphore
rm -r $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}*/molecule rm -r $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}*/molecule
@ -553,102 +415,31 @@ rm -r $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}*/molecule
rm -r $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}*/.[A-Za-z]* rm -r $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}*/.[A-Za-z]*
rm $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}*/tests/.git* rm $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}*/tests/.git*
rm $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/roles # NOTE: sshd/examples/example-root-login.yml is
rmdir $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}metrics/README.md \
$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}metrics/README.html \
$RPM_BUILD_ROOT%{_pkgdocdir}/metrics
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}metrics/LICENSE \
$RPM_BUILD_ROOT%{_pkglicensedir}/metrics.LICENSE
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}tlog/README.md \
$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}tlog/README.html \
$RPM_BUILD_ROOT%{_pkgdocdir}/tlog
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}tlog/LICENSE \
$RPM_BUILD_ROOT%{_pkglicensedir}/tlog.LICENSE
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}kernel_settings/README.md \
$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}kernel_settings/README.html \
$RPM_BUILD_ROOT%{_pkgdocdir}/kernel_settings
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}kernel_settings/LICENSE \
$RPM_BUILD_ROOT%{_pkglicensedir}/kernel_settings.LICENSE
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}kernel_settings/COPYING \
$RPM_BUILD_ROOT%{_pkglicensedir}/kernel_settings.COPYING
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}logging/README.md \
$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}logging/README.html \
$RPM_BUILD_ROOT%{_pkgdocdir}/logging
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}logging/LICENSE \
$RPM_BUILD_ROOT%{_pkglicensedir}/logging.LICENSE
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}logging/COPYING \
$RPM_BUILD_ROOT%{_pkglicensedir}/logging.COPYING
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}nbde_server/README.md \
$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}nbde_server/README.html \
$RPM_BUILD_ROOT%{_pkgdocdir}/nbde_server
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}nbde_server/LICENSE \
$RPM_BUILD_ROOT%{_pkglicensedir}/nbde_server.LICENSE
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}nbde_client/README.md \
$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}nbde_client/README.html \
$RPM_BUILD_ROOT%{_pkgdocdir}/nbde_client
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}nbde_client/LICENSE \
$RPM_BUILD_ROOT%{_pkglicensedir}/nbde_client.LICENSE
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}certificate/README.md \
$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}certificate/README.html \
$RPM_BUILD_ROOT%{_pkgdocdir}/certificate
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}certificate/LICENSE \
$RPM_BUILD_ROOT%{_pkglicensedir}/certificate.LICENSE
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}crypto_policies/README.md \
$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}crypto_policies/README.html \
$RPM_BUILD_ROOT%{_pkgdocdir}/crypto_policies
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}crypto_policies/LICENSE \
$RPM_BUILD_ROOT%{_pkglicensedir}/crypto_policies.LICENSE
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}sshd/README.md \
$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}sshd/README.html \
$RPM_BUILD_ROOT%{_pkgdocdir}/sshd
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}sshd/LICENSE \
$RPM_BUILD_ROOT%{_pkglicensedir}/sshd.LICENSE
# referenced in the configuring-openssh-servers-using-the-sshd-system-role documentation module # referenced in the configuring-openssh-servers-using-the-sshd-system-role documentation module
# must be updated if changing the file path # must be updated if changing the file path
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}sshd/examples/example-root-login.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/sshd/example-root-login-playbook.yml
rmdir $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}sshd/examples
cp -p $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}ssh/README.md \
$RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}ssh/README.html \
$RPM_BUILD_ROOT%{_pkgdocdir}/ssh
cp -p $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}ssh/LICENSE \
$RPM_BUILD_ROOT%{_pkglicensedir}/ssh.LICENSE
cp -p $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}ha_cluster/README.md \
$RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}ha_cluster/README.html \
$RPM_BUILD_ROOT%{_pkgdocdir}/ha_cluster
cp -p $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}ha_cluster/LICENSE \
$RPM_BUILD_ROOT%{_pkglicensedir}/ha_cluster.LICENSE
mv $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}ha_cluster/examples/simple.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/ha_cluster/example-simple-playbook.yml
rmdir $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{roleprefix}ha_cluster/examples
pushd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/ pushd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/
%ansible_collection_install %ansible_collection_install
popd
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/collection mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/collection
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/collection/roles mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/collection/roles
cp -p %{buildroot}%{ansible_collection_files}%{collection_name}/README.md \ cp -p %{buildroot}%{ansible_collection_files}%{collection_name}/README.md \
../../../../README.html $RPM_BUILD_ROOT%{_pkgdocdir}/collection %{buildroot}%{ansible_collection_files}%{collection_name}/README.html \
$RPM_BUILD_ROOT%{_pkgdocdir}/collection
# no html files in collection directory
rm -f %{buildroot}%{ansible_collection_files}%{collection_name}/README.html
for rolename in %{rolenames}; do for rolename in %{rolenames}; do
if [ -f %{buildroot}%{ansible_collection_files}%{collection_name}/roles/${rolename}/README.md ]; then if [ -f %{buildroot}%{ansible_collection_files}%{collection_name}/roles/${rolename}/README.md ]; then
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/collection/roles/${rolename} mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/collection/roles/${rolename}
cp -p %{buildroot}%{ansible_collection_files}%{collection_name}/roles/${rolename}/README.md \ cp -p %{buildroot}%{ansible_collection_files}%{collection_name}/roles/${rolename}/README.md \
../../../../roles/%{rolename1}/README.html \ %{buildroot}%{ansible_collection_files}%{collection_name}/roles/${rolename}/README.html \
$RPM_BUILD_ROOT%{_pkgdocdir}/collection/roles/${rolename} $RPM_BUILD_ROOT%{_pkgdocdir}/collection/roles/${rolename}
# no html files in collection directory
rm -f %{buildroot}%{ansible_collection_files}%{collection_name}/roles/${rolename}/README.html
fi fi
done done
@ -659,101 +450,101 @@ if [ -f %{collection_namespace}-%{collection_name}-%{version}.tar.gz ]; then
$RPM_BUILD_ROOT%{_datadir}/ansible/collections/ $RPM_BUILD_ROOT%{_datadir}/ansible/collections/
fi fi
%endif %endif
popd
%files # generate the %files section in the file files_section.txt
format_item_for_files() {
# $1 is directory or file name in buildroot
# $2 - if true, and item is a directory, use %dir
local item
local files_item
item="$1"
files_item=${item##"%{buildroot}"}
if [ -L "$item" ]; then
echo "$files_item"
elif [ -d "$item" ]; then
if [[ "$item" == */doc* ]]; then
echo "%doc $files_item"
elif [ "${2:-false}" = true ]; then
echo "%dir $files_item"
else
echo "$files_item"
fi
elif [[ "$item" == */README.md ]] || [[ "$item" == */README.html ]]; then
if [[ "$item" == */private_* ]]; then
# mark as regular file, not %doc
echo "$files_item"
else
echo "%doc $files_item"
fi
elif [[ "$item" == */COPYING* ]] || [[ "$item" == */LICENSE* ]]; then
echo "%%license $files_item"
else
echo "$files_item"
fi
}
files_section=files_section.txt
rm -f $files_section
touch $files_section
%if %{without ansible} %if %{without ansible}
%dir %{_datadir}/ansible echo '%dir %{_datadir}/ansible' >> $files_section
%dir %{_datadir}/ansible/roles echo '%dir %{_datadir}/ansible/roles' >> $files_section
%endif %endif
%if "%{installbase}" != "%{_datadir}/ansible/roles" %if "%{installbase}" != "%{_datadir}/ansible/roles"
%dir %{installbase} echo '%dir %{installbase}' >> $files_section
%endif %endif
%if 0%{?rolealtprefix:1} echo '%dir %{ansible_collection_files}' >> $files_section
%{_datadir}/ansible/roles/%{rolealtprefix}kdump echo '%dir %{ansible_collection_files}%{collection_name}' >> $files_section
%{_datadir}/ansible/roles/%{rolealtprefix}postfix find %{buildroot}%{ansible_collection_files}%{collection_name} -mindepth 1 -maxdepth 1 | \
%{_datadir}/ansible/roles/%{rolealtprefix}selinux while read item; do
%{_datadir}/ansible/roles/%{rolealtprefix}timesync if [[ "$item" == */roles ]]; then
%{_datadir}/ansible/roles/%{rolealtprefix}network format_item_for_files "$item" true >> $files_section
%{_datadir}/ansible/roles/%{rolealtprefix}storage find "$item" -mindepth 1 -maxdepth 1 | while read roles_dir; do
%{_datadir}/ansible/roles/%{rolealtprefix}metrics format_item_for_files "$roles_dir" true >> $files_section
%{_datadir}/ansible/roles/%{rolealtprefix}tlog find "$roles_dir" -mindepth 1 -maxdepth 1 | while read roles_item; do
%{_datadir}/ansible/roles/%{rolealtprefix}kernel_settings format_item_for_files "$roles_item" >> $files_section
%{_datadir}/ansible/roles/%{rolealtprefix}logging done
%{_datadir}/ansible/roles/%{rolealtprefix}nbde_server done
%{_datadir}/ansible/roles/%{rolealtprefix}nbde_client else
%{_datadir}/ansible/roles/%{rolealtprefix}certificate format_item_for_files "$item" >> $files_section
%{_datadir}/ansible/roles/%{rolealtprefix}crypto_policies fi
%{_datadir}/ansible/roles/%{rolealtprefix}sshd done
%{_datadir}/ansible/roles/%{rolealtprefix}ssh
%{_datadir}/ansible/roles/%{rolealtprefix}ha_cluster find %{buildroot}%{installbase} -mindepth 1 -maxdepth 1 | \
%endif while read item; do
%{installbase}/%{roleinstprefix}kdump if [ -d "$item" ]; then
%{installbase}/%{roleinstprefix}postfix format_item_for_files "$item" true >> $files_section
%{installbase}/%{roleinstprefix}selinux find "$item" -mindepth 1 -maxdepth 1 | while read roles_item; do
%{installbase}/%{roleinstprefix}timesync format_item_for_files "$roles_item" >> $files_section
%{installbase}/%{roleinstprefix}network done
%{installbase}/%{roleinstprefix}storage else
%{installbase}/%{roleinstprefix}metrics format_item_for_files "$item" >> $files_section
%{installbase}/%{roleinstprefix}tlog fi
%{installbase}/%{roleinstprefix}kernel_settings done
%{installbase}/%{roleinstprefix}logging if [ "%{installbase}" != "%{_datadir}/ansible/roles" ]; then
%{installbase}/%{roleinstprefix}nbde_server find %{buildroot}%{_datadir}/ansible/roles -mindepth 1 -maxdepth 1 | \
%{installbase}/%{roleinstprefix}nbde_client while read item; do
%{installbase}/%{roleinstprefix}certificate if [ -d "$item" ]; then
%{installbase}/%{roleinstprefix}crypto_policies format_item_for_files "$item" true >> $files_section
%{installbase}/%{roleinstprefix}sshd find "$item" -mindepth 1 -maxdepth 1 | while read roles_item; do
%{installbase}/%{roleinstprefix}ssh format_item_for_files "$roles_item" >> $files_section
%{installbase}/%{roleinstprefix}ha_cluster done
%{_pkgdocdir}/*/example-*-playbook.yml else
%{_pkgdocdir}/network/example-inventory format_item_for_files "$item" >> $files_section
fi
done
fi
# cat files_section.txt
# done with files_section.txt generation
%files -f files_section.txt
%{_pkgdocdir}/*/README.md %{_pkgdocdir}/*/README.md
%{_pkgdocdir}/*/README.html %{_pkgdocdir}/*/README.html
%{_pkgdocdir}/*/example-*
%{_pkgdocdir}/collection/roles/*/README.md %{_pkgdocdir}/collection/roles/*/README.md
%{_pkgdocdir}/collection/roles/*/README.html %{_pkgdocdir}/collection/roles/*/README.html
%doc %{installbase}/%{roleinstprefix}*/README.md
%doc %{installbase}/%{roleinstprefix}*/README.html
%doc %{ansible_collection_files}/%{collection_name}/README.md
%doc %{ansible_collection_files}/%{collection_name}/roles/kdump/README.md
%doc %{ansible_collection_files}/%{collection_name}/roles/postfix/README.md
%doc %{ansible_collection_files}/%{collection_name}/roles/selinux/README.md
%doc %{ansible_collection_files}/%{collection_name}/roles/timesync/README.md
%doc %{ansible_collection_files}/%{collection_name}/roles/network/README.md
%doc %{ansible_collection_files}/%{collection_name}/roles/storage/README.md
%doc %{ansible_collection_files}/%{collection_name}/roles/metrics/README.md
%doc %{ansible_collection_files}/%{collection_name}/roles/tlog/README.md
%doc %{ansible_collection_files}/%{collection_name}/roles/kernel_settings/README.md
%doc %{ansible_collection_files}/%{collection_name}/roles/logging/README.md
%doc %{ansible_collection_files}/%{collection_name}/roles/nbde_server/README.md
%doc %{ansible_collection_files}/%{collection_name}/roles/nbde_client/README.md
%doc %{ansible_collection_files}/%{collection_name}/roles/certificate/README.md
%doc %{ansible_collection_files}/%{collection_name}/roles/crypto_policies/README.md
%doc %{ansible_collection_files}/%{collection_name}/roles/sshd/README.md
%doc %{ansible_collection_files}/%{collection_name}/roles/ssh/README.md
%doc %{ansible_collection_files}/%{collection_name}/roles/ha_cluster/README.md
%license %{_pkglicensedir}/* %license %{_pkglicensedir}/*
%license %{installbase}/%{roleinstprefix}kdump/COPYING
%license %{installbase}/%{roleinstprefix}postfix/COPYING
%license %{installbase}/%{roleinstprefix}selinux/COPYING
%license %{installbase}/%{roleinstprefix}timesync/COPYING
%license %{installbase}/%{roleinstprefix}network/LICENSE
%license %{installbase}/%{roleinstprefix}storage/LICENSE
%license %{installbase}/%{roleinstprefix}metrics/LICENSE
%license %{installbase}/%{roleinstprefix}tlog/LICENSE
%license %{installbase}/%{roleinstprefix}kernel_settings/LICENSE
%license %{installbase}/%{roleinstprefix}kernel_settings/COPYING
%license %{installbase}/%{roleinstprefix}logging/LICENSE
%license %{installbase}/%{roleinstprefix}logging/COPYING
%license %{installbase}/%{roleinstprefix}nbde_server/LICENSE
%license %{installbase}/%{roleinstprefix}nbde_client/LICENSE
%license %{installbase}/%{roleinstprefix}certificate/LICENSE
%license %{installbase}/%{roleinstprefix}crypto_policies/LICENSE
%license %{installbase}/%{roleinstprefix}sshd/LICENSE
%license %{installbase}/%{roleinstprefix}ssh/LICENSE
%license %{installbase}/%{roleinstprefix}ha_cluster/LICENSE
%{ansible_collection_files}
%if %{with collection_artifact} %if %{with collection_artifact}
%files collection-artifact %files collection-artifact