Modify genpatches logic to delay setting UNIPATCH_LIST_GENPATCHES until
src_unpack(). The value of UNIPATCH_LIST_GENPATCHES depends on state of
'use experimental', therefore it can not be obtained in global scope.
Therefore, handle_genpatches() will only set the URI when called in
global scope, and it will set UNIPATCH_LIST_GENPATCHES on request which
is done during kernel-2_src_unpack().

Fixes: https://bugs.gentoo.org/show_bug.cgi?id=566520
---
 eclass/kernel-2.eclass | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
index 1a508f1..02da62a 100644
--- a/eclass/kernel-2.eclass
+++ b/eclass/kernel-2.eclass
@@ -132,9 +132,20 @@ debug-print-kernel2-variables() {
 #Eclass functions only from here onwards ...
 #==============================================================
 handle_genpatches() {
-       local tarball
+       local tarball want_unipatch_list
        [[ -z ${K_WANT_GENPATCHES} || -z ${K_GENPATCHES_VER} ]] && return 1
 
+       if [[ -n ${1} ]]; then
+               # set UNIPATCH_LIST_GENPATCHES only on explicit request
+               # since that requires 'use' call which can be used only in phase
+               # functions, while the function is also called in global scope
+               if [[ ${1} == --set-unipatch-list ]]; then
+                       want_unipatch_list=1
+               else
+                       die "Usage: ${FUNCNAME} [--set-unipatch-list]"
+               fi
+       fi
+
        debug-print "Inside handle_genpatches"
        local OKV_ARRAY
        IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
@@ -161,11 +172,11 @@ handle_genpatches() {
                        use_cond_start="experimental? ( "
                        use_cond_end=" )"
 
-                       if use experimental ; then
+                       if [[ -n ${want_unipatch_list} ]] && use experimental ; 
then
                                UNIPATCH_LIST_GENPATCHES+=" 
${DISTDIR}/${tarball}"
                                debug-print "genpatches tarball: $tarball"
                        fi
-               else
+               elif [[ -n ${want_unipatch_list} ]]; then
                        UNIPATCH_LIST_GENPATCHES+=" ${DISTDIR}/${tarball}"
                        debug-print "genpatches tarball: $tarball"
                fi
@@ -1232,6 +1243,8 @@ kernel-2_src_unpack() {
        universal_unpack
        debug-print "Doing unipatch"
 
+       # request UNIPATCH_LIST_GENPATCHES in phase since it calls 'use'
+       handle_genpatches --set-unipatch-list
        [[ -n ${UNIPATCH_LIST} || -n ${UNIPATCH_LIST_DEFAULT} || -n 
${UNIPATCH_LIST_GENPATCHES} ]] && \
                unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST_GENPATCHES} 
${UNIPATCH_LIST}"
 
-- 
2.6.3


Reply via email to