From f8618af8f973aa0fa0056e29c0a4094190ff44fb Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Wed, 21 Mar 2007 00:14:35 +0000 Subject: [PATCH] Pass a list of USE flags into config.getMissingLicenses() so that the method can eventually be used for binary packages in addition to ebuilds. svn path=/main/trunk/; revision=6260 --- pym/emerge/__init__.py | 7 ++++++- pym/portage/__init__.py | 17 +++++++++++------ pym/portage/dbapi/porttree.py | 7 ++++++- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/pym/emerge/__init__.py b/pym/emerge/__init__.py index bd700ff92..11cb50a47 100644 --- a/pym/emerge/__init__.py +++ b/pym/emerge/__init__.py @@ -1693,10 +1693,15 @@ class depgraph: print comment oldcomment = comment licenses = portdb.aux_get(p, ["LICENSE"])[0] + uselist = [] + if "?" in licenses: + pkgsettings.setcpv(p, mydb=portdb) + uselist = pkgsettings.get("USE", "").split() missing_licenses = [] try: missing_licenses = \ - pkgsettings.getMissingLicenses(licenses, p) + pkgsettings.getMissingLicenses( + licenses, p, uselist) except portage.exception.InvalidDependString: # This will have already been reported # above via mreasons. diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 11dca580a..1b04d35b1 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -1748,7 +1748,7 @@ class config: if has_changed: self.reset(keeping_pkg=1,use_cache=use_cache) - def getMissingLicenses(self, licenses, cpv): + def getMissingLicenses(self, licenses, cpv, uselist): """ Take a LICENSE string and return a list any licenses that the user may may need to accept for the given package. The returned list will not @@ -1757,8 +1757,10 @@ class config: @param licenses: A raw LICENSE string as returned form dbapi.aux_get() @type licenses: String - @param cpv: The package name (for evaluation of USE conditionals) + @param cpv: The package name (for package.license support) @type cpv: String + @param uselist: A list of flags for evaluation of USE conditionals + @type uselist: List @rtype: List @return: A list of licenses that have not been accepted. """ @@ -1769,11 +1771,9 @@ class config: acceptable_licenses.update(cpdict[atom]) if "*" in acceptable_licenses: return [] - if "?" in licenses: - self.setcpv(cpv) license_struct = portage.dep.paren_reduce(licenses) license_struct = portage.dep.use_reduce( - license_struct, uselist=self["USE"].split()) + license_struct, uselist=uselist) license_struct = portage.dep.dep_opconvert(license_struct) return self._getMissingLicenses(license_struct, acceptable_licenses) @@ -4717,8 +4717,13 @@ def getmaskingstatus(mycpv, settings=None, portdb=None): if kmask: rValue.append(kmask+" keyword") + uselist = [] + if "?" in licenses: + settings.setcpv(mycpv, mydb=portdb) + uselist = settings.get("USE", "").split() try: - missing_licenses = settings.getMissingLicenses(licenses, mycpv) + missing_licenses = settings.getMissingLicenses( + licenses, mycpv, uselist) if missing_licenses: allowed_tokens = set(["||", "(", ")"]) allowed_tokens.update(missing_licenses) diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index 4118a4da4..af14499d6 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -685,8 +685,13 @@ class portdbapi(dbapi): hasstable = True if not match and ((hastesting and "~*" in pgroups) or (hasstable and "*" in pgroups) or "**" in pgroups): match=1 + uselist = [] + if "?" in licenses: + self.mysettings.setcpv(mycpv, mydb=self) + uselist = self.mysettings.get("USE", "").split() try: - if self.mysettings.getMissingLicenses(licenses, mycpv): + if self.mysettings.getMissingLicenses( + licenses, mycpv, uselist): match = 0 except InvalidDependString: match = 0 -- 2.26.2