From 6b501880d0b2f83ce35a0583f51a2e9fb6244eae Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Tue, 13 Aug 2013 21:48:42 -0700 Subject: [PATCH] Adjust it so that updated packages are not removed. Anvil has its own dependencies which may be updated by later installs. Instead of removing those later updated packages we should just keep them around so that anvil can continue working. Fixes bug 1211647 Change-Id: Ie8523b80ca3f9114eb1bbad12be456d2e1bdc10c --- anvil/packaging/helpers/yum_helper.py | 3 +++ anvil/trace.py | 5 ++++ tools/yyoom | 33 +++++++++++++++++++-------- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/anvil/packaging/helpers/yum_helper.py b/anvil/packaging/helpers/yum_helper.py index abeb26af..1bab864e 100644 --- a/anvil/packaging/helpers/yum_helper.py +++ b/anvil/packaging/helpers/yum_helper.py @@ -73,11 +73,14 @@ class Helper(object): def _handle_transaction_data(tracewriter, data): if not data: return + failed_names = None try: if tracewriter: for action in data: if action['action_type'] == 'install': tracewriter.package_installed(action['name']) + elif action['action_type'] == 'upgrade': + tracewriter.package_upgraded(action['name']) failed_names = [action['name'] for action in data if action['action_type'] == 'error'] diff --git a/anvil/trace.py b/anvil/trace.py index e6c246e0..5a263d39 100644 --- a/anvil/trace.py +++ b/anvil/trace.py @@ -27,6 +27,7 @@ DOWNLOADED = "DOWNLOADED" FILE_TOUCHED = "FILE_TOUCHED" PIP_INSTALL = 'PIP_INSTALL' PKG_INSTALL = "PKG_INSTALL" +PKG_UPGRADE = "PKG_UPGRADE" SYMLINK_MAKE = "SYMLINK_MAKE" @@ -86,6 +87,10 @@ class TraceWriter(object): self._start() self.trace(PKG_INSTALL, pkg_name) + def package_upgraded(self, pkg_name): + self._start() + self.trace(PKG_UPGRADE, pkg_name) + def app_started(self, name, info_fn, how): self._start() data = dict() diff --git a/tools/yyoom b/tools/yyoom index 9aa50c81..13c1136f 100755 --- a/tools/yyoom +++ b/tools/yyoom @@ -36,6 +36,27 @@ from contextlib import contextmanager LOG = logging.getLogger('yyoom') OUTPUT = None +ACTION_TYPE_MAP = None + + +def _get_action_type_map(): + global ACTION_TYPE_MAP + if ACTION_TYPE_MAP is not None: + return ACTION_TYPE_MAP + # Yum has a mapping that sometimes really isn't that accurate enough + # for our needs, so make a mapping that will suit our needs instead. + ACTION_TYPE_MAP = { + yum.constants.TS_UPDATE: 'upgrade', + yum.constants.TS_OBSOLETING: 'upgrade', + yum.constants.TS_FAILED: 'error', + } + for i in yum.constants.TS_INSTALL_STATES: + if i not in ACTION_TYPE_MAP: + ACTION_TYPE_MAP[i] = 'install' + for i in yum.constants.TS_REMOVE_STATES: + if i not in ACTION_TYPE_MAP: + ACTION_TYPE_MAP[i] = 'erase' + return ACTION_TYPE_MAP def _setup_output(): @@ -68,14 +89,8 @@ def _write_output(data): def _action_type_from_code(action): - if action in yum.constants.TS_INSTALL_STATES: - return 'install' - elif action in yum.constants.TS_REMOVE_STATES: - return 'erase' - elif action == yum.constants.TS_FAILED: - return 'error' - else: - return 'other' + a_mapping = _get_action_type_map() + return a_mapping.get(action, 'other') def _package_info(pkg, **kwargs): @@ -119,7 +134,7 @@ class _RPMCallback(yum.rpmtrans.RPMBaseCallback): LOG.info("Performed %(action_type)s (code %(action)s) on %(package)s", dict(package=package, action=action, - aciton_type=_action_type_from_code(action))) + action_type=_action_type_from_code(action))) class _OutputtingRPMCallback(_RPMCallback):