1 |
commit: a41dacf7926c0242678300a8e1770df84029e8a4 |
2 |
Author: James Le Cuirot <chewi <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Apr 23 21:49:43 2018 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue May 1 08:28:43 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=a41dacf7 |
7 |
|
8 |
Export SYSROOT and ESYSROOT in ebuild env in EAPI 7 |
9 |
|
10 |
SYSROOT is the new destination for DEPEND, however it must currently |
11 |
be equal either / or ROOT. This is partly to simplify the |
12 |
implementation and partly because supporting a third separate |
13 |
destination would not be of much practical benefit anyway. |
14 |
|
15 |
Bug: https://bugs.gentoo.org/317337 |
16 |
|
17 |
bin/eapi.sh | 4 ++++ |
18 |
bin/phase-functions.sh | 6 ++++++ |
19 |
pym/_emerge/actions.py | 2 +- |
20 |
pym/_emerge/depgraph.py | 4 +++- |
21 |
pym/portage/__init__.py | 6 +++--- |
22 |
pym/portage/_legacy_globals.py | 3 ++- |
23 |
pym/portage/eapi.py | 7 ++++++- |
24 |
.../package/ebuild/_config/LocationsManager.py | 19 +++++++++++++++-- |
25 |
pym/portage/package/ebuild/config.py | 24 +++++++++++++++++++--- |
26 |
9 files changed, 63 insertions(+), 12 deletions(-) |
27 |
|
28 |
diff --git a/bin/eapi.sh b/bin/eapi.sh |
29 |
index 40af7b776..b4d8c9a90 100644 |
30 |
--- a/bin/eapi.sh |
31 |
+++ b/bin/eapi.sh |
32 |
@@ -30,6 +30,10 @@ ___eapi_has_prefix_variables() { |
33 |
[[ ! ${1-${EAPI-0}} =~ ^(0|1|2)$ || " ${FEATURES} " == *" force-prefix "* ]] |
34 |
} |
35 |
|
36 |
+___eapi_has_SYSROOT() { |
37 |
+ [[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress|6)$ ]] |
38 |
+} |
39 |
+ |
40 |
___eapi_has_HDEPEND() { |
41 |
[[ ${1-${EAPI-0}} =~ ^(5-hdepend)$ ]] |
42 |
} |
43 |
|
44 |
diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh |
45 |
index 3de8d01b5..1e096cddc 100644 |
46 |
--- a/bin/phase-functions.sh |
47 |
+++ b/bin/phase-functions.sh |
48 |
@@ -100,10 +100,16 @@ __filter_readonly_variables() { |
49 |
filtered_vars="$readonly_bash_vars $bash_misc_vars |
50 |
$PORTAGE_READONLY_VARS $misc_garbage_vars" |
51 |
|
52 |
+ if ___eapi_has_SYSROOT; then |
53 |
+ filtered_vars+=" SYSROOT" |
54 |
+ fi |
55 |
# Don't filter/interfere with prefix variables unless they are |
56 |
# supported by the current EAPI. |
57 |
if ___eapi_has_prefix_variables; then |
58 |
filtered_vars+=" ED EPREFIX EROOT" |
59 |
+ if ___eapi_has_SYSROOT; then |
60 |
+ filtered_vars+=" ESYSROOT" |
61 |
+ fi |
62 |
fi |
63 |
if ___eapi_has_PORTDIR_ECLASSDIR; then |
64 |
filtered_vars+=" PORTDIR ECLASSDIR" |
65 |
|
66 |
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py |
67 |
index 1a289f523..70fb8d3b4 100644 |
68 |
--- a/pym/_emerge/actions.py |
69 |
+++ b/pym/_emerge/actions.py |
70 |
@@ -2438,7 +2438,7 @@ def load_emerge_config(emerge_config=None, env=None, **kargs): |
71 |
env = os.environ if env is None else env |
72 |
kwargs = {'env': env} |
73 |
for k, envvar in (("config_root", "PORTAGE_CONFIGROOT"), ("target_root", "ROOT"), |
74 |
- ("eprefix", "EPREFIX")): |
75 |
+ ("sysroot", "SYSROOT"), ("eprefix", "EPREFIX")): |
76 |
v = env.get(envvar) |
77 |
if v and v.strip(): |
78 |
kwargs[k] = v |
79 |
|
80 |
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py |
81 |
index 67f912f5e..fbd16ad98 100644 |
82 |
--- a/pym/_emerge/depgraph.py |
83 |
+++ b/pym/_emerge/depgraph.py |
84 |
@@ -3322,8 +3322,10 @@ class depgraph(object): |
85 |
if removal_action: |
86 |
depend_root = myroot |
87 |
else: |
88 |
- if eapi_attrs.bdepend or eapi_attrs.hdepend: |
89 |
+ if eapi_attrs.hdepend: |
90 |
depend_root = myroot |
91 |
+ elif eapi_attrs.bdepend: |
92 |
+ depend_root = pkg.root_config.settings["ESYSROOT"] |
93 |
else: |
94 |
depend_root = self._frozen_config._running_root.root |
95 |
root_deps = self._frozen_config.myopts.get("--root-deps") |
96 |
|
97 |
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py |
98 |
index 137351a69..15c404f6f 100644 |
99 |
--- a/pym/portage/__init__.py |
100 |
+++ b/pym/portage/__init__.py |
101 |
@@ -525,7 +525,7 @@ class _trees_dict(dict): |
102 |
self._target_eroot = None |
103 |
|
104 |
def create_trees(config_root=None, target_root=None, trees=None, env=None, |
105 |
- eprefix=None): |
106 |
+ sysroot=None, eprefix=None): |
107 |
|
108 |
if trees is None: |
109 |
trees = _trees_dict() |
110 |
@@ -538,7 +538,7 @@ def create_trees(config_root=None, target_root=None, trees=None, env=None, |
111 |
env = os.environ |
112 |
|
113 |
settings = config(config_root=config_root, target_root=target_root, |
114 |
- env=env, eprefix=eprefix) |
115 |
+ env=env, sysroot=sysroot, eprefix=eprefix) |
116 |
settings.lock() |
117 |
|
118 |
depcachedir = settings.get('PORTAGE_DEPCACHEDIR') |
119 |
@@ -562,7 +562,7 @@ def create_trees(config_root=None, target_root=None, trees=None, env=None, |
120 |
if depcachedir is not None: |
121 |
clean_env['PORTAGE_DEPCACHEDIR'] = depcachedir |
122 |
settings = config(config_root=None, target_root="/", |
123 |
- env=clean_env, eprefix=None) |
124 |
+ env=clean_env, sysroot="/", eprefix=None) |
125 |
settings.lock() |
126 |
trees._running_eroot = settings['EROOT'] |
127 |
myroots.append((settings['EROOT'], settings)) |
128 |
|
129 |
diff --git a/pym/portage/_legacy_globals.py b/pym/portage/_legacy_globals.py |
130 |
index f916cc66b..45113d150 100644 |
131 |
--- a/pym/portage/_legacy_globals.py |
132 |
+++ b/pym/portage/_legacy_globals.py |
133 |
@@ -28,7 +28,8 @@ def _get_legacy_global(name): |
134 |
|
135 |
kwargs = {} |
136 |
for k, envvar in (("config_root", "PORTAGE_CONFIGROOT"), |
137 |
- ("target_root", "ROOT"), ("eprefix", "EPREFIX")): |
138 |
+ ("target_root", "ROOT"), ("sysroot", "SYSROOT"), |
139 |
+ ("eprefix", "EPREFIX")): |
140 |
kwargs[k] = os.environ.get(envvar) |
141 |
|
142 |
portage._initializing_globals = True |
143 |
|
144 |
diff --git a/pym/portage/eapi.py b/pym/portage/eapi.py |
145 |
index b0f993a14..f34e19ac9 100644 |
146 |
--- a/pym/portage/eapi.py |
147 |
+++ b/pym/portage/eapi.py |
148 |
@@ -123,6 +123,10 @@ def eapi_path_variables_end_with_trailing_slash(eapi): |
149 |
return eapi in ("0", "1", "2", "3", "4", "4-python", "4-slot-abi", |
150 |
"5", "5-progress", "6") |
151 |
|
152 |
+def eapi_has_sysroot(eapi): |
153 |
+ return eapi not in ("0", "1", "2", "3", "4", "4-python", "4-slot-abi", |
154 |
+ "5", "5-progress", "5-hdepend", "6") |
155 |
+ |
156 |
_eapi_attrs = collections.namedtuple('_eapi_attrs', |
157 |
'allows_package_provided ' |
158 |
'bdepend dots_in_PN dots_in_use_flags exports_EBUILD_PHASE_FUNC ' |
159 |
@@ -132,7 +136,7 @@ _eapi_attrs = collections.namedtuple('_eapi_attrs', |
160 |
'path_variables_end_with_trailing_slash ' |
161 |
'repo_deps required_use required_use_at_most_one_of slot_operator slot_deps ' |
162 |
'src_uri_arrows strong_blocks use_deps use_dep_defaults ' |
163 |
- 'empty_groups_always_true') |
164 |
+ 'empty_groups_always_true sysroot') |
165 |
|
166 |
_eapi_attrs_cache = {} |
167 |
|
168 |
@@ -176,6 +180,7 @@ def _get_eapi_attrs(eapi): |
169 |
slot_operator = (eapi is None or eapi_has_slot_operator(eapi)), |
170 |
src_uri_arrows = (eapi is None or eapi_has_src_uri_arrows(eapi)), |
171 |
strong_blocks = (eapi is None or eapi_has_strong_blocks(eapi)), |
172 |
+ sysroot = (eapi is None or eapi_has_sysroot(eapi)), |
173 |
use_deps = (eapi is None or eapi_has_use_deps(eapi)), |
174 |
use_dep_defaults = (eapi is None or eapi_has_use_dep_defaults(eapi)) |
175 |
) |
176 |
|
177 |
diff --git a/pym/portage/package/ebuild/_config/LocationsManager.py b/pym/portage/package/ebuild/_config/LocationsManager.py |
178 |
index 55b8c089a..3a2697145 100644 |
179 |
--- a/pym/portage/package/ebuild/_config/LocationsManager.py |
180 |
+++ b/pym/portage/package/ebuild/_config/LocationsManager.py |
181 |
@@ -16,7 +16,7 @@ from portage import os, eapi_is_supported, _encodings, _unicode_encode |
182 |
from portage.const import CUSTOM_PROFILE_PATH, GLOBAL_CONFIG_PATH, \ |
183 |
PROFILE_PATH, USER_CONFIG_PATH |
184 |
from portage.eapi import eapi_allows_directories_on_profile_level_and_repository_level |
185 |
-from portage.exception import DirectoryNotFound, ParseError |
186 |
+from portage.exception import DirectoryNotFound, InvalidLocation, ParseError |
187 |
from portage.localization import _ |
188 |
from portage.util import ensure_dirs, grabfile, \ |
189 |
normalize_path, read_corresponding_eapi_file, shlex_split, writemsg |
190 |
@@ -40,12 +40,13 @@ _allow_parent_colon = frozenset( |
191 |
class LocationsManager(object): |
192 |
|
193 |
def __init__(self, config_root=None, eprefix=None, config_profile_path=None, local_config=True, \ |
194 |
- target_root=None): |
195 |
+ target_root=None, sysroot=None): |
196 |
self.user_profile_dir = None |
197 |
self._local_repo_conf_path = None |
198 |
self.eprefix = eprefix |
199 |
self.config_root = config_root |
200 |
self.target_root = target_root |
201 |
+ self.sysroot = sysroot |
202 |
self._user_config = local_config |
203 |
|
204 |
if self.eprefix is None: |
205 |
@@ -65,6 +66,13 @@ class LocationsManager(object): |
206 |
self.abs_user_config = os.path.join(self.config_root, USER_CONFIG_PATH) |
207 |
self.config_profile_path = config_profile_path |
208 |
|
209 |
+ if self.sysroot is None: |
210 |
+ self.sysroot = "/" |
211 |
+ else: |
212 |
+ self.sysroot = normalize_path(os.path.abspath(self.sysroot)).rstrip(os.sep) + os.sep |
213 |
+ |
214 |
+ self.esysroot = self.sysroot.rstrip(os.sep) + self.eprefix + os.sep |
215 |
+ |
216 |
def load_profiles(self, repositories, known_repository_paths): |
217 |
known_repository_paths = set(os.path.realpath(x) |
218 |
for x in known_repository_paths) |
219 |
@@ -298,6 +306,13 @@ class LocationsManager(object): |
220 |
self.target_root = normalize_path(os.path.abspath( |
221 |
self.target_root)).rstrip(os.path.sep) + os.path.sep |
222 |
|
223 |
+ if self.sysroot != "/" and self.sysroot != self.target_root: |
224 |
+ writemsg(_("!!! Error: SYSROOT (currently %s) must " |
225 |
+ "equal / or ROOT (currently %s).\n") % |
226 |
+ (self.sysroot, self.target_root), |
227 |
+ noiselevel=-1) |
228 |
+ raise InvalidLocation(self.sysroot) |
229 |
+ |
230 |
ensure_dirs(self.target_root) |
231 |
self._check_var_directory("ROOT", self.target_root) |
232 |
|
233 |
|
234 |
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py |
235 |
index 071385684..e7a047884 100644 |
236 |
--- a/pym/portage/package/ebuild/config.py |
237 |
+++ b/pym/portage/package/ebuild/config.py |
238 |
@@ -175,7 +175,7 @@ class config(object): |
239 |
|
240 |
def __init__(self, clone=None, mycpv=None, config_profile_path=None, |
241 |
config_incrementals=None, config_root=None, target_root=None, |
242 |
- eprefix=None, local_config=True, env=None, |
243 |
+ sysroot=None, eprefix=None, local_config=True, env=None, |
244 |
_unmatched_removal=False, repositories=None): |
245 |
""" |
246 |
@param clone: If provided, init will use deepcopy to copy by value the instance. |
247 |
@@ -193,6 +193,9 @@ class config(object): |
248 |
@param target_root: the target root, which typically corresponds to the |
249 |
value of the $ROOT env variable (default is /) |
250 |
@type target_root: String |
251 |
+ @param sysroot: the sysroot to build against, which typically corresponds |
252 |
+ to the value of the $SYSROOT env variable (default is /) |
253 |
+ @type sysroot: String |
254 |
@param eprefix: set the EPREFIX variable (default is portage.const.EPREFIX) |
255 |
@type eprefix: String |
256 |
@param local_config: Enables loading of local config (/etc/portage); used most by repoman to |
257 |
@@ -335,11 +338,14 @@ class config(object): |
258 |
|
259 |
locations_manager = LocationsManager(config_root=config_root, |
260 |
config_profile_path=config_profile_path, eprefix=eprefix, |
261 |
- local_config=local_config, target_root=target_root) |
262 |
+ local_config=local_config, target_root=target_root, |
263 |
+ sysroot=sysroot) |
264 |
self._locations_manager = locations_manager |
265 |
|
266 |
eprefix = locations_manager.eprefix |
267 |
config_root = locations_manager.config_root |
268 |
+ sysroot = locations_manager.sysroot |
269 |
+ esysroot = locations_manager.esysroot |
270 |
abs_user_config = locations_manager.abs_user_config |
271 |
make_conf_paths = [ |
272 |
os.path.join(config_root, 'etc', 'make.conf'), |
273 |
@@ -499,8 +505,10 @@ class config(object): |
274 |
#Loading Repositories |
275 |
self["PORTAGE_CONFIGROOT"] = config_root |
276 |
self["ROOT"] = target_root |
277 |
+ self["SYSROOT"] = sysroot |
278 |
self["EPREFIX"] = eprefix |
279 |
self["EROOT"] = eroot |
280 |
+ self["ESYSROOT"] = esysroot |
281 |
known_repos = [] |
282 |
portdir = "" |
283 |
portdir_overlay = "" |
284 |
@@ -664,10 +672,14 @@ class config(object): |
285 |
self.backup_changes("PORTAGE_CONFIGROOT") |
286 |
self["ROOT"] = target_root |
287 |
self.backup_changes("ROOT") |
288 |
+ self["SYSROOT"] = sysroot |
289 |
+ self.backup_changes("SYSROOT") |
290 |
self["EPREFIX"] = eprefix |
291 |
self.backup_changes("EPREFIX") |
292 |
self["EROOT"] = eroot |
293 |
self.backup_changes("EROOT") |
294 |
+ self["ESYSROOT"] = esysroot |
295 |
+ self.backup_changes("ESYSROOT") |
296 |
|
297 |
# The prefix of the running portage instance is used in the |
298 |
# ebuild environment to implement the --host-root option for |
299 |
@@ -2741,6 +2753,11 @@ class config(object): |
300 |
if not eapi_exports_merge_type(eapi): |
301 |
mydict.pop("MERGE_TYPE", None) |
302 |
|
303 |
+ src_phase = _phase_func_map.get(phase, '').startswith('src_') |
304 |
+ |
305 |
+ if not (src_phase and eapi_attrs.sysroot): |
306 |
+ mydict.pop("ESYSROOT", None) |
307 |
+ |
308 |
# Prefix variables are supported beginning with EAPI 3, or when |
309 |
# force-prefix is in FEATURES, since older EAPIs would otherwise be |
310 |
# useless with prefix configurations. This brings compatibility with |
311 |
@@ -2752,6 +2769,7 @@ class config(object): |
312 |
mydict.pop("ED", None) |
313 |
mydict.pop("EPREFIX", None) |
314 |
mydict.pop("EROOT", None) |
315 |
+ mydict.pop("ESYSROOT", None) |
316 |
|
317 |
if phase not in ("pretend", "setup", "preinst", "postinst") or \ |
318 |
not eapi_exports_replace_vars(eapi): |
319 |
@@ -2788,7 +2806,7 @@ class config(object): |
320 |
mydict.pop("ECLASSDIR", None) |
321 |
|
322 |
if not eapi_attrs.path_variables_end_with_trailing_slash: |
323 |
- for v in ("D", "ED", "ROOT", "EROOT"): |
324 |
+ for v in ("D", "ED", "ROOT", "EROOT", "SYSROOT", "ESYSROOT"): |
325 |
if v in mydict: |
326 |
mydict[v] = mydict[v].rstrip(os.path.sep) |