Carlos Mogas da Silva
433fdfa91f
All checks were successful
Build docker image / build-and-publish (push) Successful in 5m28s
This way they can all be uploaded by an artifact-upload step
70 lines
1.9 KiB
Bash
70 lines
1.9 KiB
Bash
#!/bin/bash
|
|
|
|
# SPECS should be a JSON array of all the to-process spec files
|
|
# Forgejo runner doesn't support dynamic matrix jobs so, this has to be made this way
|
|
# Convert the JSON array to a bash array and iterate over it
|
|
echo "::debug::input_specs: ${INPUT_SPECS}"
|
|
readarray -t SPECS < <(echo ${INPUT_SPECS} | jq -c .[] | tr -d '"')
|
|
echo "::debug::specs: ${SPECS}"
|
|
SYSTEM=${INPUT_SYSTEM}
|
|
ARCH=${INPUT_ARCH}
|
|
NOCHECK=${INPUT_NOCHECK}
|
|
|
|
rm -rf /var/lib/mock/*
|
|
mount -t tmpfs tmpfs /var/lib/mock
|
|
|
|
RESULT="rpms=["
|
|
OUTPUTDIR=$(pwd)/artifacts
|
|
mkdir ${OUTPUTDIR}
|
|
|
|
for SPEC in ${SPECS[@]}; do
|
|
SPEC_NAME=$(basename ${SPEC})
|
|
CONFIGURATION="${SYSTEM}-${ARCH}"
|
|
|
|
echo "::debug::spec file: ${SPEC}"
|
|
echo "::debug::target: ${SYSTEM}-${ARCH}"
|
|
echo "::debug::nocheck: ${NOCHECK}"
|
|
|
|
echo "Building ${SPEC_NAME} for ${CONFIGURATION}"
|
|
|
|
echo "::group::Building SRPM"
|
|
cd $(dirname ${SPEC})
|
|
|
|
spectool -g ${SPEC_NAME}
|
|
if [ $? -ne 0 ]; then
|
|
echo "::error::Failed to download sources"
|
|
exit 1
|
|
fi
|
|
|
|
PKG_OUTPUTDIR=${OUTPUTDIR}/$(dirname ${SPEC})
|
|
|
|
mock -r "${SYSTEM}-${ARCH}" --buildsrpm --spec ${SPEC_NAME} --sources . --resultdir ${PKG_OUTPUTDIR}
|
|
if [ $? -ne 0 ]; then
|
|
echo "::error::Failed to build SRPM"
|
|
exit 1
|
|
fi
|
|
echo "::endgroup::"
|
|
|
|
SRPM=$(grep Wrote ${PKG_OUTPUTDIR}/build.log | cut -d ":" -f 2 | tr -d " " | xargs basename)
|
|
|
|
echo "::group::Building RPM"
|
|
OPTS=""
|
|
if [ ${NOCHECK,,} == "true" ]; then
|
|
OPTS="${OPTS} --nocheck"
|
|
fi
|
|
mock -r "${SYSTEM}-${ARCH}" --resultdir ${PKG_OUTPUTDIR} ${OPTS} ${PKG_OUTPUTDIR}/${SRPM}
|
|
if [ $? -ne 0 ]; then
|
|
echo "::error::Failed to build RPM"
|
|
exit 1
|
|
fi
|
|
echo "::endgroup::"
|
|
|
|
RPMS=$(grep Wrote ${PKG_OUTPUTDIR}/build.log | grep "/RPMS/" | cut -d" " -f 2 | xargs basename)
|
|
echo "::debug::built rpm: ${RPMS}"
|
|
RESULT="${RESULT},\"${RPMS}\""
|
|
cd - &> /dev/null
|
|
done
|
|
|
|
RESULT="${RESULT/[,/[}]"
|
|
echo "::debug::final built rpms: ${RESULT}"
|
|
echo ${RESULT} >> ${GITHUB_OUTPUT}
|