* [gentoo-dev] [PATCH] eclass/kernel-2.eclass: Remove use of tr in global scope
@ 2017-08-31 0:02 Mike Pagano
2017-08-31 1:51 ` [gentoo-dev] " Jonathan Callen
0 siblings, 1 reply; 4+ messages in thread
From: Mike Pagano @ 2017-08-31 0:02 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1.1: Type: text/plain, Size: 1376 bytes --]
As per PMS remove calls to external command 'tr' in global scope
See bug #629106
Signed-off-by: Mike Pagano <mpagano@gentoo.org>
---
eclass/kernel-2.eclass | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
index 09409ab1f..cdc8c4043 100644
--- a/eclass/kernel-2.eclass
+++ b/eclass/kernel-2.eclass
@@ -1410,7 +1410,7 @@ getfilevar() {
detect_arch() {
- local ALL_ARCH LOOP_ARCH COMPAT_URI i
+ local ALL_ARCH LOOP_ARCH COMPAT_URI TC_ARCH_KERNEL
# COMPAT_URI is the contents of ${ARCH}_URI
# ARCH_URI is the URI for all the ${ARCH}_URI patches
@@ -1418,6 +1418,7 @@ detect_arch() {
ARCH_URI=""
ARCH_PATCH=""
+ TC_ARCH_KERNEL=""
ALL_ARCH="ALPHA AMD64 ARM HPPA IA64 M68K MIPS PPC PPC64 S390 SH SPARC X86"
for LOOP_ARCH in ${ALL_ARCH}; do
@@ -1425,9 +1426,10 @@ detect_arch() {
COMPAT_URI="${!COMPAT_URI}"
[[ -n ${COMPAT_URI} ]] && \
- ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )"
+ ARCH_URI="${ARCH_URI} ${LOOP_ARCH,,}? ( ${COMPAT_URI} )"
- if [[ ${LOOP_ARCH} == "$(echo $(tc-arch-kernel) | tr '[:lower:]' '[:upper:]')" ]]; then
+ TC_ARCH_KERNEL=$(tc-arch-kernel);
+ if [[ ${LOOP_ARCH} == ${TC_ARCH_KERNEL^^} ]]; then
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [gentoo-dev] Re: [PATCH] eclass/kernel-2.eclass: Remove use of tr in global scope
2017-08-31 0:02 [gentoo-dev] [PATCH] eclass/kernel-2.eclass: Remove use of tr in global scope Mike Pagano
@ 2017-08-31 1:51 ` Jonathan Callen
2017-08-31 5:25 ` Michał Górny
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Callen @ 2017-08-31 1:51 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1.1: Type: text/plain, Size: 1819 bytes --]
On 08/30/2017 08:02 PM, Mike Pagano wrote:
> As per PMS remove calls to external command 'tr' in global scope
> See bug #629106
>
> Signed-off-by: Mike Pagano <mpagano@gentoo.org>
> ---
> eclass/kernel-2.eclass | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
> index 09409ab1f..cdc8c4043 100644
> --- a/eclass/kernel-2.eclass
> +++ b/eclass/kernel-2.eclass
> @@ -1410,7 +1410,7 @@ getfilevar() {
>
> detect_arch() {
>
> - local ALL_ARCH LOOP_ARCH COMPAT_URI i
> + local ALL_ARCH LOOP_ARCH COMPAT_URI TC_ARCH_KERNEL
>
> # COMPAT_URI is the contents of ${ARCH}_URI
> # ARCH_URI is the URI for all the ${ARCH}_URI patches
> @@ -1418,6 +1418,7 @@ detect_arch() {
>
> ARCH_URI=""
> ARCH_PATCH=""
> + TC_ARCH_KERNEL=""
> ALL_ARCH="ALPHA AMD64 ARM HPPA IA64 M68K MIPS PPC PPC64 S390 SH SPARC X86"
>
> for LOOP_ARCH in ${ALL_ARCH}; do
> @@ -1425,9 +1426,10 @@ detect_arch() {
> COMPAT_URI="${!COMPAT_URI}"
>
> [[ -n ${COMPAT_URI} ]] && \
> - ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )"
> + ARCH_URI="${ARCH_URI} ${LOOP_ARCH,,}? ( ${COMPAT_URI} )"
>
> - if [[ ${LOOP_ARCH} == "$(echo $(tc-arch-kernel) | tr '[:lower:]' '[:upper:]')" ]]; then
> + TC_ARCH_KERNEL=$(tc-arch-kernel);
> + if [[ ${LOOP_ARCH} == ${TC_ARCH_KERNEL^^} ]]; then
>
>
Unfortunately, the ${VAR,,} and ${VAR^^} forms were added in bash 4.0
[1], which means they are not available in EAPIs before 6, which only
allow constructs from bash 3.2 [2].
[1]: https://tiswww.case.edu/php/chet/bash/NEWS
[2]: https://projects.gentoo.org/pms/6/pms.html#x1-640006
--
Jonathan Callen
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-dev] Re: [PATCH] eclass/kernel-2.eclass: Remove use of tr in global scope
2017-08-31 1:51 ` [gentoo-dev] " Jonathan Callen
@ 2017-08-31 5:25 ` Michał Górny
2017-08-31 9:24 ` Ulrich Mueller
0 siblings, 1 reply; 4+ messages in thread
From: Michał Górny @ 2017-08-31 5:25 UTC (permalink / raw
To: gentoo-dev
W dniu śro, 30.08.2017 o godzinie 21∶51 -0400, użytkownik Jonathan
Callen napisał:
> On 08/30/2017 08:02 PM, Mike Pagano wrote:
> > As per PMS remove calls to external command 'tr' in global scope
> > See bug #629106
> >
> > Signed-off-by: Mike Pagano <mpagano@gentoo.org>
> > ---
> > eclass/kernel-2.eclass | 8 +++++---
> > 1 file changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
> > index 09409ab1f..cdc8c4043 100644
> > --- a/eclass/kernel-2.eclass
> > +++ b/eclass/kernel-2.eclass
> > @@ -1410,7 +1410,7 @@ getfilevar() {
> >
> > detect_arch() {
> >
> > - local ALL_ARCH LOOP_ARCH COMPAT_URI i
> > + local ALL_ARCH LOOP_ARCH COMPAT_URI TC_ARCH_KERNEL
> >
> > # COMPAT_URI is the contents of ${ARCH}_URI
> > # ARCH_URI is the URI for all the ${ARCH}_URI patches
> > @@ -1418,6 +1418,7 @@ detect_arch() {
> >
> > ARCH_URI=""
> > ARCH_PATCH=""
> > + TC_ARCH_KERNEL=""
> > ALL_ARCH="ALPHA AMD64 ARM HPPA IA64 M68K MIPS PPC PPC64 S390 SH SPARC X86"
> >
> > for LOOP_ARCH in ${ALL_ARCH}; do
> > @@ -1425,9 +1426,10 @@ detect_arch() {
> > COMPAT_URI="${!COMPAT_URI}"
> >
> > [[ -n ${COMPAT_URI} ]] && \
> > - ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )"
> > + ARCH_URI="${ARCH_URI} ${LOOP_ARCH,,}? ( ${COMPAT_URI} )"
> >
> > - if [[ ${LOOP_ARCH} == "$(echo $(tc-arch-kernel) | tr '[:lower:]' '[:upper:]')" ]]; then
> > + TC_ARCH_KERNEL=$(tc-arch-kernel);
> > + if [[ ${LOOP_ARCH} == ${TC_ARCH_KERNEL^^} ]]; then
> >
> >
>
> Unfortunately, the ${VAR,,} and ${VAR^^} forms were added in bash 4.0
> [1], which means they are not available in EAPIs before 6, which only
> allow constructs from bash 3.2 [2].
>
> [1]: https://tiswww.case.edu/php/chet/bash/NEWS
> [2]: https://projects.gentoo.org/pms/6/pms.html#x1-640006
>
That's what I wanted to say. However, considering it's broken anyway, I
guess this is kind of improvement (since it technically breaks old
ebuilds only).
As a cheap alternative, you could just do a big 'case' with hardcoded
mappings. Or given that ALL_ARCH is already defined, you can define
ALL_ARCH_LC (lowercase) and map from one to the other.
--
Best regards,
Michał Górny
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-dev] Re: [PATCH] eclass/kernel-2.eclass: Remove use of tr in global scope
2017-08-31 5:25 ` Michał Górny
@ 2017-08-31 9:24 ` Ulrich Mueller
0 siblings, 0 replies; 4+ messages in thread
From: Ulrich Mueller @ 2017-08-31 9:24 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 1428 bytes --]
>>>>> On Thu, 31 Aug 2017, Michał Górny wrote:
>> > @@ -1425,9 +1426,10 @@ detect_arch() {
>> > COMPAT_URI="${!COMPAT_URI}"
>> >
>> > [[ -n ${COMPAT_URI} ]] && \
>> > - ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )"
>> > + ARCH_URI="${ARCH_URI} ${LOOP_ARCH,,}? ( ${COMPAT_URI} )"
>> >
>> > - if [[ ${LOOP_ARCH} == "$(echo $(tc-arch-kernel) | tr '[:lower:]' '[:upper:]')" ]]; then
>> > + TC_ARCH_KERNEL=$(tc-arch-kernel);
>> > + if [[ ${LOOP_ARCH} == ${TC_ARCH_KERNEL^^} ]]; then
>> >
>> >
>>
>> Unfortunately, the ${VAR,,} and ${VAR^^} forms were added in bash
>> 4.0 [1], which means they are not available in EAPIs before 6,
>> which only allow constructs from bash 3.2 [2].
>>
>> [1]: https://tiswww.case.edu/php/chet/bash/NEWS
>> [2]: https://projects.gentoo.org/pms/6/pms.html#x1-640006
> That's what I wanted to say. However, considering it's broken
> anyway, I guess this is kind of improvement (since it technically
> breaks old ebuilds only).
Many kernel ebuilds are still at EAPI 5, though.
> As a cheap alternative, you could just do a big 'case' with
> hardcoded mappings. Or given that ALL_ARCH is already defined, you
> can define ALL_ARCH_LC (lowercase) and map from one to the other.
There is also "shopt -s nocasematch" which is available since
bash 3.1.
Ulrich
[-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-08-31 9:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-31 0:02 [gentoo-dev] [PATCH] eclass/kernel-2.eclass: Remove use of tr in global scope Mike Pagano
2017-08-31 1:51 ` [gentoo-dev] " Jonathan Callen
2017-08-31 5:25 ` Michał Górny
2017-08-31 9:24 ` Ulrich Mueller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox