commit:     9633b33624bebab51dcd521b28dca614880e198f
Author:     Michael Palimaka <kensington <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 16 16:43:31 2015 +0000
Commit:     Michael Palimaka <kensington <AT> gentoo <DOT> org>
CommitDate: Thu Apr 16 16:47:26 2015 +0000
URL:        https://gitweb.gentoo.org/proj/kde.git/commit/?id=9633b336

[eclass] Introduce KDE_PUNT_BOGUS_DEPS to control the new black magic.

 eclass/kde5-functions.eclass | 21 +++++++++++++++++----
 eclass/kde5.eclass           | 21 ++++++++++++++++++---
 2 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/eclass/kde5-functions.eclass b/eclass/kde5-functions.eclass
index 648dff0..d618368 100644
--- a/eclass/kde5-functions.eclass
+++ b/eclass/kde5-functions.eclass
@@ -210,11 +210,24 @@ get_kde_version() {
        fi
 }
 
-# @FUNCTION: punt_bogus_deps
+# @FUNCTION: punt_bogus_dep
+# @USAGE: <prefix> <dependency>
 # @DESCRIPTION:
-# Remove hard-coded upstream dependencies that are not correct.
-punt_bogus_deps() {
-       sed -e "/find_package(Qt5 /s/ Test//" -i CMakeLists.txt || die
+# Removes a specified dependency from a find_package call with multiple 
components.
+punt_bogus_dep() {
+       local prefix=${1}
+       local dep=${2}
+
+       pcregrep -Mn "(?s)find_package\(\s*${prefix}.[^)]*?${dep}.*?\)" 
CMakeLists.txt > "${T}/bogus${dep}"
+       local length=$(wc -l "${T}/bogus${dep}" | cut -d " " -f 1)
+       local first=$(head -n 1 "${T}/bogus${dep}" | cut -d ":" -f 1)
+       local last=$(( ${length} + ${first} - 1))
+
+       sed -e "${first},${last}s/${dep}//" -i CMakeLists.txt || die
+
+       if [[ ${length} = 1 ]] ; then
+               sed -e 
"/find_package(\s*${prefix}\s*REQUIRED\s*COMPONENTS\s*)/d" -i CMakeLists.txt || 
die
+       fi
 }
 
 fi

diff --git a/eclass/kde5.eclass b/eclass/kde5.eclass
index 6755541..2511ba8 100644
--- a/eclass/kde5.eclass
+++ b/eclass/kde5.eclass
@@ -81,6 +81,13 @@ else
        : ${KDE_TEST:=false}
 fi
 
+# @ECLASS-VARIABLE: KDE_PUNT_BOGUS_DEPS
+# @DESCRIPTION:
+# If set to "none", do nothing.
+# For any other value, do black magic to make hardcoded-but-optional 
dependencies
+# optional again. An upstream solution is preferable and this is a last resort.
+: ${KDE_PUNT_BOGUS_DEPS:=none}
+
 # @ECLASS-VARIABLE: KDE_SELINUX_MODULE
 # @DESCRIPTION:
 # If set to "none", do nothing.
@@ -396,9 +403,17 @@ kde5_src_prepare() {
                fi
        fi
 
-       if [[ ${CATEGORY} = kde-plasma ]] && ! use_if_iuse test ; then
-               punt_bogus_deps
-       fi
+       case ${KDE_PUNT_BOGUS_DEPS} in
+               false)  ;;
+               *)
+                       if ! use_if_iuse test ; then
+                               punt_bogus_dep Qt5 Test
+                       fi
+                       if ! use_if_iuse handbook ; then
+                               punt_bogus_dep KF5 DocTools
+                       fi
+                       ;;
+       esac
 
        cmake-utils_src_prepare
 }

Reply via email to