@@ -1322,29 +1322,36 @@ function yum_install {
13221322
13231323 time_start " yum_install"
13241324
1325- # Warning: this would not work if yum output message
1326- # have been translated to another language
1325+ # - We run with LC_ALL=C so string matching *should* be OK
1326+ # - Exit 1 if the failure might get better with a retry.
1327+ # - Exit 2 if it is fatal.
13271328 parse_yum_result=' \
13281329 BEGIN { result=0 } \
13291330 /^YUM_FAILED/ { exit $2 } \
1330- /^No package/ { result=1 } \
1331- /^Failed:/ { result=1 } \
1331+ /^No package/ { result=2 } \
1332+ /^Failed:/ { result=2 } \
13321333 //{ print } \
13331334 END { exit result }'
13341335
13351336 # The manual check for missing packages is because yum -y assumes
13361337 # missing or failed packages are OK.
13371338 # See https://bugzilla.redhat.com/show_bug.cgi?id=965567
13381339 (sudo_with_proxies " ${YUM:- yum} " install -y " $@ " 2>&1 || echo YUM_FAILED $? ) \
1339- | awk " $parse_yum_result "
1340- result=$?
1341-
1342- if [ " $result " != 0 ]; then
1343- echo $LINENO " ${YUM:- yum} " install failure: $result
1344- fi
1340+ | awk " $parse_yum_result " && result=$? || result=$?
13451341
13461342 time_stop " yum_install"
13471343
1344+ # if we return 1, then the wrapper functions will run an update
1345+ # and try installing the package again as a defense against bad
1346+ # mirrors. This can hide failures, especially when we have
1347+ # packages that are in the "Failed:" section because their rpm
1348+ # install scripts failed to run correctly (in this case, the
1349+ # package looks installed, so when the retry happens we just think
1350+ # the package is OK, and incorrectly continue on).
1351+ if [ " $result " == 2 ]; then
1352+ die " Detected fatal package install failure"
1353+ fi
1354+
13481355 return " $result "
13491356}
13501357
0 commit comments