From 94d02f3cf940d0e9e1f23ec0e8845f33105fc8fc Mon Sep 17 00:00:00 2001 From: Michael E Brown Date: Fri, 7 Mar 2008 21:15:44 -0600 Subject: handle idiots with grace and poise. --- py/mock.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'py') diff --git a/py/mock.py b/py/mock.py index 9935b30..9efd4bf 100755 --- a/py/mock.py +++ b/py/mock.py @@ -637,6 +637,17 @@ if __name__ == '__main__': except (SystemExit,): raise + except (OSError,), e: + if e.errno == 1: + print + log.error("%s" % str(e)) + print + log.error("The most common cause for this error is trying to run /usr/sbin/mock as an unprivileged user.") + log.error("Check your path to make sure that /usr/bin/ is listed before /usr/sbin, or manually run /usr/bin/mock to see if that fixes this problem.") + print + else: + raise + except (KeyboardInterrupt,): exitStatus = 7 log.error("Exiting on user interrupt, -C") -- cgit From 97d9d11d4c68648efe347049afe68e538d250f56 Mon Sep 17 00:00:00 2001 From: Michael E Brown Date: Sun, 9 Mar 2008 12:09:00 -0500 Subject: add support for shm --- py/mock/backend.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'py') diff --git a/py/mock/backend.py b/py/mock/backend.py index 6726deb..3cc0a9f 100644 --- a/py/mock/backend.py +++ b/py/mock/backend.py @@ -269,6 +269,7 @@ class Root(object): # files in /dev mock.util.rmtree(self.makeChrootPath("dev")) mock.util.mkdirIfAbsent(self.makeChrootPath("dev", "pts")) + mock.util.mkdirIfAbsent(self.makeChrootPath("dev", "shm")) prevMask = os.umask(0000) devFiles = ( (stat.S_IFCHR | 0666, os.makedev(1, 3), "dev/null"), @@ -295,13 +296,17 @@ class Root(object): os.umask(prevMask) # mount/umount - umntCmd = 'umount -n %s' % self.makeChrootPath('/dev/pts') - if umntCmd not in self.umountCmds: - self.umountCmds.append(umntCmd) - - mntCmd = 'mount -n -t devpts mock_chroot_devpts %s' % self.makeChrootPath('/dev/pts') - if mntCmd not in self.mountCmds: - self.mountCmds.append(mntCmd) + for devUnmtCmd in ( + 'umount -n %s' % self.makeChrootPath('/dev/pts'), + 'umount -n %s' % self.makeChrootPath('/dev/shm') ): + if devUnmtCmd not in self.umountCmds: + self.umountCmds.append(devUnmtCmd) + + for devMntCmd in ( + 'mount -n -t devpts mock_chroot_devpts %s' % self.makeChrootPath('/dev/pts'), + 'mount -n -t tmpfs mock_chroot_shmfs %s' % self.makeChrootPath('/dev/shm') ): + if devMntCmd not in self.mountCmds: + self.mountCmds.append(devMntCmd) # bad hack # comment out decorator here so we dont get double exceptions in the root log -- cgit From b9313a12c37362126128284aa31f27ee47b2e80c Mon Sep 17 00:00:00 2001 From: Michael E Brown Date: Mon, 31 Mar 2008 17:34:52 -0500 Subject: fix typo which causes exception in command-timeout code (which was trying to raise exception) --- py/mock/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'py') diff --git a/py/mock/util.py b/py/mock/util.py index 9f0eb3a..7f46b94 100644 --- a/py/mock/util.py +++ b/py/mock/util.py @@ -306,7 +306,7 @@ def do(command, shell=False, chrootPath=None, cwd=None, timeout=0, raiseExc=True os.killpg(child.pid, 9) if not niceExit: - raise commandTimeoutExpired, ("Timeout(%s) expired for command:\n # %s\n%s" % (timeout, cmd, output)) + raise commandTimeoutExpired, ("Timeout(%s) expired for command:\n # %s\n%s" % (timeout, command, output)) logger.debug("Child returncode was: %s" % str(child.returncode)) if raiseExc and child.returncode: -- cgit