else:
#Only carry out if in package directory or check forced
if xmllint_capable:
- st = spawn(["xmllint", "--nonet", "--noout", "--nowarning", "--dtdvalid",
- metadata_dtd, os.path.join(checkdir, "metadata.xml")])
+ # xmlint can produce garbage output even on success, so only dump
+ # the ouput when it fails.
+ st, out = getstatusoutput(
+ "xmllint --nonet --noout --dtdvalid '%s' '%s'" % \
+ (metadata_dtd, os.path.join(checkdir, "metadata.xml")))
if st != os.EX_OK:
- print red("!!! metadata.xml is invalid")
+ print red("!!!") + " metadata.xml is invalid:"
+ for z in out.splitlines():
+ print red("!!! ")+z
stats["metadata.bad"]+=1
fails["metadata.bad"].append(x+"/metadata.xml")
self.uvlist.append(self.configdict[x])
self.uvlist.reverse()
- myflags = []
+ myflags = set()
for curdb in self.uvlist:
cur_use_expand = [x for x in use_expand if x in curdb]
mysplit = curdb.get("USE", "").split()
continue
for x in mysplit:
if x == "-*":
- myflags = []
+ myflags.clear()
continue
if x[0] == "+":
continue
if x[0] == "-":
- try:
- myflags.remove(x[1:])
- except ValueError:
- pass
+ myflags.discard(x[1:])
continue
- myflags.append(x)
+ myflags.add(x)
for var in cur_use_expand:
var_lower = var.lower()
if var not in myincrementals:
prefix = var_lower + "_"
- myflags = [x for x in myflags if not x.startswith(prefix)]
+ for x in list(myflags):
+ if x.startswith(prefix):
+ myflags.remove(x)
for x in curdb[var].split():
# Any incremental USE_EXPAND variables have already been
# processed, so leading +/- operators are invalid here.
"non-incremental variable '%s': '%s'\n" % (var, x)),
noiselevel=-1)
continue
- myflags.append(var_lower + "_" + x)
+ myflags.add(var_lower + "_" + x)
- myflags = set(myflags)
myflags.update(self.useforce)
# FEATURES=test should imply USE=test
${PKGDIR}/${CATEGORY}/${PF}.tbz2 so that both can coexist."""
if not self._all_directory:
return
- if not self.populated:
- # Try to avoid the population routine when possible, so that
- # FEATURES=buildpkg doesn't always force population.
- mycat, mypkg = catsplit(cpv)
- myfile = mypkg + ".tbz2"
- full_path = os.path.join(self.pkgdir, "All", myfile)
- if not os.path.exists(full_path):
- return
- tbz2_cat = portage.xpak.tbz2(full_path).getfile("CATEGORY")
- if tbz2_cat and tbz2_cat.strip() == mycat:
- return
full_path = self.getname(cpv)
if "All" == full_path.split(os.path.sep)[-2]:
return
from portage.locks import lockfile, unlockfile
pkgindex_lock = None
try:
- if not self._all_directory and os.access(self.pkgdir, os.W_OK):
+ if os.access(self.pkgdir, os.W_OK):
pkgindex_lock = lockfile(self._pkgindex_file,
wantnewlockfile=1)
self._populate(getbinpkgs, getbinpkgsonly)
pkgindex = portage.getbinpkg.PackageIndex()
header = pkgindex.header
metadata = pkgindex.packages
+ pf_index = None
try:
f = open(self._pkgindex_file)
except EnvironmentError:
s = os.lstat(full_path)
if stat.S_ISLNK(s.st_mode):
continue
+
+ # Validate data from the package index and try to avoid
+ # reading the xpak if possible.
if mydir != "All":
- # Validate data from the package index and try to avoid
- # reading the xpak if possible.
- mycpv = mydir + "/" + myfile[:-5]
- d = metadata.get(mycpv)
- skip = False
+ possibilities = None
+ d = metadata.get(mydir+"/"+myfile[:-5])
if d:
+ possibilities = [d]
+ else:
+ if pf_index is None:
+ pf_index = {}
+ for mycpv in metadata:
+ mycat, mypf = catsplit(mycpv)
+ pf_index.setdefault(
+ mypf, []).append(metadata[mycpv])
+ possibilities = pf_index.get(myfile[:-5])
+ if possibilities:
+ match = None
+ for d in possibilities:
try:
- if long(d["MTIME"]) == long(s.st_mtime):
- skip = True
+ if long(d["MTIME"]) != long(s.st_mtime):
+ continue
except (KeyError, ValueError):
- pass
- if skip and not self._pkgindex_keys.difference(d):
+ continue
+ try:
+ if long(d["SIZE"]) != long(s.st_size):
+ continue
+ except (KeyError, ValueError):
+ continue
+ if not self._pkgindex_keys.difference(d):
+ match = d
+ break
+ if match:
+ mycpv = match["CPV"]
+ if mycpv in pkg_paths:
+ # discard duplicates (All/ is preferred)
+ continue
pkg_paths[mycpv] = mypath
self.dbapi.cpv_inject(mycpv)
if not self.dbapi._aux_cache_keys.difference(d):
# Do not bother to write the Packages index if $PKGDIR/All/ exists
# since it will provide no benefit due to the need to read CATEGORY
# from xpak.
- if update_pkgindex and not self._all_directory and \
- os.access(self.pkgdir, os.W_OK):
+ if update_pkgindex and os.access(self.pkgdir, os.W_OK):
cpv_all = self._pkg_paths.keys()
stale = set(metadata).difference(cpv_all)
for cpv in stale:
@rtype: None
"""
mycat, mypkg = catsplit(cpv)
- if not self.populated and self._all_directory:
- if filename is not None:
- # In order to avoid population, don't call getname() here.
- os.rename(filename, os.path.join(
- self.pkgdir, "All", mypkg + ".tbz2"))
- self._create_symlink(cpv)
- # There's nothing to update in this case, since the Packages
- # index is not created when $PKGDIR/All/ exists.
- return
if not self.populated:
self.populate()
if filename is None:
self.dbapi.cpv_inject(cpv)
self.dbapi._aux_cache.pop(cpv, None)
- if self._all_directory:
- if filename is not None:
- os.rename(filename, self.getname(cpv))
- self._create_symlink(cpv)
- return
-
# Reread the Packages index (in case it's been changed by another
# process) and then updated it, all while holding a lock.
from portage.locks import lockfile, unlockfile
wantnewlockfile=1)
if filename is not None:
os.rename(filename, self.getname(cpv))
+ if self._all_directory and \
+ self.getname(cpv).split(os.path.sep)[-2] == "All":
+ self._create_symlink(cpv)
pkgindex = portage.getbinpkg.PackageIndex()
try:
f = open(self._pkgindex_file)