diskimage-builder/elements/epel/pre-install.d/05-rpm-epel-release
Derek Higgins 0c0c7275a9 Use DIB_EPEL_MIRROR when finding the epel-release package
download.fedoraproject.org uses dns round robin and occasionally
hits a bad server. Using DIB_EPEL_MIRROR when finding the
epel-release package will allow us to avoid it e.g. in ci.

Change-Id: I756223b3e669532476663c05e79c238449b8a0db
2015-10-20 17:25:58 +01:00

39 lines
907 B
Bash
Executable File

#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
[ -n "$ARCH" ]
if [ 'amd64' = "$ARCH" ] ; then
ARCH="x86_64"
fi
BASE_URL=${DIB_EPEL_MIRROR:-http://download.fedoraproject.org/pub/epel}
case "$DISTRO_NAME" in
rhel7|centos7)
RELEASE=7
URL=$BASE_URL/$RELEASE/x86_64/e/
;;
rhel|centos)
RELEASE=6
URL=$BASE_URL/$RELEASE/$ARCH/
;;
*)
echo "$DISTRO_NAME is not supported"
exit 1
;;
esac
PKG_NAME=$(wget -q $URL -O - |grep -oE "(href=\"epel-release-$RELEASE-[0-9,.].*)" | cut -d'"' -f2)
rpm -q epel-release || yum install -y $URL/$PKG_NAME
DIB_EPEL_MIRROR=${DIB_EPEL_MIRROR:-}
[ -n "$DIB_EPEL_MIRROR" ] || exit 0
# Set the EPEL mirror to use
sed -e "s|^#baseurl=http://download.fedoraproject.org/pub/epel|baseurl=$DIB_EPEL_MIRROR|;/^mirrorlist=/d" -i /etc/yum.repos.d/epel.repo