PR 2115 - Fix checking when the path does not fully exist.

This commit is contained in:
Chris Johns 2013-04-15 11:15:01 +10:00
parent c95c2456a4
commit 255e032bab
2 changed files with 9 additions and 1 deletions

View File

@ -261,7 +261,7 @@ class command_line:
for m in um:
self.defaults.load(m)
# Check the prefix permission
if not self.no_install() and not path.iswritable(self.defaults['_prefix']):
if not self.no_install() and not path.ispathwritable(self.defaults['_prefix']):
raise error.general('prefix is not writable: %s' % (path.host(self.defaults['_prefix'])))
def command(self):

View File

@ -92,6 +92,14 @@ def isabspath(path):
def iswritable(path):
return os.access(host(path), os.W_OK)
def ispathwritable(path):
path = host(path)
while len(path) != 0:
if os.path.exists(path):
return iswritable(path)
path = os.path.dirname(path)
return False
def mkdir(path):
path = host(path)
if exists(path):