From 00986ce08071c59f978b4d0e8d62c6c31b25acce Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 20 Feb 2013 21:46:37 -0800 Subject: [PATCH] install: be more careful about package removal - call apt separately for each package; it will error out annoyingly if there is one in the list not in the APT sources. - use dpkg with appropriate force to clean up broken half-installs. Signed-off-by: Sage Weil --- teuthology/task/install.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/teuthology/task/install.py b/teuthology/task/install.py index e9021d369b41..fb82a824a1e9 100644 --- a/teuthology/task/install.py +++ b/teuthology/task/install.py @@ -102,15 +102,28 @@ def install_debs(ctx, debs, branch, flavor): ctx, remote, debs, branch, flavor) def _remove_deb(remote, debs): - args=[ - 'sudo', 'apt-get', '-y', '--force-yes', 'purge', - ] - args.extend(debs) - args.extend([ - run.Raw('||'), - 'true' + # first ask nicely + for d in debs: + remote.run( + args=[ + 'sudo', 'apt-get', '-y', '--force-yes', 'purge', d, + run.Raw('||'), + 'true', + ]) + # mop up anything that is broken + remote.run( + args=[ + 'dpkg', '-l', + run.Raw('|'), + 'grep', '^.HR', + run.Raw('|'), + 'awk', '{print $2}', + run.Raw('|'), + 'sudo', + 'xargs', '--no-run-if-empty', + 'dpkg', '-P', '--force-remove-reinstreq', ]) - remote.run(args=args) + # then let apt clean up remote.run( args=[ 'sudo', 'apt-get', '-y', '--force-yes', -- 2.47.3