1 |
commit: d8d47bf451bb3fd6bce1cdb035a5f12253f5a167 |
2 |
Author: James Le Cuirot <chewi <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Sep 30 20:45:54 2017 +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=d8d47bf4 |
7 |
|
8 |
Export BROOT to ebuild env in EAPI 7 |
9 |
|
10 |
Export the BROOT variable corresponding to the location where BDEPEND |
11 |
are installed. |
12 |
|
13 |
Bug: https://bugs.gentoo.org/317337 |
14 |
|
15 |
bin/eapi.sh | 4 ++++ |
16 |
bin/ebuild.sh | 3 +++ |
17 |
bin/phase-functions.sh | 3 +++ |
18 |
man/ebuild.5 | 6 ++++++ |
19 |
pym/portage/eapi.py | 7 ++++++- |
20 |
pym/portage/package/ebuild/_config/LocationsManager.py | 4 ++++ |
21 |
pym/portage/package/ebuild/_config/special_env_vars.py | 4 ++-- |
22 |
pym/portage/package/ebuild/config.py | 10 +++++++++- |
23 |
repoman/cnf/qa_data/qa_data.yaml | 2 +- |
24 |
repoman/man/repoman.1 | 2 +- |
25 |
.../pym/repoman/modules/linechecks/assignment/assignment.py | 9 ++++++++- |
26 |
repoman/pym/repoman/modules/linechecks/quotes/quotes.py | 3 ++- |
27 |
12 files changed, 49 insertions(+), 8 deletions(-) |
28 |
|
29 |
diff --git a/bin/eapi.sh b/bin/eapi.sh |
30 |
index b4d8c9a90..3f4c9691b 100644 |
31 |
--- a/bin/eapi.sh |
32 |
+++ b/bin/eapi.sh |
33 |
@@ -30,6 +30,10 @@ ___eapi_has_prefix_variables() { |
34 |
[[ ! ${1-${EAPI-0}} =~ ^(0|1|2)$ || " ${FEATURES} " == *" force-prefix "* ]] |
35 |
} |
36 |
|
37 |
+___eapi_has_BROOT() { |
38 |
+ [[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress|6)$ ]] |
39 |
+} |
40 |
+ |
41 |
___eapi_has_SYSROOT() { |
42 |
[[ ! ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress|6)$ ]] |
43 |
} |
44 |
|
45 |
diff --git a/bin/ebuild.sh b/bin/ebuild.sh |
46 |
index 11441bfb2..98ed570c2 100755 |
47 |
--- a/bin/ebuild.sh |
48 |
+++ b/bin/ebuild.sh |
49 |
@@ -769,6 +769,9 @@ else |
50 |
if ___eapi_has_prefix_variables; then |
51 |
declare -r ED EPREFIX EROOT |
52 |
fi |
53 |
+ if ___eapi_has_BROOT; then |
54 |
+ declare -r BROOT |
55 |
+ fi |
56 |
|
57 |
# If ${EBUILD_FORCE_TEST} == 1 and USE came from ${T}/environment |
58 |
# then it might not have USE=test like it's supposed to here. |
59 |
|
60 |
diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh |
61 |
index 1e096cddc..1f9faaa41 100644 |
62 |
--- a/bin/phase-functions.sh |
63 |
+++ b/bin/phase-functions.sh |
64 |
@@ -100,6 +100,9 @@ __filter_readonly_variables() { |
65 |
filtered_vars="$readonly_bash_vars $bash_misc_vars |
66 |
$PORTAGE_READONLY_VARS $misc_garbage_vars" |
67 |
|
68 |
+ if ___eapi_has_BROOT; then |
69 |
+ filtered_vars+=" BROOT" |
70 |
+ fi |
71 |
if ___eapi_has_SYSROOT; then |
72 |
filtered_vars+=" SYSROOT" |
73 |
fi |
74 |
|
75 |
diff --git a/man/ebuild.5 b/man/ebuild.5 |
76 |
index eb27d43bb..9f491dd73 100644 |
77 |
--- a/man/ebuild.5 |
78 |
+++ b/man/ebuild.5 |
79 |
@@ -527,6 +527,12 @@ Beginning with \fBEAPI 3\fR, contains |
80 |
"${ROOT%/}${EPREFIX}/" for convenience |
81 |
purposes. Do not modify this variable. |
82 |
.TP |
83 |
+.B BROOT\fR = \fI"${EPREFIX}" |
84 |
+Beginning with \fBEAPI 7\fR, the absolute path to the root directory |
85 |
+containing build dependencies satisfied by BDEPEND, typically |
86 |
+executable build tools. This includes any applicable offset prefix. Do |
87 |
+not modify this variable. |
88 |
+.TP |
89 |
.B DESCRIPTION\fR = \fI"A happy little package" |
90 |
Should contain a short description of the package. |
91 |
.TP |
92 |
|
93 |
diff --git a/pym/portage/eapi.py b/pym/portage/eapi.py |
94 |
index f34e19ac9..158d58243 100644 |
95 |
--- a/pym/portage/eapi.py |
96 |
+++ b/pym/portage/eapi.py |
97 |
@@ -123,13 +123,17 @@ def eapi_path_variables_end_with_trailing_slash(eapi): |
98 |
return eapi in ("0", "1", "2", "3", "4", "4-python", "4-slot-abi", |
99 |
"5", "5-progress", "6") |
100 |
|
101 |
+def eapi_has_broot(eapi): |
102 |
+ return eapi not in ("0", "1", "2", "3", "4", "4-python", "4-slot-abi", |
103 |
+ "5", "5-progress", "5-hdepend", "6") |
104 |
+ |
105 |
def eapi_has_sysroot(eapi): |
106 |
return eapi not in ("0", "1", "2", "3", "4", "4-python", "4-slot-abi", |
107 |
"5", "5-progress", "5-hdepend", "6") |
108 |
|
109 |
_eapi_attrs = collections.namedtuple('_eapi_attrs', |
110 |
'allows_package_provided ' |
111 |
- 'bdepend dots_in_PN dots_in_use_flags exports_EBUILD_PHASE_FUNC ' |
112 |
+ 'bdepend broot dots_in_PN dots_in_use_flags exports_EBUILD_PHASE_FUNC ' |
113 |
'exports_PORTDIR exports_ECLASSDIR ' |
114 |
'feature_flag_test feature_flag_targetroot ' |
115 |
'hdepend iuse_defaults iuse_effective posixish_locale ' |
116 |
@@ -159,6 +163,7 @@ def _get_eapi_attrs(eapi): |
117 |
eapi_attrs = _eapi_attrs( |
118 |
allows_package_provided=(eapi is None or eapi_allows_package_provided(eapi)), |
119 |
bdepend = (eapi is not None and eapi_has_bdepend(eapi)), |
120 |
+ broot = (eapi is None or eapi_has_broot(eapi)), |
121 |
dots_in_PN = (eapi is None or eapi_allows_dots_in_PN(eapi)), |
122 |
dots_in_use_flags = (eapi is None or eapi_allows_dots_in_use_flags(eapi)), |
123 |
empty_groups_always_true = (eapi is not None and eapi_empty_groups_always_true(eapi)), |
124 |
|
125 |
diff --git a/pym/portage/package/ebuild/_config/LocationsManager.py b/pym/portage/package/ebuild/_config/LocationsManager.py |
126 |
index 3a2697145..b57443ba7 100644 |
127 |
--- a/pym/portage/package/ebuild/_config/LocationsManager.py |
128 |
+++ b/pym/portage/package/ebuild/_config/LocationsManager.py |
129 |
@@ -73,6 +73,10 @@ class LocationsManager(object): |
130 |
|
131 |
self.esysroot = self.sysroot.rstrip(os.sep) + self.eprefix + os.sep |
132 |
|
133 |
+ # TODO: Set this via the constructor using |
134 |
+ # PORTAGE_OVERRIDE_EPREFIX. |
135 |
+ self.broot = portage.const.EPREFIX |
136 |
+ |
137 |
def load_profiles(self, repositories, known_repository_paths): |
138 |
known_repository_paths = set(os.path.realpath(x) |
139 |
for x in known_repository_paths) |
140 |
|
141 |
diff --git a/pym/portage/package/ebuild/_config/special_env_vars.py b/pym/portage/package/ebuild/_config/special_env_vars.py |
142 |
index 68770e237..3323ff064 100644 |
143 |
--- a/pym/portage/package/ebuild/_config/special_env_vars.py |
144 |
+++ b/pym/portage/package/ebuild/_config/special_env_vars.py |
145 |
@@ -14,7 +14,7 @@ import re |
146 |
# to enter the config instance from the external environment or |
147 |
# configuration files. |
148 |
env_blacklist = frozenset(( |
149 |
- "A", "AA", "BDEPEND", "CATEGORY", "DEPEND", "DESCRIPTION", |
150 |
+ "A", "AA", "BDEPEND", "BROOT", "CATEGORY", "DEPEND", "DESCRIPTION", |
151 |
"DOCS", "EAPI", |
152 |
"EBUILD_FORCE_TEST", "EBUILD_PHASE", |
153 |
"EBUILD_PHASE_FUNC", "EBUILD_SKIP_MANIFEST", |
154 |
@@ -42,7 +42,7 @@ environ_whitelist = [] |
155 |
# environment in order to prevent sandbox from sourcing /etc/profile |
156 |
# in it's bashrc (causing major leakage). |
157 |
environ_whitelist += [ |
158 |
- "ACCEPT_LICENSE", "BASH_ENV", "BUILD_PREFIX", "COLUMNS", "D", |
159 |
+ "ACCEPT_LICENSE", "BASH_ENV", "BROOT", "BUILD_PREFIX", "COLUMNS", "D", |
160 |
"DISTDIR", "DOC_SYMLINKS_DIR", "EAPI", "EBUILD", |
161 |
"EBUILD_FORCE_TEST", |
162 |
"EBUILD_PHASE", "EBUILD_PHASE_FUNC", "ECLASSDIR", "ECLASS_DEPTH", "ED", |
163 |
|
164 |
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py |
165 |
index e7a047884..f9b257b86 100644 |
166 |
--- a/pym/portage/package/ebuild/config.py |
167 |
+++ b/pym/portage/package/ebuild/config.py |
168 |
@@ -346,6 +346,7 @@ class config(object): |
169 |
config_root = locations_manager.config_root |
170 |
sysroot = locations_manager.sysroot |
171 |
esysroot = locations_manager.esysroot |
172 |
+ broot = locations_manager.broot |
173 |
abs_user_config = locations_manager.abs_user_config |
174 |
make_conf_paths = [ |
175 |
os.path.join(config_root, 'etc', 'make.conf'), |
176 |
@@ -509,6 +510,7 @@ class config(object): |
177 |
self["EPREFIX"] = eprefix |
178 |
self["EROOT"] = eroot |
179 |
self["ESYSROOT"] = esysroot |
180 |
+ self["BROOT"] = broot |
181 |
known_repos = [] |
182 |
portdir = "" |
183 |
portdir_overlay = "" |
184 |
@@ -680,6 +682,8 @@ class config(object): |
185 |
self.backup_changes("EROOT") |
186 |
self["ESYSROOT"] = esysroot |
187 |
self.backup_changes("ESYSROOT") |
188 |
+ self["BROOT"] = broot |
189 |
+ self.backup_changes("BROOT") |
190 |
|
191 |
# The prefix of the running portage instance is used in the |
192 |
# ebuild environment to implement the --host-root option for |
193 |
@@ -2758,6 +2762,9 @@ class config(object): |
194 |
if not (src_phase and eapi_attrs.sysroot): |
195 |
mydict.pop("ESYSROOT", None) |
196 |
|
197 |
+ if not (src_phase and eapi_attrs.broot): |
198 |
+ mydict.pop("BROOT", None) |
199 |
+ |
200 |
# Prefix variables are supported beginning with EAPI 3, or when |
201 |
# force-prefix is in FEATURES, since older EAPIs would otherwise be |
202 |
# useless with prefix configurations. This brings compatibility with |
203 |
@@ -2806,7 +2813,8 @@ class config(object): |
204 |
mydict.pop("ECLASSDIR", None) |
205 |
|
206 |
if not eapi_attrs.path_variables_end_with_trailing_slash: |
207 |
- for v in ("D", "ED", "ROOT", "EROOT", "SYSROOT", "ESYSROOT"): |
208 |
+ for v in ("D", "ED", "ROOT", "EROOT", "SYSROOT", "ESYSROOT", |
209 |
+ "BROOT"): |
210 |
if v in mydict: |
211 |
mydict[v] = mydict[v].rstrip(os.path.sep) |
212 |
|
213 |
|
214 |
diff --git a/repoman/cnf/qa_data/qa_data.yaml b/repoman/cnf/qa_data/qa_data.yaml |
215 |
index 573cdb449..32994e013 100644 |
216 |
--- a/repoman/cnf/qa_data/qa_data.yaml |
217 |
+++ b/repoman/cnf/qa_data/qa_data.yaml |
218 |
@@ -128,7 +128,7 @@ qahelp: |
219 |
variable: |
220 |
invalidchar: "A variable contains an invalid character that is not part of the ASCII character set" |
221 |
readonly: "Assigning a readonly variable" |
222 |
- usedwithhelpers: "Ebuild uses D, ROOT, ED, EROOT or EPREFIX with helpers" |
223 |
+ usedwithhelpers: "Ebuild uses D, ROOT, BROOT, ED, EROOT or EPREFIX with helpers" |
224 |
virtual: |
225 |
suspect: "Ebuild contains a package that usually should be pulled via virtual/, not directly." |
226 |
wxwidgets: |
227 |
|
228 |
diff --git a/repoman/man/repoman.1 b/repoman/man/repoman.1 |
229 |
index c87146b61..01f37dd99 100644 |
230 |
--- a/repoman/man/repoman.1 |
231 |
+++ b/repoman/man/repoman.1 |
232 |
@@ -432,7 +432,7 @@ character set. |
233 |
Assigning a readonly variable |
234 |
.TP |
235 |
.B variable.usedwithhelpers |
236 |
-Ebuild uses D, ROOT, ED, EROOT or EPREFIX with helpers |
237 |
+Ebuild uses D, ROOT, BROOT, ED, EROOT or EPREFIX with helpers |
238 |
.TP |
239 |
.B virtual.suspect |
240 |
Ebuild contains a package that usually should be pulled via virtual/, |
241 |
|
242 |
diff --git a/repoman/pym/repoman/modules/linechecks/assignment/assignment.py b/repoman/pym/repoman/modules/linechecks/assignment/assignment.py |
243 |
index 496c9d092..33bef8a08 100644 |
244 |
--- a/repoman/pym/repoman/modules/linechecks/assignment/assignment.py |
245 |
+++ b/repoman/pym/repoman/modules/linechecks/assignment/assignment.py |
246 |
@@ -1,7 +1,7 @@ |
247 |
|
248 |
import re |
249 |
|
250 |
-from portage.eapi import eapi_supports_prefix |
251 |
+from portage.eapi import eapi_supports_prefix, eapi_has_broot |
252 |
from repoman.modules.linechecks.base import LineCheck |
253 |
|
254 |
|
255 |
@@ -29,3 +29,10 @@ class Eapi3EbuildAssignment(EbuildAssignment): |
256 |
def check_eapi(self, eapi): |
257 |
return eapi_supports_prefix(eapi) |
258 |
|
259 |
+class Eapi7EbuildAssignment(EbuildAssignment): |
260 |
+ """Ensure ebuilds don't assign to readonly EAPI 7-introduced variables.""" |
261 |
+ |
262 |
+ readonly_assignment = re.compile(r'\s*(export\s+)?BROOT=') |
263 |
+ |
264 |
+ def check_eapi(self, eapi): |
265 |
+ return eapi_has_broot(eapi) |
266 |
|
267 |
diff --git a/repoman/pym/repoman/modules/linechecks/quotes/quotes.py b/repoman/pym/repoman/modules/linechecks/quotes/quotes.py |
268 |
index 68c594e23..e5ea4d0ca 100644 |
269 |
--- a/repoman/pym/repoman/modules/linechecks/quotes/quotes.py |
270 |
+++ b/repoman/pym/repoman/modules/linechecks/quotes/quotes.py |
271 |
@@ -17,7 +17,8 @@ class EbuildQuote(LineCheck): |
272 |
r'(^$)|(^\s*#.*)|(^\s*\w+=.*)' + |
273 |
r'|(^\s*(' + "|".join(_ignored_commands) + r')\s+)') |
274 |
ignore_comment = False |
275 |
- var_names = ["D", "DISTDIR", "FILESDIR", "S", "T", "ROOT", "WORKDIR"] |
276 |
+ var_names = [ |
277 |
+ "D", "DISTDIR", "FILESDIR", "S", "T", "ROOT", "BROOT", "WORKDIR"] |
278 |
|
279 |
# EAPI=3/Prefix vars |
280 |
var_names += ["ED", "EPREFIX", "EROOT"] |