Make doebuild() bail out early with a PermissionDenied error if there
authorZac Medico <zmedico@gentoo.org>
Fri, 11 Apr 2008 19:48:06 +0000 (19:48 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 11 Apr 2008 19:48:06 +0000 (19:48 -0000)
is no write access to $PKGDIR.

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

pym/portage/__init__.py

index e92669c745cb66bf9a9f1a57ab62a0d9d22c43e7..0a240002b6e2d85af99c344387191cdd453d955a 100644 (file)
@@ -5006,6 +5006,16 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
                                actionmap[x]["dep"] = ' '.join(actionmap_deps[x])
 
                if mydo in actionmap:
+                       if mydo == "package":
+                               # Make sure the package directory exists before executing
+                               # this phase. This can raise PermissionDenied if
+                               # the current user doesn't have write access to $PKGDIR.
+                               parent_dir = os.path.join(mysettings["PKGDIR"],
+                                       mysettings["CATEGORY"])
+                               portage.util.ensure_dirs(parent_dir)
+                               if not os.access(parent_dir, os.W_OK):
+                                       raise portage.exception.PermissionDenied(
+                                               "access('%s', os.W_OK)" % parent_dir)
                        retval = spawnebuild(mydo,
                                actionmap, mysettings, debug, logfile=logfile)
                elif mydo=="qmerge":