summaryrefslogtreecommitdiffstats
path: root/py/mock.py
diff options
context:
space:
mode:
authorMichael E Brown <michael_e_brown@dell.com>2008-01-20 13:30:41 -0600
committerMichael E Brown <michael_e_brown@dell.com>2008-01-20 13:30:41 -0600
commit5aaa59800cae18440c1ba6caca5800e45b3ff5fa (patch)
tree5ff0a59f1718f0afca5bcaa1f88bb9dd383e001c /py/mock.py
parent7589279b856ae73eb26fc728a38a58edbe06d94c (diff)
downloadmock-5aaa59800cae18440c1ba6caca5800e45b3ff5fa.tar.gz
mock-5aaa59800cae18440c1ba6caca5800e45b3ff5fa.tar.xz
mock-5aaa59800cae18440c1ba6caca5800e45b3ff5fa.zip
convert mock.util.do() to use subprocess.Popen() rather than raw fork/exec.\nThis cleans up the code considerably. Also, start reducing the places where we use a shell in the subcommand.
Diffstat (limited to 'py/mock.py')
-rwxr-xr-xpy/mock.py16
1 files changed, 6 insertions, 10 deletions
diff --git a/py/mock.py b/py/mock.py
index f9045ff..4a589bc 100755
--- a/py/mock.py
+++ b/py/mock.py
@@ -496,7 +496,8 @@ def main(ret):
log.info("Namespace unshare failed.")
# set personality (ie. setarch)
- mock.util.condPersonality(config_opts['target_arch'])
+ if config_opts['internal_setarch']:
+ mock.util.condPersonality(config_opts['target_arch'])
if options.mode == 'init':
if config_opts['clean']:
@@ -510,8 +511,6 @@ def main(ret):
chroot.tryLockBuildRoot()
try:
chroot._mountall()
- if config_opts['internal_setarch']:
- mock.util.condPersonality(config_opts['target_arch'])
cmd = ' '.join(args)
status = os.system("PS1='mock-chroot> ' /usr/sbin/chroot %s %s" % (chroot.makeChrootPath(), cmd))
ret['exitStatus'] = os.WEXITSTATUS(status)
@@ -520,18 +519,20 @@ def main(ret):
chroot._umountall()
elif options.mode == 'chroot':
+ shell=False
if len(args) == 0:
log.critical("You must specify a command to run")
sys.exit(50)
elif len(args) == 1:
args = args[0]
+ shell=True
log.info("Running in chroot: %s" % args)
chroot.tryLockBuildRoot()
chroot._resetLogging()
try:
chroot._mountall()
- chroot.doChroot(args)
+ chroot.doChroot(args, shell=shell)
finally:
chroot._umountall()
@@ -626,12 +627,7 @@ if __name__ == '__main__':
exitStatus = 7
log.error("Exiting on user interrupt, <CTRL>-C")
- except (mock.exception.BadCmdline), exc:
- exitStatus = exc.resultcode
- log.error(str(exc))
- killOrphans = 0
-
- except (mock.exception.BuildRootLocked), exc:
+ except (mock.exception.BadCmdline, mock.exception.BuildRootLocked), exc:
exitStatus = exc.resultcode
log.error(str(exc))
killOrphans = 0