Gentoo Archives: gentoo-portage-dev

From: Ambroz Bizjak <ambrop7@×××××.com>
To: gentoo-portage-dev@l.g.o
Cc: Ambroz Bizjak <ambrop7@×××××.com>
Subject: [gentoo-portage-dev] [PATCH] Implement host dependencies and targetroot USE flag
Date: Mon, 24 Sep 2012 03:17:35
Message-Id: 1348450713-20768-2-git-send-email-ambrop7@gmail.com
In Reply to: [gentoo-portage-dev] [PATCH] Implement host dependencies and targetroot USE flag by Ambroz Bizjak
1 ---
2 bin/ebuild.sh | 30 +++++++++++++++-----
3 pym/_emerge/depgraph.py | 55 +++++++++++++++++++++---------------
4 pym/_emerge/main.py | 1 -
5 pym/portage/__init__.py | 4 +--
6 pym/portage/dbapi/bintree.py | 6 ++--
7 pym/portage/dbapi/porttree.py | 2 +-
8 pym/portage/dbapi/vartree.py | 1 +
9 pym/portage/eapi.py | 3 +-
10 pym/portage/package/ebuild/config.py | 11 +++++++-
11 9 files changed, 76 insertions(+), 37 deletions(-)
12
13 diff --git a/bin/ebuild.sh b/bin/ebuild.sh
14 index 79da2b5..a376d2f 100755
15 --- a/bin/ebuild.sh
16 +++ b/bin/ebuild.sh
17 @@ -215,6 +215,7 @@ inherit() {
18 local B_DEPEND
19 local B_RDEPEND
20 local B_PDEPEND
21 + local B_HDEPEND
22 while [ "$1" ]; do
23 location="${ECLASSDIR}/${1}.eclass"
24 olocation=""
25 @@ -257,20 +258,21 @@ inherit() {
26 EBUILD_OVERLAY_ECLASSES="${EBUILD_OVERLAY_ECLASSES} ${location}"
27 fi
28
29 - #We need to back up the value of DEPEND and RDEPEND to B_DEPEND and B_RDEPEND
30 + #We need to back up the values of *DEPEND to B_*DEPEND
31 #(if set).. and then restore them after the inherit call.
32
33 #turn off glob expansion
34 set -f
35
36 # Retain the old data and restore it later.
37 - unset B_IUSE B_REQUIRED_USE B_DEPEND B_RDEPEND B_PDEPEND
38 + unset B_IUSE B_REQUIRED_USE B_DEPEND B_RDEPEND B_PDEPEND B_HDEPEND
39 [ "${IUSE+set}" = set ] && B_IUSE="${IUSE}"
40 [ "${REQUIRED_USE+set}" = set ] && B_REQUIRED_USE="${REQUIRED_USE}"
41 [ "${DEPEND+set}" = set ] && B_DEPEND="${DEPEND}"
42 [ "${RDEPEND+set}" = set ] && B_RDEPEND="${RDEPEND}"
43 [ "${PDEPEND+set}" = set ] && B_PDEPEND="${PDEPEND}"
44 - unset IUSE REQUIRED_USE DEPEND RDEPEND PDEPEND
45 + [ "${HDEPEND+set}" = set ] && B_HDEPEND="${HDEPEND}"
46 + unset IUSE REQUIRED_USE DEPEND RDEPEND PDEPEND HDEPEND
47 #turn on glob expansion
48 set +f
49
50 @@ -286,6 +288,7 @@ inherit() {
51 [ "${DEPEND+set}" = set ] && E_DEPEND+="${E_DEPEND:+ }${DEPEND}"
52 [ "${RDEPEND+set}" = set ] && E_RDEPEND+="${E_RDEPEND:+ }${RDEPEND}"
53 [ "${PDEPEND+set}" = set ] && E_PDEPEND+="${E_PDEPEND:+ }${PDEPEND}"
54 + [ "${HDEPEND+set}" = set ] && E_HDEPEND+="${E_HDEPEND:+ }${HDEPEND}"
55
56 [ "${B_IUSE+set}" = set ] && IUSE="${B_IUSE}"
57 [ "${B_IUSE+set}" = set ] || unset IUSE
58 @@ -302,6 +305,9 @@ inherit() {
59 [ "${B_PDEPEND+set}" = set ] && PDEPEND="${B_PDEPEND}"
60 [ "${B_PDEPEND+set}" = set ] || unset PDEPEND
61
62 + [ "${B_HDEPEND+set}" = set ] && HDEPEND="${B_HDEPEND}"
63 + [ "${B_HDEPEND+set}" = set ] || unset HDEPEND
64 +
65 #turn on glob expansion
66 set +f
67
68 @@ -528,8 +534,9 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then
69 # In order to ensure correct interaction between ebuilds and
70 # eclasses, they need to be unset before this process of
71 # interaction begins.
72 - unset EAPI DEPEND RDEPEND PDEPEND INHERITED IUSE REQUIRED_USE \
73 - ECLASS E_IUSE E_REQUIRED_USE E_DEPEND E_RDEPEND E_PDEPEND
74 + unset EAPI DEPEND RDEPEND PDEPEND HDEPEND INHERITED IUSE REQUIRED_USE \
75 + ECLASS E_IUSE E_REQUIRED_USE E_DEPEND E_RDEPEND E_PDEPEND \
76 + E_HDEPEND
77
78 if [[ $PORTAGE_DEBUG != 1 || ${-/x/} != $- ]] ; then
79 source "$EBUILD" || die "error sourcing ebuild"
80 @@ -560,9 +567,10 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then
81 DEPEND+="${DEPEND:+ }${E_DEPEND}"
82 RDEPEND+="${RDEPEND:+ }${E_RDEPEND}"
83 PDEPEND+="${PDEPEND:+ }${E_PDEPEND}"
84 + HDEPEND+="${HDEPEND:+ }${E_HDEPEND}"
85 REQUIRED_USE+="${REQUIRED_USE:+ }${E_REQUIRED_USE}"
86
87 - unset ECLASS E_IUSE E_REQUIRED_USE E_DEPEND E_RDEPEND E_PDEPEND \
88 + unset ECLASS E_IUSE E_REQUIRED_USE E_DEPEND E_RDEPEND E_PDEPEND E_HDEPEND \
89 __INHERITED_QA_CACHE
90
91 # alphabetically ordered by $EBUILD_PHASE value
92 @@ -664,9 +672,17 @@ if [[ $EBUILD_PHASE = depend ]] ; then
93
94 auxdbkeys="DEPEND RDEPEND SLOT SRC_URI RESTRICT HOMEPAGE LICENSE
95 DESCRIPTION KEYWORDS INHERITED IUSE REQUIRED_USE PDEPEND PROVIDE EAPI
96 - PROPERTIES DEFINED_PHASES UNUSED_05 UNUSED_04
97 + PROPERTIES DEFINED_PHASES HDEPEND UNUSED_04
98 UNUSED_03 UNUSED_02 UNUSED_01"
99
100 + case "$EAPI" in
101 + 5-hdepend)
102 + ;;
103 + *)
104 + unset HDEPEND
105 + ;;
106 + esac
107 +
108 # The extra $(echo) commands remove newlines.
109 if [ -n "${dbkey}" ] ; then
110 > "${dbkey}"
111 diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
112 index 9da202c..5407077 100644
113 --- a/pym/_emerge/depgraph.py
114 +++ b/pym/_emerge/depgraph.py
115 @@ -504,7 +504,7 @@ class depgraph(object):
116
117 pkg_tree_map = RootConfig.pkg_tree_map
118
119 - _dep_keys = ["DEPEND", "RDEPEND", "PDEPEND"]
120 + _dep_keys = ["DEPEND", "RDEPEND", "PDEPEND", "HDEPEND"]
121
122 def __init__(self, settings, trees, myopts, myparams, spinner,
123 frozen_config=None, backtrack_parameters=BacktrackParameter(), allow_backtracking=False):
124 @@ -537,10 +537,6 @@ class depgraph(object):
125 preload_installed_pkgs = \
126 "--nodeps" not in self._frozen_config.myopts
127
128 - if self._frozen_config.myopts.get("--root-deps") is not None and \
129 - myroot != self._frozen_config.target_root:
130 - continue
131 -
132 fake_vartree = self._frozen_config.trees[myroot]["vartree"]
133 if not fake_vartree.dbapi:
134 # This needs to be called for the first depgraph, but not for
135 @@ -1685,7 +1681,7 @@ class depgraph(object):
136 removal_action = "remove" in self._dynamic_config.myparams
137
138 edepend={}
139 - depkeys = ["DEPEND","RDEPEND","PDEPEND"]
140 + depkeys = ["DEPEND","RDEPEND","PDEPEND","HDEPEND"]
141 for k in depkeys:
142 edepend[k] = metadata[k]
143
144 @@ -1713,31 +1709,44 @@ class depgraph(object):
145 # Removal actions never traverse ignored buildtime
146 # dependencies, so it's safe to discard them early.
147 edepend["DEPEND"] = ""
148 + edepend["HDEPEND"] = ""
149 ignore_build_time_deps = True
150
151 + ignore_depend_deps = ignore_build_time_deps
152 + ignore_hdepend_deps = ignore_build_time_deps
153 +
154 if removal_action:
155 depend_root = myroot
156 else:
157 - depend_root = self._frozen_config._running_root.root
158 - root_deps = self._frozen_config.myopts.get("--root-deps")
159 - if root_deps is not None:
160 - if root_deps is True:
161 - depend_root = myroot
162 - elif root_deps == "rdeps":
163 - ignore_build_time_deps = True
164 + if pkg.metadata['EAPI'] == "5-hdepend":
165 + depend_root = myroot
166 + else:
167 + depend_root = self._frozen_config._running_root.root
168 + root_deps = self._frozen_config.myopts.get("--root-deps")
169 + if root_deps is not None:
170 + if root_deps is True:
171 + depend_root = myroot
172 + elif root_deps == "rdeps":
173 + ignore_depend_deps = True
174
175 # If rebuild mode is not enabled, it's safe to discard ignored
176 # build-time dependencies. If you want these deps to be traversed
177 # in "complete" mode then you need to specify --with-bdeps=y.
178 - if ignore_build_time_deps and \
179 - not self._rebuild.rebuild:
180 - edepend["DEPEND"] = ""
181 -
182 + if not self._rebuild.rebuild:
183 + if ignore_depend_deps:
184 + edepend["DEPEND"] = ""
185 + if ignore_hdepend_deps:
186 + edepend["HDEPEND"] = ""
187 +
188 deps = (
189 (depend_root, edepend["DEPEND"],
190 self._priority(buildtime=True,
191 - optional=(pkg.built or ignore_build_time_deps),
192 - ignored=ignore_build_time_deps)),
193 + optional=(pkg.built or ignore_depend_deps),
194 + ignored=ignore_depend_deps)),
195 + (self._frozen_config._running_root.root, edepend["HDEPEND"],
196 + self._priority(buildtime=True,
197 + optional=(pkg.built or ignore_hdepend_deps),
198 + ignored=ignore_hdepend_deps)),
199 (myroot, edepend["RDEPEND"],
200 self._priority(runtime=True)),
201 (myroot, edepend["PDEPEND"],
202 @@ -2838,7 +2847,7 @@ class depgraph(object):
203 return [pkg.slot_atom for pkg in greedy_pkgs]
204
205 blockers = {}
206 - blocker_dep_keys = ["DEPEND", "PDEPEND", "RDEPEND"]
207 + blocker_dep_keys = ["DEPEND", "PDEPEND", "RDEPEND", "HDEPEND"]
208 for pkg in greedy_pkgs + [highest_pkg]:
209 dep_str = " ".join(pkg.metadata[k] for k in blocker_dep_keys)
210 try:
211 @@ -3099,7 +3108,7 @@ class depgraph(object):
212
213 if target_atom is not None and isinstance(node, Package):
214 affecting_use = set()
215 - for dep_str in "DEPEND", "RDEPEND", "PDEPEND":
216 + for dep_str in "DEPEND", "RDEPEND", "PDEPEND", "HDEPEND":
217 try:
218 affecting_use.update(extract_affecting_use(
219 node.metadata[dep_str], target_atom,
220 @@ -3183,10 +3192,12 @@ class depgraph(object):
221 dep_strings.add(node.metadata["DEPEND"])
222 dep_strings.add(node.metadata["RDEPEND"])
223 dep_strings.add(node.metadata["PDEPEND"])
224 + dep_strings.add(node.metadata["HDEPEND"])
225 else:
226 for priority in priorities:
227 if priority.buildtime:
228 dep_strings.add(node.metadata["DEPEND"])
229 + dep_strings.add(node.metadata["HDEPEND"])
230 if priority.runtime:
231 dep_strings.add(node.metadata["RDEPEND"])
232 if priority.runtime_post:
233 @@ -4129,7 +4140,7 @@ class depgraph(object):
234 if pkg not in self._dynamic_config.digraph.nodes:
235 return False
236
237 - for key in "DEPEND", "RDEPEND", "PDEPEND", "LICENSE":
238 + for key in "DEPEND", "RDEPEND", "PDEPEND", "HDEPEND", "LICENSE":
239 dep = pkg.metadata[key]
240 old_val = set(portage.dep.use_reduce(dep, pkg.use.enabled, is_valid_flag=pkg.iuse.is_valid_flag, flat=True))
241 new_val = set(portage.dep.use_reduce(dep, new_use, is_valid_flag=pkg.iuse.is_valid_flag, flat=True))
242 diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
243 index d19b795..c3e9646 100644
244 --- a/pym/_emerge/main.py
245 +++ b/pym/_emerge/main.py
246 @@ -977,7 +977,6 @@ def parse_opts(tmpcmdline, silent=False):
247 "type" : "choice",
248 "choices" : true_y_or_n
249 },
250 -
251 }
252
253 from optparse import OptionParser
254 diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
255 index 30c7e72..695f1ea 100644
256 --- a/pym/portage/__init__.py
257 +++ b/pym/portage/__init__.py
258 @@ -414,7 +414,7 @@ def abssymlink(symlink, target=None):
259
260 _doebuild_manifest_exempt_depend = 0
261
262 -_testing_eapis = frozenset(["4-python", "4-slot-abi", "5-progress"])
263 +_testing_eapis = frozenset(["4-python", "4-slot-abi", "5-progress", "5-hdepend"])
264 _deprecated_eapis = frozenset(["4_pre1", "3_pre2", "3_pre1", "5_pre1", "5_pre2"])
265
266 def _eapi_is_deprecated(eapi):
267 @@ -472,7 +472,7 @@ auxdbkeys = (
268 'RESTRICT', 'HOMEPAGE', 'LICENSE', 'DESCRIPTION',
269 'KEYWORDS', 'INHERITED', 'IUSE', 'REQUIRED_USE',
270 'PDEPEND', 'PROVIDE', 'EAPI',
271 - 'PROPERTIES', 'DEFINED_PHASES', 'UNUSED_05', 'UNUSED_04',
272 + 'PROPERTIES', 'DEFINED_PHASES', 'HDEPEND', 'UNUSED_04',
273 'UNUSED_03', 'UNUSED_02', 'UNUSED_01',
274 )
275 auxdbkeylen=len(auxdbkeys)
276 diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
277 index 7f09436..921f51d 100644
278 --- a/pym/portage/dbapi/bintree.py
279 +++ b/pym/portage/dbapi/bintree.py
280 @@ -75,6 +75,7 @@ class bindbapi(fakedbapi):
281 ["BUILD_TIME", "CHOST", "DEPEND", "EAPI", "IUSE", "KEYWORDS",
282 "LICENSE", "PDEPEND", "PROPERTIES", "PROVIDE",
283 "RDEPEND", "repository", "RESTRICT", "SLOT", "USE", "DEFINED_PHASES",
284 + "HDEPEND",
285 ])
286 self._aux_cache_slot_dict = slot_dict_class(self._aux_cache_keys)
287 self._aux_cache = {}
288 @@ -304,11 +305,11 @@ class binarytree(object):
289 ["BUILD_TIME", "CHOST", "DEPEND", "DESCRIPTION", "EAPI",
290 "IUSE", "KEYWORDS", "LICENSE", "PDEPEND", "PROPERTIES",
291 "PROVIDE", "RDEPEND", "repository", "SLOT", "USE", "DEFINED_PHASES",
292 - "BASE_URI"]
293 + "BASE_URI", "HDEPEND"]
294 self._pkgindex_aux_keys = list(self._pkgindex_aux_keys)
295 self._pkgindex_use_evaluated_keys = \
296 ("LICENSE", "RDEPEND", "DEPEND",
297 - "PDEPEND", "PROPERTIES", "PROVIDE")
298 + "PDEPEND", "PROPERTIES", "PROVIDE", "HDEPEND")
299 self._pkgindex_header_keys = set([
300 "ACCEPT_KEYWORDS", "ACCEPT_LICENSE",
301 "ACCEPT_PROPERTIES", "CBUILD",
302 @@ -330,6 +331,7 @@ class binarytree(object):
303 "SLOT" : "0",
304 "USE" : "",
305 "DEFINED_PHASES" : "",
306 + "HDEPEND" : "",
307 }
308 self._pkgindex_inherited_keys = ["CHOST", "repository"]
309
310 diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py
311 index 0cb290f..b6b3d00 100644
312 --- a/pym/portage/dbapi/porttree.py
313 +++ b/pym/portage/dbapi/porttree.py
314 @@ -189,7 +189,7 @@ class portdbapi(dbapi):
315 self._aux_cache_keys = set(
316 ["DEPEND", "EAPI", "INHERITED", "IUSE", "KEYWORDS", "LICENSE",
317 "PDEPEND", "PROPERTIES", "PROVIDE", "RDEPEND", "repository",
318 - "RESTRICT", "SLOT", "DEFINED_PHASES", "REQUIRED_USE"])
319 + "RESTRICT", "SLOT", "DEFINED_PHASES", "REQUIRED_USE", "HDEPEND"])
320
321 self._aux_cache = {}
322 self._broken_ebuilds = set()
323 diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
324 index 7d6d6a8..0822883 100644
325 --- a/pym/portage/dbapi/vartree.py
326 +++ b/pym/portage/dbapi/vartree.py
327 @@ -164,6 +164,7 @@ class vardbapi(dbapi):
328 "EAPI", "HOMEPAGE", "IUSE", "KEYWORDS",
329 "LICENSE", "PDEPEND", "PROPERTIES", "PROVIDE", "RDEPEND",
330 "repository", "RESTRICT" , "SLOT", "USE", "DEFINED_PHASES",
331 + "HDEPEND",
332 ])
333 self._aux_cache_obj = None
334 self._aux_cache_filename = os.path.join(self._eroot,
335 diff --git a/pym/portage/eapi.py b/pym/portage/eapi.py
336 index b12d81d..9452bd2 100644
337 --- a/pym/portage/eapi.py
338 +++ b/pym/portage/eapi.py
339 @@ -85,7 +85,7 @@ def eapi_allows_directories_on_profile_level_and_repository_level(eapi):
340
341 _eapi_attrs = collections.namedtuple('_eapi_attrs',
342 'dots_in_PN dots_in_use_flags exports_EBUILD_PHASE_FUNC '
343 - 'feature_flag_test iuse_defaults iuse_effective '
344 + 'feature_flag_test feature_flag_targetroot iuse_defaults iuse_effective '
345 'repo_deps required_use required_use_at_most_one_of slot_operator slot_deps '
346 'src_uri_arrows strong_blocks use_deps use_dep_defaults')
347
348 @@ -112,6 +112,7 @@ def _get_eapi_attrs(eapi):
349 dots_in_use_flags = (eapi is None or eapi_allows_dots_in_use_flags(eapi)),
350 exports_EBUILD_PHASE_FUNC = (eapi is None or eapi_exports_EBUILD_PHASE_FUNC(eapi)),
351 feature_flag_test = True,
352 + feature_flag_targetroot = eapi in ("5-hdepend",),
353 iuse_defaults = (eapi is None or eapi_has_iuse_defaults(eapi)),
354 iuse_effective = (eapi is not None and eapi_has_iuse_effective(eapi)),
355 repo_deps = (eapi is None or eapi_has_repo_deps(eapi)),
356 diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
357 index 894d14c..f7399bb 100644
358 --- a/pym/portage/package/ebuild/config.py
359 +++ b/pym/portage/package/ebuild/config.py
360 @@ -63,7 +63,7 @@ if sys.hexversion >= 0x3000000:
361 _feature_flags_cache = {}
362
363 def _get_feature_flags(eapi_attrs):
364 - cache_key = (eapi_attrs.feature_flag_test,)
365 + cache_key = (eapi_attrs.feature_flag_test, eapi_attrs.feature_flag_targetroot)
366 flags = _feature_flags_cache.get(cache_key)
367 if flags is not None:
368 return flags
369 @@ -71,6 +71,8 @@ def _get_feature_flags(eapi_attrs):
370 flags = []
371 if eapi_attrs.feature_flag_test:
372 flags.append("test")
373 + if eapi_attrs.feature_flag_targetroot:
374 + flags.append("targetroot")
375
376 flags = frozenset(flags)
377 _feature_flags_cache[cache_key] = flags
378 @@ -1503,6 +1505,13 @@ class config(object):
379 self.usemask = \
380 frozenset(x for x in self.usemask if x != "test")
381
382 + if ("targetroot" in explicit_iuse or iuse_implicit_match("targetroot")) and \
383 + eapi == "5-hdepend":
384 + if self["ROOT"] != "/":
385 + use.add("targetroot")
386 + else:
387 + use.discard("targetroot")
388 +
389 # Allow _* flags from USE_EXPAND wildcards to pass through here.
390 use.difference_update([x for x in use \
391 if (x not in explicit_iuse and \
392 --
393 1.7.12