porterbox: allow uninstallation
[mirror/dsa-puppet.git] / modules / porterbox / files / dd-schroot-cmd
index 76f3c9d..6506b6e 100755 (executable)
@@ -80,7 +80,7 @@ def ensure_ok(session):
         die("Session owner mismatch.")
 
 def os_supports_unshare():
-    if platform.uname()[0] == 'GNU/kFreeBSD':
+    if platform.uname()[0] in ('GNU/kFreeBSD', 'GNU'):
         return False
     return True
 
@@ -88,7 +88,7 @@ class WrappedRunner():
     def __init__(self, session, args, unshare=True):
         self.unshare = unshare
         if not os_supports_unshare(): self.unshare = False
-        s,r = self.run('schroot', '-c', session, '--run-session', '--', 'env', 'DEBIAN_FRONTEND=noninteractive', *args)
+        s,r = self.run('schroot', '-c', session, '--directory=/', '--run-session', '--', 'env', 'DEBIAN_FRONTEND=noninteractive', *args)
         if s != 0:
             die("Command %s exited due to signal %d."%(' '.join(args), s))
         if r != 0:
@@ -154,7 +154,12 @@ class AptSchroot:
         elif op == "install":
             self.apt_install(args)
         elif op == "build-dep":
-            self.apt_build_dep(args)
+            try:
+                args.remove("--arch-only")
+                archonly = True
+            except ValueError:
+                archonly = False
+            self.apt_build_dep(args, archonly)
         else:
             die("Invalid operation %s"%(op,))
 
@@ -174,8 +179,9 @@ class AptSchroot:
     def apt_install(self, packages):
         self.apt_simulate_and_ask(['install', '--'] + packages)
 
-    def apt_build_dep(self, packages):
-        self.apt_simulate_and_ask(['build-dep', '--'] + packages)
+    def apt_build_dep(self, packages, archonly=False):
+        cmd = (['--arch-only'] if archonly else []) + ['build-dep', '--']
+        self.apt_simulate_and_ask(cmd + packages)
 
     def apt_simulate_and_ask(self, cmd, split_download=True, run_clean=True):
         if not self.assume_yes: