Add sandbox write access to PORTAGE_PYM_PATH before importing portage in
authorZac Medico <zmedico@gentoo.org>
Wed, 23 Jul 2008 12:33:28 +0000 (12:33 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 23 Jul 2008 12:33:28 +0000 (12:33 -0000)
order to avoid sandbox violations after python upgrade.

svn path=/main/trunk/; revision=11175

bin/portageq

index ce631807705ef92dbd338b484b9e7d44eb139ab9..117549fcbe8b348621461578237dbc3d7a0bed1b 100755 (executable)
@@ -476,13 +476,22 @@ def main():
                        sys.exit(os.EX_USAGE)
                os.environ["ROOT"] = sys.argv[2]
 
+       # Avoid sandbox violations after python upgrade.
+       from os import path as osp
+       pym_path = osp.join(osp.dirname(
+               osp.dirname(osp.realpath(__file__))), "pym")
+       if os.environ.get("SANDBOX_ON") == "1":
+               sandbox_write = os.environ.get("SANDBOX_WRITE", "").split(":")
+               if pym_path not in sandbox_write:
+                       sandbox_write.append(pym_path)
+                       os.environ["SANDBOX_WRITE"] = \
+                               ":".join(filter(None, sandbox_write))
+
        global portage
        try:
                import portage
        except ImportError:
-               from os import path as osp
-               sys.path.insert(0, osp.join(osp.dirname(
-                       osp.dirname(osp.realpath(__file__))), "pym"))
+               sys.path.insert(0, pym_path)
                import portage
 
        try: