yum -y doesn't report an error when packages are missing (see [1] for
upstream discussion). Thus we run the output of yum through a small
awk script looking for missing packages output.
The one change required for RHEL is that python-wsgiref is included in
the distro python, so doesn't need a separate package.
[1] https://bugzilla.redhat.com/show_bug.cgi?id=965567
Change-Id: I9908ff4edbf2b0d961d25837a08a34e1417bbb02
... | ... |
@@ -938,9 +938,24 @@ function yum_install { |
938 | 938 |
[[ "$OFFLINE" = "True" ]] && return |
939 | 939 |
local sudo="sudo" |
940 | 940 |
[[ "$(id -u)" = "0" ]] && sudo="env" |
941 |
+ |
|
942 |
+ # The manual check for missing packages is because yum -y assumes |
|
943 |
+ # missing packages are OK. See |
|
944 |
+ # https://bugzilla.redhat.com/show_bug.cgi?id=965567 |
|
941 | 945 |
$sudo http_proxy=$http_proxy https_proxy=$https_proxy \ |
942 | 946 |
no_proxy=$no_proxy \ |
943 |
- yum install -y "$@" |
|
947 |
+ yum install -y "$@" 2>&1 | \ |
|
948 |
+ awk ' |
|
949 |
+ BEGIN { fail=0 } |
|
950 |
+ /No package/ { fail=1 } |
|
951 |
+ { print } |
|
952 |
+ END { exit fail }' || \ |
|
953 |
+ die $LINENO "Missing packages detected" |
|
954 |
+ |
|
955 |
+ # also ensure we catch a yum failure |
|
956 |
+ if [[ ${PIPESTATUS[0]} != 0 ]]; then |
|
957 |
+ die $LINENO "Yum install failure" |
|
958 |
+ fi |
|
944 | 959 |
} |
945 | 960 |
|
946 | 961 |
# zypper wrapper to set arguments correctly |