def update(self):
""" Update the global library->consumer map for the given vdb instance. """
obj_dict = {}
+ aux_get = self._dbapi.aux_get
for cpv in self._dbapi.cpv_all():
- needed_list = grabfile(self._dbapi.getpath(cpv, "NEEDED"))
+ needed_list = aux_get(cpv, ["NEEDED"])[0].splitlines()
for l in needed_list:
mysplit = l.split()
if len(mysplit) < 2:
cache_valid = cache_mtime == mydir_mtime
if cache_valid:
cache_incomplete = self._aux_cache_keys.difference(metadata)
+ needed = metadata.get("NEEDED")
+ if needed is None or needed and "\n" not in needed:
+ # Cached value has whitespace filtered, so it has to be pulled
+ # again. This is temporary migration code which can be removed
+ # later, since it only affects users who are running trunk.
+ cache_incomplete.add("NEEDED")
if cache_incomplete:
# Allow self._aux_cache_keys to change without a cache version
# bump and efficiently recycle partial cache whenever possible.
myd = myf.read()
finally:
myf.close()
- myd = " ".join(myd.split())
+ if x != "NEEDED":
+ myd = " ".join(myd.split())
except IOError:
myd = ""
if x == "EAPI" and not myd:
def counter_tick_core(self, myroot, incrementing=1, mycpv=None):
"This method will grab the next COUNTER value and record it back to the global file. Returns new counter value."
cpath = os.path.join(myroot, CACHE_PATH.lstrip(os.sep), "counter")
- changed = 0
- min_counter = 0
- if mycpv:
- mysplit = pkgsplit(mycpv)
- for x in self.match(mysplit[0], use_cache=0):
- if x == mycpv:
- continue
- try:
- old_counter = long(self.aux_get(x, ["COUNTER"])[0])
- writemsg("COUNTER '%d' '%s'\n" % (old_counter, x), 1)
- except (ValueError, KeyError): # valueError from long(), KeyError from aux_get
- old_counter = 0
- writemsg("!!! BAD COUNTER in '%s'\n" % (x), noiselevel=-1)
- if old_counter > min_counter:
- min_counter = old_counter
-
- # We write our new counter value to a new file that gets moved into
- # place to avoid filesystem corruption.
- find_counter = ("find '%s' -type f -name COUNTER | " + \
- "while read f; do echo $(<\"${f}\"); done | " + \
- "sort -n | tail -n1") % os.path.join(self.root, VDB_PATH)
- if os.path.exists(cpath):
+ changed = False
+ counter = -1
+ try:
cfile = open(cpath, "r")
- try:
- counter = long(cfile.readline())
- except (ValueError,OverflowError):
- try:
- counter = long(commands.getoutput(find_counter).strip())
- writemsg("!!! COUNTER was corrupted; resetting to value of %d\n" % counter,
- noiselevel=-1)
- changed=1
- except (ValueError, OverflowError):
- writemsg("!!! COUNTER data is corrupt in pkg db. The values need to be\n",
- noiselevel=-1)
- writemsg("!!! corrected/normalized so that portage can operate properly.\n",
- noiselevel=-1)
- writemsg("!!! A simple solution is not yet available so try #gentoo on IRC.\n")
- sys.exit(2)
- cfile.close()
+ except EnvironmentError:
+ writemsg("!!! COUNTER file is missing: '%s'\n" % cpath,
+ noiselevel=-1)
else:
try:
- counter = long(commands.getoutput(find_counter).strip())
- writemsg("!!! Global counter missing. Regenerated from counter files to: %s\n" % counter,
+ try:
+ counter = long(cfile.readline().strip())
+ finally:
+ cfile.close()
+ except (OverflowError, ValueError):
+ writemsg("!!! COUNTER file is corrupt: '%s'\n" % cpath,
noiselevel=-1)
- except ValueError: # Value Error for long(), probably others for commands.getoutput
- writemsg("!!! Initializing global counter.\n", noiselevel=-1)
- counter = long(0)
- changed = 1
- if counter < min_counter:
- counter = min_counter + 1000
- changed = 1
+ if counter < 0:
+ changed = True
+ max_counter = 0
+ cp_list = self.cp_list
+ for cp in self.cp_all():
+ for cpv in cp_list(cp):
+ try:
+ counter = int(self.aux_get(cpv, ["COUNTER"])[0])
+ except (KeyError, OverflowError, ValueError):
+ continue
+ if counter > max_counter:
+ max_counter = counter
+ counter = max_counter
+ writemsg("!!! Initializing COUNTER to " + \
+ "value of %d\n" % counter, noiselevel=-1)
if incrementing or changed:
a Manifest (not needed for parsing and checking sums)."""
self.pkgdir = pkgdir.rstrip(os.sep) + os.sep
self.fhashdict = {}
- self.hashes = portage.const.MANIFEST2_HASH_FUNCTIONS[:]
- self.hashes.append("size")
+ self.hashes = set()
+ self.hashes.update(portage.const.MANIFEST2_HASH_FUNCTIONS)
if manifest1_compat:
- self.hashes.extend(portage.const.MANIFEST1_HASH_FUNCTIONS)
- self.hashes = set(self.hashes)
+ self.hashes.update(portage.const.MANIFEST1_HASH_FUNCTIONS)
+ self.hashes.difference_update(hashname for hashname in \
+ list(self.hashes) if hashname not in hashfunc_map)
+ self.hashes.add("size")
+ if manifest1_compat:
+ self.hashes.add(portage.const.MANIFEST1_REQUIRED_HASH)
+ self.hashes.add(portage.const.MANIFEST2_REQUIRED_HASH)
for t in portage.const.MANIFEST2_IDENTIFIERS:
self.fhashdict[t] = {}
self.compat = manifest1_compat
if self.compat:
cvp_list = self.fetchlist_dict.keys()
cvp_list.sort()
+ manifest1_hashes = set(hashname for hashname in \
+ portage.const.MANIFEST1_HASH_FUNCTIONS \
+ if hashname in hashfunc_map)
+ manifest1_hashes.add(portage.const.MANIFEST1_REQUIRED_HASH)
+ manifest1_hashes.add("size")
for cpv in cvp_list:
digest_path = os.path.join("files", "digest-%s" % self._catsplit(cpv)[1])
dname = os.path.join(self.pkgdir, digest_path)
try:
- myhashes = perform_multiple_checksums(dname, portage.const.MANIFEST1_HASH_FUNCTIONS+["size"])
+ myhashes = perform_multiple_checksums(dname, manifest1_hashes)
myhashkeys = myhashes.keys()
myhashkeys.sort()
for h in myhashkeys: