Check if transaction failed for some packages
When yum is processing transaction and some failure occures (e.g. prein script fails for package being installed) yum API does not raise an exception. Instead, it sets output_state of corresponding transaction member to TS_FAILED and continues. With this commit we ensure that such cases are handled correctly. In particular, when it happens: - action_type in output is set for 'error' for such packages; - yyoom prints a message to stderr and exits with non-zero exit status. Co-authored-by: Joshua Harlow<harlowja@yahoo-inc.com> Change-Id: Idc3823a4dfa3641122b7037fa3c6ba23b869d72f
This commit is contained in:
11
tools/yyoom
11
tools/yyoom
@@ -72,6 +72,8 @@ def _action_type_from_code(action):
|
||||
return 'install'
|
||||
elif action in yum.constants.TS_REMOVE_STATES:
|
||||
return 'erase'
|
||||
elif action == yum.constants.TS_FAILED:
|
||||
return 'error'
|
||||
else:
|
||||
return 'other'
|
||||
|
||||
@@ -299,19 +301,28 @@ def _transaction(base, callback):
|
||||
try:
|
||||
base.doLock()
|
||||
yield
|
||||
|
||||
code = _run_yum_api('building transaction',
|
||||
base.buildTransaction, ok_codes=(0, 2))
|
||||
|
||||
failed = []
|
||||
if code == 0:
|
||||
LOG.debug('Nothing to do')
|
||||
elif code == 2:
|
||||
base.processTransaction(rpmTestDisplay=callback,
|
||||
rpmDisplay=callback)
|
||||
failed = [txmbr for txmbr in base.tsInfo
|
||||
if txmbr.output_state == yum.constants.TS_FAILED]
|
||||
else:
|
||||
raise RuntimeError("Transaction failed: %s" % code)
|
||||
|
||||
post_cb = getattr(callback, 'yyoom_post_transaction', None)
|
||||
if post_cb:
|
||||
post_cb(base, code)
|
||||
if failed:
|
||||
raise RuntimeError("Operation failed for %s" %
|
||||
', '.join(txmbr.name for txmbr in failed))
|
||||
|
||||
finally:
|
||||
del base.tsInfo
|
||||
del base.ts
|
||||
|
||||
Reference in New Issue
Block a user