portage.proxy.lazyimport.lazyimport(globals(),
'portage.checksum:hashfunc_map,perform_multiple_checksums,verify_all',
'portage.dbapi.dep_expand:dep_expand',
- 'portage.dep:dep_getkey,isjustname,match_from_list',
- 'portage.eapi:_get_eapi_attrs',
+ 'portage.dep:dep_getkey,isjustname,isvalidatom,match_from_list',
'portage.output:EOutput,colorize',
'portage.locks:lockfile,unlockfile',
'portage.package.ebuild.fetch:_check_distfile,_hide_url_passwd',
from urlparse import urlparse
if sys.hexversion >= 0x3000000:
+ _unicode = str
basestring = str
long = int
+else:
+ _unicode = unicode
class bindbapi(fakedbapi):
_known_keys = frozenset(list(fakedbapi._known_keys) + \
if repo_match is not None \
and not repo_match(mycpv.repo):
continue
- eapi_attrs = _get_eapi_attrs(mycpv.eapi)
- if not eapi_attrs.dots_in_PN and "." in catsplit(newcp)[1]:
+
+ # Use isvalidatom() to check if this move is valid for the
+ # EAPI (characters allowed in package names may vary).
+ if not isvalidatom(newcp, eapi=mycpv.eapi):
continue
- mynewcpv = mycpv.replace(mycpv_cp, str(newcp), 1)
+
+ mynewcpv = mycpv.replace(mycpv_cp, _unicode(newcp), 1)
myoldpkg = catsplit(mycpv)[1]
mynewpkg = catsplit(mynewcpv)[1]
'portage.data:portage_gid,portage_uid,secpass',
'portage.dbapi.dep_expand:dep_expand',
'portage.dbapi._MergeProcess:MergeProcess',
- 'portage.dep:dep_getkey,isjustname,match_from_list,' + \
+ 'portage.dep:dep_getkey,isjustname,isvalidatom,match_from_list,' + \
'use_reduce,_get_slot_re',
'portage.eapi:_get_eapi_attrs',
'portage.elog:collect_ebuild_messages,collect_messages,' + \
if repo_match is not None \
and not repo_match(mycpv.repo):
continue
- eapi_attrs = _get_eapi_attrs(mycpv.eapi)
- if not eapi_attrs.dots_in_PN and "." in catsplit(newcp)[1]:
+
+ # Use isvalidatom() to check if this move is valid for the
+ # EAPI (characters allowed in package names may vary).
+ if not isvalidatom(newcp, eapi=mycpv.eapi):
continue
- mynewcpv = mycpv.replace(mycpv_cp, str(newcp), 1)
+
+ mynewcpv = mycpv.replace(mycpv_cp, _unicode(newcp), 1)
mynewcat = catsplit(newcp)[0]
origpath = self.getpath(mycpv)
if not os.path.exists(origpath):
eapi_attrs = _get_eapi_attrs(eapi)
atom_re = _get_atom_re(eapi_attrs)
+ self.__dict__['eapi'] = eapi
if eapi is not None:
# Ignore allow_repo when eapi is specified.
allow_repo = eapi_attrs.repo_deps
open_bracket = depend.find( '[', open_bracket+1 )
return tuple(use_list)
-def isvalidatom(atom, allow_blockers=False, allow_wildcard=False, allow_repo=False):
+def isvalidatom(atom, allow_blockers=False, allow_wildcard=False,
+ allow_repo=False, eapi=None):
"""
Check to see if a depend atom is valid
1) False if the atom is invalid
2) True if the atom is valid
"""
+
+ if eapi is not None and isinstance(atom, Atom) and atom.eapi != eapi:
+ # We'll construct a new atom with the given eapi.
+ atom = _unicode(atom)
+
try:
if not isinstance(atom, Atom):
- atom = Atom(atom, allow_wildcard=allow_wildcard, allow_repo=allow_repo)
+ atom = Atom(atom, allow_wildcard=allow_wildcard,
+ allow_repo=allow_repo, eapi=eapi)
if not allow_blockers and atom.blocker:
return False
return True
ignored_dbentries = ("CONTENTS", "environment.bz2")
def update_dbentry(update_cmd, mycontent, eapi=None):
- eapi_attrs = _get_eapi_attrs(eapi)
+
if update_cmd[0] == "move":
- avoid_dots_in_PN = (not eapi_attrs.dots_in_PN and
- "." in catsplit(update_cmd[2].cp)[1])
- if not avoid_dots_in_PN and _unicode(update_cmd[1]) in mycontent:
- old_value = _unicode(update_cmd[1])
- new_value = _unicode(update_cmd[2])
+ old_value = _unicode(update_cmd[1])
+ new_value = _unicode(update_cmd[2])
+
+ # Use isvalidatom() to check if this move is valid for the
+ # EAPI (characters allowed in package names may vary).
+ if old_value in mycontent and isvalidatom(new_value, eapi=eapi):
old_value = re.escape(old_value);
mycontent = re.sub(old_value+"(:|$|\\s)", new_value+"\\1", mycontent)
def myreplace(matchobj):