summaryrefslogtreecommitdiffstats
path: root/py
diff options
context:
space:
mode:
authorMichael E Brown <mebrown@michaels-house.net>2008-01-29 23:48:50 -0600
committerMichael E Brown <mebrown@michaels-house.net>2008-01-29 23:48:50 -0600
commit5ff9b7b2da07756df55e56a0ef58e21b66d6ee2b (patch)
tree52ee54c1df0ab4420690ffad02b482fc4bd09e6c /py
parentf1f47ae2bb7770c6ed072f779763c275a18f9828 (diff)
parent56957fc4b42272bf900daf00649e1acbf94378f4 (diff)
downloadmock-5ff9b7b2da07756df55e56a0ef58e21b66d6ee2b.tar.gz
mock-5ff9b7b2da07756df55e56a0ef58e21b66d6ee2b.tar.xz
mock-5ff9b7b2da07756df55e56a0ef58e21b66d6ee2b.zip
Merge ssh://mock/var/ftp/pub/Applications/git/mock
* ssh://mock/var/ftp/pub/Applications/git/mock: updates to mock.util.do(): 1) nonblocking read, 2) dont leave zombies (waitpid). we now run /etc/profile, so no need to manually do ccache stuff. use makeChrootPath() functionality rather than obscure string interpolation
Diffstat (limited to 'py')
-rw-r--r--py/mock/backend.py2
-rw-r--r--py/mock/plugins/ccache.py17
-rw-r--r--py/mock/util.py44
3 files changed, 34 insertions, 29 deletions
diff --git a/py/mock/backend.py b/py/mock/backend.py
index 43affce..7d11532 100644
--- a/py/mock/backend.py
+++ b/py/mock/backend.py
@@ -386,7 +386,7 @@ class Root(object):
)
# rebuild srpm/rpm from SPEC file
- specs = glob.glob("%s/%s/SPECS/*.spec" % (self.makeChrootPath(), self.builddir))
+ specs = glob.glob(self.makeChrootPath(self.builddir, "SPECS", "*.spec"))
if len(specs) < 1:
raise mock.exception.PkgError, "No Spec file found in srpm: %s" % srpmBasename
diff --git a/py/mock/plugins/ccache.py b/py/mock/plugins/ccache.py
index 52e55fd..04768f2 100644
--- a/py/mock/plugins/ccache.py
+++ b/py/mock/plugins/ccache.py
@@ -48,23 +48,8 @@ class CCache(object):
# cache.
decorate(traceLog())
def _ccachePreInitHook(self):
+ getLog().info("enabled ccache")
mock.util.mkdirIfAbsent(self.rootObj.makeChrootPath('/tmp/ccache'))
mock.util.mkdirIfAbsent(self.ccachePath)
- os.environ['PATH'] = "/tmp/ccache:%s" % (os.environ['PATH'])
os.environ['CCACHE_DIR'] = "/tmp/ccache"
os.environ['CCACHE_UMASK'] = "002"
- for i in ("cc", "gcc", "gcc296", "gcc32", "gcc33", "gcc34",
- "g++", "c++", "c++32", "c++33", "c++34", "g++296", "g++32", "g++33", "g++34",
- "g++-libstdc++-so_7",):
- forceLink("/usr/bin/ccache", os.path.join(self.ccachePath, "%s" % i))
- forceLink("/usr/bin/ccache", os.path.join(self.ccachePath, "x86_64-redhat-linux-%s" % i))
- forceLink("/usr/bin/ccache", os.path.join(self.ccachePath, "i386-redhat-linux-%s" % i))
-
-decorate(traceLog())
-def forceLink( existing, linkname ):
- try:
- os.unlink(linkname)
- except OSError:
- pass
-
- os.symlink(existing, linkname)
diff --git a/py/mock/util.py b/py/mock/util.py
index 65cc995..a0a6b65 100644
--- a/py/mock/util.py
+++ b/py/mock/util.py
@@ -224,6 +224,13 @@ def condPersonality(per=None):
def logOutput(fds, logger, returnOutput=1, start=0, timeout=0):
output=""
done = 0
+
+ # set all fds to nonblocking
+ for fd in fds:
+ flags = fcntl.fcntl(fd, fcntl.F_GETFL)
+ if not fd.closed:
+ fcntl.fcntl(fd, fcntl.F_SETFL, flags| os.O_NONBLOCK)
+
while not done:
if (time.time() - start)>timeout and timeout!=0:
done = 1
@@ -231,15 +238,19 @@ def logOutput(fds, logger, returnOutput=1, start=0, timeout=0):
i_rdy,o_rdy,e_rdy = select.select(fds,[],[],1)
for s in i_rdy:
- # this isnt perfect as a whole line of input may not be
- # ready, but should be "good enough" for now
- line = s.readline()
- if line == "":
+ # slurp as much input as is ready
+ input = s.read()
+ if input == "":
done = 1
break
- logger.debug(chomp(line))
+ if logger is not None:
+ for line in input.split("\n"):
+ if line == '': continue
+ logger.debug(chomp(line))
+ for h in logger.handlers:
+ h.flush()
if returnOutput:
- output += line
+ output += input
return output
# logger =
@@ -275,17 +286,26 @@ def do(command, shell=False, chrootPath=None, cwd=None, timeout=0, raiseExc=True
except:
# kill children if they arent done
if child is not None and child.returncode is None:
- os.kill(-child.pid, 15)
- os.kill(-child.pid, 9)
+ os.killpg(child.pid, 9)
+ try:
+ if child is not None:
+ os.waitpid(child.pid, 0)
+ except:
+ pass
raise
# wait until child is done, kill it if it passes timeout
+ niceExit=1
while child.poll() is None:
if (time.time() - start)>timeout and timeout!=0:
- os.kill(-child.pid, 15)
- os.kill(-child.pid, 9)
- raise commandTimeoutExpired, ("Timeout(%s) expired for command:\n # %s\n%s" % (command, output))
-
+ niceExit=0
+ os.killpg(child.pid, 15)
+ if (time.time() - start)>(timeout+1) and timeout!=0:
+ niceExit=0
+ os.killpg(child.pid, 9)
+
+ if not niceExit:
+ raise commandTimeoutExpired, ("Timeout(%s) expired for command:\n # %s\n%s" % (timeout, cmd, output))
if raiseExc and child.returncode:
if returnOutput: