Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r11743 - in main/trunk/pym: _emerge portage
Date: Wed, 29 Oct 2008 17:03:40
Message-Id: E1KvESG-0001PV-Vx@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-10-29 17:03:35 +0000 (Wed, 29 Oct 2008)
3 New Revision: 11743
4
5 Modified:
6 main/trunk/pym/_emerge/__init__.py
7 main/trunk/pym/portage/__init__.py
8 Log:
9 Make config.setcpv() store the ebuild metadata inside self.configdict["pkg"],
10 and reuse this metadata inside doebuild() in order to avoid redundant
11 portdbapi.aux_get() calls.
12
13
14 Modified: main/trunk/pym/_emerge/__init__.py
15 ===================================================================
16 --- main/trunk/pym/_emerge/__init__.py 2008-10-29 00:07:34 UTC (rev 11742)
17 +++ main/trunk/pym/_emerge/__init__.py 2008-10-29 17:03:35 UTC (rev 11743)
18 @@ -9970,6 +9970,7 @@
19 # Since config.setcpv() isn't guaranteed to call config.reset() due to
20 # performance reasons, call it here to make sure all settings from the
21 # previous package get flushed out (such as PORTAGE_LOG_FILE).
22 + temp_settings.reload()
23 temp_settings.reset()
24 return temp_settings
25
26
27 Modified: main/trunk/pym/portage/__init__.py
28 ===================================================================
29 --- main/trunk/pym/portage/__init__.py 2008-10-29 00:07:34 UTC (rev 11742)
30 +++ main/trunk/pym/portage/__init__.py 2008-10-29 17:03:35 UTC (rev 11743)
31 @@ -1939,19 +1939,33 @@
32
33 if self.mycpv == mycpv:
34 return
35 - ebuild_phase = self.get("EBUILD_PHASE")
36 has_changed = False
37 self.mycpv = mycpv
38 + cat, pf = catsplit(mycpv)
39 cp = dep_getkey(mycpv)
40 cpv_slot = self.mycpv
41 pkginternaluse = ""
42 iuse = ""
43 + env_configdict = self.configdict["env"]
44 + pkg_configdict = self.configdict["pkg"]
45 + previous_iuse = pkg_configdict.get("IUSE")
46 + for k in ("CATEGORY", "PKGUSE", "PF", "PORTAGE_USE"):
47 + env_configdict.pop(k, None)
48 + pkg_configdict["CATEGORY"] = cat
49 + pkg_configdict["PF"] = pf
50 if mydb:
51 if not hasattr(mydb, "aux_get"):
52 - slot = mydb["SLOT"]
53 - iuse = mydb["IUSE"]
54 + pkg_configdict.update(mydb)
55 else:
56 - slot, iuse = mydb.aux_get(self.mycpv, ["SLOT", "IUSE"])
57 + aux_keys = [k for k in auxdbkeys \
58 + if not k.startswith("UNUSED_")]
59 + for k, v in izip(aux_keys, mydb.aux_get(self.mycpv, aux_keys)):
60 + pkg_configdict[k] = v
61 + for k in pkg_configdict:
62 + if k != "USE":
63 + env_configdict.pop(k, None)
64 + slot = pkg_configdict["SLOT"]
65 + iuse = pkg_configdict["IUSE"]
66 if pkg is None:
67 cpv_slot = "%s:%s" % (self.mycpv, slot)
68 else:
69 @@ -2046,22 +2060,13 @@
70 has_changed = True
71 self.configdict["pkg"]["PKGUSE"] = self.puse[:] # For saving to PUSE file
72 self.configdict["pkg"]["USE"] = self.puse[:] # this gets appended to USE
73 - previous_iuse = self.configdict["pkg"].get("IUSE")
74 - self.configdict["pkg"]["IUSE"] = iuse
75
76 - # Always set known good values for these variables, since
77 - # corruption of these can cause problems:
78 - cat, pf = catsplit(self.mycpv)
79 - self.configdict["pkg"]["CATEGORY"] = cat
80 - self.configdict["pkg"]["PF"] = pf
81 -
82 if has_changed:
83 self.reset(keeping_pkg=1,use_cache=use_cache)
84
85 - # If this is not an ebuild phase and reset() has not been called,
86 - # it's safe to return early here if IUSE has not changed.
87 - if not (has_changed or ebuild_phase) and \
88 - previous_iuse == iuse:
89 + # If reset() has not been called, it's safe to return
90 + # early if IUSE has not changed.
91 + if not has_changed and previous_iuse == iuse:
92 return
93
94 # Filter out USE flags that aren't part of IUSE. This has to
95 @@ -2079,7 +2084,7 @@
96 self.configdict["pkg"]["PORTAGE_IUSE"] = regex
97
98 ebuild_force_test = self.get("EBUILD_FORCE_TEST") == "1"
99 - if ebuild_force_test and ebuild_phase and \
100 + if ebuild_force_test and \
101 not hasattr(self, "_ebuild_force_test_msg_shown"):
102 self._ebuild_force_test_msg_shown = True
103 writemsg("Forcing test.\n", noiselevel=-1)
104 @@ -4665,12 +4670,7 @@
105 # so that the caller can override it.
106 tmpdir = mysettings["PORTAGE_TMPDIR"]
107
108 - # This variable is a signal to setcpv where it triggers
109 - # filtering of USE for the ebuild environment.
110 - mysettings["EBUILD_PHASE"] = mydo
111 - mysettings.backup_changes("EBUILD_PHASE")
112 -
113 - if mydo != "depend":
114 + if mydo != "depend" and mycpv != mysettings.mycpv:
115 """For performance reasons, setcpv only triggers reset when it
116 detects a package-specific change in config. For the ebuild
117 environment, a reset call is forced in order to ensure that the
118 @@ -4732,18 +4732,17 @@
119 mysettings["PORTAGE_QUIET"] = "1"
120
121 if mydo != "depend":
122 - eapi, mysettings["INHERITED"], mysettings["SLOT"], mysettings["RESTRICT"] = \
123 - mydbapi.aux_get(mycpv, ["EAPI", "INHERITED", "SLOT", "RESTRICT"])
124 + # Metadata vars such as EAPI and RESTRICT are
125 + # set by the above config.setcpv() call.
126 + eapi = mysettings["EAPI"]
127 if not eapi_is_supported(eapi):
128 # can't do anything with this.
129 raise portage.exception.UnsupportedAPIException(mycpv, eapi)
130 - mysettings.pop("EAPI", None)
131 - mysettings.configdict["pkg"]["EAPI"] = eapi
132 try:
133 mysettings["PORTAGE_RESTRICT"] = " ".join(flatten(
134 portage.dep.use_reduce(portage.dep.paren_reduce(
135 - mysettings.get("RESTRICT","")),
136 - uselist=mysettings.get("USE","").split())))
137 + mysettings["RESTRICT"]),
138 + uselist=mysettings["PORTAGE_USE"].split())))
139 except portage.exception.InvalidDependString:
140 # RESTRICT is validated again inside doebuild, so let this go
141 mysettings["PORTAGE_RESTRICT"] = ""
142 @@ -5603,20 +5602,35 @@
143
144 mycpv = "/".join((mysettings["CATEGORY"], mysettings["PF"]))
145
146 - # Make sure we get the correct tree in case there are overlays.
147 - mytree = os.path.realpath(
148 - os.path.dirname(os.path.dirname(mysettings["O"])))
149 - useflags = mysettings["PORTAGE_USE"].split()
150 - try:
151 - alist = mydbapi.getFetchMap(mycpv, useflags=useflags, mytree=mytree)
152 - aalist = mydbapi.getFetchMap(mycpv, mytree=mytree)
153 - except portage.exception.InvalidDependString, e:
154 - writemsg("!!! %s\n" % str(e), noiselevel=-1)
155 - writemsg("!!! Invalid SRC_URI for '%s'.\n" % mycpv, noiselevel=-1)
156 - del e
157 - return 1
158 - mysettings["A"] = " ".join(alist)
159 - mysettings["AA"] = " ".join(aalist)
160 + emerge_skip_distfiles = returnpid
161 + # Only try and fetch the files if we are going to need them ...
162 + # otherwise, if user has FEATURES=noauto and they run `ebuild clean
163 + # unpack compile install`, we will try and fetch 4 times :/
164 + need_distfiles = not emerge_skip_distfiles and \
165 + (mydo in ("fetch", "unpack") or \
166 + mydo not in ("digest", "manifest") and "noauto" not in features)
167 + alist = mysettings.configdict["pkg"].get("A")
168 + aalist = mysettings.configdict["pkg"].get("AA")
169 + if need_distfiles or alist is None or aalist is None:
170 + # Make sure we get the correct tree in case there are overlays.
171 + mytree = os.path.realpath(
172 + os.path.dirname(os.path.dirname(mysettings["O"])))
173 + useflags = mysettings["PORTAGE_USE"].split()
174 + try:
175 + alist = mydbapi.getFetchMap(mycpv, useflags=useflags,
176 + mytree=mytree)
177 + aalist = mydbapi.getFetchMap(mycpv, mytree=mytree)
178 + except portage.exception.InvalidDependString, e:
179 + writemsg("!!! %s\n" % str(e), noiselevel=-1)
180 + writemsg("!!! Invalid SRC_URI for '%s'.\n" % mycpv,
181 + noiselevel=-1)
182 + del e
183 + return 1
184 + mysettings.configdict["pkg"]["A"] = " ".join(alist)
185 + mysettings.configdict["pkg"]["AA"] = " ".join(aalist)
186 + else:
187 + alist = set(alist.split())
188 + aalist = set(aalist.split())
189 if ("mirror" in features) or fetchall:
190 fetchme = aalist
191 checkme = aalist
192 @@ -5629,12 +5643,7 @@
193 # so do not check them again.
194 checkme = []
195
196 - # Only try and fetch the files if we are going to need them ...
197 - # otherwise, if user has FEATURES=noauto and they run `ebuild clean
198 - # unpack compile install`, we will try and fetch 4 times :/
199 - need_distfiles = (mydo in ("fetch", "unpack") or \
200 - mydo not in ("digest", "manifest") and "noauto" not in features)
201 - emerge_skip_distfiles = returnpid
202 +
203 if not emerge_skip_distfiles and \
204 need_distfiles and not fetch(
205 fetchme, mysettings, listonly=listonly, fetchonly=fetchonly):
206 @@ -5828,8 +5837,7 @@
207 misc_keys = ["LICENSE", "PROPERTIES", "PROVIDE", "RESTRICT", "SRC_URI"]
208 other_keys = ["SLOT"]
209 all_keys = dep_keys + misc_keys + other_keys
210 - metadata = dict(izip(all_keys,
211 - mydbapi.aux_get(mysettings.mycpv, all_keys)))
212 + metadata = mysettings.configdict["pkg"]
213
214 class FakeTree(object):
215 def __init__(self, mydb):