Browse code

Cleanup yum things

We no longer support platforms with Yum on master. Cleanup old
references and convert to dnf.

We don't need any of the failure wrapper stuff as dnf runs in strict
mode by default.

There seem to be a few callers out there, so we'll leave it called
yum_install for now.

Change-Id: Ie71a48fd85b00a97a14bf260cd013b18af4cce06

Ian Wienand authored on 2020/04/30 08:24:04
Showing 3 changed files
... ...
@@ -329,9 +329,6 @@ function _ensure_lsb_release {
329 329
         sudo zypper -n install lsb-release
330 330
     elif [[ -x $(command -v dnf 2>/dev/null) ]]; then
331 331
         sudo dnf install -y redhat-lsb-core
332
-    elif [[ -x $(command -v yum 2>/dev/null) ]]; then
333
-        # all rh patforms (fedora, centos, rhel) have this pkg
334
-        sudo yum install -y redhat-lsb-core
335 332
     else
336 333
         die $LINENO "Unable to find or auto-install lsb_release"
337 334
     fi
... ...
@@ -1361,7 +1358,7 @@ function uninstall_package {
1361 1361
     if is_ubuntu; then
1362 1362
         apt_get purge "$@"
1363 1363
     elif is_fedora; then
1364
-        sudo ${YUM:-yum} remove -y "$@" ||:
1364
+        sudo dnf remove -y "$@" ||:
1365 1365
     elif is_suse; then
1366 1366
         sudo zypper remove -y "$@" ||:
1367 1367
     else
... ...
@@ -1369,8 +1366,11 @@ function uninstall_package {
1369 1369
     fi
1370 1370
 }
1371 1371
 
1372
-# Wrapper for ``yum`` to set proxy environment variables
1373
-# Uses globals ``OFFLINE``, ``*_proxy``, ``YUM``
1372
+# Wrapper for ``dnf`` to set proxy environment variables
1373
+# Uses globals ``OFFLINE``, ``*_proxy``
1374
+# The name is kept for backwards compatability with external
1375
+# callers, despite none of our supported platforms using yum
1376
+# any more.
1374 1377
 # yum_install package [package ...]
1375 1378
 function yum_install {
1376 1379
     local result parse_yum_result
... ...
@@ -1378,44 +1378,8 @@ function yum_install {
1378 1378
     [[ "$OFFLINE" = "True" ]] && return
1379 1379
 
1380 1380
     time_start "yum_install"
1381
-
1382
-    # This is a bit tricky, because yum -y assumes missing or failed
1383
-    # packages are OK (see [1]).  We want devstack to stop if we are
1384
-    # installing missing packages.
1385
-    #
1386
-    # Thus we manually match on the output (stack.sh runs in a fixed
1387
-    # locale, so lang shouldn't change).
1388
-    #
1389
-    # If yum returns !0, we echo the result as "YUM_FAILED" and return
1390
-    # that from the awk (we're subverting -e with this trick).
1391
-    # Otherwise we use awk to look for failure strings and return "2"
1392
-    # to indicate a terminal failure.
1393
-    #
1394
-    # [1] https://bugzilla.redhat.com/show_bug.cgi?id=965567
1395
-    parse_yum_result='              \
1396
-        BEGIN { result=0 }          \
1397
-        /^YUM_FAILED/ { result=$2 } \
1398
-        /^No package/ { result=2 }  \
1399
-        /^Failed:/    { result=2 }  \
1400
-        //{ print }                 \
1401
-        END { exit result }'
1402
-    (sudo_with_proxies "${YUM:-yum}" install -y "$@" 2>&1 || echo YUM_FAILED $?) \
1403
-        | awk "$parse_yum_result" && result=$? || result=$?
1404
-
1381
+    sudo_with_proxies dnf install -y "$@"
1405 1382
     time_stop "yum_install"
1406
-
1407
-    # if we return 1, then the wrapper functions will run an update
1408
-    # and try installing the package again as a defense against bad
1409
-    # mirrors.  This can hide failures, especially when we have
1410
-    # packages that are in the "Failed:" section because their rpm
1411
-    # install scripts failed to run correctly (in this case, the
1412
-    # package looks installed, so when the retry happens we just think
1413
-    # the package is OK, and incorrectly continue on).
1414
-    if [ "$result" == 2 ]; then
1415
-        die "Detected fatal package install failure"
1416
-    fi
1417
-
1418
-    return "$result"
1419 1383
 }
1420 1384
 
1421 1385
 # zypper wrapper to set arguments correctly
... ...
@@ -283,19 +283,12 @@ fi
283 283
 # to pick up required packages.
284 284
 
285 285
 function _install_epel {
286
-    # NOTE: We always remove and install latest -- some environments
287
-    # use snapshot images, and if EPEL version updates they break
288
-    # unless we update them to latest version.
289
-    if sudo yum repolist enabled epel | grep -q 'epel'; then
290
-        uninstall_package epel-release || true
291
-    fi
292
-
293 286
     # epel-release is in extras repo which is enabled by default
294 287
     install_package epel-release
295 288
 
296 289
     # RDO repos are not tested with epel and may have incompatibilities so
297 290
     # let's limit the packages fetched from epel to the ones not in RDO repos.
298
-    sudo yum-config-manager --save --setopt=includepkgs=debootstrap,dpkg epel
291
+    sudo dnf config-manager --save --setopt=includepkgs=debootstrap,dpkg epel
299 292
 }
300 293
 
301 294
 function _install_rdo {
... ...
@@ -813,15 +813,6 @@ SERVICE_GRACEFUL_SHUTDOWN_TIMEOUT=${SERVICE_GRACEFUL_SHUTDOWN_TIMEOUT:-5}
813 813
 # Service graceful shutdown timeout
814 814
 WORKER_TIMEOUT=${WORKER_TIMEOUT:-90}
815 815
 
816
-# Choose DNF on RedHat/Fedora platforms with it, or otherwise default
817
-# to YUM.  Can remove this when only dnf is supported (i.e. centos7
818
-# disappears)
819
-if [[ -e /usr/bin/dnf ]]; then
820
-    YUM=${YUM:-dnf}
821
-else
822
-    YUM=${YUM:-yum}
823
-fi
824
-
825 816
 # Common Configuration
826 817
 # --------------------
827 818