summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/portage.py52
-rw-r--r--pym/portage_exception.py3
-rw-r--r--pym/portage_util.py10
3 files changed, 36 insertions, 29 deletions
diff --git a/pym/portage.py b/pym/portage.py
index 0c348bd48..3b69bebc6 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -1853,6 +1853,33 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
del missingSourceHost
can_fetch=True
+
+ if not listonly:
+ dirmode = 02070
+ filemode = 060
+ modemask = 02
+ distdir_dirs = ["", "cvs-src"]
+ if "distlocks" in features:
+ distdir_dirs.append(".locks")
+ try:
+
+ for x in distdir_dirs:
+ mydir = os.path.join(mysettings["DISTDIR"], x)
+ if portage_util.ensure_dirs(mydir, gid=portage_gid, mode=dirmode, mask=modemask):
+ writemsg("Adjusting permissions recursively: '%s'\n" % mydir)
+ def onerror(e):
+ raise # bail out on the first error that occurs during recursion
+ if not apply_recursive_permissions(mydir,
+ gid=portage_gid, dirmode=dirmode, dirmask=modemask,
+ filemode=filemode, filemask=modemask, onerror=onerror):
+ raise portage_exception.OperationNotPermitted(
+ "Failed to apply recursive permissions for the portage group.")
+ except portage_exception.PortageException, e:
+ if not os.path.dir(mysettings["DISTDIR"]):
+ writemsg("!!! %s\n" % str(e))
+ writemsg("!!! Directory Not Found: DISTDIR='%s'\n" % mysettings["DISTDIR"])
+ writemsg("!!! Fetching will fail!\n")
+
if not os.access(mysettings["DISTDIR"]+"/",os.W_OK):
if not fetch_to_ro:
print "!!! No write access to %s" % mysettings["DISTDIR"]+"/"
@@ -2730,31 +2757,6 @@ def doebuild(myebuild,mydo,myroot,mysettings,debug=0,listonly=0,fetchonly=0,clea
fetchme=newuris[:]
checkme=alist[:]
- if not listonly:
- dirmode = 02070
- filemode = 060
- modemask = 02
- distdir_dirs = ["", "cvs-src"]
- if "distlocks" in features:
- distdir_dirs.append(".locks")
- try:
-
- for x in distdir_dirs:
- mydir = os.path.join(mysettings["DISTDIR"], x)
- if portage_util.ensure_dirs(mydir, gid=portage_gid, mode=dirmode, mask=modemask):
- writemsg("Adjusting permissions recursively: '%s'\n" % mydir)
- def onerror(e):
- raise # bail out on the first error that occurs during recursion
- if not apply_recursive_permissions(mydir,
- gid=portage_gid, dirmode=dirmode, dirmask=modemask,
- filemode=filemode, filemask=modemask, onerror=onerror):
- raise portage_exception.OperationNotPermitted(
- "Failed to apply recursive permissions for the portage group.")
- except portage_exception.PortageException, e:
- writemsg("!!! %s\n" % str(e))
- writemsg("!!! Problem adjusting permissions on DISTDIR='%s'\n" % mysettings["DISTDIR"])
- writemsg("!!! Fetching may fail!\n")
-
# Only try and fetch the files if we are going to need them ... otherwise,
# if user has FEATURES=noauto and they run `ebuild clean unpack compile install`,
# we will try and fetch 4 times :/
diff --git a/pym/portage_exception.py b/pym/portage_exception.py
index 0d0206df1..c00965d6e 100644
--- a/pym/portage_exception.py
+++ b/pym/portage_exception.py
@@ -49,6 +49,9 @@ class DirectoryNotFound(InvalidLocation):
class OperationNotPermitted(PortageException):
"""An operation was not permitted operating system"""
+class ReadOnlyFileSystem(PortageException):
+ """Read-only file system"""
+
class CommandNotFound(PortageException):
"""A required binary was not available or executable"""
diff --git a/pym/portage_util.py b/pym/portage_util.py
index ae7525186..5c128d59d 100644
--- a/pym/portage_util.py
+++ b/pym/portage_util.py
@@ -2,7 +2,7 @@
# Distributed under the terms of the GNU General Public License v2
# $Id: /var/cvsroot/gentoo-src/portage/pym/portage_util.py,v 1.11.2.6 2005/04/23 07:26:04 jstubbs Exp $
-from portage_exception import PortageException, FileNotFound, OperationNotPermitted
+from portage_exception import PortageException, FileNotFound, OperationNotPermitted, ReadOnlyFileSystem
import sys,string,shlex,os,errno
try:
@@ -512,12 +512,14 @@ def apply_permissions(filename, uid=-1, gid=-1, mode=-1, mask=-1,
os.chmod(filename, new_mode)
modified = True
except OSError, oe:
+ func_call = "chmod('%s', %s)" % (filename, oct(new_mode))
if oe.errno == errno.EPERM:
- raise OperationNotPermitted("chmod('%s', %s)" % (filename, oct(new_mode)))
+ raise OperationNotPermitted(func_call)
+ elif oe.errno == errno.EROFS:
+ raise ReadOnlyFileSystem(func_call)
elif oe.errno == errno.ENOENT:
raise FileNotFound(filename)
- else:
- raise
+ raise
return modified
def apply_stat_permissions(filename, newstat, **kwargs):