dd5ff52
#!/usr/bin/bash -eux
dd5ff52
dd5ff52
config="/tmp/fedora-rawhide-x86_64-ci.cfg"
dd5ff52
dd5ff52
# create mock config if not present
dd5ff52
# this makes sure tested version of pyproject-rpm-macros is available
dd5ff52
# TODO: check if it has precedence if the release was not bumped in tested PR
dd5ff52
if [ ! -f $config ]; then
dd5ff52
  original="/etc/mock/fedora-rawhide-x86_64.cfg"
dd5ff52
  split=$(sed -n '/\[fedora\]/=' $original | head -n1)
dd5ff52
  head -n$(($split-1)) $original > $config
dd5ff52
  cat /etc/yum.repos.d/test-pyproject-rpm-macros.repo >> $config
dd5ff52
  echo >> $config
dd5ff52
  tail -n +$split $original >> $config
dd5ff52
fi
dd5ff52
dd5ff52
# prepare the rpmbuild folders, make sure nothing relevant is there
dd5ff52
mkdir -p ~/rpmbuild/{SOURCES,SRPMS}
dd5ff52
rm -f ~/rpmbuild/SRPMS/${1}-*.src.rpm
dd5ff52
dd5ff52
# download the sources and create SRPM
dd5ff52
spectool -g -R ${1}.spec
dd5ff52
rpmbuild -bs ${1}.spec
dd5ff52
dd5ff52
# build the SRPM in mock
7e01f58
res=0
dd5ff52
mock -r $config --enablerepo=local init
7e01f58
mock -r $config --enablerepo=local ~/rpmbuild/SRPMS/${1}-*.src.rpm || res=$?
dd5ff52
dd5ff52
# move the results to the artifacts directory, so we can examine them
dd5ff52
artifacts=${TEST_ARTIFACTS:-/tmp/artifacts}
dd5ff52
pushd /var/lib/mock/fedora-rawhide-x86_64/result
7e01f58
mv *.rpm ${artifacts}/ || :
dd5ff52
for log in *.log; do
dd5ff52
 mv ${log} ${artifacts}/${1}-${log}
dd5ff52
done
dd5ff52
popd
7e01f58
7e01f58
exit $res