Don't die when yum fails.
Not all yum failures has to be considered catastrofic failures also because install_package function should implement the same behavior in Fedora, CentOS and Ubuntu. Let return the error to be solved at higher level. Change-Id: I93e9f312a94aeb086925e069a83ec1d3d3419423 Closes-Bug: #1522590
This commit is contained in:
parent
1d27155f65
commit
5dcbf7aeff
@ -1320,27 +1320,35 @@ function uninstall_package {
|
|||||||
# Uses globals ``OFFLINE``, ``*_proxy``, ``YUM``
|
# Uses globals ``OFFLINE``, ``*_proxy``, ``YUM``
|
||||||
# yum_install package [package ...]
|
# yum_install package [package ...]
|
||||||
function yum_install {
|
function yum_install {
|
||||||
|
local result parse_yum_result
|
||||||
|
|
||||||
[[ "$OFFLINE" = "True" ]] && return
|
[[ "$OFFLINE" = "True" ]] && return
|
||||||
local sudo="sudo"
|
|
||||||
[[ "$(id -u)" = "0" ]] && sudo="env"
|
time_start "yum_install"
|
||||||
|
|
||||||
|
# Warning: this would not work if yum output message
|
||||||
|
# have been translated to another language
|
||||||
|
parse_yum_result='\
|
||||||
|
BEGIN { result=0 }\
|
||||||
|
/^YUM_FAILED/ { exit $2 }\
|
||||||
|
/^No package/ { result=1 }\
|
||||||
|
//{ print }\
|
||||||
|
END { exit result }'
|
||||||
|
|
||||||
# The manual check for missing packages is because yum -y assumes
|
# The manual check for missing packages is because yum -y assumes
|
||||||
# missing packages are OK. See
|
# missing packages are OK.
|
||||||
# https://bugzilla.redhat.com/show_bug.cgi?id=965567
|
# See https://bugzilla.redhat.com/show_bug.cgi?id=965567
|
||||||
$sudo http_proxy="${http_proxy:-}" https_proxy="${https_proxy:-}" \
|
(sudo_with_proxies "${YUM:-yum}" install -y "$@" 2>&1 || echo YUM_FAILED $?) \
|
||||||
no_proxy="${no_proxy:-}" \
|
| awk "$parse_yum_result"
|
||||||
${YUM:-yum} install -y "$@" 2>&1 | \
|
result=$?
|
||||||
awk '
|
|
||||||
BEGIN { fail=0 }
|
|
||||||
/No package/ { fail=1 }
|
|
||||||
{ print }
|
|
||||||
END { exit fail }' || \
|
|
||||||
die $LINENO "Missing packages detected"
|
|
||||||
|
|
||||||
# also ensure we catch a yum failure
|
if [ "$result" != 0 ]; then
|
||||||
if [[ ${PIPESTATUS[0]} != 0 ]]; then
|
echo $LINENO "${YUM:-yum}" install failure: $result
|
||||||
die $LINENO "${YUM:-yum} install failure"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
time_stop "yum_install"
|
||||||
|
|
||||||
|
return "$result"
|
||||||
}
|
}
|
||||||
|
|
||||||
# zypper wrapper to set arguments correctly
|
# zypper wrapper to set arguments correctly
|
||||||
@ -2279,6 +2287,18 @@ function test_with_retry {
|
|||||||
time_stop "test_with_retry"
|
time_stop "test_with_retry"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Like sudo but forwarding http_proxy https_proxy no_proxy environment vars.
|
||||||
|
# If it is run as superuser then sudo is replaced by env.
|
||||||
|
#
|
||||||
|
function sudo_with_proxies {
|
||||||
|
local sudo
|
||||||
|
|
||||||
|
[[ "$(id -u)" = "0" ]] && sudo="env" || sudo="sudo"
|
||||||
|
|
||||||
|
$sudo http_proxy="${http_proxy:-}" https_proxy="${https_proxy:-}"\
|
||||||
|
no_proxy="${no_proxy:-}" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
# Timing infrastructure - figure out where large blocks of time are
|
# Timing infrastructure - figure out where large blocks of time are
|
||||||
# used in DevStack
|
# used in DevStack
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user