summaryrefslogtreecommitdiffstats
path: root/py
diff options
context:
space:
mode:
authorMichael E Brown <michael_e_brown@dell.com>2007-12-11 18:09:25 -0600
committerMichael E Brown <michael_e_brown@dell.com>2007-12-11 18:09:25 -0600
commit7cfb96aebd24dee149e2573eae2c169fe0fc4c27 (patch)
treeb682716ef86be7753724df47a8b780c3ce29d58c /py
parentfeaaffe73baa6808eb229041b86cdea6f5c1c56f (diff)
parentbd5d08919539538c0bfead439fd8e3a33f3b01b3 (diff)
downloadmock-7cfb96aebd24dee149e2573eae2c169fe0fc4c27.tar.gz
mock-7cfb96aebd24dee149e2573eae2c169fe0fc4c27.tar.xz
mock-7cfb96aebd24dee149e2573eae2c169fe0fc4c27.zip
Merge branch 'master' of /var/ftp/pub/Applications/git/mock
* 'master' of /var/ftp/pub/Applications/git/mock: - make "mock --chroot" non-interactive - set the exit code of "mock --chroot" to the exit code of the process run in the chroot - log the output of the process to root.log
Diffstat (limited to 'py')
-rwxr-xr-xpy/mock.py13
-rw-r--r--py/mock/exception.py5
-rw-r--r--py/mock/util.py6
3 files changed, 19 insertions, 5 deletions
diff --git a/py/mock.py b/py/mock.py
index 90cd1d5..c4b9a68 100755
--- a/py/mock.py
+++ b/py/mock.py
@@ -467,7 +467,7 @@ def main(ret):
elif options.mode == 'clean':
chroot.clean()
- elif options.mode in ('chroot', 'shell'):
+ elif options.mode == 'shell':
chroot.tryLockBuildRoot()
try:
chroot._mountall()
@@ -480,6 +480,17 @@ def main(ret):
finally:
chroot._umountall()
+ elif options.mode == 'chroot':
+ if len(args) == 0:
+ log.critical("You must specify a command to run")
+ sys.exit(50)
+ else:
+ log.info("Running in chroot: %s" % args)
+
+ chroot.tryLockBuildRoot()
+ chroot._resetLogging()
+ chroot.doChroot(args)
+
elif options.mode == 'installdeps':
if len(args) == 0:
log.critical("You must specify an SRPM file.")
diff --git a/py/mock/exception.py b/py/mock/exception.py
index d93fcf3..b6d6282 100644
--- a/py/mock/exception.py
+++ b/py/mock/exception.py
@@ -8,16 +8,19 @@
# python library imports
#from exceptions import Exception
+import os
# our imports
# classes
class Error(Exception):
"base class for our errors."
- def __init__(self, msg):
+ def __init__(self, msg, status=None):
Exception.__init__(self)
self.msg = msg
self.resultcode = 1
+ if status is not None and os.WIFEXITED(status):
+ self.resultcode = os.WEXITSTATUS(status)
def __str__(self):
return self.msg
diff --git a/py/mock/util.py b/py/mock/util.py
index c11c6d4..cbb3653 100644
--- a/py/mock/util.py
+++ b/py/mock/util.py
@@ -279,11 +279,11 @@ def do(command, chrootPath=None, timeout=0, raiseExc=True, returnOutput=0, uidMa
signal.signal(signal.SIGALRM, oldhandler)
# mask and return just return value, plus child output
- if raiseExc and os.WEXITSTATUS(ret):
+ if raiseExc and ((os.WIFEXITED(ret) and os.WEXITSTATUS(ret)) or os.WIFSIGNALED(ret)):
if returnOutput:
- raise mock.exception.Error, "Command failed: \n # %s\n%s" % (command, output)
+ raise mock.exception.Error, ("Command failed: \n # %s\n%s" % (command, output), ret)
else:
- raise mock.exception.Error, "Command failed. See logs for output.\n # %s" % command
+ raise mock.exception.Error, ("Command failed. See logs for output.\n # %s" % (command,), ret)
return output