Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions scripts/devenv-builder/configure-vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,6 @@ function configure_rhel_subscription() {
function configure_rhel_repositories() {
sudo subscription-manager config --rhsm.manage_repos=1

# Extract major version from Makefile.version
local -r ocp_major="$(grep '^OCP_VERSION' "${MAKE_VERSION}" | cut -d'=' -f2 | tr -d ' ' | cut -d'.' -f1)"

# Map of last minor version for each major (for cross-major transitions)
local -A last_minor_for_major=([4]=22)

Expand All @@ -214,34 +211,35 @@ function configure_rhel_repositories() {
}

RHOCP=$("${RHOCP_REPO}")
if [[ "${RHOCP}" =~ ^[0-9]{1,2}$ ]]; then
sudo subscription-manager repos --enable "rhocp-${ocp_major}.${RHOCP}-for-rhel-9-$(uname -m)-rpms"
if [[ "${RHOCP}" =~ ^[0-9]+\.[0-9]+$ ]]; then
sudo subscription-manager repos --enable "rhocp-${RHOCP}-for-rhel-9-$(uname -m)-rpms"
elif [[ "${RHOCP}" =~ ^http ]]; then
url=$(echo "${RHOCP}" | cut -d, -f1)
major=$(echo "${RHOCP}" | cut -d, -f2)
ver=$(echo "${RHOCP}" | cut -d, -f3)
OCP_REPO_NAME="rhocp-${major}.${ver}-for-rhel-9-mirrorbeta-$(uname -i)-rpms"
ver=$(echo "${RHOCP}" | cut -d, -f2)
OCP_REPO_NAME="rhocp-${ver}-for-rhel-9-mirrorbeta-$(uname -m)-rpms"
sudo tee "/etc/yum.repos.d/${OCP_REPO_NAME}.repo" >/dev/null <<EOF
[${OCP_REPO_NAME}]
name=Beta rhocp-${major}.${ver} RPMs for RHEL 9
name=Beta rhocp-${ver} RPMs for RHEL 9
baseurl=${url}
enabled=1
gpgcheck=0
skip_if_unavailable=0
EOF
# Calculate Y-1 version
get_prev_version "${major}" "${ver}"
local major=${ver%%.*}
local minor=${ver##*.}
get_prev_version "${major}" "${minor}"
if [[ -n "${prev_minor}" ]]; then
PREVIOUS_RHOCP=$("${RHOCP_REPO}" "${prev_minor}" "${prev_major}")
if [[ "${PREVIOUS_RHOCP}" =~ ^[0-9]{1,2}$ ]]; then
sudo subscription-manager repos --enable "rhocp-${prev_major}.${PREVIOUS_RHOCP}-for-rhel-9-$(uname -m)-rpms"
if [[ "${PREVIOUS_RHOCP}" =~ ^[0-9]+\.[0-9]+$ ]]; then
sudo subscription-manager repos --enable "rhocp-${PREVIOUS_RHOCP}-for-rhel-9-$(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]{1,2}$ ]]; then
sudo subscription-manager repos --enable "rhocp-${prev_major}.${Y2_RHOCP}-for-rhel-9-$(uname -m)-rpms"
if [[ "${Y2_RHOCP}" =~ ^[0-9]+\.[0-9]+$ ]]; then
sudo subscription-manager repos --enable "rhocp-${Y2_RHOCP}-for-rhel-9-$(uname -m)-rpms"
fi
fi
fi
Expand Down
12 changes: 6 additions & 6 deletions scripts/get-latest-rhocp-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# - A minor and major version (e.g. 22 4) to check for RHOCP of a specific major.minor.
#
# Output is:
# - just a minor version in case of subscription RHOCP repository, e.g.: 15
# - or an URL to beta mirror followed by comma, major, comma, and minor version, e.g.:
# https://mirror.openshift.com/pub/openshift-v4/x86_64/dependencies/rpms/4.16-el9-beta/,4,16
# https://mirror.openshift.com/pub/openshift-v5/x86_64/dependencies/rpms/5.0-el9-beta/,5,0
# - major.minor version in case of subscription RHOCP repository, e.g.: 4.15
# - or an URL to beta mirror followed by comma and major.minor version, e.g.:
# https://mirror.openshift.com/pub/openshift-v4/x86_64/dependencies/rpms/4.16-el9-beta/,4.16
# https://mirror.openshift.com/pub/openshift-v5/x86_64/dependencies/rpms/5.0-el9-beta/,5.0

set -euo pipefail

Expand Down Expand Up @@ -82,13 +82,13 @@ check_minor="${current_minor}"
for (( step=0; step < max_steps; step++ )); do
repository="rhocp-${check_major}.${check_minor}-for-rhel-9-$(uname -m)-rpms"
if sudo dnf repository-packages --showduplicates "${repository}" info cri-o 1>&2; then
echo "${check_minor}"
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/"
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}"
echo "${rhocp_beta_url},${check_major}.${check_minor}"
exit 0
fi

Expand Down