]> git.pld-linux.org Git - projects/pld-builder.new.git/blob - PLD_Builder/chroot.py
- rpm builder actually did something (immortal alien.spec) ;-)
[projects/pld-builder.new.git] / PLD_Builder / chroot.py
1 import os
2 import re
3 from config import config
4
5 def quote(cmd):
6   return re.sub("([\"\\\\$`])", r"\\\1", cmd)
7   
8 def command(cmd, user = "builder"):
9   return "sudo chroot %s su - %s -c \"export LC_ALL=C; %s\"" % (config.chroot, user, quote(cmd))
10   
11 def command_sh(cmd):
12   return "sudo chroot %s /bin/sh -c \"export LC_ALL=C; %s\"" % (config.chroot, quote(cmd))
13
14 def popen(cmd, user = "builder", mode = "r"):
15   f = os.popen(command(cmd, user), mode)
16   return f
17   
18 def run(cmd, user = "builder", logfile = None):
19   c = command(cmd, user)
20   if logfile != None:
21     c = "%s >> %s 2>&1" % (c, logfile)
22   f = os.popen(c)
23   for l in f.xreadlines():
24     pass
25   r = f.close()
26   if r == None:
27     return 0
28   else:
29     return r
This page took 0.071981 seconds and 4 git commands to generate.