locations = mymirrors
file_uri_tuples = []
- if isinstance(myuris, dict):
+ # Check for 'items' attribute since OrderedDict is not a dict.
+ if hasattr(myuris, 'items'):
for myfile, uri_set in myuris.items():
for myuri in uri_set:
file_uri_tuples.append((myfile, myuri))
return rval
-_testing_eapis = frozenset(["4_pre1"])
+_testing_eapis = frozenset()
_deprecated_eapis = frozenset(["3_pre1", "2_pre3", "2_pre2", "2_pre1"])
def _eapi_is_deprecated(eapi):
print("!!!",e)
return None
+ # Always use stat_obj[stat.ST_MTIME] for the integral timestamp which
+ # is returned, since the stat_obj.st_mtime float attribute rounds *up*
+ # if the nanosecond part of the timestamp is 999999881 ns or greater.
try:
if hardlinked:
- newmtime = long(os.stat(dest).st_mtime)
+ newmtime = os.stat(dest)[stat.ST_MTIME]
else:
# Note: It is not possible to preserve nanosecond precision
# (supported in POSIX.1-2008 via utimensat) with the IEEE 754
# If rename succeeded then this is not necessary, since
# rename automatically preserves timestamps with complete
# precision.
- os.utime(dest, (sstat.st_atime, sstat.st_mtime))
- newmtime = long(sstat.st_mtime)
+ if sstat[stat.ST_MTIME] == long(sstat.st_mtime):
+ newmtime = sstat.st_mtime
+ else:
+ # Prevent mtime from rounding up to the next second.
+ int_mtime = sstat[stat.ST_MTIME]
+ mtime_str = "%i.9999999" % int_mtime
+ min_len = len(str(int_mtime)) + 2
+ while True:
+ mtime_str = mtime_str[:-1]
+ newmtime = float(mtime_str)
+ if int_mtime == long(newmtime):
+ break
+ elif len(mtime_str) <= min_len:
+ # This shouldn't happen, but let's make sure
+ # we can never have an infinite loop.
+ newmtime = int_mtime
+ break
+
+ os.utime(dest, (newmtime, newmtime))
+ newmtime = sstat[stat.ST_MTIME]
except OSError:
# The utime can fail here with EPERM even though the move succeeded.
# Instead of failing, use stat to return the mtime if possible.
try:
- newmtime = long(os.stat(dest).st_mtime)
+ newmtime = os.stat(dest)[stat.ST_MTIME]
except OSError as e:
writemsg(_("!!! Failed to stat in movefile()\n"), noiselevel=-1)
writemsg("!!! %s\n" % dest, noiselevel=-1)
if pkgindex is rmt_idx:
pkgindex.modified = False # don't update the header
from portage.util import atomic_ofstream, ensure_dirs
- ensure_dirs(os.path.dirname(pkgindex_file))
- f = atomic_ofstream(pkgindex_file)
- pkgindex.write(f)
- f.close()
+ try:
+ ensure_dirs(os.path.dirname(pkgindex_file))
+ f = atomic_ofstream(pkgindex_file)
+ pkgindex.write(f)
+ f.close()
+ except PortageException:
+ if os.access(os.path.join(
+ self.settings["ROOT"], CACHE_PATH), os.W_OK):
+ raise
+ # The current user doesn't have permission to cache the
+ # file, but that's alright.
if pkgindex:
self._remotepkgs = {}
for d in pkgindex.packages: