f13eb1bcea
We are running yum-config-manager/dnf config-manager in the epel element. Even though the yum-utils package is declared in the package-installs.yaml file, the package-installs pre-install.d script is executed after the one in the epel element, so image build fails. This commit ensures yum-utils or dnf-plugins-core are installed before running the command. Change-Id: Ib292b0b2b31bd966e0c5e8f2b2ce560bba89c45c
52 lines
1.6 KiB
Bash
Executable file
52 lines
1.6 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
|
|
set -x
|
|
fi
|
|
set -eu
|
|
set -o pipefail
|
|
|
|
if [[ ${DISTRO_NAME} =~ "centos" ]]; then
|
|
# Centos has "epel-release" in extras, which is default enabled.
|
|
${YUM} install -y epel-release
|
|
else
|
|
# For RHEL, we have to scrape the download page to find the latest
|
|
# release and install that
|
|
[ -n "$ARCH" ]
|
|
if [ 'amd64' = "$ARCH" ] ; then
|
|
ARCH="x86_64"
|
|
fi
|
|
|
|
BASE_URL=${DIB_EPEL_MIRROR:-https://dl.fedoraproject.org/pub/epel}
|
|
case "$DISTRO_NAME" in
|
|
rhel7)
|
|
RELEASE=7
|
|
URL=$BASE_URL/$RELEASE/x86_64/Packages/e/
|
|
;;
|
|
*)
|
|
echo "$DISTRO_NAME is not supported"
|
|
# Not really a failure; we just don't do anything
|
|
exit 0
|
|
;;
|
|
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
|
|
fi
|
|
|
|
if [ ${DIB_EPEL_DISABLED:-0} -ne 0 ]; then
|
|
if [[ ${YUM} == "dnf" ]]; then
|
|
rpm -q dnf-plugins-core || dnf install -y dnf-plugins-core
|
|
dnf config-manager --set-disabled "epel*"
|
|
else
|
|
# Cannot rely on package-installs, it is executed later
|
|
rpm -q yum-utils || yum install -y yum-utils
|
|
yum-config-manager --disable "epel*"
|
|
fi
|
|
fi
|
|
|
|
DIB_EPEL_MIRROR=${DIB_EPEL_MIRROR:-}
|
|
[ -n "$DIB_EPEL_MIRROR" ] || exit 0
|
|
|
|
# Set the EPEL mirror to use
|
|
sed -e "s|^#baseurl=http[s]*://download.fedoraproject.org/pub/epel|baseurl=$DIB_EPEL_MIRROR|;/^mirrorlist=/d;/^metalink=/d" -i /etc/yum.repos.d/epel.repo
|
|
|