From: Sage Weil Date: Thu, 21 Feb 2013 05:46:37 +0000 (-0800) Subject: install: be more careful about package removal X-Git-Tag: 1.1.0~2303 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=00986ce08071c59f978b4d0e8d62c6c31b25acce;p=teuthology.git 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 --- diff --git a/teuthology/task/install.py b/teuthology/task/install.py index e9021d369..fb82a824a 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',