2020-10-14 23:43:13 +00:00
|
|
|
#!/usr/bin/bash -eux
|
|
|
|
. /etc/os-release
|
2022-03-17 13:02:49 +00:00
|
|
|
|
|
|
|
version=$(echo "${VERSION_ID}" | cut -d. -f1)
|
|
|
|
arch="x86_64"
|
|
|
|
|
|
|
|
case $NAME in
|
|
|
|
"Fedora Linux"|"Fedora")
|
|
|
|
mock="fedora-${version}-${arch}"
|
2022-08-13 09:56:22 +00:00
|
|
|
repos="local"
|
2022-03-17 13:02:49 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
"CentOS Stream"|"Red Hat Enterprise Linux")
|
2022-08-13 09:56:22 +00:00
|
|
|
mock="centos-stream+epel-next-${version}-${arch}"
|
|
|
|
repos="local,local-centos-stream"
|
2022-03-17 13:02:49 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "Not supported OS" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2020-10-14 23:43:13 +00:00
|
|
|
|
2021-02-04 13:32:12 +00:00
|
|
|
pkgname=${1}
|
|
|
|
shift
|
|
|
|
|
2022-03-17 13:02:49 +00:00
|
|
|
config="/tmp/${mock}-ci.cfg"
|
2020-10-14 23:43:13 +00:00
|
|
|
|
|
|
|
# create mock config if not present
|
|
|
|
# this makes sure tested version of pyproject-rpm-macros is available
|
|
|
|
# TODO: check if it has precedence if the release was not bumped in tested PR
|
|
|
|
if [ ! -f $config ]; then
|
2022-03-17 13:02:49 +00:00
|
|
|
original="/etc/mock/${mock}.cfg"
|
2020-10-14 23:43:13 +00:00
|
|
|
cp $original $config
|
|
|
|
|
2021-02-04 13:32:12 +00:00
|
|
|
echo -e '\n\n' >> $config
|
2022-04-27 08:34:30 +00:00
|
|
|
echo -e 'config_opts["package_manager_max_attempts"] = 10' >> $config
|
|
|
|
echo -e 'config_opts["package_manager_attempt_delay"] = 60' >> $config
|
2020-10-14 23:43:13 +00:00
|
|
|
echo -e '\n\nconfig_opts[f"{config_opts.package_manager}.conf"] += """' >> $config
|
|
|
|
|
|
|
|
# The zuul CI has zuul-build.repo
|
|
|
|
# The Jenkins CI has test-<pkgname>.repo
|
|
|
|
# We run this code from various packages, so we support any <pkgname>
|
|
|
|
if [ -f /etc/yum.repos.d/zuul-build.repo ]; then
|
|
|
|
cat /etc/yum.repos.d/zuul-build.repo >> $config
|
|
|
|
else
|
|
|
|
cat /etc/yum.repos.d/test-*.repo >> $config
|
|
|
|
fi
|
|
|
|
echo -e '\n"""\n' >> $config
|
|
|
|
fi
|
|
|
|
|
|
|
|
# prepare the rpmbuild folders, make sure nothing relevant is there
|
2023-01-09 16:27:31 +00:00
|
|
|
mkdir -p ~/rpmbuild/SRPMS
|
2021-02-04 13:32:12 +00:00
|
|
|
rm -f ~/rpmbuild/SRPMS/${pkgname}-*.src.rpm
|
2020-10-14 23:43:13 +00:00
|
|
|
|
|
|
|
# download the sources and create SRPM
|
2023-01-09 16:27:31 +00:00
|
|
|
spectool -g ${pkgname}.spec
|
|
|
|
rpmbuild -bs --define '_sourcedir .' ${pkgname}.spec
|
2020-10-14 23:43:13 +00:00
|
|
|
|
|
|
|
# build the SRPM in mock
|
|
|
|
res=0
|
2023-08-21 20:40:58 +00:00
|
|
|
mock --verbose --isolation=simple -r $config --enablerepo="$repos" init
|
|
|
|
mock --verbose --isolation=simple -r $config --enablerepo="$repos" "$@" ~/rpmbuild/SRPMS/${pkgname}-*.src.rpm || res=$?
|
2020-10-14 23:43:13 +00:00
|
|
|
|
|
|
|
# move the results to the artifacts directory, so we can examine them
|
|
|
|
artifacts=${TEST_ARTIFACTS:-/tmp/artifacts}
|
2022-03-17 13:02:49 +00:00
|
|
|
|
|
|
|
# on Fedora Rawhide, the directory contains "rawhide" instead of the actual version
|
|
|
|
pushd /var/lib/mock/${mock}/result || pushd /var/lib/mock/${mock/${version}/rawhide}/result
|
2020-10-14 23:43:13 +00:00
|
|
|
mv *.rpm ${artifacts}/ || :
|
|
|
|
for log in *.log; do
|
2021-02-04 13:32:12 +00:00
|
|
|
mv ${log} ${artifacts}/${pkgname}-${log}
|
2020-10-14 23:43:13 +00:00
|
|
|
done
|
|
|
|
popd
|
|
|
|
|
|
|
|
exit $res
|