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}
# 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
%define ansible_collection_install() ansible-galaxy collection install -n -p %{buildroot}%{_datadir}/ansible/collections %{collection_namespace}-%{collection_name}-%{version}.tar.gz
%endif
@ -306,24 +306,11 @@ find -type f -executable -name '*.py' -exec \
sed -i -r -e '1s@^(#! */usr/bin/env python)(\s|$)@#\13\2@' '{}' +
%build
sh md2html.sh \
%{rolename1}/README.md \
%{rolename2}/README.md \
%{rolename3}/README.md \
%{rolename4}/README.md \
%{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
readmes=""
for role in %{rolenames}; do
readmes="${readmes} $role/README.md"
done
sh md2html.sh $readmes
mkdir .collections
%if 0%{?rhel}
@ -358,194 +345,69 @@ 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 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}/
%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
%install
mkdir -p $RPM_BUILD_ROOT%{installbase}
mkdir -p $RPM_BUILD_ROOT%{_datadir}/ansible/roles
cp -pR %{rolename1} $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}%{rolename1}
cp -pR %{rolename2} $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}%{rolename2}
cp -pR %{rolename3} $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}%{rolename3}
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}
for role in %{rolenames}; do
cp -pR "$role" "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role"
done
%if 0%{?rolealtprefix:1}
ln -s %{rolealtrelpath}%{roleinstprefix}%{rolename1} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename1}
ln -s %{rolealtrelpath}%{roleinstprefix}%{rolename2} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename2}
ln -s %{rolealtrelpath}%{roleinstprefix}%{rolename3} $RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}%{rolename3}
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}
for role in %{rolenames}; do
ln -s "%{rolealtrelpath}%{roleinstprefix}$role" "$RPM_BUILD_ROOT%{_datadir}/ansible/roles/%{rolealtprefix}$role"
done
%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}
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}kdump/README.md \
$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}kdump/README.html \
$RPM_BUILD_ROOT%{_pkgdocdir}/kdump
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}kdump/COPYING \
$RPM_BUILD_ROOT%{_pkglicensedir}/kdump.COPYING
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}postfix/README.md \
$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}postfix/README.html \
$RPM_BUILD_ROOT%{_pkgdocdir}/postfix
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}postfix/COPYING \
$RPM_BUILD_ROOT%{_pkglicensedir}/postfix.COPYING
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}selinux/README.md \
$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}selinux/README.html \
$RPM_BUILD_ROOT%{_pkgdocdir}/selinux
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}selinux/COPYING \
$RPM_BUILD_ROOT%{_pkglicensedir}/selinux.COPYING
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}selinux/selinux-playbook.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/selinux/example-selinux-playbook.yml
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}timesync/README.md \
$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}timesync/README.html \
$RPM_BUILD_ROOT%{_pkgdocdir}/timesync
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}timesync/COPYING \
$RPM_BUILD_ROOT%{_pkglicensedir}/timesync.COPYING
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}timesync/examples/multiple-ntp-servers.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/timesync/example-timesync-playbook.yml
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}timesync/examples/single-pool.yml \
$RPM_BUILD_ROOT%{_pkgdocdir}/timesync/example-timesync-pool-playbook.yml
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/README.md \
$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/README.html \
$RPM_BUILD_ROOT%{_pkgdocdir}/network
cp -p $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/LICENSE \
$RPM_BUILD_ROOT%{_pkglicensedir}/network.LICENSE
mv $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/bond_with_vlan.yml \
$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}network/examples/roles
for role in %{rolenames}; do
mkdir -p "$RPM_BUILD_ROOT%{_pkgdocdir}/$role"
cp -p "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/README.md" \
"$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/README.html" \
"$RPM_BUILD_ROOT%{_pkgdocdir}/$role"
if [ -f "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/COPYING" ]; then
cp -p "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/COPYING" \
"$RPM_BUILD_ROOT%{_pkglicensedir}/$role.COPYING"
fi
if [ -f "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/LICENSE" ]; then
cp -p "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/LICENSE" \
"$RPM_BUILD_ROOT%{_pkglicensedir}/$role.LICENSE"
fi
if [ -d "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/examples" ]; then
for file in "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/examples/"*.yml ; do
basename=$(basename "$file" .yml)
newname="$basename"
if [[ "$newname" != example-* ]]; then
newname="example-$newname"
fi
if [[ "$newname" != *-playbook ]]; then
newname="${newname}-playbook"
fi
cp "$file" "$RPM_BUILD_ROOT%{_pkgdocdir}/$role/${newname}.yml"
rm "$file"
done
if [ -f "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/examples/inventory" ]; then
cp "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/examples/inventory" \
"$RPM_BUILD_ROOT%{_pkgdocdir}/$role/example-inventory"
rm "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/examples/inventory"
fi
# special case for network
# this will error if the directory is unexpectedly empty
rmdir "$RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}$role/examples"
fi
done
rm $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}*/semaphore
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 $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}*/tests/.git*
rm $RPM_BUILD_ROOT%{installbase}/%{roleinstprefix}network/examples/roles
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
# NOTE: sshd/examples/example-root-login.yml is
# referenced in the configuring-openssh-servers-using-the-sshd-system-role documentation module
# 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}/
%ansible_collection_install
popd
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/collection
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/collection/roles
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
if [ -f %{buildroot}%{ansible_collection_files}%{collection_name}/roles/${rolename}/README.md ]; then
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/collection/roles/${rolename}
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}
# no html files in collection directory
rm -f %{buildroot}%{ansible_collection_files}%{collection_name}/roles/${rolename}/README.html
fi
done
@ -659,101 +450,101 @@ if [ -f %{collection_namespace}-%{collection_name}-%{version}.tar.gz ]; then
$RPM_BUILD_ROOT%{_datadir}/ansible/collections/
fi
%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}
%dir %{_datadir}/ansible
%dir %{_datadir}/ansible/roles
echo '%dir %{_datadir}/ansible' >> $files_section
echo '%dir %{_datadir}/ansible/roles' >> $files_section
%endif
%if "%{installbase}" != "%{_datadir}/ansible/roles"
%dir %{installbase}
echo '%dir %{installbase}' >> $files_section
%endif
%if 0%{?rolealtprefix:1}
%{_datadir}/ansible/roles/%{rolealtprefix}kdump
%{_datadir}/ansible/roles/%{rolealtprefix}postfix
%{_datadir}/ansible/roles/%{rolealtprefix}selinux
%{_datadir}/ansible/roles/%{rolealtprefix}timesync
%{_datadir}/ansible/roles/%{rolealtprefix}network
%{_datadir}/ansible/roles/%{rolealtprefix}storage
%{_datadir}/ansible/roles/%{rolealtprefix}metrics
%{_datadir}/ansible/roles/%{rolealtprefix}tlog
%{_datadir}/ansible/roles/%{rolealtprefix}kernel_settings
%{_datadir}/ansible/roles/%{rolealtprefix}logging
%{_datadir}/ansible/roles/%{rolealtprefix}nbde_server
%{_datadir}/ansible/roles/%{rolealtprefix}nbde_client
%{_datadir}/ansible/roles/%{rolealtprefix}certificate
%{_datadir}/ansible/roles/%{rolealtprefix}crypto_policies
%{_datadir}/ansible/roles/%{rolealtprefix}sshd
%{_datadir}/ansible/roles/%{rolealtprefix}ssh
%{_datadir}/ansible/roles/%{rolealtprefix}ha_cluster
%endif
%{installbase}/%{roleinstprefix}kdump
%{installbase}/%{roleinstprefix}postfix
%{installbase}/%{roleinstprefix}selinux
%{installbase}/%{roleinstprefix}timesync
%{installbase}/%{roleinstprefix}network
%{installbase}/%{roleinstprefix}storage
%{installbase}/%{roleinstprefix}metrics
%{installbase}/%{roleinstprefix}tlog
%{installbase}/%{roleinstprefix}kernel_settings
%{installbase}/%{roleinstprefix}logging
%{installbase}/%{roleinstprefix}nbde_server
%{installbase}/%{roleinstprefix}nbde_client
%{installbase}/%{roleinstprefix}certificate
%{installbase}/%{roleinstprefix}crypto_policies
%{installbase}/%{roleinstprefix}sshd
%{installbase}/%{roleinstprefix}ssh
%{installbase}/%{roleinstprefix}ha_cluster
%{_pkgdocdir}/*/example-*-playbook.yml
%{_pkgdocdir}/network/example-inventory
echo '%dir %{ansible_collection_files}' >> $files_section
echo '%dir %{ansible_collection_files}%{collection_name}' >> $files_section
find %{buildroot}%{ansible_collection_files}%{collection_name} -mindepth 1 -maxdepth 1 | \
while read item; do
if [[ "$item" == */roles ]]; then
format_item_for_files "$item" true >> $files_section
find "$item" -mindepth 1 -maxdepth 1 | while read roles_dir; do
format_item_for_files "$roles_dir" true >> $files_section
find "$roles_dir" -mindepth 1 -maxdepth 1 | while read roles_item; do
format_item_for_files "$roles_item" >> $files_section
done
done
else
format_item_for_files "$item" >> $files_section
fi
done
find %{buildroot}%{installbase} -mindepth 1 -maxdepth 1 | \
while read item; do
if [ -d "$item" ]; then
format_item_for_files "$item" true >> $files_section
find "$item" -mindepth 1 -maxdepth 1 | while read roles_item; do
format_item_for_files "$roles_item" >> $files_section
done
else
format_item_for_files "$item" >> $files_section
fi
done
if [ "%{installbase}" != "%{_datadir}/ansible/roles" ]; then
find %{buildroot}%{_datadir}/ansible/roles -mindepth 1 -maxdepth 1 | \
while read item; do
if [ -d "$item" ]; then
format_item_for_files "$item" true >> $files_section
find "$item" -mindepth 1 -maxdepth 1 | while read roles_item; do
format_item_for_files "$roles_item" >> $files_section
done
else
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.html
%{_pkgdocdir}/*/example-*
%{_pkgdocdir}/collection/roles/*/README.md
%{_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 %{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}
%files collection-artifact