Gentoo Archives: gentoo-commits

From: Thomas Sachau <tommy@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:multilib commit in: pym/portage/package/ebuild/, pym/portage/package/ebuild/_config/, pym/_emerge/
Date: Sun, 06 Feb 2011 13:17:17
Message-Id: ce0cbf82cafc78ee22354257b9821d55b780d35e.tommy@gentoo
1 commit: ce0cbf82cafc78ee22354257b9821d55b780d35e
2 Author: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
3 AuthorDate: Sun Jan 30 03:22:58 2011 +0000
4 Commit: Thomas Sachau <tommy <AT> gentoo <DOT> org>
5 CommitDate: Sun Jan 30 09:11:58 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ce0cbf82
7
8 add a new function to MaskManager that optimizies getting any raw mask atoms
9
10 ---
11 pym/_emerge/Package.py | 29 ++++----------------
12 pym/portage/package/ebuild/_config/MaskManager.py | 28 ++++++++++++++++++++
13 pym/portage/package/ebuild/config.py | 22 +++++++++++++--
14 3 files changed, 53 insertions(+), 26 deletions(-)
15
16 diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py
17 index 96c76b9..ae9e8f2 100644
18 --- a/pym/_emerge/Package.py
19 +++ b/pym/_emerge/Package.py
20 @@ -239,7 +239,7 @@ class Package(Task):
21
22 def accepted_keyword(self):
23 """returns the keyword used from the ebuild's KEYWORDS string"""
24 -
25 +
26 keywords = set(self.metadata.get('KEYWORDS').split())
27 accept_keywords = set(self.root_config.settings['ACCEPT_KEYWORDS'].split())
28 used_keyword = list(set.intersection(keywords, accept_keywords))
29 @@ -250,31 +250,14 @@ class Package(Task):
30 writemsg_level( "_emerge.output.resolver.Display(), too many keywords recieved for pkg: %s, %s"
31 % (pkg.cpv, used_keyword))
32 used_keyword = used_keyword[0]
33 - #print "pmaskdict", self.root_config.settings.pmaskdict
34 return used_keyword
35
36 def isHardMasked(self):
37 - """returns a bool if the cpv is in the list of
38 + """returns a bool if the cpv is in the list of
39 expanded pmaskdict[cp] availble ebuilds"""
40 - try:
41 - # returns a list of mask atoms
42 - pmask = self.root_config.settings.pmaskdict[self.cp]
43 - except KeyError:
44 - pmask = []
45 - if pmask:
46 - # narrow pmask atoms down to the relevant repo
47 - n = [x for x in pmask if x.split('::')[-1] in [self.repo]]
48 - # hopefully it is down to only 1 mask atom
49 - #print "n =", n
50 - #count = 0
51 - hardmasked = set()
52 - for x in n:
53 - #expand the atom to matching available ebuilds
54 - hardmasked.update(self.root_config.trees['porttree'].dbapi.xmatch("match-all",x))
55 - #count += 1
56 - #print "for x in n: loop count =", count, hardmasked
57 - return self.cpv in hardmasked
58 - return False
59 + pmask = self.root_config.settings._getRawMaskAtom(self.cpv, self.metadata)
60 + print "pmask =", pmask
61 + return pmask is not None
62
63
64 def _metadata_exception(self, k, e):
65 @@ -448,7 +431,7 @@ class Package(Task):
66 not self._iuse_implicit_match(flag):
67 return False
68 return True
69 -
70 +
71 def get_missing_iuse(self, flags):
72 """
73 @returns: A list of flags missing from IUSE.
74
75 diff --git a/pym/portage/package/ebuild/_config/MaskManager.py b/pym/portage/package/ebuild/_config/MaskManager.py
76 index 25d679e..66278ec 100644
77 --- a/pym/portage/package/ebuild/_config/MaskManager.py
78 +++ b/pym/portage/package/ebuild/_config/MaskManager.py
79 @@ -135,3 +135,31 @@ class MaskManager(object):
80 return None
81 return x
82 return None
83 +
84 + def getRawMaskAtom(self, cpv, slot, repo):
85 + """
86 + Take a package and return a matching package.mask atom, or None if no
87 + such atom exists. It HAS NOT! been cancelled by any package.unmask.
88 + PROVIDE is not checked, so atoms will not be found for old-style
89 + virtuals.
90 +
91 + @param cpv: The package name
92 + @type cpv: String
93 + @param slot: The package's slot
94 + @type slot: String
95 + @rtype: String
96 + @return: A matching atom string or None if one is not found.
97 + """
98 +
99 + cp = cpv_getkey(cpv)
100 + mask_atoms = self._pmaskdict.get(cp)
101 + if mask_atoms:
102 + pkg = "".join((cpv, _slot_separator, slot))
103 + if repo:
104 + pkg = "".join((pkg, _repo_separator, repo))
105 + pkg_list = [pkg]
106 + for x in mask_atoms:
107 + if not match_from_list(x, pkg_list):
108 + continue
109 + return x
110 + return None
111
112 diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
113 index ba6ac21..b15a195 100644
114 --- a/pym/portage/package/ebuild/config.py
115 +++ b/pym/portage/package/ebuild/config.py
116 @@ -110,10 +110,10 @@ class _iuse_implicit_match_cache(object):
117 class config(object):
118 """
119 This class encompasses the main portage configuration. Data is pulled from
120 - ROOT/PORTDIR/profiles/, from ROOT/etc/make.profile incrementally through all
121 + ROOT/PORTDIR/profiles/, from ROOT/etc/make.profile incrementally through all
122 parent profiles as well as from ROOT/PORTAGE_CONFIGROOT/* for user specified
123 overrides.
124 -
125 +
126 Generally if you need data like USE flags, FEATURES, environment variables,
127 virtuals ...etc you look in here.
128 """
129 @@ -1376,6 +1376,22 @@ class config(object):
130 """
131 return self._mask_manager.getMaskAtom(cpv, metadata["SLOT"], metadata.get('repository'))
132
133 + def _getRawMaskAtom(self, cpv, metadata):
134 + """
135 + Take a package and return a matching package.mask atom, or None if no
136 + such atom exists or it has been cancelled by package.unmask. PROVIDE
137 + is not checked, so atoms will not be found for old-style virtuals.
138 +
139 + @param cpv: The package name
140 + @type cpv: String
141 + @param metadata: A dictionary of raw package metadata
142 + @type metadata: dict
143 + @rtype: String
144 + @return: A matching atom string or None if one is not found.
145 + """
146 + return self._mask_manager.getRawMaskAtom(cpv, metadata["SLOT"], metadata.get('repository'))
147 +
148 +
149 def _getProfileMaskAtom(self, cpv, metadata):
150 """
151 Take a package and return a matching profile atom, or None if no
152 @@ -1424,7 +1440,7 @@ class config(object):
153 @return: A list of KEYWORDS that have not been accepted.
154 """
155
156 - # Hack: Need to check the env directly here as otherwise stacking
157 + # Hack: Need to check the env directly here as otherwise stacking
158 # doesn't work properly as negative values are lost in the config
159 # object (bug #139600)
160 backuped_accept_keywords = self.configdict["backupenv"].get("ACCEPT_KEYWORDS", "")