-# Copyright 2010 Gentoo Foundation
+# Copyright 2010-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
__all__ = ['getmaskingreason']
from portage.dep import Atom, match_from_list, _slot_separator, _repo_separator
from portage.exception import InvalidAtom
from portage.localization import _
+from portage.repository.config import _gen_valid_repo
from portage.util import grablines, normalize_path
from portage.versions import catpkgsplit
+from _emerge.Package import Package
-def getmaskingreason(mycpv, metadata=None, settings=None, portdb=None, return_location=False):
+def getmaskingreason(mycpv, metadata=None, settings=None,
+ portdb=None, return_location=False, myrepo=None):
if settings is None:
settings = portage.settings
if portdb is None:
mysplit = catpkgsplit(mycpv)
if not mysplit:
raise ValueError(_("invalid CPV: %s") % mycpv)
+
+ if myrepo:
+ myrepo = _gen_valid_repo(myrepo)
+
if metadata is None:
db_keys = list(portdb._aux_cache_keys)
try:
- metadata = dict(zip(db_keys, portdb.aux_get(mycpv, db_keys)))
+ metadata = dict(zip(db_keys,
+ portdb.aux_get(mycpv, db_keys, myrepo=myrepo)))
except KeyError:
if not portdb.cpv_exists(mycpv):
raise
- if metadata is None:
- # Can't access SLOT due to corruption.
- cpv_slot_list = [mycpv]
- else:
+ else:
+ if not myrepo:
+ myrepo = _gen_valid_repo(metadata["repository"])
+
+ elif not myrepo:
+ myrepo = metadata.get("repository")
+ if myrepo is not None:
+ myrepo = _gen_valid_repo(metadata["repository"])
+
+ # Sometimes we can't access SLOT or repository due to corruption.
+ pkg = mycpv
+ if metadata is not None:
pkg = "".join((mycpv, _slot_separator, metadata["SLOT"]))
- if 'repository' in metadata:
- pkg = "".join((pkg, _repo_separator, metadata['repository']))
- cpv_slot_list = [pkg]
+ # At this point myrepo should be None, a valid name, or
+ # Package.UNKNOWN_REPO which we ignore.
+ if myrepo is not None and myrepo != Package.UNKNOWN_REPO:
+ pkg = "".join((pkg, _repo_separator, myrepo))
+ cpv_slot_list = [pkg]
+
mycp=mysplit[0]+"/"+mysplit[1]
# XXX- This is a temporary duplicate of code from the config constructor.