From 096c3a9545c2f98167d38b89d1115d9ae1031c87 Mon Sep 17 00:00:00 2001 From: Michal Reznik Date: Fri, 25 Mar 2022 18:17:50 +0100 Subject: [PATCH 01/30] Add leapp pkgs rpm verification into the breadcrumbs --- commands/upgrade/breadcrumbs.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/commands/upgrade/breadcrumbs.py b/commands/upgrade/breadcrumbs.py index 9138965c..bfb91148 100644 --- a/commands/upgrade/breadcrumbs.py +++ b/commands/upgrade/breadcrumbs.py @@ -41,6 +41,7 @@ class _BreadCrumbs(object): self._crumbs = { 'activity': activity, 'packages': self._get_packages(), + 'leapp_file_changes': [], 'executed': ' '.join([v if ' ' not in v else '"{}"'.format(v) for v in sys.argv]), 'success': True, 'activity_started': datetime.datetime.utcnow().isoformat() + 'Z', @@ -86,6 +87,7 @@ class _BreadCrumbs(object): def save(self): self._crumbs['run_id'] = os.environ.get('LEAPP_EXECUTION_ID', 'N/A') + self._crumbs['leapp_file_changes'].extend(self._verify_leapp_pkgs()) messages = get_messages(('IPUConfig',), self._crumbs['run_id']) versions = json.loads((messages or [{}])[0].get('message', {}).get( 'data', '{}')).get('version', {'target': 'N/A', 'source': 'N/A'}) @@ -124,6 +126,16 @@ class _BreadCrumbs(object): for t in [line.strip().split(' ', 1) for line in res['stdout'].split('\n') if line.strip()]] return [] + def _verify_leapp_pkgs(self): + upg_path = os.environ.get('LEAPP_IPU_IN_PROGRESS').split('to') + cmd = ['/bin/bash', '-c', 'rpm -V leapp leapp-upgrade-el{}toel{}'.format(upg_path[0], upg_path[1])] + res = _call(cmd, lambda x, y: None, lambda x, y: None) + if res.get('exit_code', None) == 1: + if res.get('stdout', None): + return [{'result': t[0], 'file_name': t[1]} + for t in [line.strip().split(' ', 1) for line in res['stdout'].split('\n') if line.strip()]] + return [] + def produces_breadcrumbs(f): """ -- 2.40.1