mockbuild: use rpmrepo in mock templates
We're using rpmrepo snapshots as system repositories on the runners, so let's use them also for mockbuild.
This commit is contained in:
parent
65a777b286
commit
0aad2fa43f
1 changed files with 32 additions and 14 deletions
|
|
@ -6,6 +6,36 @@ function greenprint {
|
||||||
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
|
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# function to override template respositores with system repositories which contain rpmrepos snapshots
|
||||||
|
function template_override {
|
||||||
|
sudo dnf -y install jq
|
||||||
|
if sudo subscription-manager status; then
|
||||||
|
greenprint "📋 Running on subscribed RHEL machine, no mock template override done."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
if [[ "$ID" == rhel ]]; then
|
||||||
|
TEMPLATE=${ID}-${VERSION_ID%.*}.tpl
|
||||||
|
if [[ ${VERSION_ID%.*} == 8 ]]; then
|
||||||
|
sudo sed -i "s/config_opts\['redhat_subscription_required'\] = True/config_opts['redhat_subscription_required'] = False/" /etc/mock/templates/rhel-8.tpl
|
||||||
|
elif [[ ${VERSION_ID%.*} == 9 ]]; then
|
||||||
|
greenprint "📋 Inserting $ID-$VERSION_ID mock template"
|
||||||
|
sudo cp -r schutzbot/el9-mock-configs/* /etc/mock/
|
||||||
|
fi
|
||||||
|
elif [[ "$ID" == fedora ]]; then
|
||||||
|
TEMPLATE=fedora-branched.tpl
|
||||||
|
elif [[ "$ID" == centos ]]; then
|
||||||
|
TEMPLATE=${ID}-stream-${VERSION_ID}.tpl
|
||||||
|
STREAM=-stream
|
||||||
|
fi
|
||||||
|
greenprint "📋 Updating $ID-$VERSION_ID mock template with rpmrepo snapshot repositories"
|
||||||
|
REPOS=$(jq -r ."\"${ID}${STREAM:-}-${VERSION_ID}\".repos[].file" Schutzfile)
|
||||||
|
sudo sed -i '/user_agent/q' /etc/mock/templates/"$TEMPLATE"
|
||||||
|
for REPO in $REPOS; do
|
||||||
|
sudo cat "$REPO" | sudo tee -a /etc/mock/templates/"$TEMPLATE"
|
||||||
|
done
|
||||||
|
echo '"""' | sudo tee -a /etc/mock/templates/"$TEMPLATE"
|
||||||
|
}
|
||||||
|
|
||||||
# Get OS and architecture details.
|
# Get OS and architecture details.
|
||||||
source tools/set-env-variables.sh
|
source tools/set-env-variables.sh
|
||||||
|
|
||||||
|
|
@ -72,20 +102,8 @@ greenprint "🧬 Using mock config: ${MOCK_CONFIG}"
|
||||||
greenprint "📦 SHA: ${COMMIT}"
|
greenprint "📦 SHA: ${COMMIT}"
|
||||||
greenprint "📤 RPMS will be uploaded to: ${REPO_URL}"
|
greenprint "📤 RPMS will be uploaded to: ${REPO_URL}"
|
||||||
|
|
||||||
if [[ "$ID" == rhel && ${VERSION_ID%.*} == 8 ]] && ! sudo subscription-manager status; then
|
# override template repositories
|
||||||
greenprint "📋 Updating RHEL 8 mock template with the latest nightly repositories"
|
template_override
|
||||||
# strip everything after line with # repos
|
|
||||||
sudo sed -i '/# repos/q' /etc/mock/templates/rhel-8.tpl
|
|
||||||
# remove the subscription check
|
|
||||||
sudo sed -i "s/config_opts\['redhat_subscription_required'\] = True/config_opts['redhat_subscription_required'] = False/" /etc/mock/templates/rhel-8.tpl
|
|
||||||
# reuse redhat.repo
|
|
||||||
cat /etc/yum.repos.d/rhel8internal.repo | sudo tee -a /etc/mock/templates/rhel-8.tpl > /dev/null
|
|
||||||
# We need triple quotes at the end of the template to mark the end of the repo list.
|
|
||||||
echo '"""' | sudo tee -a /etc/mock/templates/rhel-8.tpl
|
|
||||||
elif [[ ${VERSION_ID%.*} == 9 ]]; then
|
|
||||||
greenprint "📋 Inserting EL9 mock templates"
|
|
||||||
sudo cp -r schutzbot/el9-mock-configs/* /etc/mock/
|
|
||||||
fi
|
|
||||||
|
|
||||||
greenprint "🔧 Building source RPM"
|
greenprint "🔧 Building source RPM"
|
||||||
git archive --prefix "osbuild-composer-${COMMIT}/" --output "osbuild-composer-${COMMIT}.tar.gz" HEAD
|
git archive --prefix "osbuild-composer-${COMMIT}/" --output "osbuild-composer-${COMMIT}.tar.gz" HEAD
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue