Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH 10/10] Ban DESTTREE/INSDESTTREE in EAPI 7
Date: Mon, 26 Feb 2018 16:01:38
Message-Id: 20180226155942.9148-11-mgorny@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH 00/10] EAPI 7, part one by "Michał Górny"
1 Ban the direct use of DESTTREE/INSDESTTREE in EAPI 7. Use new _E_*
2 helper variables for into/insinto.
3
4 Bug: https://bugs.gentoo.org/173630
5 ---
6 bin/eapi.sh | 4 ++++
7 bin/ebuild-helpers/dobin | 16 ++++++++++++----
8 bin/ebuild-helpers/doconfd | 4 ++--
9 bin/ebuild-helpers/doenvd | 4 ++--
10 bin/ebuild-helpers/doheader | 4 ++--
11 bin/ebuild-helpers/doins | 18 +++++++++++++-----
12 bin/ebuild-helpers/dolib | 10 +++++++++-
13 bin/ebuild-helpers/dolib.a | 10 +++++++++-
14 bin/ebuild-helpers/dolib.so | 10 +++++++++-
15 bin/ebuild-helpers/domo | 16 ++++++++++++----
16 bin/ebuild-helpers/dosbin | 16 ++++++++++++----
17 bin/phase-functions.sh | 11 ++++++++---
18 bin/phase-helpers.sh | 33 +++++++++++++++++++++++----------
19 bin/save-ebuild-env.sh | 4 ++--
20 14 files changed, 119 insertions(+), 41 deletions(-)
21
22 diff --git a/bin/eapi.sh b/bin/eapi.sh
23 index d8c487b69..309198be4 100644
24 --- a/bin/eapi.sh
25 +++ b/bin/eapi.sh
26 @@ -190,6 +190,10 @@ ___eapi_domo_respects_into() {
27 [[ ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress|6)$ ]]
28 }
29
30 +___eapi_has_DESTTREE_INSDESTTREE() {
31 + [[ ${1-${EAPI-0}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress|6)$ ]]
32 +}
33 +
34 # OTHERS
35
36 ___eapi_enables_failglob_in_global_scope() {
37 diff --git a/bin/ebuild-helpers/dobin b/bin/ebuild-helpers/dobin
38 index 9f4d73dc4..f43871f49 100755
39 --- a/bin/ebuild-helpers/dobin
40 +++ b/bin/ebuild-helpers/dobin
41 @@ -1,5 +1,5 @@
42 #!/bin/bash
43 -# Copyright 1999-2012 Gentoo Foundation
44 +# Copyright 1999-2018 Gentoo Foundation
45 # Distributed under the terms of the GNU General Public License v2
46
47 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
48 @@ -13,15 +13,23 @@ if ! ___eapi_has_prefix_variables; then
49 ED=${D}
50 fi
51
52 -if [[ ! -d ${ED}${DESTTREE}/bin ]] ; then
53 - install -d "${ED}${DESTTREE}/bin" || { __helpers_die "${0##*/}: failed to install ${ED}${DESTTREE}/bin"; exit 2; }
54 +if ! ___eapi_has_DESTTREE_INSDESTTREE; then
55 + [[ -n ${DESTTREE} ]] &&
56 + die "${0##*/}: \${DESTTREE} has been banned for EAPI '$EAPI'; use 'into' instead"
57 +else
58 + # backwards compatibility
59 + _E_DESTTREE_=${DESTTREE}
60 +fi
61 +
62 +if [[ ! -d ${ED}${_E_DESTTREE_}/bin ]] ; then
63 + install -d "${ED}${_E_DESTTREE_}/bin" || { __helpers_die "${0##*/}: failed to install ${ED}${_E_DESTTREE_}/bin"; exit 2; }
64 fi
65
66 ret=0
67
68 for x in "$@" ; do
69 if [[ -e ${x} ]] ; then
70 - install -m0755 -o ${PORTAGE_INST_UID:-0} -g ${PORTAGE_INST_GID:-0} "${x}" "${ED}${DESTTREE}/bin"
71 + install -m0755 -o ${PORTAGE_INST_UID:-0} -g ${PORTAGE_INST_GID:-0} "${x}" "${ED}${_E_DESTTREE_}/bin"
72 else
73 echo "!!! ${0##*/}: $x does not exist" 1>&2
74 false
75 diff --git a/bin/ebuild-helpers/doconfd b/bin/ebuild-helpers/doconfd
76 index 926c31839..38cf58234 100755
77 --- a/bin/ebuild-helpers/doconfd
78 +++ b/bin/ebuild-helpers/doconfd
79 @@ -1,5 +1,5 @@
80 #!/bin/bash
81 -# Copyright 1999-2010 Gentoo Foundation
82 +# Copyright 1999-2018 Gentoo Foundation
83 # Distributed under the terms of the GNU General Public License v2
84
85 if [[ $# -lt 1 ]] ; then
86 @@ -8,4 +8,4 @@ if [[ $# -lt 1 ]] ; then
87 exit 1
88 fi
89
90 -INSDESTTREE='/etc/conf.d/' exec doins "$@"
91 +_E_INSDESTTREE_='/etc/conf.d/' exec doins "$@"
92 diff --git a/bin/ebuild-helpers/doenvd b/bin/ebuild-helpers/doenvd
93 index eb31f375b..a15cec7f2 100755
94 --- a/bin/ebuild-helpers/doenvd
95 +++ b/bin/ebuild-helpers/doenvd
96 @@ -1,5 +1,5 @@
97 #!/bin/bash
98 -# Copyright 1999-2010 Gentoo Foundation
99 +# Copyright 1999-2018 Gentoo Foundation
100 # Distributed under the terms of the GNU General Public License v2
101
102 if [[ $# -lt 1 ]] ; then
103 @@ -8,4 +8,4 @@ if [[ $# -lt 1 ]] ; then
104 exit 1
105 fi
106
107 -INSDESTTREE='/etc/env.d/' exec doins "$@"
108 +_E_INSDESTTREE_='/etc/env.d/' exec doins "$@"
109 diff --git a/bin/ebuild-helpers/doheader b/bin/ebuild-helpers/doheader
110 index b827086ec..03bf23b1c 100755
111 --- a/bin/ebuild-helpers/doheader
112 +++ b/bin/ebuild-helpers/doheader
113 @@ -1,5 +1,5 @@
114 #!/bin/bash
115 -# Copyright 1999-2012 Gentoo Foundation
116 +# Copyright 1999-2018 Gentoo Foundation
117 # Distributed under the terms of the GNU General Public License v2
118
119 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
120 @@ -13,4 +13,4 @@ if [[ $# -lt 1 ]] || [[ $1 == -r && $# -lt 2 ]] ; then
121 exit 1
122 fi
123
124 -INSDESTTREE='/usr/include/' exec doins "$@"
125 +_E_INSDESTTREE_='/usr/include/' exec doins "$@"
126 diff --git a/bin/ebuild-helpers/doins b/bin/ebuild-helpers/doins
127 index 73c9d8b91..327d409a4 100755
128 --- a/bin/ebuild-helpers/doins
129 +++ b/bin/ebuild-helpers/doins
130 @@ -1,5 +1,5 @@
131 #!/bin/bash
132 -# Copyright 1999-2012 Gentoo Foundation
133 +# Copyright 1999-2018 Gentoo Foundation
134 # Distributed under the terms of the GNU General Public License v2
135
136 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
137 @@ -15,7 +15,15 @@ if [[ ${helper} == dodoc ]] ; then
138 exit 0
139 fi
140 export INSOPTIONS=-m0644
141 - export INSDESTTREE=usr/share/doc/${PF}/${_E_DOCDESTTREE_}
142 + export _E_INSDESTTREE_=usr/share/doc/${PF}/${_E_DOCDESTTREE_}
143 +else
144 + if ! ___eapi_has_DESTTREE_INSDESTTREE; then
145 + [[ -n ${INSDESTTREE} ]] &&
146 + die "${0##*/}: \${INSDESTTREE} has been banned for EAPI '$EAPI'; use 'into' instead"
147 + else
148 + # backwards compatibility
149 + _E_INSDESTTREE_=${INSDESTTREE}
150 + fi
151 fi
152
153 if [ $# -lt 1 ] ; then
154 @@ -33,10 +41,10 @@ if ! ___eapi_has_prefix_variables; then
155 export ED="${D}"
156 fi
157
158 -if [[ ${INSDESTTREE#${ED}} != "${INSDESTTREE}" ]]; then
159 +if [[ ${_E_INSDESTTREE_#${ED}} != "${_E_INSDESTTREE_}" ]]; then
160 __vecho "-------------------------------------------------------" 1>&2
161 __vecho "You should not use \${D} or \${ED} with helpers." 1>&2
162 - __vecho " --> ${INSDESTTREE}" 1>&2
163 + __vecho " --> ${_E_INSDESTTREE_}" 1>&2
164 __vecho "-------------------------------------------------------" 1>&2
165 __helpers_die "${helper} used with \${D} or \${ED}"
166 exit 1
167 @@ -75,7 +83,7 @@ fi
168
169 DOINS_ARGS+=(
170 "--helper=${helper}"
171 - "--dest=${ED}${INSDESTTREE}"
172 + "--dest=${ED}${_E_INSDESTTREE_}"
173 )
174
175 # Explicitly set PYTHONPATH to non empty.
176 diff --git a/bin/ebuild-helpers/dolib b/bin/ebuild-helpers/dolib
177 index 4be4aa4ea..30fe25e84 100755
178 --- a/bin/ebuild-helpers/dolib
179 +++ b/bin/ebuild-helpers/dolib
180 @@ -13,6 +13,14 @@ if ! ___eapi_has_prefix_variables; then
181 ED=${D}
182 fi
183
184 +if ! ___eapi_has_DESTTREE_INSDESTTREE; then
185 + [[ -n ${DESTTREE} ]] &&
186 + die "${0##*/}: \${DESTTREE} has been banned for EAPI '$EAPI'; use 'into' instead"
187 +else
188 + # backwards compatibility
189 + _E_DESTTREE_=${DESTTREE}
190 +fi
191 +
192 # Setup ABI cruft
193 LIBDIR_VAR="LIBDIR_${ABI}"
194 if [[ -n ${ABI} && -n ${!LIBDIR_VAR} ]] ; then
195 @@ -21,7 +29,7 @@ fi
196 unset LIBDIR_VAR
197 # we need this to default to lib so that things dont break
198 CONF_LIBDIR=${CONF_LIBDIR:-lib}
199 -libdir="${ED}${DESTTREE}/${CONF_LIBDIR}"
200 +libdir="${ED}${_E_DESTTREE_}/${CONF_LIBDIR}"
201
202
203 if [[ $# -lt 1 ]] ; then
204 diff --git a/bin/ebuild-helpers/dolib.a b/bin/ebuild-helpers/dolib.a
205 index 9c1cbeca1..b93b425d4 100755
206 --- a/bin/ebuild-helpers/dolib.a
207 +++ b/bin/ebuild-helpers/dolib.a
208 @@ -8,6 +8,14 @@ if ! ___eapi_has_prefix_variables; then
209 ED=${D}
210 fi
211
212 +if ! ___eapi_has_DESTTREE_INSDESTTREE; then
213 + [[ -n ${DESTTREE} ]] &&
214 + die "${0##*/}: \${DESTTREE} has been banned for EAPI '$EAPI'; use 'into' instead"
215 +else
216 + # backwards compatibility
217 + _E_DESTTREE_=${DESTTREE}
218 +fi
219 +
220 # Setup ABI cruft
221 LIBDIR_VAR="LIBDIR_${ABI}"
222 if [[ -n ${ABI} && -n ${!LIBDIR_VAR} ]] ; then
223 @@ -16,7 +24,7 @@ fi
224 unset LIBDIR_VAR
225 # we need this to default to lib so that things dont break
226 CONF_LIBDIR=${CONF_LIBDIR:-lib}
227 -libdir="${ED}${DESTTREE}/${CONF_LIBDIR}"
228 +libdir="${ED}${_E_DESTTREE_}/${CONF_LIBDIR}"
229
230
231 if [[ $# -lt 1 ]] ; then
232 diff --git a/bin/ebuild-helpers/dolib.so b/bin/ebuild-helpers/dolib.so
233 index e99962ae4..f86520e57 100755
234 --- a/bin/ebuild-helpers/dolib.so
235 +++ b/bin/ebuild-helpers/dolib.so
236 @@ -8,6 +8,14 @@ if ! ___eapi_has_prefix_variables; then
237 ED=${D}
238 fi
239
240 +if ! ___eapi_has_DESTTREE_INSDESTTREE; then
241 + [[ -n ${DESTTREE} ]] &&
242 + die "${0##*/}: \${DESTTREE} has been banned for EAPI '$EAPI'; use 'into' instead"
243 +else
244 + # backwards compatibility
245 + _E_DESTTREE_=${DESTTREE}
246 +fi
247 +
248 # Setup ABI cruft
249 LIBDIR_VAR="LIBDIR_${ABI}"
250 if [[ -n ${ABI} && -n ${!LIBDIR_VAR} ]] ; then
251 @@ -16,7 +24,7 @@ fi
252 unset LIBDIR_VAR
253 # we need this to default to lib so that things dont break
254 CONF_LIBDIR=${CONF_LIBDIR:-lib}
255 -libdir="${ED}${DESTTREE}/${CONF_LIBDIR}"
256 +libdir="${ED}${_E_DESTTREE_}/${CONF_LIBDIR}"
257
258
259 if [[ $# -lt 1 ]] ; then
260 diff --git a/bin/ebuild-helpers/domo b/bin/ebuild-helpers/domo
261 index e08e55a3a..70f93d61e 100755
262 --- a/bin/ebuild-helpers/domo
263 +++ b/bin/ebuild-helpers/domo
264 @@ -14,13 +14,21 @@ if ! ___eapi_has_prefix_variables; then
265 ED=${D}
266 fi
267
268 +if ! ___eapi_has_DESTTREE_INSDESTTREE; then
269 + [[ -n ${DESTTREE} ]] &&
270 + die "${0##*/}: \${DESTTREE} has been banned for EAPI '$EAPI'; use 'into' instead"
271 +else
272 + # backwards compatibility
273 + _E_DESTTREE_=${DESTTREE}
274 +fi
275 +
276 # newer EAPIs force /usr consistently with other /usr/share helpers
277 if ! ___eapi_domo_respects_into; then
278 - DESTTREE=/usr
279 + _E_DESTTREE_=/usr
280 fi
281
282 -if [ ! -d "${ED}${DESTTREE}/share/locale" ] ; then
283 - install -d "${ED}${DESTTREE}/share/locale/"
284 +if [ ! -d "${ED}${_E_DESTTREE_}/share/locale" ] ; then
285 + install -d "${ED}${_E_DESTTREE_}/share/locale/"
286 fi
287
288 ret=0
289 @@ -28,7 +36,7 @@ ret=0
290 for x in "$@" ; do
291 if [ -e "${x}" ] ; then
292 mytiny="${x##*/}"
293 - mydir="${ED}${DESTTREE}/share/locale/${mytiny%.*}/LC_MESSAGES"
294 + mydir="${ED}${_E_DESTTREE_}/share/locale/${mytiny%.*}/LC_MESSAGES"
295 if [ ! -d "${mydir}" ] ; then
296 install -d "${mydir}"
297 fi
298 diff --git a/bin/ebuild-helpers/dosbin b/bin/ebuild-helpers/dosbin
299 index 2fee9d4e9..f698f6fbb 100755
300 --- a/bin/ebuild-helpers/dosbin
301 +++ b/bin/ebuild-helpers/dosbin
302 @@ -1,5 +1,5 @@
303 #!/bin/bash
304 -# Copyright 1999-2012 Gentoo Foundation
305 +# Copyright 1999-2018 Gentoo Foundation
306 # Distributed under the terms of the GNU General Public License v2
307
308 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
309 @@ -13,15 +13,23 @@ if ! ___eapi_has_prefix_variables; then
310 ED=${D}
311 fi
312
313 -if [[ ! -d ${ED}${DESTTREE}/sbin ]] ; then
314 - install -d "${ED}${DESTTREE}/sbin" || { __helpers_die "${0##*/}: failed to install ${ED}${DESTTREE}/sbin"; exit 2; }
315 +if ! ___eapi_has_DESTTREE_INSDESTTREE; then
316 + [[ -n ${DESTTREE} ]] &&
317 + die "${0##*/}: \${DESTTREE} has been banned for EAPI '$EAPI'; use 'into' instead"
318 +else
319 + # backwards compatibility
320 + _E_DESTTREE_=${DESTTREE}
321 +fi
322 +
323 +if [[ ! -d ${ED}${_E_DESTTREE_}/sbin ]] ; then
324 + install -d "${ED}${_E_DESTTREE_}/sbin" || { __helpers_die "${0##*/}: failed to install ${ED}${_E_DESTTREE_}/sbin"; exit 2; }
325 fi
326
327 ret=0
328
329 for x in "$@" ; do
330 if [[ -e ${x} ]] ; then
331 - install -m0755 -o ${PORTAGE_INST_UID:-0} -g ${PORTAGE_INST_GID:-0} "${x}" "${ED}${DESTTREE}/sbin"
332 + install -m0755 -o ${PORTAGE_INST_UID:-0} -g ${PORTAGE_INST_GID:-0} "${x}" "${ED}${_E_DESTTREE_}/sbin"
333 else
334 echo "!!! ${0##*/}: ${x} does not exist" 1>&2
335 false
336 diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
337 index 0ffabd99e..d95012d6b 100644
338 --- a/bin/phase-functions.sh
339 +++ b/bin/phase-functions.sh
340 @@ -1,5 +1,5 @@
341 #!/bin/bash
342 -# Copyright 1999-2015 Gentoo Foundation
343 +# Copyright 1999-2018 Gentoo Foundation
344 # Distributed under the terms of the GNU General Public License v2
345
346 # Hardcoded bash lists are needed for backward compatibility with
347 @@ -584,8 +584,13 @@ __dyn_install() {
348 # Reset exeinto(), docinto(), insinto(), and into() state variables
349 # in case the user is running the install phase multiple times
350 # consecutively via the ebuild command.
351 - export DESTTREE=/usr
352 - export INSDESTTREE=""
353 + if ___eapi_has_DESTTREE_INSDESTTREE; then
354 + export DESTTREE=/usr
355 + export INSDESTTREE=""
356 + else
357 + export _E_DESTTREE_=/usr
358 + export _E_INSDESTTREE_=""
359 + fi
360 export _E_EXEDESTTREE_=""
361 export _E_DOCDESTTREE_=""
362
363 diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
364 index 12ccf6716..3a2138636 100644
365 --- a/bin/phase-helpers.sh
366 +++ b/bin/phase-helpers.sh
367 @@ -2,8 +2,13 @@
368 # Copyright 1999-2018 Gentoo Foundation
369 # Distributed under the terms of the GNU General Public License v2
370
371 -export DESTTREE=/usr
372 -export INSDESTTREE=""
373 +if ___eapi_has_DESTTREE_INSDESTTREE; then
374 + export DESTTREE=/usr
375 + export INSDESTTREE=""
376 +else
377 + export _E_DESTTREE_=/usr
378 + export _E_INSDESTTREE_=""
379 +fi
380 export _E_EXEDESTTREE_=""
381 export _E_DOCDESTTREE_=""
382 export INSOPTIONS="-m0644"
383 @@ -18,14 +23,14 @@ declare -a PORTAGE_DOCOMPRESS_SKIP=( /usr/share/doc/${PF}/html )
384
385 into() {
386 if [ "$1" == "/" ]; then
387 - export DESTTREE=""
388 + export _E_DESTTREE_=""
389 else
390 - export DESTTREE=$1
391 + export _E_DESTTREE_=$1
392 if ! ___eapi_has_prefix_variables; then
393 local ED=${D}
394 fi
395 - if [ ! -d "${ED}${DESTTREE}" ]; then
396 - install -d "${ED}${DESTTREE}"
397 + if [ ! -d "${ED}${_E_DESTTREE_}" ]; then
398 + install -d "${ED}${_E_DESTTREE_}"
399 local ret=$?
400 if [[ $ret -ne 0 ]] ; then
401 __helpers_die "${FUNCNAME[0]} failed"
402 @@ -33,18 +38,22 @@ into() {
403 fi
404 fi
405 fi
406 +
407 + if ___eapi_has_DESTTREE_INSDESTTREE; then
408 + export DESTTREE=${_E_DESTTREE_}
409 + fi
410 }
411
412 insinto() {
413 if [ "$1" == "/" ]; then
414 - export INSDESTTREE=""
415 + export _E_INSDESTTREE_=""
416 else
417 - export INSDESTTREE=$1
418 + export _E_INSDESTTREE_=$1
419 if ! ___eapi_has_prefix_variables; then
420 local ED=${D}
421 fi
422 - if [ ! -d "${ED}${INSDESTTREE}" ]; then
423 - install -d "${ED}${INSDESTTREE}"
424 + if [ ! -d "${ED}${_E_INSDESTTREE_}" ]; then
425 + install -d "${ED}${_E_INSDESTTREE_}"
426 local ret=$?
427 if [[ $ret -ne 0 ]] ; then
428 __helpers_die "${FUNCNAME[0]} failed"
429 @@ -52,6 +61,10 @@ insinto() {
430 fi
431 fi
432 fi
433 +
434 + if ___eapi_has_DESTTREE_INSDESTTREE; then
435 + export INSDESTTREE=${_E_INSDESTTREE_}
436 + fi
437 }
438
439 exeinto() {
440 diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
441 index f0bf00130..e5ae8af88 100644
442 --- a/bin/save-ebuild-env.sh
443 +++ b/bin/save-ebuild-env.sh
444 @@ -1,5 +1,5 @@
445 #!/bin/bash
446 -# Copyright 1999-2014 Gentoo Foundation
447 +# Copyright 1999-2018 Gentoo Foundation
448 # Distributed under the terms of the GNU General Public License v2
449
450 # @FUNCTION: __save_ebuild_env
451 @@ -13,7 +13,7 @@
452 __save_ebuild_env() {
453 (
454 if has --exclude-init-phases $* ; then
455 - unset S _E_DOCDESTTREE_ _E_EXEDESTTREE_ \
456 + unset S _E_DESTTREE _E_INSDESTTREE _E_DOCDESTTREE_ _E_EXEDESTTREE_ \
457 PORTAGE_DOCOMPRESS_SIZE_LIMIT PORTAGE_DOCOMPRESS \
458 PORTAGE_DOCOMPRESS_SKIP
459 if [[ -n $PYTHONPATH &&
460 --
461 2.16.2