Skip to content

Commit 17af4e6

Browse files
committed
Element for building previous releases of CentOS 7
Use the CentOS vault and some known build numbers for cloud images and repos. Modify repos to pin packages at the designated release.
1 parent d5e501a commit 17af4e6

9 files changed

Lines changed: 165 additions & 0 deletions

File tree

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ This repository provides the following DIB elements:
2828
Ironic Python Agent (IPA) ramdisk image.
2929
* ``nvidia-cuda``: Installs Nvidia CUDA repo and packages for GPU support.
3030
* ``centos-linkup-extra``: Allows extra time for slow network links to come up.
31+
* ``centos7-vault``: Deploy older releases of CentOS 7

elements/centos7-vault/README.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
=============
2+
centos7-vault
3+
=============
4+
5+
Based on the standard centos7 element with minimal changes.
6+
7+
Use previous (but still available) versions of CentOS 7 cloud images as
8+
the baseline for built disk images.
9+
10+
DIB_CENTOS7_VERSION:
11+
:Required: No
12+
:Default: 7.7
13+
:Description: Set a version, from 7.1 to 7.7 (inclusive) and the last-known
14+
public locations for package repos and cloud images will be used.
15+
16+
DIB_CENTOS7_MIRROR_VERSION:
17+
:Required: No
18+
:Default: 7.7.1908
19+
:Description: Set a fully-qualified version for a build of CentOS.
20+
A sensible last-known default value is set according to
21+
``DIB_CENTOS7_VERSION``. This value also overwrites
22+
``$releasever`` in a standard ``CentOS-Base`` yum repo.
23+
24+
DIB_CENTOS7_CLOUDIMAGE_VERSION:
25+
:Required: No
26+
:Default: GenericCloud-1907
27+
:Description: Set a fully-qualified version for a cloud image build.
28+
A sensible last-known default value is set according to
29+
``DIB_CENTOS7_VERSION``.
30+
31+
DIB_CENTOS7_MIRROR:
32+
:Required: No
33+
:Default: ``http://vault.centos.org``
34+
:Description: A default value is the CentOS vault repo URL.
35+
It must have a subdirectory which is the CentOS mirror version.
36+
:Example: ``DIB_DISTRIBUTION_MIRROR=http://mirror.local/centos``
37+
38+
DIB_CENTOS7_CLOUDIMAGE_REPO:
39+
:Required: No
40+
:Default: ``https://cloud.centos.org/centos/7/images``
41+
:Description: URL to a folder for fetching the cloud image.
42+
43+
DIB_CENTOS7_CLOUDIMAGE:
44+
:Required: No
45+
:Default: ``https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-$DIB_CENTOS7_CLOUDIMAGE_VERSION.qcow2.xz``
46+
:Description: Set the desired fully-qualified URL to fetch the cloud image from.
47+
:Example: ``DIB_CLOUD_IMAGES=/path/to/my/centos/7/CentOS-7-x86_64-GenericCloud.qcow2.xz``
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cache-url
2+
redhat-common
3+
rpm-distro
4+
source-repositories
5+
yum
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
operating-system
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
export DISTRO_NAME=centos7
2+
export DIB_RELEASE=7
3+
4+
# Useful for elements that work with fedora (dnf) & centos
5+
export YUM=${YUM:-yum}
6+
7+
export DIB_CENTOS7_VERSION=${DIB_CENTOS7_VERSION:-"7.7"}
8+
case "$DIB_CENTOS7_VERSION" in
9+
7.7)
10+
DIB_CENTOS7_MIRROR_VERSION=${DIB_CENTOS7_MIRROR_VERSION:-"7.7.1908"}
11+
DIB_CENTOS7_CLOUDIMAGE_VERSION=${DIB_CENTOS7_CLOUDIMAGE_VERSION:-"GenericCloud-1907"}
12+
;;
13+
7.6)
14+
DIB_CENTOS7_MIRROR_VERSION=${DIB_CENTOS7_MIRROR_VERSION:-"7.6.1810"}
15+
DIB_CENTOS7_CLOUDIMAGE_VERSION=${DIB_CENTOS7_CLOUDIMAGE_VERSION:-"GenericCloud-1811"}
16+
;;
17+
7.5)
18+
DIB_CENTOS7_MIRROR_VERSION=${DIB_CENTOS7_MIRROR_VERSION:-"7.5.1804"}
19+
DIB_CENTOS7_CLOUDIMAGE_VERSION=${DIB_CENTOS7_CLOUDIMAGE_VERSION:-"GenericCloud-1805"}
20+
;;
21+
7.4)
22+
DIB_CENTOS7_MIRROR_VERSION=${DIB_CENTOS7_MIRROR_VERSION:-"7.4.1708"}
23+
DIB_CENTOS7_CLOUDIMAGE_VERSION=${DIB_CENTOS7_CLOUDIMAGE_VERSION:-"GenericCloud-1708"}
24+
;;
25+
7.3)
26+
DIB_CENTOS7_MIRROR_VERSION=${DIB_CENTOS7_MIRROR_VERSION:-"7.3.1611"}
27+
DIB_CENTOS7_CLOUDIMAGE_VERSION=${DIB_CENTOS7_CLOUDIMAGE_VERSION:-"GenericCloud-1611"}
28+
;;
29+
7.2)
30+
DIB_CENTOS7_MIRROR_VERSION=${DIB_CENTOS7_MIRROR_VERSION:-"7.2.1511"}
31+
DIB_CENTOS7_CLOUDIMAGE_VERSION=${DIB_CENTOS7_CLOUDIMAGE_VERSION:-"GenericCloud-1511"}
32+
;;
33+
7.1)
34+
DIB_CENTOS7_MIRROR_VERSION=${DIB_CENTOS7_MIRROR_VERSION:-"7.1.1503"}
35+
DIB_CENTOS7_CLOUDIMAGE_VERSION=${DIB_CENTOS7_CLOUDIMAGE_VERSION:-"GenericCloud-1503"}
36+
;;
37+
*)
38+
echo "CentOS 7 version \"$DIB_CENTOS7_VERSION\" is not recognised"
39+
exit -1
40+
;;
41+
esac
42+
export DIB_CENTOS7_MIRROR_VERSION DIB_CENTOS7_CLOUDIMAGE_VERSION
43+
44+
[ -n "$ARCH" ]
45+
46+
if [[ "amd64 x86_64" =~ "$ARCH" ]]; then
47+
ARCH="x86_64"
48+
export DIB_CENTOS7_CLOUDIMAGE_REPO=${DIB_CENTOS7_CLOUDIMAGE_REPO:-"https://cloud.centos.org/centos/7/images"}
49+
elif [[ "arm64 aarch64" =~ "$ARCH" ]]; then
50+
ARCH="aarch64"
51+
export DIB_CENTOS7_CLOUDIMAGE_REPO=${DIB_CENTOS7_CLOUDIMAGE_REPO:-http://cloud.centos.org/altarch/7/images/aarch64}
52+
elif [[ "ppc64le" =~ "$ARCH" ]]; then
53+
export DIB_CENTOS7_CLOUDIMAGE_REPO=${DIB_CENTOS7_CLOUDIMAGE_REPO:-http://cloud.centos.org/altarch/7/images/ppc64le}
54+
else
55+
echo 'centos7-vault root element only supports the x86_64, aarch64 and ppc64le values for $ARCH'
56+
exit -2
57+
fi
58+
59+
export DIB_CENTOS7_MIRROR=${DIB_CENTOS7_MIRROR:-"http://vault.centos.org"}
60+
export DIB_CENTOS7_CLOUDIMAGE_FILE=${DIB_CENTOS7_CLOUDIMAGE_FILE:-CentOS-7-${ARCH}-${DIB_CENTOS7_CLOUDIMAGE_VERSION}.qcow2.xz}
61+
export DIB_CENTOS7_CLOUDIMAGE=${DIB_CENTOS7_CLOUDIMAGE:-${DIB_CENTOS7_CLOUDIMAGE_REPO}/${DIB_CENTOS7_CLOUDIMAGE_FILE}}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
4+
set -x
5+
fi
6+
set -eu
7+
set -o pipefail
8+
9+
10+
# Only set the mirror for the Base, Extras, Updates and CentOSPlus repositories
11+
# This assumes a fair amount about the structure of the CentOS-Base repo file.
12+
# Would be nice to use -E "s/^\[(base|updates|extras|centosplus)\]/\[\1_$DIB_CENTOS7_MIRROR_VERSION\]/g"
13+
14+
sed -e "s|^#baseurl=http[s]*://mirror.centos.org/centos|baseurl=$DIB_CENTOS7_MIRROR|" \
15+
-e "/^mirrorlist=/d" \
16+
-e "s/^\[base\]/\[base_$DIB_CENTOS7_MIRROR_VERSION\]/g" \
17+
-e "s/^\[updates\]/\[updates_$DIB_CENTOS7_MIRROR_VERSION\]/g" \
18+
-e "s/^\[extras\]/\[extras_$DIB_CENTOS7_MIRROR_VERSION\]/g" \
19+
-e "s/^\[centosplus\]/\[centosplus_$DIB_CENTOS7_MIRROR_VERSION\]/g" \
20+
-e "s/\$releasever\>/$DIB_CENTOS7_MIRROR_VERSION/g" /etc/yum.repos.d/CentOS-Base.repo > /etc/yum.repos.d/CentOS-Vault.repo
21+
22+
yum clean all
23+
yum-config-manager --disable base updates extras centosplus
24+
yum-config-manager --enable {base,updates,extras,centosplus}_$DIB_CENTOS7_MIRROR_VERSION
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
4+
set -x
5+
fi
6+
set -eu
7+
set -o pipefail
8+
9+
[ -n "$TARGET_ROOT" ]
10+
11+
DIB_LOCAL_IMAGE=${DIB_LOCAL_IMAGE:-}
12+
13+
if [ -n "$DIB_LOCAL_IMAGE" ]; then
14+
# No need to copy a local image into the cache directory, so just specify
15+
# the cached path as the original path.
16+
CACHED_IMAGE=$DIB_CENTOS7_CLOUDIMAGE
17+
else
18+
CACHED_IMAGE=$DIB_IMAGE_CACHE/$DIB_CENTOS7_CLOUDIMAGE_FILE
19+
fi
20+
21+
BASE_IMAGE_TAR=$DIB_CENTOS7_CLOUDIMAGE_FILE.tgz
22+
23+
$TMP_HOOKS_PATH/bin/extract-image $DIB_CENTOS7_CLOUDIMAGE_FILE $BASE_IMAGE_TAR $DIB_CENTOS7_CLOUDIMAGE $CACHED_IMAGE

elements/centos7-vault/test-elements/build-succeeds/README.rst

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
base
2+
epel
3+
openstack-ci-mirrors

0 commit comments

Comments
 (0)