From b27f16d71660f75fcd82a035cdaf2b2eddec99ce Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Fri, 28 Feb 2014 14:29:02 +1100 Subject: [PATCH] Detect missing packages with yum 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 --- files/rpms/glance | 2 +- functions-common | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/files/rpms/glance b/files/rpms/glance index 25c5d3902b..534097a92f 100644 --- a/files/rpms/glance +++ b/files/rpms/glance @@ -13,6 +13,6 @@ python-lxml #dist:f18,f19,f20,rhel7 python-paste-deploy #dist:f18,f19,f20,rhel7 python-routes python-sqlalchemy -python-wsgiref +python-wsgiref #dist:f18,f19,f20 pyxattr zlib-devel # testonly diff --git a/functions-common b/functions-common index 0db3ff3e7c..ed3d8832fd 100644 --- a/functions-common +++ b/functions-common @@ -938,9 +938,24 @@ function yum_install { [[ "$OFFLINE" = "True" ]] && return local sudo="sudo" [[ "$(id -u)" = "0" ]] && sudo="env" + + # The manual check for missing packages is because yum -y assumes + # missing packages are OK. See + # https://bugzilla.redhat.com/show_bug.cgi?id=965567 $sudo http_proxy=$http_proxy https_proxy=$https_proxy \ no_proxy=$no_proxy \ - yum install -y "$@" + yum install -y "$@" 2>&1 | \ + 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 [[ ${PIPESTATUS[0]} != 0 ]]; then + die $LINENO "Yum install failure" + fi } # zypper wrapper to set arguments correctly