Skip to content

Commit 67fd81a

Browse files
committed
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
1 parent 36705b5 commit 67fd81a

3 files changed

Lines changed: 8 additions & 60 deletions

File tree

functions-common

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,6 @@ function _ensure_lsb_release {
329329
sudo zypper -n install lsb-release
330330
elif [[ -x $(command -v dnf 2>/dev/null) ]]; then
331331
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
335332
else
336333
die $LINENO "Unable to find or auto-install lsb_release"
337334
fi
@@ -1361,61 +1358,28 @@ function uninstall_package {
13611358
if is_ubuntu; then
13621359
apt_get purge "$@"
13631360
elif is_fedora; then
1364-
sudo ${YUM:-yum} remove -y "$@" ||:
1361+
sudo dnf remove -y "$@" ||:
13651362
elif is_suse; then
13661363
sudo zypper remove -y "$@" ||:
13671364
else
13681365
exit_distro_not_supported "uninstalling packages"
13691366
fi
13701367
}
13711368

1372-
# Wrapper for ``yum`` to set proxy environment variables
1373-
# Uses globals ``OFFLINE``, ``*_proxy``, ``YUM``
1369+
# Wrapper for ``dnf`` to set proxy environment variables
1370+
# Uses globals ``OFFLINE``, ``*_proxy``
1371+
# The name is kept for backwards compatability with external
1372+
# callers, despite none of our supported platforms using yum
1373+
# any more.
13741374
# yum_install package [package ...]
13751375
function yum_install {
13761376
local result parse_yum_result
13771377

13781378
[[ "$OFFLINE" = "True" ]] && return
13791379

13801380
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 "$@"
14051382
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"
14191383
}
14201384

14211385
# zypper wrapper to set arguments correctly

stack.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -283,19 +283,12 @@ fi
283283
# to pick up required packages.
284284

285285
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-
293286
# epel-release is in extras repo which is enabled by default
294287
install_package epel-release
295288

296289
# RDO repos are not tested with epel and may have incompatibilities so
297290
# 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
299292
}
300293

301294
function _install_rdo {

stackrc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -813,15 +813,6 @@ SERVICE_GRACEFUL_SHUTDOWN_TIMEOUT=${SERVICE_GRACEFUL_SHUTDOWN_TIMEOUT:-5}
813813
# Service graceful shutdown timeout
814814
WORKER_TIMEOUT=${WORKER_TIMEOUT:-90}
815815

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-
825816
# Common Configuration
826817
# --------------------
827818

0 commit comments

Comments
 (0)