]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
install: be more careful about package removal
authorSage Weil <sage@inktank.com>
Thu, 21 Feb 2013 05:46:37 +0000 (21:46 -0800)
committerSage Weil <sage@inktank.com>
Thu, 21 Feb 2013 05:46:37 +0000 (21:46 -0800)
- 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 <sage@inktank.com>
teuthology/task/install.py

index e9021d369b41a9fb0636fb3158fdb0080da97c07..fb82a824a1e9b3678021296df9ed2871b353720e 100644 (file)
@@ -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',