Make binarytree.prevent_collision() adjust permissions on directories
authorZac Medico <zmedico@gentoo.org>
Sat, 12 Apr 2008 09:16:17 +0000 (09:16 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 12 Apr 2008 09:16:17 +0000 (09:16 -0000)
and raise a PermissionDenied error if the required directories is
not writable.

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

pym/portage/dbapi/bintree.py

index 785b8c730f3f441fc2568bc6ed435b8da1be8264..fe8b372c2120bfe892b899b3ec8f3bfc6347421e 100644 (file)
@@ -4,7 +4,8 @@
 
 from portage.dep import isvalidatom, isjustname, dep_getkey, match_from_list
 from portage.dbapi.virtual import fakedbapi
-from portage.exception import InvalidPackageName, InvalidAtom, PortageException
+from portage.exception import InvalidPackageName, InvalidAtom, \
+       PermissionDenied, PortageException
 from portage.output import green
 from portage.util import ensure_dirs, normalize_path, writemsg, writemsg_stdout
 from portage.versions import best, catpkgsplit, catsplit
@@ -284,6 +285,15 @@ class binarytree(object):
                ${PKGDIR}/${CATEGORY}/${PF}.tbz2 so that both can coexist."""
                if not self._all_directory:
                        return
+
+               # Copy group permissions for new directories that
+               # may have been created.
+               for path in ("All", catsplit(cpv)[0]):
+                       path = os.path.join(self.pkgdir, path)
+                       self._ensure_dir(path)
+                       if not os.access(path, os.W_OK):
+                               raise PermissionDenied("access('%s', W_OK)" % path)
+
                full_path = self.getname(cpv)
                if "All" == full_path.split(os.path.sep)[-2]:
                        return