# Copyright 1999-2016 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ # @ECLASS: kde4-base.eclass # @MAINTAINER: # kde@gentoo.org # @BLURB: This eclass provides functions for kde 4.X ebuilds # @DESCRIPTION: # The kde4-base.eclass provides support for building KDE4 based ebuilds # and KDE4 applications. # # NOTE: KDE 4 ebuilds currently support EAPI 5. This will be # reviewed over time as new EAPI versions are approved. if [[ -z ${_KDE4_BASE_ECLASS} ]]; then _KDE4_BASE_ECLASS=1 # @ECLASS-VARIABLE: KDE_SELINUX_MODULE # @DESCRIPTION: # If set to "none", do nothing. # For any other value, add selinux to IUSE, and depending on that useflag # add a dependency on sec-policy/selinux-${KDE_SELINUX_MODULE} to (R)DEPEND : ${KDE_SELINUX_MODULE:=none} # @ECLASS-VARIABLE: VIRTUALDBUS_TEST # @DESCRIPTION: # If defined, launch and use a private dbus session during src_test. # @ECLASS-VARIABLE: VIRTUALX_REQUIRED # @DESCRIPTION: # For proper description see virtualx.eclass manpage. # Here we redefine default value to be manual, if your package needs virtualx # for tests you should proceed with setting VIRTUALX_REQUIRED=test. : ${VIRTUALX_REQUIRED:=manual} inherit kde4-functions toolchain-funcs fdo-mime flag-o-matic gnome2-utils virtualx versionator eutils multilib if [[ ${KDE_BUILD_TYPE} = live ]]; then case ${KDE_SCM} in svn) inherit subversion ;; git) inherit git-r3 ;; esac fi # @ECLASS-VARIABLE: CMAKE_REQUIRED # @DESCRIPTION: # Specify if cmake buildsystem is being used. Possible values are 'always' and 'never'. # Please note that if it's set to 'never' you need to explicitly override following phases: # src_configure, src_compile, src_test and src_install. # Defaults to 'always'. : ${CMAKE_REQUIRED:=always} if [[ ${CMAKE_REQUIRED} = always ]]; then buildsystem_eclass="cmake-utils" export_fns="src_configure src_compile src_test src_install" fi # @ECLASS-VARIABLE: KDE_MINIMAL # @DESCRIPTION: # This variable is used when KDE_REQUIRED is set, to specify required KDE minimal # version for apps to work. Currently defaults to 4.4 # One may override this variable to raise version requirements. # Note that it is fixed to ${PV} for kde-base packages. KDE_MINIMAL="${KDE_MINIMAL:-4.4}" # Set slot for KDEBASE known packages case ${KDEBASE} in kde-base) SLOT=4/$(get_version_component_range 1-2) KDE_MINIMAL="${PV}" ;; kdevelop) if [[ ${KDE_BUILD_TYPE} = live ]]; then # @ECLASS-VARIABLE: KDEVELOP_VERSION # @DESCRIPTION: # Specifies KDevelop version. Default is 4.0.0 for tagged packages and 9999 for live packages. # Applies to KDEBASE=kdevelop only. KDEVELOP_VERSION="${KDEVELOP_VERSION:-4.9999}" # @ECLASS-VARIABLE: KDEVPLATFORM_VERSION # @DESCRIPTION: # Specifies KDevplatform version. Default is 1.0.0 for tagged packages and 9999 for live packages. # Applies to KDEBASE=kdevelop only. KDEVPLATFORM_VERSION="${KDEVPLATFORM_VERSION:-4.9999}" else case ${PN} in kdevelop) KDEVELOP_VERSION=${PV} KDEVPLATFORM_VERSION="$(($(get_major_version)-3)).$(get_after_major_version)" ;; kdevplatform|kdevelop-php*|kdevelop-python) KDEVELOP_VERSION="$(($(get_major_version)+3)).$(get_after_major_version)" KDEVPLATFORM_VERSION=${PV} ;; *) KDEVELOP_VERSION="${KDEVELOP_VERSION:-4.0.0}" KDEVPLATFORM_VERSION="${KDEVPLATFORM_VERSION:-1.0.0}" esac fi SLOT="4" ;; esac inherit ${buildsystem_eclass} EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare ${export_fns} pkg_preinst pkg_postinst pkg_postrm unset buildsystem_eclass unset export_fns # @ECLASS-VARIABLE: DECLARATIVE_REQUIRED # @DESCRIPTION: # Is qtdeclarative required? Possible values are 'always', 'optional' and 'never'. # This variable must be set before inheriting any eclasses. Defaults to 'never'. DECLARATIVE_REQUIRED="${DECLARATIVE_REQUIRED:-never}" # @ECLASS-VARIABLE: QTHELP_REQUIRED # @DESCRIPTION: # Is qthelp required? Possible values are 'always', 'optional' and 'never'. # This variable must be set before inheriting any eclasses. Defaults to 'never'. QTHELP_REQUIRED="${QTHELP_REQUIRED:-never}" # @ECLASS-VARIABLE: OPENGL_REQUIRED # @DESCRIPTION: # Is qtopengl required? Possible values are 'always', 'optional' and 'never'. # This variable must be set before inheriting any eclasses. Defaults to 'never'. OPENGL_REQUIRED="${OPENGL_REQUIRED:-never}" # @ECLASS-VARIABLE: MULTIMEDIA_REQUIRED # @DESCRIPTION: # Is qtmultimedia required? Possible values are 'always', 'optional' and 'never'. # This variable must be set before inheriting any eclasses. Defaults to 'never'. MULTIMEDIA_REQUIRED="${MULTIMEDIA_REQUIRED:-never}" # @ECLASS-VARIABLE: WEBKIT_REQUIRED # @DESCRIPTION: # Is qtwebkit required? Possible values are 'always', 'optional' and 'never'. # This variable must be set before inheriting any eclasses. Defaults to 'never'. WEBKIT_REQUIRED="${WEBKIT_REQUIRED:-never}" # @ECLASS-VARIABLE: CPPUNIT_REQUIRED # @DESCRIPTION: # Is cppunit required for tests? Possible values are 'always', 'optional' and 'never'. # This variable must be set before inheriting any eclasses. Defaults to 'never'. CPPUNIT_REQUIRED="${CPPUNIT_REQUIRED:-never}" # @ECLASS-VARIABLE: KDE_REQUIRED # @DESCRIPTION: # Is kde required? Possible values are 'always', 'optional' and 'never'. # This variable must be set before inheriting any eclasses. Defaults to 'always' # If set to 'always' or 'optional', KDE_MINIMAL may be overriden as well. # Note that for kde-base packages this variable is fixed to 'always'. KDE_REQUIRED="${KDE_REQUIRED:-always}" # @ECLASS-VARIABLE: KDE_HANDBOOK # @DESCRIPTION: # Set to enable handbook in application. Possible values are 'always', 'optional' # (handbook USE flag) and 'never'. # This variable must be set before inheriting any eclasses. Defaults to 'never'. # It adds default handbook dirs for kde-base packages to KMEXTRA and in any case it # ensures buildtime and runtime dependencies. KDE_HANDBOOK="${KDE_HANDBOOK:-never}" # @ECLASS-VARIABLE: KDE_LINGUAS_LIVE_OVERRIDE # @DESCRIPTION: # Set this varible if you want your live package to manage its # translations. (Mostly all kde ebuilds does not ship documentation # and translations in live ebuilds) if [[ ${KDE_BUILD_TYPE} == live && -z ${KDE_LINGUAS_LIVE_OVERRIDE} ]]; then # Kdebase actually provides the handbooks even for live stuff [[ ${KDEBASE} == kde-base ]] || KDE_HANDBOOK=never KDE_LINGUAS="" fi # Setup packages inheriting this eclass case ${KDEBASE} in kde-base) HOMEPAGE="https://www.kde.org/" LICENSE="GPL-2" if [[ ${KDE_BUILD_TYPE} = live && -z ${I_KNOW_WHAT_I_AM_DOING} ]]; then # Disable tests for live ebuilds by default RESTRICT+=" test" fi # This code is to prevent portage from searching GENTOO_MIRRORS for # packages that will never be mirrored. (As they only will ever be in # the overlay). case ${PV} in *9999* | 4.?.[6-9]? | 4.??.[6-9]? | ??.?.[6-9]? | ??.??.[6-9]?) RESTRICT+=" mirror" ;; esac ;; kdevelop) HOMEPAGE="https://www.kdevelop.org/" LICENSE="GPL-2" ;; esac # @ECLASS-VARIABLE: QT_MINIMAL # @DESCRIPTION: # Determine version of qt we enforce as minimal for the package. QT_MINIMAL="${QT_MINIMAL:-4.8.5}" # Declarative dependencies qtdeclarativedepend=" >=dev-qt/qtdeclarative-${QT_MINIMAL}:4 " case ${DECLARATIVE_REQUIRED} in always) COMMONDEPEND+=" ${qtdeclarativedepend}" ;; optional) IUSE+=" declarative" COMMONDEPEND+=" declarative? ( ${qtdeclarativedepend} )" ;; *) ;; esac unset qtdeclarativedepend # QtHelp dependencies qthelpdepend=" >=dev-qt/qthelp-${QT_MINIMAL}:4 " case ${QTHELP_REQUIRED} in always) COMMONDEPEND+=" ${qthelpdepend}" ;; optional) IUSE+=" qthelp" COMMONDEPEND+=" qthelp? ( ${qthelpdepend} )" ;; esac unset qthelpdepend # OpenGL dependencies qtopengldepend=" >=dev-qt/qtopengl-${QT_MINIMAL}:4 " case ${OPENGL_REQUIRED} in always) COMMONDEPEND+=" ${qtopengldepend}" ;; optional) IUSE+=" opengl" COMMONDEPEND+=" opengl? ( ${qtopengldepend} )" ;; *) ;; esac unset qtopengldepend # MultiMedia dependencies qtmultimediadepend=" >=dev-qt/qtmultimedia-${QT_MINIMAL}:4 " case ${MULTIMEDIA_REQUIRED} in always) COMMONDEPEND+=" ${qtmultimediadepend}" ;; optional) IUSE+=" multimedia" COMMONDEPEND+=" multimedia? ( ${qtmultimediadepend} )" ;; *) ;; esac unset qtmultimediadepend # WebKit dependencies qtwebkitdepend=" >=dev-qt/qtwebkit-${QT_MINIMAL}:4 " case ${WEBKIT_REQUIRED} in always) COMMONDEPEND+=" ${qtwebkitdepend}" ;; optional) IUSE+=" +webkit" COMMONDEPEND+=" webkit? ( ${qtwebkitdepend} )" ;; *) ;; esac unset qtwebkitdepend # CppUnit dependencies cppuintdepend=" dev-util/cppunit " case ${CPPUNIT_REQUIRED} in always) DEPEND+=" ${cppuintdepend}" ;; optional) IUSE+=" test" DEPEND+=" test? ( ${cppuintdepend} )" ;; *) ;; esac unset cppuintdepend # KDE dependencies # Qt accessibility classes are needed in various places, bug 325461 kdecommondepend=" dev-lang/perl >=dev-qt/qt3support-${QT_MINIMAL}:4[accessibility] >=dev-qt/qtcore-${QT_MINIMAL}:4[qt3support,ssl] >=dev-qt/qtdbus-${QT_MINIMAL}:4 >=dev-qt/designer-${QT_MINIMAL}:4 >=dev-qt/qtgui-${QT_MINIMAL}:4[accessibility,dbus(+)] >=dev-qt/qtscript-${QT_MINIMAL}:4 >=dev-qt/qtsql-${QT_MINIMAL}:4[qt3support] >=dev-qt/qtsvg-${QT_MINIMAL}:4 >=dev-qt/qttest-${QT_MINIMAL}:4 " if [[ ${PN} != kdelibs ]]; then local _kdelibsuse case ${WEBKIT_REQUIRED} in always) _kdelibsuse="webkit" ;; optional) _kdelibsuse="webkit?" ;; *) ;; esac kdecommondepend+=" || ( $(add_kdebase_dep kdelibs "${_kdelibsuse}" 4.14.22) &-) != "declare -a mycmakeargs="* ]]; then if [[ ${mycmakeargs} ]]; then eqawarn "mycmakeargs should always be declared as an array, not a string" fi mycmakeargs=(${mycmakeargs}) fi mycmakeargs=("${cmakeargs[@]}" "${mycmakeargs[@]}") cmake-utils_src_configure } # @FUNCTION: kde4-base_src_compile # @DESCRIPTION: # General function for compiling KDE4 applications. kde4-base_src_compile() { debug-print-function ${FUNCNAME} "$@" cmake-utils_src_compile "$@" } # @FUNCTION: kde4-base_src_test # @DESCRIPTION: # Function for testing KDE4 applications. kde4-base_src_test() { debug-print-function ${FUNCNAME} "$@" local kded4_pid _test_runner() { if [[ -n "${VIRTUALDBUS_TEST}" ]]; then export $(dbus-launch) kded4 2>&1 > /dev/null & kded4_pid=$! fi cmake-utils_src_test } # When run as normal user during ebuild development with the ebuild command, the # kde tests tend to access the session DBUS. This however is not possible in a real # emerge or on the tinderbox. # > make sure it does not happen, so bad tests can be recognized and disabled unset DBUS_SESSION_BUS_ADDRESS DBUS_SESSION_BUS_PID # Override this value, set in kde4-base_src_configure() mycmakeargs+=(-DKDE4_BUILD_TESTS=ON) cmake-utils_src_configure kde4-base_src_compile if [[ ${VIRTUALX_REQUIRED} == always || ${VIRTUALX_REQUIRED} == test ]]; then # check for sanity if anyone already redefined VIRTUALX_COMMAND from the default if [[ ${VIRTUALX_COMMAND} != emake ]]; then # surprise- we are already INSIDE virtualmake!!! debug-print "QA Notice: This version of kde4-base.eclass includes the virtualx functionality." debug-print " You may NOT set VIRTUALX_COMMAND or call virtualmake from the ebuild." debug-print " Setting VIRTUALX_REQUIRED is completely sufficient. See the" debug-print " kde4-base.eclass docs for details... Applying workaround." _test_runner else virtx _test_runner fi else _test_runner fi if [ -n "${kded4_pid}" ] ; then kill ${kded4_pid} fi if [ -n "${DBUS_SESSION_BUS_PID}" ] ; then kill ${DBUS_SESSION_BUS_PID} fi } # @FUNCTION: kde4-base_src_install # @DESCRIPTION: # Function for installing KDE4 applications. kde4-base_src_install() { debug-print-function ${FUNCNAME} "$@" if [[ -n ${KMSAVELIBS} ]] ; then install_library_dependencies fi # Install common documentation of KDE4 applications local doc if ! has kde4-meta ${INHERITED}; then for doc in "${S}"/{AUTHORS,CHANGELOG,ChangeLog*,README*,NEWS,TODO,HACKING}; do [[ -f ${doc} && -s ${doc} ]] && dodoc "${doc}" done for doc in "${S}"/*/{AUTHORS,CHANGELOG,ChangeLog*,README*,NEWS,TODO,HACKING}; do [[ -f ${doc} && -s ${doc} ]] && newdoc "${doc}" "$(basename $(dirname ${doc})).$(basename ${doc})" done fi cmake-utils_src_install # We don't want ${PREFIX}/share/doc/HTML to be compressed, # because then khelpcenter can't find the docs [[ -d ${ED}/${PREFIX}/share/doc/HTML ]] && docompress -x ${PREFIX}/share/doc/HTML } # @FUNCTION: kde4-base_pkg_preinst # @DESCRIPTION: # Function storing icon caches kde4-base_pkg_preinst() { debug-print-function ${FUNCNAME} "$@" gnome2_icon_savelist if [[ ${KDE_BUILD_TYPE} == live && ${KDE_SCM} == svn ]]; then subversion_pkg_preinst fi } # @FUNCTION: kde4-base_pkg_postinst # @DESCRIPTION: # Function to rebuild the KDE System Configuration Cache after an application has been installed. kde4-base_pkg_postinst() { debug-print-function ${FUNCNAME} "$@" gnome2_icon_cache_update fdo-mime_desktop_database_update fdo-mime_mime_database_update buildsycoca if [[ -z ${I_KNOW_WHAT_I_AM_DOING} ]]; then if [[ ${KDE_BUILD_TYPE} = live ]]; then echo einfo "WARNING! This is an experimental live ebuild of ${CATEGORY}/${PN}" einfo "Use it at your own risk." einfo "Do _NOT_ file bugs at bugs.gentoo.org because of this ebuild!" echo fi fi } # @FUNCTION: kde4-base_pkg_postrm # @DESCRIPTION: # Function to rebuild the KDE System Configuration Cache after an application has been removed. kde4-base_pkg_postrm() { debug-print-function ${FUNCNAME} "$@" gnome2_icon_cache_update fdo-mime_desktop_database_update fdo-mime_mime_database_update buildsycoca } fi