from portage import os
def quickpkg_main(options, args, eout):
- from portage import catsplit, dep_expand, flatten, isvalidatom, xpak
+ from portage import catsplit, flatten, isvalidatom, xpak
+ from portage.dbapi.dep_expand import dep_expand
from portage.dep import use_reduce, paren_reduce
from portage.util import ConfigProtect, ensure_dirs
from portage.exception import InvalidAtom, InvalidData, InvalidDependString
from portage import _unicode_decode
from portage.cache.cache_errors import CacheError
from portage.const import NEWS_LIB_PATH
+from portage.dbapi.dep_expand import dep_expand
from portage.output import blue, bold, colorize, create_color_func, darkgreen, \
red, yellow
good = create_color_func("GOOD")
try:
valid_atoms.append(
- portage.dep_expand(x, mydb=vardb, settings=settings))
+ dep_expand(x, mydb=vardb, settings=settings))
except portage.exception.AmbiguousPackageName as e:
msg = "The short ebuild name \"" + x + \
"\" is ambiguous. Please specify " + \
from portage import os
from portage import digraph
from portage.dbapi import dbapi
+from portage.dbapi.dep_expand import dep_expand
from portage.dep import Atom
from portage.output import bold, blue, colorize, create_color_func, darkblue, \
darkgreen, green, nc_len, red, teal, turquoise, yellow
else:
blocker_style = "PKG_BLOCKER"
addl = "%s %s " % (colorize(blocker_style, "B"), fetch)
- resolved = portage.dep_expand(
+ resolved = dep_expand(
str(x.atom).lstrip("!"), mydb=vardb, settings=pkgsettings)
if "--columns" in self._frozen_config.myopts and "--quiet" in self._frozen_config.myopts:
addl += " " + colorize(blocker_style, str(resolved))
import portage.locks
import portage.exception
from portage.data import secpass
+from portage.dbapi.dep_expand import dep_expand
from portage.util import normalize_path as normpath
from portage.util import writemsg, writemsg_level, writemsg_stdout
from portage.sets import SETPREFIX
if is_valid_package_atom(x):
try:
valid_atoms.append(
- portage.dep_expand(x, mydb=vardb, settings=settings))
+ dep_expand(x, mydb=vardb, settings=settings))
except portage.exception.AmbiguousPackageName as e:
msg = "The short ebuild name \"" + x + \
"\" is ambiguous. Please specify " + \
'uid,userland,userpriv_groups,wheelgid',
'portage.dbapi',
'portage.dbapi.bintree:bindbapi,binarytree',
+ 'portage.dbapi.cpv_expand:cpv_expand',
+ 'portage.dbapi.dep_expand:dep_expand',
'portage.dbapi.porttree:close_portdbapi_caches,FetchlistDict,' + \
'portagetree,portdbapi',
'portage.dbapi.vartree:vardbapi,vartree,dblink',
assert(False) # This point should not be reachable
-def dep_expand(mydep, mydb=None, use_cache=1, settings=None):
- '''
- @rtype: Atom
- '''
- if not len(mydep):
- return mydep
- if mydep[0]=="*":
- mydep=mydep[1:]
- orig_dep = mydep
- if isinstance(orig_dep, dep.Atom):
- mydep = orig_dep.cp
- else:
- mydep = orig_dep
- has_cat = '/' in orig_dep
- if not has_cat:
- alphanum = re.search(r'\w', orig_dep)
- if alphanum:
- mydep = orig_dep[:alphanum.start()] + "null/" + \
- orig_dep[alphanum.start():]
- try:
- mydep = dep.Atom(mydep)
- except exception.InvalidAtom:
- # Missing '=' prefix is allowed for backward compatibility.
- if not dep.isvalidatom("=" + mydep):
- raise
- mydep = dep.Atom('=' + mydep)
- orig_dep = '=' + orig_dep
- if not has_cat:
- null_cat, pn = catsplit(mydep.cp)
- mydep = pn
- else:
- mydep = mydep.cp
- expanded = cpv_expand(mydep, mydb=mydb,
- use_cache=use_cache, settings=settings)
- return portage.dep.Atom(orig_dep.replace(mydep, expanded, 1))
-
def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None,
use_cache=1, use_binaries=0, myroot="/", trees=None):
"""Takes a depend string and parses the condition."""
return None
return deplist
-def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None):
- """Given a string (packagename or virtual) expand it into a valid
- cat/package string. Virtuals use the mydb to determine which provided
- virtual is a valid choice and defaults to the first element when there
- are no installed/available candidates."""
- myslash=mycpv.split("/")
- mysplit = versions._pkgsplit(myslash[-1])
- if settings is None:
- settings = globals()["settings"]
- virts = settings.getvirtuals()
- virts_p = settings.get_virts_p()
- if len(myslash)>2:
- # this is illegal case.
- mysplit=[]
- mykey=mycpv
- elif len(myslash)==2:
- if mysplit:
- mykey=myslash[0]+"/"+mysplit[0]
- else:
- mykey=mycpv
- if mydb and virts and mykey in virts:
- writemsg("mydb.__class__: %s\n" % (mydb.__class__), 1)
- if hasattr(mydb, "cp_list"):
- if not mydb.cp_list(mykey, use_cache=use_cache):
- writemsg("virts[%s]: %s\n" % (str(mykey),virts[mykey]), 1)
- mykey_orig = mykey[:]
- for vkey in virts[mykey]:
- # The virtuals file can contain a versioned atom, so
- # it may be necessary to remove the operator and
- # version from the atom before it is passed into
- # dbapi.cp_list().
- if mydb.cp_list(vkey.cp):
- mykey = str(vkey)
- writemsg(_("virts chosen: %s\n") % (mykey), 1)
- break
- if mykey == mykey_orig:
- mykey = str(virts[mykey][0])
- writemsg(_("virts defaulted: %s\n") % (mykey), 1)
- #we only perform virtual expansion if we are passed a dbapi
- else:
- #specific cpv, no category, ie. "foo-1.0"
- if mysplit:
- myp=mysplit[0]
- else:
- # "foo" ?
- myp=mycpv
- mykey=None
- matches=[]
- if mydb and hasattr(mydb, "categories"):
- for x in mydb.categories:
- if mydb.cp_list(x+"/"+myp,use_cache=use_cache):
- matches.append(x+"/"+myp)
- if len(matches) > 1:
- virtual_name_collision = False
- if len(matches) == 2:
- for x in matches:
- if not x.startswith("virtual/"):
- # Assume that the non-virtual is desired. This helps
- # avoid the ValueError for invalid deps that come from
- # installed packages (during reverse blocker detection,
- # for example).
- mykey = x
- else:
- virtual_name_collision = True
- if not virtual_name_collision:
- # AmbiguousPackageName inherits from ValueError,
- # for backward compatibility with calling code
- # that already handles ValueError.
- raise portage.exception.AmbiguousPackageName(matches)
- elif matches:
- mykey=matches[0]
-
- if not mykey and not isinstance(mydb, list):
- if myp in virts_p:
- mykey=virts_p[myp][0]
- #again, we only perform virtual expansion if we have a dbapi (not a list)
- if not mykey:
- mykey="null/"+myp
- if mysplit:
- if mysplit[2]=="r0":
- return mykey+"-"+mysplit[1]
- else:
- return mykey+"-"+mysplit[1]+"-"+mysplit[2]
- else:
- return mykey
-
def getmaskingreason(mycpv, metadata=None, settings=None, portdb=None, return_location=False):
from portage.util import grablines
if settings is None:
import portage
portage.proxy.lazyimport.lazyimport(globals(),
+ 'portage.dbapi.dep_expand:dep_expand',
'portage.dep:match_from_list',
'portage.locks:unlockfile',
'portage.output:colorize',
)
from portage import os
-from portage import auxdbkeys, dep_expand
+from portage import auxdbkeys
from portage.localization import _
class dbapi(object):
import portage
portage.proxy.lazyimport.lazyimport(globals(),
+ 'portage.dbapi.dep_expand:dep_expand',
'portage.dep:dep_getkey,isjustname,match_from_list',
'portage.output:EOutput,colorize',
'portage.package.ebuild.doebuild:_vdb_use_conditional_atoms',
PermissionDenied, PortageException
from portage.localization import _
-from portage import dep_expand, _movefile
+from portage import _movefile
from portage import os
from portage import _encodings
from portage import _unicode_decode
--- /dev/null
+# Copyright 2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+__all__ = ["cpv_expand"]
+
+from portage.exception import AmbiguousPackageName
+from portage.localization import _
+from portage.util import writemsg
+from portage.versions import _pkgsplit
+
+def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None):
+ """Given a string (packagename or virtual) expand it into a valid
+ cat/package string. Virtuals use the mydb to determine which provided
+ virtual is a valid choice and defaults to the first element when there
+ are no installed/available candidates."""
+ myslash=mycpv.split("/")
+ mysplit = _pkgsplit(myslash[-1])
+ if settings is None:
+ settings = globals()["settings"]
+ virts = settings.getvirtuals()
+ virts_p = settings.get_virts_p()
+ if len(myslash)>2:
+ # this is illegal case.
+ mysplit=[]
+ mykey=mycpv
+ elif len(myslash)==2:
+ if mysplit:
+ mykey=myslash[0]+"/"+mysplit[0]
+ else:
+ mykey=mycpv
+ if mydb and virts and mykey in virts:
+ writemsg("mydb.__class__: %s\n" % (mydb.__class__), 1)
+ if hasattr(mydb, "cp_list"):
+ if not mydb.cp_list(mykey, use_cache=use_cache):
+ writemsg("virts[%s]: %s\n" % (str(mykey),virts[mykey]), 1)
+ mykey_orig = mykey[:]
+ for vkey in virts[mykey]:
+ # The virtuals file can contain a versioned atom, so
+ # it may be necessary to remove the operator and
+ # version from the atom before it is passed into
+ # dbapi.cp_list().
+ if mydb.cp_list(vkey.cp):
+ mykey = str(vkey)
+ writemsg(_("virts chosen: %s\n") % (mykey), 1)
+ break
+ if mykey == mykey_orig:
+ mykey = str(virts[mykey][0])
+ writemsg(_("virts defaulted: %s\n") % (mykey), 1)
+ #we only perform virtual expansion if we are passed a dbapi
+ else:
+ #specific cpv, no category, ie. "foo-1.0"
+ if mysplit:
+ myp=mysplit[0]
+ else:
+ # "foo" ?
+ myp=mycpv
+ mykey=None
+ matches=[]
+ if mydb and hasattr(mydb, "categories"):
+ for x in mydb.categories:
+ if mydb.cp_list(x+"/"+myp,use_cache=use_cache):
+ matches.append(x+"/"+myp)
+ if len(matches) > 1:
+ virtual_name_collision = False
+ if len(matches) == 2:
+ for x in matches:
+ if not x.startswith("virtual/"):
+ # Assume that the non-virtual is desired. This helps
+ # avoid the ValueError for invalid deps that come from
+ # installed packages (during reverse blocker detection,
+ # for example).
+ mykey = x
+ else:
+ virtual_name_collision = True
+ if not virtual_name_collision:
+ # AmbiguousPackageName inherits from ValueError,
+ # for backward compatibility with calling code
+ # that already handles ValueError.
+ raise AmbiguousPackageName(matches)
+ elif matches:
+ mykey=matches[0]
+
+ if not mykey and not isinstance(mydb, list):
+ if myp in virts_p:
+ mykey=virts_p[myp][0]
+ #again, we only perform virtual expansion if we have a dbapi (not a list)
+ if not mykey:
+ mykey="null/"+myp
+ if mysplit:
+ if mysplit[2]=="r0":
+ return mykey+"-"+mysplit[1]
+ else:
+ return mykey+"-"+mysplit[1]+"-"+mysplit[2]
+ else:
+ return mykey
--- /dev/null
+# Copyright 2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+__all__ = ["dep_expand"]
+
+import re
+
+from portage.dbapi.cpv_expand import cpv_expand
+from portage.dep import Atom, isvalidatom
+from portage.exception import InvalidAtom
+from portage.versions import catsplit
+
+def dep_expand(mydep, mydb=None, use_cache=1, settings=None):
+ '''
+ @rtype: Atom
+ '''
+ if not len(mydep):
+ return mydep
+ if mydep[0]=="*":
+ mydep=mydep[1:]
+ orig_dep = mydep
+ if isinstance(orig_dep, Atom):
+ mydep = orig_dep.cp
+ else:
+ mydep = orig_dep
+ has_cat = '/' in orig_dep
+ if not has_cat:
+ alphanum = re.search(r'\w', orig_dep)
+ if alphanum:
+ mydep = orig_dep[:alphanum.start()] + "null/" + \
+ orig_dep[alphanum.start():]
+ try:
+ mydep = Atom(mydep)
+ except InvalidAtom:
+ # Missing '=' prefix is allowed for backward compatibility.
+ if not isvalidatom("=" + mydep):
+ raise
+ mydep = Atom('=' + mydep)
+ orig_dep = '=' + orig_dep
+ if not has_cat:
+ null_cat, pn = catsplit(mydep.cp)
+ mydep = pn
+ else:
+ mydep = mydep.cp
+ expanded = cpv_expand(mydep, mydb=mydb,
+ use_cache=use_cache, settings=settings)
+ return Atom(orig_dep.replace(mydep, expanded, 1))
import portage
portage.proxy.lazyimport.lazyimport(globals(),
'portage.checksum',
+ 'portage.dbapi.dep_expand:dep_expand',
'portage.dep:dep_getkey,flatten,match_from_list,paren_reduce,use_reduce',
'portage.env.loaders:KeyValuePairFileLoader',
'portage.package.ebuild.doebuild:doebuild',
from portage.manifest import Manifest
from portage import eclass_cache, auxdbkeys, \
- dep_expand, eapi_is_supported, dep_check, \
+ eapi_is_supported, dep_check, \
_eapi_is_deprecated
from portage import os
from portage import _encodings
import portage
portage.proxy.lazyimport.lazyimport(globals(),
'portage.checksum:_perform_md5_merge@perform_md5',
+ 'portage.dbapi.dep_expand:dep_expand',
'portage.dep:dep_getkey,isjustname,flatten,match_from_list,' + \
'use_reduce,paren_reduce,_slot_re',
'portage.elog:elog_process',
FileNotFound, PermissionDenied, UnsupportedAPIException
from portage.localization import _
-from portage import dep_expand, \
- abssymlink, movefile, _movefile, bsd_chflags
+from portage import abssymlink, movefile, _movefile, bsd_chflags
# This is a special version of the os module, wrapped for unicode support.
from portage import os