]> git.donarmstrong.com Git - dsa-puppet.git/blobdiff - modules/porterbox/files/dd-schroot-cmd
This is redundant
[dsa-puppet.git] / modules / porterbox / files / dd-schroot-cmd
index e82a71c889473dce58a00ef405e996575809de55..e2d2111efe0aaad20297200856966787c8846e39 100755 (executable)
@@ -106,20 +106,26 @@ class WrappedRunner():
             cmdstr = ' '.join(pipes.quote(s) for s in cmd)
             cmd = ['unshare', '--uts', '--ipc', '--net', '--']
             cmd += ['sh', '-c', 'ip addr add 127.0.0.1/8 dev lo && ip link set dev lo up && %s'%(cmdstr)]
-        pid, fd = pty.fork()
+        (r, w) = os.pipe()
+        pid, ptyfd = pty.fork()
         if pid == pty.CHILD:
+            os.close(r)
             fd = os.open("/dev/null", os.O_RDWR)
             os.dup2(fd, 0) # stdin
+            os.dup2(w, 1) # stdout
+            os.dup2(w, 2) # stderr
             os.execlp(cmd[0], *cmd)
+        os.close(w)
         try:
             while 1:
-                b = os.read(fd, 1)
+                b = os.read(r, 1)
                 if b == "": break
                 sys.stdout.write(b)
         except OSError, e:
             if e[0] == EIO: pass
             else: raise
-        os.close(fd)
+        os.close(r)
+        os.close(ptyfd) # we don't care about that one
         p,v = os.waitpid(pid, 0)
         s,r = WrappedRunner.get_ret(v)
         return s,r
@@ -148,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,))
 
@@ -168,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 = ['build-dep'] + (['--arch-only'] if archonly else []) + ['--']
+        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: