apache-2.eclass: reflect module dependencies to REQUIRED_USE
authorRolf Eike Beer <eike@sf-mail.de>
Tue, 27 Mar 2018 15:58:27 +0000 (17:58 +0200)
committerLars Wendler <polynomial-c@gentoo.org>
Fri, 27 Apr 2018 14:01:22 +0000 (16:01 +0200)
Portage can do all the checks automatically, with the added bonus that they can
get tested with the portage API, which helps e.g. tatt finding out valid
combinations of use flags.
Closes: https://github.com/gentoo/gentoo/pull/7650

eclass/apache-2.eclass

index 91ff966c8f13d310c1a052cc09f92d25fe646c6c..8eae93fb1d6b2329e0687f1434d5189052fb6b9c 100644 (file)
@@ -119,6 +119,23 @@ PDEPEND="~app-admin/apache-tools-${PV}"
 
 S="${WORKDIR}/httpd-${PV}"
 
+# @VARIABLE: MODULE_DEPENDS
+# @DESCRIPTION:
+# This variable needs to be set in the ebuild and contains a space-separated
+# list of dependency tokens each with a module and the module it depends on
+# separated by a colon
+
+# now extend REQUIRED_USE to reflect the module dependencies to portage
+_apache2_set_module_depends() {
+       local dep
+
+       for dep in ${MODULE_DEPENDS} ; do
+               REQUIRED_USE="${REQUIRED_USE} apache2_modules_${dep%:*}? ( apache2_modules_${dep#*:} )"
+       done
+}
+_apache2_set_module_depends
+unset -f _apache2_set_module_depends
+
 # ==============================================================================
 # INTERNAL FUNCTIONS
 # ==============================================================================
@@ -207,35 +224,6 @@ check_module_critical() {
        fi
 }
 
-# @VARIABLE: MODULE_DEPENDS
-# @DESCRIPTION:
-# This variable needs to be set in the ebuild and contains a space-separated
-# list of dependency tokens each with a module and the module it depends on
-# separated by a colon
-
-# @FUNCTION: check_module_depends
-# @DESCRIPTION:
-# This internal function makes sure that all inter-module dependencies are
-# satisfied with the current module selection
-check_module_depends() {
-       local err=0
-
-       for m in ${MY_MODS[@]} ; do
-               for dep in ${MODULE_DEPENDS} ; do
-                       if [[ "${m}" == "${dep%:*}" ]] ; then
-                               if ! use apache2_modules_${dep#*:} ; then
-                                       eerror "Module '${m}' depends on '${dep#*:}'"
-                                       err=1
-                               fi
-                       fi
-               done
-       done
-
-       if [[ ${err} -ne 0 ]] ; then
-               die "invalid use flag combination"
-       fi
-}
-
 # @ECLASS-VARIABLE: MY_CONF
 # @DESCRIPTION:
 # This internal variable contains the econf options for the current module
@@ -316,7 +304,6 @@ setup_modules() {
 
        # sort and uniquify MY_MODS
        MY_MODS=( $(echo ${MY_MODS[@]} | tr ' ' '\n' | sort -u) )
-       check_module_depends
        check_module_critical
 }