Bug #218559 - Make portdbapi automatically add sandbox write access to
authorZac Medico <zmedico@gentoo.org>
Sun, 20 Apr 2008 20:50:48 +0000 (20:50 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 20 Apr 2008 20:50:48 +0000 (20:50 -0000)
self.depcachedir when appropriate. This makes the portageq blanket sandbox
exemption unnecessary.

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

bin/portageq
pym/portage/dbapi/porttree.py

index eb0d0ff69139cfcab168dcad0bf4768521587013..c3fe8b37dba5bd55e61d351d5bda89953fcf8367 100755 (executable)
@@ -21,10 +21,6 @@ except KeyboardInterrupt:
 
 import os
 
-# This allows portageq to be exempt from sandbox,
-# for things like updating metadata cache.
-os.environ["SANDBOX_ON"] = "0"
-
 import types
 
 #-----------------------------------------------------------------------------
index 845fdbae5be843a2dba7333d275e353a4615f87d..3c0bc01b5b4eb728b0b1a06c314a0025b47dfe69 100644 (file)
@@ -62,7 +62,16 @@ class portdbapi(dbapi):
                #self.root=settings["PORTDIR"]
                self.porttree_root = os.path.realpath(porttree_root)
 
-               self.depcachedir = self.mysettings.depcachedir[:]
+               self.depcachedir = os.path.realpath(self.mysettings.depcachedir)
+
+               if os.environ.get("SANDBOX_ON") == "1":
+                       # Make api consumers exempt from sandbox violations
+                       # when doing metadata cache updates.
+                       sandbox_write = os.environ.get("SANDBOX_WRITE", "").split(":")
+                       if self.depcachedir not in sandbox_write:
+                               sandbox_write.append(self.depcachedir)
+                               os.environ["SANDBOX_WRITE"] = \
+                                       ":".join(filter(None, sandbox_write))
 
                self.eclassdb = eclass_cache.cache(self.porttree_root,
                        overlays=self.mysettings["PORTDIR_OVERLAY"].split())