Browse code

Install latest EPEL release

Use a little trick cribbed from [1] to install the latest EPEL
release, rather than hard-coding versions

[1] http://stackoverflow.com/questions/14016286/how-to-programmatically-install-the-latest-epel-release-rpm-without-knowing-its

Closes-bug: #1376321
Change-Id: Ib89d73d669efe2e2d61fc0b12b46395fce113386

Ian Wienand authored on 2014/10/08 13:37:23
Showing 1 changed files
... ...
@@ -234,15 +234,35 @@ fi
234 234
 
235 235
 if [[ is_fedora && ( $DISTRO == "rhel6" || $DISTRO == "rhel7" ) ]]; then
236 236
     # RHEL requires EPEL for many Open Stack dependencies
237
-    if [[ $DISTRO == "rhel7" ]]; then
238
-        EPEL_RPM=${RHEL7_EPEL_RPM:-"http://dl.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-1.noarch.rpm"}
239
-    elif [[ $DISTRO == "rhel6" ]]; then
240
-        EPEL_RPM=${RHEL6_EPEL_RPM:-"http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm"}
241
-    fi
242 237
     if ! sudo yum repolist enabled epel | grep -q 'epel'; then
243 238
         echo "EPEL not detected; installing"
244
-        yum_install ${EPEL_RPM} || \
239
+        # This trick installs the latest epel-release from a bootstrap
240
+        # repo, then removes itself (as epel-release installed the
241
+        # "real" repo).
242
+        #
243
+        # you would think that rather than this, you could use
244
+        # $releasever directly in .repo file we create below.  However
245
+        # RHEL gives a $releasever of "6Server" which breaks the path;
246
+        # see https://bugzilla.redhat.com/show_bug.cgi?id=1150759
247
+        if [[ $DISTRO == "rhel7" ]]; then
248
+            epel_ver="7"
249
+        elif [[ $DISTRO == "rhel6" ]]; then
250
+            epel_ver="6"
251
+        fi
252
+
253
+        cat <<EOF | sudo tee /etc/yum.repos.d/epel-bootstrap.repo
254
+[epel]
255
+name=Bootstrap EPEL
256
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-$epel_ver&arch=\$basearch
257
+failovermethod=priority
258
+enabled=0
259
+gpgcheck=0
260
+EOF
261
+        # bare yum call due to --enablerepo
262
+        sudo yum --enablerepo=epel -y install epel-release || \
245 263
             die $LINENO "Error installing EPEL repo, cannot continue"
264
+        # epel rpm has installed it's version
265
+        sudo rm -f /etc/yum.repos.d/epel-bootstrap.repo
246 266
     fi
247 267
 
248 268
     # ... and also optional to be enabled