From 710bb557cc124fc88aca249b9e938b432a958c01 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Wed, 20 Dec 2006 02:17:02 +0000 Subject: For bug #158608, don't attempt to use distlocks when it's detected that the filesystem is readonly (unless "skiprocheck" is in FEATURES for some strange reason). svn path=/main/trunk/; revision=5330 --- pym/portage.py | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'pym/portage.py') diff --git a/pym/portage.py b/pym/portage.py index d0f2bbe5f..c41832557 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -2169,11 +2169,21 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", can_fetch=True + if listonly: + can_fetch = False + for var_name in ("FETCHCOMMAND", "RESUMECOMMAND"): if not mysettings.get(var_name, None): can_fetch = False - if not listonly: + if can_fetch and \ + not fetch_to_ro and \ + not os.access(mysettings["DISTDIR"], os.W_OK): + writemsg("!!! No write access to '%s'\n" % mysettings["DISTDIR"], + noiselevel=-1) + can_fetch = False + + if can_fetch: dirmode = 02070 filemode = 060 modemask = 02 @@ -2200,12 +2210,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", writemsg("!!! Directory Not Found: DISTDIR='%s'\n" % mysettings["DISTDIR"], noiselevel=-1) writemsg("!!! Fetching will fail!\n", noiselevel=-1) - if not os.access(mysettings["DISTDIR"]+"/",os.W_OK): - if not fetch_to_ro: - print "!!! No write access to %s" % mysettings["DISTDIR"]+"/" - can_fetch=False - else: - if use_locks and locks_in_subdir: + if can_fetch and use_locks and locks_in_subdir: distlocks_subdir = os.path.join(mysettings["DISTDIR"], locks_in_subdir) if not os.access(distlocks_subdir, os.W_OK): writemsg("!!! No write access to write to %s. Aborting.\n" % distlocks_subdir, @@ -2328,16 +2333,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", else: continue - # check if we can actually write to the directory/existing file. - if fetched!=2 and os.path.exists(mysettings["DISTDIR"]+"/"+myfile) != \ - os.access(mysettings["DISTDIR"]+"/"+myfile, os.W_OK) and not fetch_to_ro: - writemsg( red("***") + \ - " Lack write access to %s, failing fetch\n" % \ - os.path.join(mysettings["DISTDIR"], myfile), - noiselevel=-1) - fetched=0 - break - elif fetched!=2: + if fetched != 2: #we either need to resume or start the download #you can't use "continue" when you're inside a "try" block if fetched==1: -- cgit v1.2.3-1-g7c22