Re: [gentoo-dev] [PATCH v3] eclass/kernel-2.eclass: Remove use of tr in global scope

2017-09-07 Thread Ciaran McCreesh
On Thu, 07 Sep 2017 07:42:31 +0200
Michał Górny  wrote:
> >+if [[ "${EAPI}" -lt 6 ]]; then   
> 
> EAPI is not a number. The next one we'll call gray-grizzly just to
> prove the point.

Careful, you're turning into me.

-- 
Ciaran McCreesh



Re: [gentoo-dev] [PATCH v3] eclass/kernel-2.eclass: Remove use of tr in global scope

2017-09-06 Thread Michał Górny
Dnia 7 września 2017 01:40:50 CEST, Mike Pagano  napisał(a):
>This time, use bash 4.0, but limit the use of this function to ebuild
>that have EAPI >= 6.
>Display a warning for maintainers to upgrade their ebuilds, or remove
>the call.
>Thanks to mgorny for the suggestion.
>
>Signed-off-by: Mike Pagano 
>---
> eclass/kernel-2.eclass | 20 +---
> 1 file changed, 13 insertions(+), 7 deletions(-)
>
>diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
>index 84909f30c..a80f3e91a 100644
>--- a/eclass/kernel-2.eclass
>+++ b/eclass/kernel-2.eclass
>@@ -1407,11 +1407,20 @@ getfilevar() {
> # This function sets ARCH_URI and ARCH_PATCH
> # with the neccessary info for the arch sepecific compatibility
> # patchsets.
>+# To use, an ebuild could contain a line like:
>+# AMD64_URI=http//linktothearchspecificpatch
>+# This function requires EAPI >= 6.
> 
> detect_arch() {
> 
>-  local ALL_ARCH LOOP_ARCH LOOP_ARCH_L COMPAT_URI i TC_ARCH_KERNEL
>+  if [[ "${EAPI}" -lt 6 ]]; then 

EAPI is not a number. The next one we'll call gray-grizzly just to prove the 
point.

>+  eqawarn "ebuild is attempting to call detect_arch when EAPI < 
>6." 
>+  eqawarn "This function will not be executed." 
>+  return
>+  fi
> 
>+  local ALL_ARCH LOOP_ARCH LOOP_ARCH_L COMPAT_URI i TC_ARCH_KERNEL
>+  
>   # COMPAT_URI is the contents of ${ARCH}_URI
>   # ARCH_URI is the URI for all the ${ARCH}_URI patches
>   # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
>@@ -1425,18 +1434,15 @@ detect_arch() {
>   COMPAT_URI="${LOOP_ARCH}_URI"
>   COMPAT_URI="${!COMPAT_URI}"
> 
>-  declare -l LOOP_ARCH_L=${LOOP_ARCH}
>-
>   [[ -n ${COMPAT_URI} ]] && \
>-  ARCH_URI="${ARCH_URI} ${LOOP_ARCH_L}? ( ${COMPAT_URI} )"
>+  ARCH_URI="${ARCH_URI} ${LOOP_ARCH,,}? ( ${COMPAT_URI} )"
> 
>-  declare -u TC_ARCH_KERNEL=$(tc-arch-kernel)
>-  if [[ ${LOOP_ARCH} == ${TC_ARCH_KERNEL} ]]; then
>+  TC_ARCH_KERNEL=$(tc-arch-kernel);

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. 

>+  if [[ ${LOOP_ARCH} == ${TC_ARCH_KERNEL^^} ]]; then
>   for i in ${COMPAT_URI}; do
>   ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
>   done
>   fi
>-
>   done
> }
> 


-- 
Best regards,
Michał Górny (by phone)



Re: [gentoo-dev] [PATCH v3] eclass/kernel-2.eclass: Remove use of tr in global scope

2017-09-06 Thread Floyd Anderson


Hello,

some remarks below ...

On Mi, 06 Sep 23:40:50 +
Mike Pagano  wrote:

This time, use bash 4.0, but limit the use of this function to ebuild that have 
EAPI >= 6.
Display a warning for maintainers to upgrade their ebuilds, or remove the call.
Thanks to mgorny for the suggestion.

Signed-off-by: Mike Pagano 
---
eclass/kernel-2.eclass | 20 +---
1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
index 84909f30c..a80f3e91a 100644
--- a/eclass/kernel-2.eclass
+++ b/eclass/kernel-2.eclass
@@ -1407,11 +1407,20 @@ getfilevar() {
# This function sets ARCH_URI and ARCH_PATCH
# with the neccessary info for the arch sepecific compatibility
# patchsets.
+# To use, an ebuild could contain a line like:
+# AMD64_URI=http//linktothearchspecificpatch


Even it’s just a comment:

   # AMD64_URI="http://link-to-the-arch-specific-patch;

looks friendlier to my eyes. However at least the colon after the scheme 
should be given.



+# This function requires EAPI >= 6.

detect_arch() {

-   local ALL_ARCH LOOP_ARCH LOOP_ARCH_L COMPAT_URI i TC_ARCH_KERNEL
+   if [[ "${EAPI}" -lt 6 ]]; then
+   eqawarn "ebuild is attempting to call detect_arch when EAPI < 
6."
+   eqawarn "This function will not be executed."
+   return
+   fi

+   local ALL_ARCH LOOP_ARCH LOOP_ARCH_L COMPAT_URI i TC_ARCH_KERNEL


Declaration of LOOP_ARCH_L seems obsolete now.


+   
# COMPAT_URI is the contents of ${ARCH}_URI
# ARCH_URI is the URI for all the ${ARCH}_URI patches
# ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
@@ -1425,18 +1434,15 @@ detect_arch() {
COMPAT_URI="${LOOP_ARCH}_URI"
COMPAT_URI="${!COMPAT_URI}"

-   declare -l LOOP_ARCH_L=${LOOP_ARCH}
-
[[ -n ${COMPAT_URI} ]] && \
-   ARCH_URI="${ARCH_URI} ${LOOP_ARCH_L}? ( ${COMPAT_URI} )"
+   ARCH_URI="${ARCH_URI} ${LOOP_ARCH,,}? ( ${COMPAT_URI} )"

-   declare -u TC_ARCH_KERNEL=$(tc-arch-kernel)
-   if [[ ${LOOP_ARCH} == ${TC_ARCH_KERNEL} ]]; then
+   TC_ARCH_KERNEL=$(tc-arch-kernel);
+   if [[ ${LOOP_ARCH} == ${TC_ARCH_KERNEL^^} ]]; then
for i in ${COMPAT_URI}; do
ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
done
fi
-
done
}

--
2.13.5





--
Regards,
floyd




[gentoo-dev] [PATCH v3] eclass/kernel-2.eclass: Remove use of tr in global scope

2017-09-06 Thread Mike Pagano
This time, use bash 4.0, but limit the use of this function to ebuild that have 
EAPI >= 6.
Display a warning for maintainers to upgrade their ebuilds, or remove the call.
Thanks to mgorny for the suggestion.

Signed-off-by: Mike Pagano 
---
 eclass/kernel-2.eclass | 20 +---
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
index 84909f30c..a80f3e91a 100644
--- a/eclass/kernel-2.eclass
+++ b/eclass/kernel-2.eclass
@@ -1407,11 +1407,20 @@ getfilevar() {
 # This function sets ARCH_URI and ARCH_PATCH
 # with the neccessary info for the arch sepecific compatibility
 # patchsets.
+# To use, an ebuild could contain a line like:
+# AMD64_URI=http//linktothearchspecificpatch
+# This function requires EAPI >= 6.
 
 detect_arch() {
 
-   local ALL_ARCH LOOP_ARCH LOOP_ARCH_L COMPAT_URI i TC_ARCH_KERNEL
+   if [[ "${EAPI}" -lt 6 ]]; then 
+   eqawarn "ebuild is attempting to call detect_arch when EAPI < 
6." 
+   eqawarn "This function will not be executed." 
+   return
+   fi
 
+   local ALL_ARCH LOOP_ARCH LOOP_ARCH_L COMPAT_URI i TC_ARCH_KERNEL
+   
# COMPAT_URI is the contents of ${ARCH}_URI
# ARCH_URI is the URI for all the ${ARCH}_URI patches
# ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
@@ -1425,18 +1434,15 @@ detect_arch() {
COMPAT_URI="${LOOP_ARCH}_URI"
COMPAT_URI="${!COMPAT_URI}"
 
-   declare -l LOOP_ARCH_L=${LOOP_ARCH}
-
[[ -n ${COMPAT_URI} ]] && \
-   ARCH_URI="${ARCH_URI} ${LOOP_ARCH_L}? ( ${COMPAT_URI} )"
+   ARCH_URI="${ARCH_URI} ${LOOP_ARCH,,}? ( ${COMPAT_URI} )"
 
-   declare -u TC_ARCH_KERNEL=$(tc-arch-kernel)
-   if [[ ${LOOP_ARCH} == ${TC_ARCH_KERNEL} ]]; then
+   TC_ARCH_KERNEL=$(tc-arch-kernel);
+   if [[ ${LOOP_ARCH} == ${TC_ARCH_KERNEL^^} ]]; then
for i in ${COMPAT_URI}; do
ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
done
fi
-
done
 }
 
-- 
2.13.5




signature.asc
Description: OpenPGP digital signature