Skip to content
19 changes: 15 additions & 4 deletions scripts/devenv-builder/configure-composer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,22 @@ install_and_configure_composer() {
local -r version_id_major="$(awk -F. '{print $1}' <<< "${version_id}")"

"${DNF_RETRY}" "install" "osbuild osbuild-composer"
"${DNF_RETRY}" "install" \
"git composer-cli ostree rpm-ostree \
cockpit-composer bash-completion podman runc genisoimage \
local packages="git composer-cli ostree rpm-ostree \
cockpit-composer bash-completion podman python3-psutil \
createrepo yum-utils selinux-policy-devel jq wget lorax rpm-build \
containernetworking-plugins expect httpd-tools vim-common"
expect httpd-tools vim-common"

# genisoimage and containernetworking-plugins were removed in RHEL 10.
# Use xorriso (provides a genisoimage-compatible CLI) instead.
# containernetworking-plugins (CNI) has no replacement — Podman uses
# Netavark on RHEL 10, and MicroShift ships its own CNI plugins RPM.
if [[ "${version_id_major}" -ge 10 ]]; then
packages+=" crun xorriso"
else
packages+=" runc genisoimage containernetworking-plugins"
fi

"${DNF_RETRY}" "install" "${packages}"

# The mock utility comes from the EPEL repository
"${DNF_RETRY}" "install" "https://dl.fedoraproject.org/pub/epel/epel-release-latest-${version_id_major}.noarch.rpm"
Expand Down
22 changes: 12 additions & 10 deletions scripts/devenv-builder/configure-vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,7 @@ function configure_rhel_subscription() {
fi
sudo subscription-manager config --rhsm.manage_repos=1

# Parse the OS versions and determine if EUS
source /etc/os-release
VERSION_ID_MAJOR="$(awk -F. '{print $1}' <<< "${VERSION_ID}")"
VERSION_ID_MINOR="$(awk -F. '{print $2}' <<< "${VERSION_ID}")"
# Determine if EUS
VERSION_ID_EUS=""
if (( "${VERSION_ID_MINOR}" % 2 == 0 )) ; then
VERSION_ID_EUS="-eus"
Expand Down Expand Up @@ -212,14 +209,14 @@ function configure_rhel_repositories() {

RHOCP=$("${RHOCP_REPO}")
if [[ "${RHOCP}" =~ ^[0-9]+\.[0-9]+$ ]]; then
sudo subscription-manager repos --enable "rhocp-${RHOCP}-for-rhel-9-$(uname -m)-rpms"
sudo subscription-manager repos --enable "rhocp-${RHOCP}-for-rhel-${VERSION_ID_MAJOR}-$(uname -m)-rpms"
elif [[ "${RHOCP}" =~ ^http ]]; then
url=$(echo "${RHOCP}" | cut -d, -f1)
ver=$(echo "${RHOCP}" | cut -d, -f2)
OCP_REPO_NAME="rhocp-${ver}-for-rhel-9-mirrorbeta-$(uname -m)-rpms"
OCP_REPO_NAME="rhocp-${ver}-for-rhel-${VERSION_ID_MAJOR}-mirrorbeta-$(uname -m)-rpms"
sudo tee "/etc/yum.repos.d/${OCP_REPO_NAME}.repo" >/dev/null <<EOF
[${OCP_REPO_NAME}]
name=Beta rhocp-${ver} RPMs for RHEL 9
name=Beta rhocp-${ver} RPMs for RHEL ${VERSION_ID_MAJOR}
baseurl=${url}
enabled=1
gpgcheck=0
Expand All @@ -232,14 +229,14 @@ EOF
if [[ -n "${prev_minor}" ]]; then
PREVIOUS_RHOCP=$("${RHOCP_REPO}" "${prev_minor}" "${prev_major}")
if [[ "${PREVIOUS_RHOCP}" =~ ^[0-9]+\.[0-9]+$ ]]; then
sudo subscription-manager repos --enable "rhocp-${PREVIOUS_RHOCP}-for-rhel-9-$(uname -m)-rpms"
sudo subscription-manager repos --enable "rhocp-${PREVIOUS_RHOCP}-for-rhel-${VERSION_ID_MAJOR}-$(uname -m)-rpms"
else
# If RHOCP Y-1 is not available, try RHOCP Y-2.
get_prev_version "${prev_major}" "${prev_minor}"
if [[ -n "${prev_minor}" ]]; then
Y2_RHOCP=$("${RHOCP_REPO}" "${prev_minor}" "${prev_major}")
if [[ "${Y2_RHOCP}" =~ ^[0-9]+\.[0-9]+$ ]]; then
sudo subscription-manager repos --enable "rhocp-${Y2_RHOCP}-for-rhel-9-$(uname -m)-rpms"
sudo subscription-manager repos --enable "rhocp-${Y2_RHOCP}-for-rhel-${VERSION_ID_MAJOR}-$(uname -m)-rpms"
fi
fi
fi
Expand Down Expand Up @@ -302,7 +299,7 @@ function install_openshift_clients() {
OCP_MAJOR="$(grep '^OCP_VERSION' "${MAKE_VERSION}" | cut -d'=' -f2 | tr -d ' ' | cut -d'.' -f1)"
OCP_MINOR="$(grep '^OCP_VERSION' "${MAKE_VERSION}" | cut -d'=' -f2 | tr -d ' ' | cut -d'.' -f2)"
OCPVERSION="${OCP_MAJOR}.${OCP_MINOR}"
OCC_SRC="https://mirror.openshift.com/pub/openshift-v${OCP_MAJOR}/$(uname -m)/dependencies/rpms/${OCPVERSION}-el9-beta"
OCC_SRC="https://mirror.openshift.com/pub/openshift-v${OCP_MAJOR}/$(uname -m)/dependencies/rpms/${OCPVERSION}-el${VERSION_ID_MAJOR}-beta"
OCC_RPM="$(curl -s "${OCC_SRC}/" | grep -o "openshift-clients-${OCP_MAJOR}[^\"']*.rpm" | sort | uniq)"
OCC_LOC="$(mktemp /tmp/openshift-client-XXXXX.rpm)"
OCC_REM="${OCC_SRC}/${OCC_RPM}"
Expand Down Expand Up @@ -395,6 +392,11 @@ parse_cmdline_args "$@"
configure_system_settings
download_script_dependencies

# Detect RHEL major version for repo name construction
source /etc/os-release
VERSION_ID_MAJOR="$(awk -F. '{print $1}' <<< "${VERSION_ID}")"
VERSION_ID_MINOR="$(awk -F. '{print $2}' <<< "${VERSION_ID}")"

check_rhel_subscription_type
if ${RHEL_SUBSCRIPTION}; then
configure_rhel_subscription
Expand Down
9 changes: 7 additions & 2 deletions scripts/devenv-builder/manage-vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,13 @@ function get_base_isofile {
}

function action_config() {
local -r deps="libvirt virt-manager virt-install virt-viewer libvirt-client qemu-kvm qemu-img sshpass wget"

source /etc/os-release
local -r rhel_major="${VERSION_ID%%.*}"
local deps="libvirt virt-install virt-viewer libvirt-client qemu-kvm qemu-img sshpass wget"
if [[ "${rhel_major}" -lt 10 ]]; then
deps+=" virt-manager"
fi

"${SCRIPTDIR}/../dnf_retry.sh" "install" "${deps}"

if [ "$(systemctl is-active libvirtd.socket)" != "active" ] ; then
Expand Down
8 changes: 6 additions & 2 deletions scripts/get-latest-rhocp-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ if ! sudo subscription-manager status >&/dev/null; then
exit 1
fi

# Detect RHEL major version for repo name construction
source /etc/os-release
RHEL_MAJOR="${VERSION_ID%%.*}"

# Get version of currently checked out branch.
# It's based on values stored in Makefile.version.$ARCH.var.
make_version="${REPOROOT}/Makefile.version.$(uname -m).var"
Expand Down Expand Up @@ -80,13 +84,13 @@ fi
check_major="${current_major}"
check_minor="${current_minor}"
for (( step=0; step < max_steps; step++ )); do
repository="rhocp-${check_major}.${check_minor}-for-rhel-9-$(uname -m)-rpms"
repository="rhocp-${check_major}.${check_minor}-for-rhel-${RHEL_MAJOR}-$(uname -m)-rpms"
if sudo dnf repository-packages --showduplicates "${repository}" info cri-o 1>&2; then
echo "${check_major}.${check_minor}"
exit 0
fi

rhocp_beta_url="https://mirror.openshift.com/pub/openshift-v${check_major}/$(uname -m)/dependencies/rpms/${check_major}.${check_minor}-el9-beta/"
rhocp_beta_url="https://mirror.openshift.com/pub/openshift-v${check_major}/$(uname -m)/dependencies/rpms/${check_major}.${check_minor}-el${RHEL_MAJOR}-beta/"
if sudo dnf repository-packages --showduplicates --disablerepo '*' --repofrompath "this,${rhocp_beta_url}" this info cri-o 1>&2; then
echo "${rhocp_beta_url},${check_major}.${check_minor}"
exit 0
Expand Down
25 changes: 19 additions & 6 deletions test/bin/pyutils/build_bootc_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@
FORCE_REBUILD = False


def _get_rhel_major():
with open('/etc/os-release') as f:
for line in f:
if line.startswith('VERSION_ID='):
return line.strip().split('=')[1].strip('"').split('.')[0]
return '9'


RHEL_MAJOR = _get_rhel_major()


def cleanup_atexit(dry_run):
common.print_msg("Running atexit cleanup")
# Terminating any running subprocesses
Expand Down Expand Up @@ -83,7 +94,7 @@ def is_rhocp_available(major, minor):
"""
# Equivalent to `uname -m`
architecture = platform.machine()
repository = f"rhocp-{major}.{minor}-for-rhel-9-{architecture}-rpms"
repository = f"rhocp-{major}.{minor}-for-rhel-{RHEL_MAJOR}-{architecture}-rpms"

try:
# Run the dnf command to check for cri-o in the specified repository
Expand All @@ -105,8 +116,8 @@ def get_rhocp_beta_url_if_available(major, minor):
Returns:
str: The beta URL if available, otherwise empty string.
"""
url_amd = f"https://mirror.openshift.com/pub/openshift-v{major}/x86_64/dependencies/rpms/{major}.{minor}-el9-beta/"
url_arm = f"https://mirror.openshift.com/pub/openshift-v{major}/aarch64/dependencies/rpms/{major}.{minor}-el9-beta/"
url_amd = f"https://mirror.openshift.com/pub/openshift-v{major}/x86_64/dependencies/rpms/{major}.{minor}-el{RHEL_MAJOR}-beta/"
url_arm = f"https://mirror.openshift.com/pub/openshift-v{major}/aarch64/dependencies/rpms/{major}.{minor}-el{RHEL_MAJOR}-beta/"

try:
# Run the dnf command to check for cri-o in the specified repository
Expand All @@ -118,7 +129,7 @@ def get_rhocp_beta_url_if_available(major, minor):

# Use specific minor version RHOCP mirror only if both arches are available.
architecture = platform.machine()
return f"https://mirror.openshift.com/pub/openshift-v{major}/{architecture}/dependencies/rpms/{major}.{minor}-el9-beta/"
return f"https://mirror.openshift.com/pub/openshift-v{major}/{architecture}/dependencies/rpms/{major}.{minor}-el{RHEL_MAJOR}-beta/"
except Exception:
return ""

Expand Down Expand Up @@ -739,8 +750,10 @@ def main():
extract_container_images(SOURCE_VERSION, LOCAL_REPO, CONTAINER_LIST, args.dry_run)
# The following images are specific to layers that use fake rpms built from source
extract_container_images(f"{FAKE_NEXT_MAJOR_VERSION}.{FAKE_NEXT_MINOR_VERSION}.*", NEXT_REPO, CONTAINER_LIST, args.dry_run)
extract_container_images(PREVIOUS_RELEASE_VERSION, PREVIOUS_RELEASE_REPO, CONTAINER_LIST, args.dry_run)
extract_container_images(YMINUS2_RELEASE_VERSION, YMINUS2_RELEASE_REPO, CONTAINER_LIST, args.dry_run)
if PREVIOUS_RELEASE_VERSION:
extract_container_images(PREVIOUS_RELEASE_VERSION, PREVIOUS_RELEASE_REPO, CONTAINER_LIST, args.dry_run)
if YMINUS2_RELEASE_VERSION:
extract_container_images(YMINUS2_RELEASE_VERSION, YMINUS2_RELEASE_REPO, CONTAINER_LIST, args.dry_run)
# The following images are specific to the brew release versions
if BREW_Y0_RELEASE_VERSION:
extract_container_images(BREW_Y0_RELEASE_VERSION, BREW_REPO, CONTAINER_LIST, args.dry_run)
Expand Down
23 changes: 17 additions & 6 deletions test/bin/pyutils/generate_common_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@

ARCH = os.uname().machine


def _get_rhel_major():
with open('/etc/os-release') as f:
for line in f:
if line.startswith('VERSION_ID='):
return line.strip().split('=')[1].strip('"').split('.')[0]
return '9'


RHEL_MAJOR = _get_rhel_major()

# Version map defining the last minor version for each major version.
# Used for cross-major Y-1/Y-2 calculations (e.g., 5.0's Y-1 is 4.22).
# Authoritative source: lastMinorForMajor in pkg/admin/prerun/version.go
Expand Down Expand Up @@ -80,7 +91,7 @@ def get_candidate_repo_url(major, minor, dev_preview=False):
Returns:
str: The URL of the candidate repository.
"""
return f"https://mirror.openshift.com/pub/openshift-v{major}/{ARCH}/microshift/ocp{'-dev-preview' if dev_preview else ''}/latest-{major}.{minor}/el9/os"
return f"https://mirror.openshift.com/pub/openshift-v{major}/{ARCH}/microshift/ocp{'-dev-preview' if dev_preview else ''}/latest-{major}.{minor}/el{RHEL_MAJOR}/os"


def get_dependencies_repo_url(major, minor, steps_back=0):
Expand All @@ -106,7 +117,7 @@ def get_dependencies_repo_url(major, minor, steps_back=0):

current_major, current_minor = major, minor
for _ in range(steps_back + 1):
url = f"https://mirror.openshift.com/pub/openshift-v{current_major}/{ARCH}/dependencies/rpms/{current_major}.{current_minor}-el9-beta"
url = f"https://mirror.openshift.com/pub/openshift-v{current_major}/{ARCH}/dependencies/rpms/{current_major}.{current_minor}-el{RHEL_MAJOR}-beta"
if mirror_exists(url) and repo_provides_pkg(url, "cri-o"):
logging.info(f"Beta dependencies repository found for {current_major}.{current_minor}")
return url
Expand Down Expand Up @@ -180,7 +191,7 @@ def get_subscription_repo_name_if_exists(major, minor):
Returns:
str or None: The name of the subscription repository, or None if not available.
"""
repo = f"rhocp-{major}.{minor}-for-rhel-9-{ARCH}-rpms"
repo = f"rhocp-{major}.{minor}-for-rhel-{RHEL_MAJOR}-{ARCH}-rpms"

if repo_provides_pkg(repo, "microshift"):
return repo
Expand Down Expand Up @@ -286,7 +297,7 @@ def get_gitops_version(major_version, minor_version):
gitops_version_ocp_compatibility = gitops_version_from_api_docs.get("openshift_compatibility") or ""
gitops_version_number = gitops_version_from_api_docs.get("name")
if f"{current_major}.{current_minor}" in gitops_version_ocp_compatibility:
gitops_repo = f"gitops-{gitops_version_number}-for-rhel-9-{ARCH}-rpms"
gitops_repo = f"gitops-{gitops_version_number}-for-rhel-{RHEL_MAJOR}-{ARCH}-rpms"
if repo_provides_pkg(gitops_repo, "microshift-gitops"):
logging.info(f"Found GitOps version: {gitops_version_number} which is compatible with OCP {gitops_version_ocp_compatibility} on {gitops_repo} repository")
return gitops_version_number
Expand Down Expand Up @@ -321,7 +332,7 @@ def generate_common_versions(major_version, minor_version):

# The 'rhocp_minor_y' variable should be the minor version number, if the
# current release is available through the 'rhocp' stream, otherwise empty.
rhocp_minor_y = minor_version if repo_provides_pkg(f"rhocp-{major_version}.{minor_version}-for-rhel-9-{ARCH}-rpms", "cri-o") else '""'
rhocp_minor_y = minor_version if repo_provides_pkg(f"rhocp-{major_version}.{minor_version}-for-rhel-{RHEL_MAJOR}-{ARCH}-rpms", "cri-o") else '""'
rhocp_major_y = major_version if rhocp_minor_y != '""' else '""'

# The beta repository, containing dependencies, should point to the
Expand All @@ -332,7 +343,7 @@ def generate_common_versions(major_version, minor_version):

# The 'rhocp_minor_y1' variable should be the previous minor version number, if
# the previous release is available through the 'rhocp' stream, otherwise empty.
rhocp_minor_y1 = previous_minor_version if repo_provides_pkg(f"rhocp-{previous_major_version}.{previous_minor_version}-for-rhel-9-{ARCH}-rpms", "cri-o") else '""'
rhocp_minor_y1 = previous_minor_version if repo_provides_pkg(f"rhocp-{previous_major_version}.{previous_minor_version}-for-rhel-{RHEL_MAJOR}-{ARCH}-rpms", "cri-o") else '""'
rhocp_major_y1 = previous_major_version if rhocp_minor_y1 != '""' else '""'

# The beta repository, containing dependencies, should point to the
Expand Down
4 changes: 3 additions & 1 deletion test/bin/scenario.sh
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,9 @@ exit_if_image_not_set() {

# Exit the script if microshift previous Z-stream version does not exist in rhocp repository
exit_if_zprel_not_exist() {
local -r rhocp_repo="rhocp-${MAJOR_VERSION}.${MINOR_VERSION}-for-rhel-9-${UNAME_M}-rpms"
source /etc/os-release
local -r rhel_major="${VERSION_ID%%.*}"
local -r rhocp_repo="rhocp-${MAJOR_VERSION}.${MINOR_VERSION}-for-rhel-${rhel_major}-${UNAME_M}-rpms"
local microshift_zprel
if ! microshift_zprel="$(dnf repoquery -q --repo "${rhocp_repo}" --latest-limit 1 --nvr microshift 2>&1)"; then
record_junit "repo ${rhocp_repo} does not exist or is not available: ${microshift_zprel}" "exit_if_zprel_not_exist" "SKIPPED"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@

# TODO: Replace this by a RHEL 10.2 image when its RPM repositories are released.
# rhel-10.2
rhel-10.1
rhel-10.2
Loading