From e4b6a2faef4bd82c027e618108d99af780cdb470 Mon Sep 17 00:00:00 2001 From: Carlos Goncalves Date: Mon, 22 Jun 2020 11:37:55 +0200 Subject: [PATCH] Add support for CentOS 8 Stream cloud image This patch adds support for CentOS 8 Stream [1] to the centos element (cloud image). Users should set DIB_RELEASE=8-stream. [1] https://www.centos.org/stream/ Change-Id: Ib8f542031c46326ffed812fa60cbc9e56db9d6fd --- .zuul.d/jobs.yaml | 1 + diskimage_builder/elements/centos/README.rst | 2 +- .../elements/centos/environment.d/11-yum-dnf.bash | 6 +++--- .../centos/pre-install.d/01-set-centos-mirror | 11 ++++++++++- .../elements/centos/root.d/10-centos-cloud-image | 2 +- .../test-elements/8-stream-build-succeeds/README.rst | 1 + .../8-stream-build-succeeds/element-deps | 3 +++ .../environment.d/10-set-distro.bash | 1 + .../8-stream-build-succeeds/test-output-formats | 1 + releasenotes/notes/add-6b94d90caea2895e.yaml | 5 +++++ 10 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 diskimage_builder/elements/centos/test-elements/8-stream-build-succeeds/README.rst create mode 100644 diskimage_builder/elements/centos/test-elements/8-stream-build-succeeds/element-deps create mode 100644 diskimage_builder/elements/centos/test-elements/8-stream-build-succeeds/environment.d/10-set-distro.bash create mode 100644 diskimage_builder/elements/centos/test-elements/8-stream-build-succeeds/test-output-formats create mode 100644 releasenotes/notes/add-6b94d90caea2895e.yaml diff --git a/.zuul.d/jobs.yaml b/.zuul.d/jobs.yaml index e1469f80..0d3e7c06 100644 --- a/.zuul.d/jobs.yaml +++ b/.zuul.d/jobs.yaml @@ -43,6 +43,7 @@ dib_functests: - centos7/build-succeeds - centos/8-build-succeeds + - centos/8-stream-build-succeeds - fedora/build-succeeds - opensuse/build-succeeds - opensuse/opensuse15-build-succeeds diff --git a/diskimage_builder/elements/centos/README.rst b/diskimage_builder/elements/centos/README.rst index 687bc533..3ef56412 100644 --- a/diskimage_builder/elements/centos/README.rst +++ b/diskimage_builder/elements/centos/README.rst @@ -14,7 +14,7 @@ DIB_DISTRIBUTION_MIRROR: :Default: None :Description: To use a CentOS Yum mirror, set this variable to the mirror URL before running bin/disk-image-create. This URL should point to - the directory containing the ``7/8`` directories. + the directory containing the ``7/8/8-stream`` directories. :Example: ``DIB_DISTRIBUTION_MIRROR=http://amirror.com/centos`` DIB_CLOUD_IMAGES: diff --git a/diskimage_builder/elements/centos/environment.d/11-yum-dnf.bash b/diskimage_builder/elements/centos/environment.d/11-yum-dnf.bash index f14bdc3b..35766e22 100644 --- a/diskimage_builder/elements/centos/environment.d/11-yum-dnf.bash +++ b/diskimage_builder/elements/centos/environment.d/11-yum-dnf.bash @@ -1,7 +1,7 @@ # since CentOS 8, dnf is the yum replacement. -if [[ ${DIB_RELEASE} == '8' ]]; then - export YUM=dnf -elif [[ ${DIB_RELEASE} == '7' ]]; then +if [[ $DIB_RELEASE == "7" ]]; then export YUM=yum +else + export YUM=dnf fi diff --git a/diskimage_builder/elements/centos/pre-install.d/01-set-centos-mirror b/diskimage_builder/elements/centos/pre-install.d/01-set-centos-mirror index 93cf814c..eb6a83df 100755 --- a/diskimage_builder/elements/centos/pre-install.d/01-set-centos-mirror +++ b/diskimage_builder/elements/centos/pre-install.d/01-set-centos-mirror @@ -14,10 +14,19 @@ DIB_DISTRIBUTION_MIRROR=${DIB_DISTRIBUTION_MIRROR:-} # The others aren't enabled and do not exist on all mirrors if [[ ${DIB_RELEASE} == '7' ]]; then sed -e "s,^#baseurl=http[s]*://mirror.centos.org/\(centos\|altarch\)/,baseurl=$DIB_DISTRIBUTION_MIRROR/,;/^mirrorlist=/d" -i /etc/yum.repos.d/CentOS-Base.repo -elif [[ ${DIB_RELEASE} == '8' ]]; then +elif [[ ${DIB_RELEASE} > '7' ]]; then sed -e "s,^#baseurl=http[s]*://mirror.centos.org/\$contentdir/,baseurl=$DIB_DISTRIBUTION_MIRROR/,;/^mirrorlist=/d" -i /etc/yum.repos.d/CentOS-Base.repo sed -e "s,^#baseurl=http[s]*://mirror.centos.org/\$contentdir/,baseurl=$DIB_DISTRIBUTION_MIRROR/,;/^mirrorlist=/d" -i /etc/yum.repos.d/CentOS-AppStream.repo sed -e "s,^#baseurl=http[s]*://mirror.centos.org/\$contentdir/,baseurl=$DIB_DISTRIBUTION_MIRROR/,;/^mirrorlist=/d" -i /etc/yum.repos.d/CentOS-centosplus.repo sed -e "s,^#baseurl=http[s]*://mirror.centos.org/\$contentdir/,baseurl=$DIB_DISTRIBUTION_MIRROR/,;/^mirrorlist=/d" -i /etc/yum.repos.d/CentOS-Extras.repo sed -e "s,^#baseurl=http[s]*://mirror.centos.org/\$contentdir/,baseurl=$DIB_DISTRIBUTION_MIRROR/,;/^mirrorlist=/d" -i /etc/yum.repos.d/CentOS-PowerTools.repo fi + +# CentOS Stream releases (e.g. 8-stream, 9-stream) +if [[ ${DIB_RELEASE} =~ '-stream' ]]; then + sed -e "s,^#baseurl=http[s]*://mirror.centos.org/\$contentdir/,baseurl=$DIB_DISTRIBUTION_MIRROR/,;/^mirrorlist=/d" -i /etc/yum.repos.d/CentOS-Stream-Base.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-centosplus.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 + sed -e "s,^#baseurl=http[s]*://mirror.centos.org/\$contentdir/,baseurl=$DIB_DISTRIBUTION_MIRROR/,;/^mirrorlist=/d" -i /etc/yum.repos.d/CentOS-Stream-PowerTools.repo +fi diff --git a/diskimage_builder/elements/centos/root.d/10-centos-cloud-image b/diskimage_builder/elements/centos/root.d/10-centos-cloud-image index 88f4111e..cca99257 100755 --- a/diskimage_builder/elements/centos/root.d/10-centos-cloud-image +++ b/diskimage_builder/elements/centos/root.d/10-centos-cloud-image @@ -51,7 +51,7 @@ else if [[ "${DIB_RELEASE}" = 7 ]]; then BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-CentOS-${DIB_RELEASE}-${ARCH}-${DIB_FLAVOR}.qcow2.xz} else - LATEST_IMAGE_FILE=$(curl -s https://cloud.centos.org/centos/${DIB_RELEASE}/${ARCH}/images/ | grep -o "CentOS-${DIB_RELEASE}-${DIB_FLAVOR}-.[^>]*.qcow2" | sort -r | head -1) + LATEST_IMAGE_FILE=$(curl -s https://cloud.centos.org/centos/${DIB_RELEASE}/${ARCH}/images/ | grep -o "CentOS-.[^>]*${DIB_FLAVOR}-.[^>]*.qcow2" | sort -r | head -1) BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-$LATEST_IMAGE_FILE} fi BASE_IMAGE_TAR=$BASE_IMAGE_FILE.tgz diff --git a/diskimage_builder/elements/centos/test-elements/8-stream-build-succeeds/README.rst b/diskimage_builder/elements/centos/test-elements/8-stream-build-succeeds/README.rst new file mode 100644 index 00000000..8f20a9d7 --- /dev/null +++ b/diskimage_builder/elements/centos/test-elements/8-stream-build-succeeds/README.rst @@ -0,0 +1 @@ +Centos Stream 8 test diff --git a/diskimage_builder/elements/centos/test-elements/8-stream-build-succeeds/element-deps b/diskimage_builder/elements/centos/test-elements/8-stream-build-succeeds/element-deps new file mode 100644 index 00000000..3a391e3e --- /dev/null +++ b/diskimage_builder/elements/centos/test-elements/8-stream-build-succeeds/element-deps @@ -0,0 +1,3 @@ +base +epel +openstack-ci-mirrors diff --git a/diskimage_builder/elements/centos/test-elements/8-stream-build-succeeds/environment.d/10-set-distro.bash b/diskimage_builder/elements/centos/test-elements/8-stream-build-succeeds/environment.d/10-set-distro.bash new file mode 100644 index 00000000..b20c3062 --- /dev/null +++ b/diskimage_builder/elements/centos/test-elements/8-stream-build-succeeds/environment.d/10-set-distro.bash @@ -0,0 +1 @@ +export DIB_RELEASE='8-stream' diff --git a/diskimage_builder/elements/centos/test-elements/8-stream-build-succeeds/test-output-formats b/diskimage_builder/elements/centos/test-elements/8-stream-build-succeeds/test-output-formats new file mode 100644 index 00000000..7895a833 --- /dev/null +++ b/diskimage_builder/elements/centos/test-elements/8-stream-build-succeeds/test-output-formats @@ -0,0 +1 @@ +qcow2 \ No newline at end of file diff --git a/releasenotes/notes/add-6b94d90caea2895e.yaml b/releasenotes/notes/add-6b94d90caea2895e.yaml new file mode 100644 index 00000000..6212b712 --- /dev/null +++ b/releasenotes/notes/add-6b94d90caea2895e.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + The ``centos`` element supports CentOS 8 Stream builds when run with + ``DIB_RELEASE=8-stream``