#!/bin/bash
# builds a single package
set -x

PKG="${1}"

if [ -z "${PKG}" ]; then
	echo "No package?"
	exit 2
fi

mockBuild() {
	package="${1}"
	mock -r /opt/build/cfg/riscv-sslengine.cfg ${package} ${@:2}
}

mockBuild "${PKG}" ${@:2}
_ret=$?

if [ "$_ret" -eq 0 ]; then
	cp /var/lib/mock/rl-10-lookahead-riscv64/result/*.rpm /opt/build/repo/
else
	printf "${1}\n" >> /opt/build/cfg/log/loop-failures.log
fi
