rhel 8.4 tests are added. The configs are based off of those used for rhel 8.3. The Schutzbot Mockbuild, Base, Image, Integration, and OSTree tests are added for 8.4. Repo overrides are added for the rhel 8.4 tests so that the tests use rpmrepo snapshots. The mockbuild uses the jenkins rhel84-nightly-repo credential to override the rhel mock template's repos with rhel 8.4 nightly repos. These repos are stored in a credential because they are internal links. The image tests and koji tests need a special distro selector since the rhel-8 test cases are only for rhel 8 versions less than 8.4. The rhel 8.4 tests are named with the rhel-84 pattern whereas the other rhel 8 versions have the rhel-8 pattern. Also, instead of having only rhel-8 and rhel-8-beta repo configs for the tests, we now have a specific repo config for each rhel release we test. The repo is also now pulled from an rpmrepo snapshot. For whichever distro is being tested, the approriate repo config will be copied to /etc/osbuild-composer/repositories as rhel-8 and rhel-8-beta since this is the naming osbuild-composer looks for. For testing purposes, the rhel-8 and rhel-8-beta repo should be the same since eventually all rhel releases will go from beta to not beta. The fedora repo overrides are already done in tools/provision.sh so the rhel override is set there as well. Currently, only rhel 8.4 requires an override.
106 lines
3.6 KiB
Bash
Executable file
106 lines
3.6 KiB
Bash
Executable file
#!/bin/bash
|
||
set -euo pipefail
|
||
|
||
# Colorful output.
|
||
function greenprint {
|
||
echo -e "\033[1;32m${1}\033[0m"
|
||
}
|
||
|
||
# Get OS and architecture details.
|
||
source /etc/os-release
|
||
ARCH=$(uname -m)
|
||
|
||
# Mock configuration file to use for building RPMs.
|
||
MOCK_CONFIG="${ID}-${VERSION_ID%.*}-$(uname -m)"
|
||
|
||
# The commit this script operates on.
|
||
COMMIT=$(git rev-parse HEAD)
|
||
|
||
# Bucket in S3 where our artifacts are uploaded
|
||
REPO_BUCKET=osbuild-composer-repos
|
||
|
||
# Public URL for the S3 bucket with our artifacts.
|
||
MOCK_REPO_BASE_URL="http://osbuild-composer-repos.s3-website.us-east-2.amazonaws.com"
|
||
|
||
# Relative path of the repository – used for constructing both the local and
|
||
# remote paths below, so that they're consistent.
|
||
REPO_PATH=osbuild-composer/${ID}-${VERSION_ID}/${ARCH}/${COMMIT}
|
||
|
||
# Directory to hold the RPMs temporarily before we upload them.
|
||
REPO_DIR=repo/${REPO_PATH}
|
||
|
||
# Full URL to the RPM repository after they are uploaded.
|
||
REPO_URL=${MOCK_REPO_BASE_URL}/${REPO_PATH}
|
||
|
||
# Don't rerun the build if it already exists
|
||
if curl --silent --fail --head --output /dev/null "${REPO_URL}/repodata/repomd.xml"; then
|
||
greenprint "🎁 Repository already exists. Exiting."
|
||
exit 0
|
||
fi
|
||
|
||
# Mock and s3cmd is only available in EPEL for RHEL.
|
||
if [[ $ID == rhel ]] && ! rpm -q epel-release; then
|
||
greenprint "📦 Setting up EPEL repository"
|
||
curl -Ls --retry 5 --output /tmp/epel.rpm \
|
||
https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
|
||
sudo rpm -Uvh /tmp/epel.rpm
|
||
fi
|
||
|
||
# Register RHEL if we are provided with a registration script.
|
||
if [[ -n "${RHN_REGISTRATION_SCRIPT:-}" ]] && ! sudo subscription-manager status; then
|
||
greenprint "🪙 Registering RHEL instance"
|
||
sudo chmod +x "$RHN_REGISTRATION_SCRIPT"
|
||
sudo "$RHN_REGISTRATION_SCRIPT"
|
||
fi
|
||
|
||
# Install requirements for building RPMs in mock.
|
||
greenprint "📦 Installing mock requirements"
|
||
sudo dnf -y install createrepo_c mock s3cmd
|
||
|
||
|
||
# Print some data.
|
||
greenprint "🧬 Using mock config: ${MOCK_CONFIG}"
|
||
greenprint "📦 SHA: ${COMMIT}"
|
||
greenprint "📤 RPMS will be uploaded to: ${REPO_URL}"
|
||
|
||
# rhel 8.4 will run off of the nightly repos and does not have a redhat subscription
|
||
if [[ $VERSION_ID == 8.4 ]]; then
|
||
greenprint "📋 Updating RHEL 8 mock template for unsubscribed image"
|
||
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
|
||
cat "$RHEL84_NIGHTLY_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
|
||
fi
|
||
|
||
greenprint "🔧 Building source RPM"
|
||
git archive --prefix "osbuild-composer-${COMMIT}/" --output "osbuild-composer-${COMMIT}.tar.gz" HEAD
|
||
sudo mock -r "$MOCK_CONFIG" --buildsrpm \
|
||
--define "commit ${COMMIT}" \
|
||
--spec ./osbuild-composer.spec \
|
||
--sources "./osbuild-composer-${COMMIT}.tar.gz" \
|
||
--resultdir ./srpm
|
||
|
||
greenprint "🎁 Building RPMs"
|
||
sudo mock -r "$MOCK_CONFIG" \
|
||
--define "commit ${COMMIT}" \
|
||
--with=tests \
|
||
--resultdir "$REPO_DIR" \
|
||
srpm/*.src.rpm
|
||
|
||
# Change the ownership of all of our repo files from root to our CI user.
|
||
sudo chown -R "$USER" "${REPO_DIR%%/*}"
|
||
|
||
greenprint "🧹 Remove logs from mock build"
|
||
rm "${REPO_DIR}"/*.log
|
||
|
||
# Create a repo of the built RPMs.
|
||
greenprint "⛓️ Creating dnf repository"
|
||
createrepo_c "${REPO_DIR}"
|
||
|
||
# Upload repository to S3.
|
||
greenprint "☁ Uploading RPMs to S3"
|
||
pushd repo
|
||
s3cmd --acl-public sync . s3://${REPO_BUCKET}/
|
||
popd
|