Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o, Mike Pagano <mpagano@g.o>
Subject: Re: [gentoo-dev] [PATCH v3] eclass/kernel-2.eclass: Remove use of tr in global scope
Date: Thu, 07 Sep 2017 05:42:46
Message-Id: F49DED4E-4557-410A-91B0-D67171C870C6@gentoo.org
In Reply to: [gentoo-dev] [PATCH v3] eclass/kernel-2.eclass: Remove use of tr in global scope by Mike Pagano
1 Dnia 7 września 2017 01:40:50 CEST, Mike Pagano <mpagano@g.o> napisał(a):
2 >This time, use bash 4.0, but limit the use of this function to ebuild
3 >that have EAPI >= 6.
4 >Display a warning for maintainers to upgrade their ebuilds, or remove
5 >the call.
6 >Thanks to mgorny for the suggestion.
7 >
8 >Signed-off-by: Mike Pagano <mpagano@g.o>
9 >---
10 > eclass/kernel-2.eclass | 20 +++++++++++++-------
11 > 1 file changed, 13 insertions(+), 7 deletions(-)
12 >
13 >diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
14 >index 84909f30c..a80f3e91a 100644
15 >--- a/eclass/kernel-2.eclass
16 >+++ b/eclass/kernel-2.eclass
17 >@@ -1407,11 +1407,20 @@ getfilevar() {
18 > # This function sets ARCH_URI and ARCH_PATCH
19 > # with the neccessary info for the arch sepecific compatibility
20 > # patchsets.
21 >+# To use, an ebuild could contain a line like:
22 >+# AMD64_URI=http//linktothearchspecificpatch
23 >+# This function requires EAPI >= 6.
24 >
25 > detect_arch() {
26 >
27 >- local ALL_ARCH LOOP_ARCH LOOP_ARCH_L COMPAT_URI i TC_ARCH_KERNEL
28 >+ if [[ "${EAPI}" -lt 6 ]]; then
29
30 EAPI is not a number. The next one we'll call gray-grizzly just to prove the point.
31
32 >+ eqawarn "ebuild is attempting to call detect_arch when EAPI < 6."
33 >+ eqawarn "This function will not be executed."
34 >+ return
35 >+ fi
36 >
37 >+ local ALL_ARCH LOOP_ARCH LOOP_ARCH_L COMPAT_URI i TC_ARCH_KERNEL
38 >+
39 > # COMPAT_URI is the contents of ${ARCH}_URI
40 > # ARCH_URI is the URI for all the ${ARCH}_URI patches
41 > # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
42 >@@ -1425,18 +1434,15 @@ detect_arch() {
43 > COMPAT_URI="${LOOP_ARCH}_URI"
44 > COMPAT_URI="${!COMPAT_URI}"
45 >
46 >- declare -l LOOP_ARCH_L=${LOOP_ARCH}
47 >-
48 > [[ -n ${COMPAT_URI} ]] && \
49 >- ARCH_URI="${ARCH_URI} ${LOOP_ARCH_L}? ( ${COMPAT_URI} )"
50 >+ ARCH_URI="${ARCH_URI} ${LOOP_ARCH,,}? ( ${COMPAT_URI} )"
51 >
52 >- declare -u TC_ARCH_KERNEL=$(tc-arch-kernel)
53 >- if [[ ${LOOP_ARCH} == ${TC_ARCH_KERNEL} ]]; then
54 >+ TC_ARCH_KERNEL=$(tc-arch-kernel);
55
56 Strictly speaking, you aren't supposed to call this in global scope either. To do it properly, you should split the function into two parts, one for global scope, and the other for phase functions.
57
58 >+ if [[ ${LOOP_ARCH} == ${TC_ARCH_KERNEL^^} ]]; then
59 > for i in ${COMPAT_URI}; do
60 > ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
61 > done
62 > fi
63 >-
64 > done
65 > }
66 >
67
68
69 --
70 Best regards,
71 Michał Górny (by phone)

Replies

Subject Author
Re: [gentoo-dev] [PATCH v3] eclass/kernel-2.eclass: Remove use of tr in global scope Ciaran McCreesh <ciaran.mccreesh@××××××××××.com>