summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-02-16 01:43:47 +0000
committerZac Medico <zmedico@gentoo.org>2007-02-16 01:43:47 +0000
commit0407594d2c5ffb99ba0e3cc4b5c1fb28b0c2c49f (patch)
tree3862ef0a4bff113c8f99113ac2f73c828986b138 /pym
parent7b5c05890e555647c739da37cacdcadbdd71412b (diff)
downloadportage-0407594d2c5ffb99ba0e3cc4b5c1fb28b0c2c49f.tar.gz
portage-0407594d2c5ffb99ba0e3cc4b5c1fb28b0c2c49f.tar.bz2
portage-0407594d2c5ffb99ba0e3cc4b5c1fb28b0c2c49f.zip
Detect potential issues with mtime granlarity in env_update() and sleep if necessary. Thanks to Brian Harring for reporting. (trunk r5960:5961)
svn path=/main/branches/2.1.2/; revision=5972
Diffstat (limited to 'pym')
-rw-r--r--pym/portage.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/pym/portage.py b/pym/portage.py
index 32907c32e..fe023f378 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -674,12 +674,18 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None):
newprelink.write("-b "+x+"\n")
newprelink.close()
+ # Portage stores mtimes with 1 second granularity but in >=python-2.5 finer
+ # granularity is possible. In order to avoid the potential ambiguity of
+ # mtimes that differ by less than 1 second, sleep here if any of the
+ # directories have been modified during the current second.
+ sleep_for_mtime_granularity = False
+ current_time = long(time.time())
mtime_changed = False
lib_dirs = set()
for lib_dir in portage_util.unique_array(specials["LDPATH"]+['usr/lib','usr/lib64','usr/lib32','lib','lib64','lib32']):
x = os.path.join(target_root, lib_dir.lstrip(os.sep))
try:
- newldpathtime = os.stat(x)[stat.ST_MTIME]
+ newldpathtime = long(os.stat(x).st_mtime)
lib_dirs.add(normalize_path(x))
except OSError, oe:
if oe.errno == errno.ENOENT:
@@ -690,6 +696,8 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None):
# ignore this path because it doesn't exist
continue
raise
+ if newldpathtime == current_time:
+ sleep_for_mtime_granularity = True
if x in prev_mtimes:
if prev_mtimes[x] == newldpathtime:
pass
@@ -761,6 +769,10 @@ def env_update(makelinks=1, target_root=None, prev_mtimes=None, contents=None):
outfile.write("setenv %s '%s'\n" % (x, env[x]))
outfile.close()
+ if sleep_for_mtime_granularity:
+ while current_time == long(time.time()):
+ sleep(1)
+
def ExtractKernelVersion(base_dir):
"""
Try to figure out what kernel version we are running