if not hasattr(__builtins__, "set"):
from sets import Set as set
+from itertools import izip
class stdout_spinner(object):
scroll_msgs = [
return "medium"
return "soft"
-class FakeVartree(object):
+class FakeVartree(portage.vartree):
"""This is implements an in-memory copy of a vartree instance that provides
all the interfaces required for use by the depgraph. The vardb is locked
during the constructor call just long enough to read a copy of the
try:
if os.access(vdb_path, os.W_OK):
vdb_lock = portage_locks.lockdir(vdb_path)
- mykeys = ["SLOT", "USE", "IUSE", "DEPEND", "RDEPEND", "PDEPEND"]
+ mykeys = ["SLOT", "PROVIDE", "USE", "IUSE",
+ "DEPEND", "RDEPEND", "PDEPEND"]
real_dbapi = real_vartree.dbapi
for cpv in real_dbapi.cpv_all():
- metadata = dict(zip(mykeys, real_dbapi.aux_get(cpv, mykeys)))
+ metadata = dict(izip(mykeys, real_dbapi.aux_get(cpv, mykeys)))
self.dbapi.cpv_inject(cpv, metadata=metadata)
finally:
if vdb_lock:
portage_locks.unlockdir(vdb_lock)
+ # Populate the old-style virtuals using the cached values.
+ if not self.settings.treeVirtuals:
+ self.settings.treeVirtuals = portage_util.map_dictlist_vals(
+ portage.getCPFromCPV, self.get_all_provides())
class depgraph:
upd_commands = self.global_updates[myroot]
aux_keys = ["DEPEND", "RDEPEND", "PDEPEND"]
aux_vals = vardb.aux_get(myeb_inst, aux_keys)
- aux_dict = dict(zip(aux_keys, aux_vals))
+ aux_dict = dict(izip(aux_keys, aux_vals))
updates = update_dbentries(upd_commands, aux_dict)
if updates:
vardb.aux_update(myeb_inst, updates)
aux_vals = portdb.aux_get(cpv, fakedb_auxkeys)
except KeyError:
aux_vals = vardb.aux_get(cpv, fakedb_auxkeys)
- fake_vardb.cpv_inject(cpv, metadata=dict(zip(fakedb_auxkeys, aux_vals)))
+ fake_vardb.cpv_inject(
+ cpv, metadata=dict(izip(fakedb_auxkeys, aux_vals)))
# HACK: Ensure that installed packages are preferenced by dep_check().
trees[settings["ROOT"]]["porttree"].dbapi = fake_vardb
continue
spinner.update()
fakedb.cpv_inject(pkg)
- myaux = dict(zip(aux_keys, fake_vardb.aux_get(pkg, aux_keys)))
+ myaux = dict(izip(aux_keys, fake_vardb.aux_get(pkg, aux_keys)))
mydeps = []
if myopts.get("--with-bdeps", "y") == "y":
mydeps.append((myaux["DEPEND"], soft))
import UserDict
if getattr(__builtins__, "set", None) is None:
from sets import Set as set
+ from itertools import chain, izip
except ImportError, e:
sys.stderr.write("\n\n")
sys.stderr.write("!!! Failed to complete python imports. These are internal modules for\n")
self.dirVirtuals[virt].reverse()
# Repoman does not use user or tree virtuals.
- if self.local_config:
+ if self.local_config and not self.treeVirtuals:
temp_vartree = vartree(myroot, None,
categories=self.categories, settings=self)
# Reduce the provides into a list by CP.
# automatically mapped to PORTAGE_INST_UID and PORTAGE_INST_GID if
# necessary. The chown system call may clear S_ISUID and S_ISGID
# bits, so those bits are restored if necessary.
- from itertools import chain
inst_uid = int(mysettings["PORTAGE_INST_UID"])
inst_gid = int(mysettings["PORTAGE_INST_GID"])
for parent, dirs, files in os.walk(mysettings["D"]):
if unreduced[0] != "||":
unresolved = []
- for (dep, satisfied) in zip(unreduced, reduced):
+ for dep, satisfied in izip(unreduced, reduced):
if isinstance(dep, list):
unresolved += dep_zapdeps(dep, satisfied, myroot,
use_binaries=use_binaries, trees=trees)
# Sort the deps into preferred (installed) and other
# with values of [[required_atom], availablility]
- for (dep, satisfied) in zip(deps, satisfieds):
+ for dep, satisfied in izip(deps, satisfieds):
if isinstance(dep, list):
atoms = dep_zapdeps(dep, satisfied, myroot,
use_binaries=use_binaries, trees=trees)
self.portroot=settings["PORTDIR"]
self.virtual=virtual
self.dbapi = portdbapi(
- settings["PORTDIR"], mysettings=config(clone=settings))
+ settings["PORTDIR"], mysettings=settings)
def dep_bestmatch(self,mydep):
"compatibility method"
results = []
for x in wants:
myfn = self.root+VDB_PATH+"/"+str(mycpv)+"/"+str(x)
- if os.access(myfn,os.R_OK):
+ try:
myf = open(myfn, "r")
myd = myf.read()
myf.close()
myd = re.sub("[\n\r\t]+"," ",myd)
myd = re.sub(" +"," ",myd)
myd = string.strip(myd)
- else:
+ except (IOError, OSError):
myd = ""
results.append(myd)
if "EAPI" in wants:
def get_provide(self,mycpv):
myprovides=[]
try:
- mylines = grabfile(self.root+VDB_PATH+"/"+mycpv+"/PROVIDE")
+ mylines, myuse = self.dbapi.aux_get(mycpv, ["PROVIDE","USE"])
if mylines:
- myuse = grabfile(self.root+VDB_PATH+"/"+mycpv+"/USE")
- myuse = string.split(string.join(myuse))
- mylines = string.join(mylines)
+ myuse = myuse.split()
mylines = flatten(portage_dep.use_reduce(portage_dep.paren_reduce(mylines), uselist=myuse))
for myprovide in mylines:
mys = catpkgsplit(myprovide)
+# portage_versions.py -- core Portage functionality
+# Copyright 1998-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
import re,string
ver_regexp = re.compile("^(cvs\\.)?(\\d+)((\\.\\d+)*)([a-z]?)((_(pre|p|beta|alpha|rc)\\d*)*)(-r(\\d+))?$")
vercmp_cache = {}
def vercmp(ver1, ver2, silent=1):
+ """
+ Compare two versions
+ Example usage:
+ >>> from portage_versions import vercmp
+ >>> vercmp('1.0-r1','1.2-r3')
+ negative number
+ >>> vercmp('1.3','1.2-r3')
+ positive number
+ >>> vercmp('1.0_p3','1.0_p3')
+ 0
+
+ @param pkg1: version to compare with (see ver_regexp in portage_versions.py)
+ @type pkg1: string (example: "2.1.2-r3")
+ @param pkg2: version to compare againts (see ver_regexp in portage_versions.py)
+ @type pkg2: string (example: "2.1.2_rc5")
+ @rtype: None or float
+ @return:
+ 1. positive if ver1 is greater than ver2
+ 2. negative if ver1 is less than ver2
+ 3. 0 if ver1 equals ver2
+ 4. None if ver1 or ver2 are invalid (see ver_regexp in portage_versions.py)
+ """
+
if ver1 == ver2:
return 0
mykey=ver1+":"+ver2