From cb55b089c8d3808ba87c1ef8f5defe23e1c9172d Mon Sep 17 00:00:00 2001 From: Curt Moore Date: Wed, 19 Jun 2024 16:11:49 -0500 Subject: [PATCH] Adapt to upstream CentOS Stream mirror changes When using DIB_DISTRIBUTION_MIRROR for an internal mirror with CentOS Stream >= 9, ensure that the yum repository configuration files reference the new upstream directory structure layout. Change-Id: I8360bb77e5ef9370ec69f9c0c327726e3554b7a4 --- .../pre-install.d/00-02-set-centos-mirror | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/diskimage_builder/elements/centos/pre-install.d/00-02-set-centos-mirror b/diskimage_builder/elements/centos/pre-install.d/00-02-set-centos-mirror index 2a197aa41..62f2b44c0 100755 --- a/diskimage_builder/elements/centos/pre-install.d/00-02-set-centos-mirror +++ b/diskimage_builder/elements/centos/pre-install.d/00-02-set-centos-mirror @@ -10,14 +10,24 @@ DIB_DISTRIBUTION_MIRROR=${DIB_DISTRIBUTION_MIRROR:-} [ -n "$DIB_DISTRIBUTION_MIRROR" ] || exit 0 +if [[ ${DIB_RELEASE} =~ ([0-9]+)-stream ]]; then + # By virtue of capturing the version number, this match also + # implicitly indicates that this is a CentOS stream release version + STREAM_RELEASE_VERSION=${BASH_REMATCH[1]} +fi + # Only set the mirror for the Base, Extras and Updates repositories # The others aren't enabled and do not exist on all mirrors -# CentOS Stream releases (9-stream) -if [[ ${DIB_RELEASE} =~ '9-stream' ]]; then +# CentOS Stream >= 9 +if [[ "${STREAM_RELEASE_VERSION}" -ge "9" ]]; then sed -e "s,^#baseurl=http[s]*://mirror.centos.org/\$contentdir/,baseurl=$DIB_DISTRIBUTION_MIRROR/,;/^mirrorlist=/d" -i /etc/yum.repos.d/centos.repo sed -e "s,^#baseurl=http[s]*://mirror.centos.org/\$contentdir/,baseurl=$DIB_DISTRIBUTION_MIRROR/,;/^mirrorlist=/d" -i /etc/yum.repos.d/centos-addons.repo -# CentOS Stream releases (8-stream) -elif [[ ${DIB_RELEASE} =~ '-stream' ]]; then + # Handle metalinks and new directory structure of https://mirror.stream.centos.org/ + sed -e "s,^metalink=http[s]*://mirrors.centos.org/metalink?repo=centos-baseos-.*,baseurl=$DIB_DISTRIBUTION_MIRROR/$DIB_RELEASE/BaseOS/\$basearch/os," -i /etc/yum.repos.d/centos.repo + sed -e "s,^metalink=http[s]*://mirrors.centos.org/metalink?repo=centos-appstream-.*,baseurl=$DIB_DISTRIBUTION_MIRROR/$DIB_RELEASE/AppStream/\$basearch/os," -i /etc/yum.repos.d/centos.repo + sed -e "s,^metalink=http[s]*://mirrors.centos.org/metalink?repo=centos-extras-sig-extras-common-.*,baseurl=$DIB_DISTRIBUTION_MIRROR/SIGs/$DIB_RELEASE/extras/\$basearch/extras-common," -i /etc/yum.repos.d/centos-addons.repo +# CentOS 8-stream +elif [[ "${STREAM_RELEASE_VERSION}" -eq "8" ]]; then sed -e "s,^#baseurl=http[s]*://mirror.centos.org/\$contentdir/,baseurl=$DIB_DISTRIBUTION_MIRROR/,;/^mirrorlist=/d" -i /etc/yum.repos.d/CentOS-Stream-BaseOS.repo sed -e "s,^#baseurl=http[s]*://mirror.centos.org/\$contentdir/,baseurl=$DIB_DISTRIBUTION_MIRROR/,;/^mirrorlist=/d" -i /etc/yum.repos.d/CentOS-Stream-AppStream.repo sed -e "s,^#baseurl=http[s]*://mirror.centos.org/\$contentdir/,baseurl=$DIB_DISTRIBUTION_MIRROR/,;/^mirrorlist=/d" -i /etc/yum.repos.d/CentOS-Stream-Extras.repo