diff --git a/elements/centos/README.rst b/elements/centos/README.rst new file mode 100644 index 00000000..a044d089 --- /dev/null +++ b/elements/centos/README.rst @@ -0,0 +1,6 @@ +====== +centos +====== +Use Centos 6 cloud images as the baseline for built disk images. + +For further details see the redhat-common README. diff --git a/elements/centos/element-deps b/elements/centos/element-deps new file mode 100644 index 00000000..57b194ac --- /dev/null +++ b/elements/centos/element-deps @@ -0,0 +1,5 @@ +cache-url +dib-run-parts +redhat-common +rpm-distro +yum diff --git a/elements/centos/element-provides b/elements/centos/element-provides new file mode 100644 index 00000000..a72e0496 --- /dev/null +++ b/elements/centos/element-provides @@ -0,0 +1 @@ +operating-system diff --git a/elements/centos/environment.d/00-bootloader.bash b/elements/centos/environment.d/00-bootloader.bash new file mode 100755 index 00000000..6478bc96 --- /dev/null +++ b/elements/centos/environment.d/00-bootloader.bash @@ -0,0 +1,9 @@ +#!/bin/bash + +if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then + set -x +fi +set -eu +set -o pipefail + +export DIB_EXTLINUX=1 diff --git a/elements/centos/environment.d/10-centos6-distro-name.bash b/elements/centos/environment.d/10-centos6-distro-name.bash new file mode 100644 index 00000000..88d6a81f --- /dev/null +++ b/elements/centos/environment.d/10-centos6-distro-name.bash @@ -0,0 +1 @@ +export DISTRO_NAME=centos diff --git a/elements/centos/package-installs.yaml b/elements/centos/package-installs.yaml new file mode 100644 index 00000000..8428374e --- /dev/null +++ b/elements/centos/package-installs.yaml @@ -0,0 +1,4 @@ +parted: +cloud-utils: +cloud-utils-growpart: +dracut-modules-growpart: diff --git a/elements/centos/pre-install.d/02-yum-repos b/elements/centos/pre-install.d/02-yum-repos new file mode 100755 index 00000000..c0d60e3a --- /dev/null +++ b/elements/centos/pre-install.d/02-yum-repos @@ -0,0 +1,25 @@ +#!/bin/bash + +if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then + set -x +fi +set -eu +set -o pipefail + +cat << EOF > /etc/yum.repos.d/centos6-latest.repo +[rhel6] +name=centos6 +baseurl=http://mirror.centos.org/centos/6/os/x86_64/ +enabled=1 +metadata_expire=7d +gpgcheck=0 +EOF + +cat << EOF > /etc/yum.repos.d/epel.repo +[epel] +name=Extra Packages for Enterprise Linux 6 - \$basearch +mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=\$basearch +failovermethod=priority +enabled=1 +gpgcheck=0 +EOF diff --git a/elements/centos/root.d/10-centos6-cloud-image b/elements/centos/root.d/10-centos6-cloud-image new file mode 100755 index 00000000..85f4d1d4 --- /dev/null +++ b/elements/centos/root.d/10-centos6-cloud-image @@ -0,0 +1,34 @@ +#!/bin/bash + +if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then + set -x +fi +set -eu +set -o pipefail + +[ -n "$ARCH" ] +[ -n "$TARGET_ROOT" ] + +if [ 'amd64' = "$ARCH" ] ; then + ARCH="x86_64" +fi + +DIB_LOCAL_IMAGE=${DIB_LOCAL_IMAGE:-} + +if [ -n "$DIB_LOCAL_IMAGE" ]; then + IMAGE_LOCATION=$DIB_LOCAL_IMAGE + # No need to copy a local image into the cache directory, so just specify + # the cached path as the original path. + CACHED_IMAGE=$IMAGE_LOCATION + BASE_IMAGE_FILE=$(basename $DIB_LOCAL_IMAGE) + BASE_IMAGE_TAR=$BASE_IMAGE_FILE.tgz +else + DIB_RELEASE=${DIB_RELEASE:-GenericCloud-20141129_01} + DIB_CLOUD_IMAGES=${DIB_CLOUD_IMAGES:-http://cloud.centos.org/centos/6/images} + BASE_IMAGE_FILE=${BASE_IMAGE_FILE:-CentOS-6-x86_64-$DIB_RELEASE.qcow2} + BASE_IMAGE_TAR=$BASE_IMAGE_FILE.tgz + IMAGE_LOCATION=$DIB_CLOUD_IMAGES/$BASE_IMAGE_FILE + CACHED_IMAGE=$DIB_IMAGE_CACHE/$BASE_IMAGE_FILE +fi + +$TMP_HOOKS_PATH/bin/extract-image $BASE_IMAGE_FILE $BASE_IMAGE_TAR $IMAGE_LOCATION $CACHED_IMAGE diff --git a/elements/pkg-map/bin/pkg-map b/elements/pkg-map/bin/pkg-map index fba7255c..51ce1ac3 100755 --- a/elements/pkg-map/bin/pkg-map +++ b/elements/pkg-map/bin/pkg-map @@ -27,7 +27,7 @@ def eprint(msg): def os_family(distro): family = None - if distro in ['fedora', 'rhel', 'rhel7', 'centos7']: + if distro in ['fedora', 'rhel', 'rhel7', 'centos', 'centos7']: family = 'redhat' elif distro in ['debian', 'ubuntu']: family = 'debian' diff --git a/elements/redhat-common/bin/extract-image b/elements/redhat-common/bin/extract-image index cb9d4cf8..799f9f99 100755 --- a/elements/redhat-common/bin/extract-image +++ b/elements/redhat-common/bin/extract-image @@ -78,8 +78,14 @@ function extract_image() { EACTION="sudo umount -f $WORKING/mnt ; $EACTION" trap "$EACTION" EXIT + # find out if chroot tar has full xattr support + if [ 0 == `sudo chroot $WORKING/mnt bin/tar --help | grep -c xattrs-exclude` ]; then + TAROPTS="--no-xattrs" + else + TAROPTS="--xattrs --xattrs-include='*' --xattrs-exclude='security.selinux'" + fi # Chroot in so that we get the correct uid/gid - sudo chroot $WORKING/mnt bin/tar --xattrs --xattrs-include='*' --xattrs-exclude='security.selinux' -cz . > $WORKING/tmp.tar + sudo chroot $WORKING/mnt bin/tar $TAROPTS -cz . > $WORKING/tmp.tar mv $WORKING/tmp.tar $CACHED_TAR else echo "Using cached tar from $CACHED_TAR" diff --git a/elements/redhat-common/pre-install.d/15-remove-grub b/elements/redhat-common/pre-install.d/15-remove-grub index c5bd935d..81c58912 100755 --- a/elements/redhat-common/pre-install.d/15-remove-grub +++ b/elements/redhat-common/pre-install.d/15-remove-grub @@ -1,13 +1,21 @@ #!/bin/bash - -if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then +if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then set -x fi set -eu set -o pipefail +GRUBNAME=$(which grub-install) || echo "trying grub2-install" +if [ -z "$GRUBNAME" ]; then + GRUBNAME=$(which grub2-install) +fi +if [ -z "$GRUBNAME" ] || [ $($GRUBNAME --version | grep -c "0.97") -ne 0 ]; then + echo "No GRUB2 found. No need to remove" + exit 0 +else # Must manually remove grub2 here, otherwise the download below does not work. -yum remove -y grub2 + yum remove -y grub2 +fi # Remove all old versions of grub2 from the yum cache and then ensure the # latest version is in the cache. diff --git a/elements/svc-map/extra-data.d/10-merge-svc-map-files b/elements/svc-map/extra-data.d/10-merge-svc-map-files index 23fd8c38..9a7510be 100755 --- a/elements/svc-map/extra-data.d/10-merge-svc-map-files +++ b/elements/svc-map/extra-data.d/10-merge-svc-map-files @@ -21,7 +21,7 @@ import yaml def os_family(distro): "Given a distribution, returns a operating system family." family = None - if distro in ['centos7', 'fedora', 'rhel', 'rhel7']: + if distro in ['centos', 'centos7', 'fedora', 'rhel', 'rhel7']: family = 'redhat' elif distro in ['debian', 'ubuntu']: family = 'debian'