1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
8 # @BLURB: Support eclass for KDE 5-related packages.
10 # The kde5.eclass provides support for building KDE 5-related packages.
12 if [[ -z ${_KDE5_ECLASS} ]]; then
15 # @ECLASS-VARIABLE: VIRTUALX_REQUIRED
17 # For proper description see virtualx.eclass manpage.
18 # Here we redefine default value to be manual, if your package needs virtualx
19 # for tests you should proceed with setting VIRTUALX_REQUIRED=test.
20 : ${VIRTUALX_REQUIRED:=manual}
22 inherit kde5-functions fdo-mime flag-o-matic gnome2-utils versionator virtualx eutils cmake-utils
24 if [[ ${KDE_BUILD_TYPE} = live ]]; then
26 svn) inherit subversion ;;
27 git) inherit git-r3 ;;
31 EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure src_compile src_test src_install pkg_preinst pkg_postinst pkg_postrm
33 # @ECLASS-VARIABLE: QT_MINIMAL
35 # Minimal Qt version to require for the package.
36 : ${QT_MINIMAL:=5.4.1}
38 # @ECLASS-VARIABLE: KDE_AUTODEPS
40 # If set to "false", do nothing.
41 # For any other value, add a dependency on dev-qt/qtcore:5 and kde-frameworks/extra-cmake-modules:5.
42 : ${KDE_AUTODEPS:=true}
44 # @ECLASS-VARIABLE: KDE_BLOCK_SLOT4
46 # This variable is used when KDE_AUTODEPS is set.
47 # If set to "true", add RDEPEND block on kde-{base,apps}/${PN}:4
48 : ${KDE_BLOCK_SLOT4:=true}
50 # @ECLASS-VARIABLE: KDE_DEBUG
52 # If set to "false", unconditionally build with -DNDEBUG.
53 # Otherwise, add debug to IUSE to control building with that flag.
56 # @ECLASS-VARIABLE: KDE_DOXYGEN
58 # If set to "false", do nothing.
59 # Otherwise, add "doc" to IUSE, add appropriate dependencies, and generate and
60 # install API documentation.
61 if [[ ${CATEGORY} = kde-frameworks ]]; then
62 : ${KDE_DOXYGEN:=true}
64 : ${KDE_DOXYGEN:=false}
67 # @ECLASS-VARIABLE: KDE_EXAMPLES
69 # If set to "false", unconditionally ignore a top-level examples subdirectory.
70 # Otherwise, add "examples" to IUSE to toggle adding that subdirectory.
71 : ${KDE_EXAMPLES:=false}
73 # @ECLASS-VARIABLE: KDE_HANDBOOK
75 # If set to "false", do nothing.
76 # Otherwise, add "+handbook" to IUSE, add the appropriate dependency, and
77 # generate and install KDE handbook.
78 : ${KDE_HANDBOOK:=false}
80 # @ECLASS-VARIABLE: KDE_DOC_DIR
82 # Defaults to "doc". Otherwise, use alternative KDE handbook path.
85 # @ECLASS-VARIABLE: KDE_TEST
87 # If set to "false", do nothing.
88 # For any other value, add test to IUSE and add a dependency on dev-qt/qttest:5.
89 if [[ ${CATEGORY} = kde-frameworks ]]; then
95 # @ECLASS-VARIABLE: KDE_PUNT_BOGUS_DEPS
97 # If set to "false", do nothing.
98 # For any other value, do black magic to make hardcoded-but-optional dependencies
99 # optional again. An upstream solution is preferable and this is a last resort.
100 : ${KDE_PUNT_BOGUS_DEPS:=false}
102 # @ECLASS-VARIABLE: KDE_SELINUX_MODULE
104 # If set to "none", do nothing.
105 # For any other value, add selinux to IUSE, and depending on that useflag
106 # add a dependency on sec-policy/selinux-${KDE_SELINUX_MODULE} to (R)DEPEND.
107 : ${KDE_SELINUX_MODULE:=none}
109 if [[ ${KDEBASE} = kdevelop ]]; then
110 HOMEPAGE="https://www.kdevelop.org/"
112 HOMEPAGE="https://www.kde.org/"
117 if [[ ${CATEGORY} = kde-frameworks ]]; then
118 SLOT=5/$(get_version_component_range 1-2)
123 case ${KDE_AUTODEPS} in
126 if [[ ${KDE_BUILD_TYPE} = live ]]; then
129 FRAMEWORKS_MINIMAL=9999
132 FRAMEWORKS_MINIMAL=9999
138 DEPEND+=" $(add_frameworks_dep extra-cmake-modules)"
139 RDEPEND+=" >=kde-frameworks/kf-env-3"
140 COMMONDEPEND+=" >=dev-qt/qtcore-${QT_MINIMAL}:5"
142 if [[ ${CATEGORY} = kde-frameworks || ${CATEGORY} = kde-plasma && ${PN} != polkit-kde-agent ]]; then
144 !kde-apps/kde4-l10n[-minimal(-)]
145 !<kde-apps/kde4-l10n-15.08.0-r1
149 if [[ ${KDE_BLOCK_SLOT4} = true && ${CATEGORY} = kde-apps ]]; then
150 RDEPEND+=" !kde-apps/${PN}:4"
155 case ${KDE_DOXYGEN} in
160 $(add_frameworks_dep kapidox)
173 case ${KDE_EXAMPLES} in
180 case ${KDE_HANDBOOK} in
184 DEPEND+=" handbook? ( $(add_frameworks_dep kdoctools) )"
192 DEPEND+=" test? ( >=dev-qt/qttest-${QT_MINIMAL}:5 )"
196 case ${KDE_SELINUX_MODULE} in
200 RDEPEND+=" selinux? ( sec-policy/selinux-${KDE_SELINUX_MODULE} )"
204 DEPEND+=" ${COMMONDEPEND} dev-util/desktop-file-utils"
205 RDEPEND+=" ${COMMONDEPEND}"
208 if [[ -n ${KMNAME} && ${KMNAME} != ${PN} && ${KDE_BUILD_TYPE} = release ]]; then
209 S=${WORKDIR}/${KMNAME}-${PV}
212 # Determine fetch location for released tarballs
213 _calculate_src_uri() {
214 debug-print-function ${FUNCNAME} "$@"
218 if [[ -n ${KMNAME} ]]; then
232 _kmname="portingAids/${_kmname}"
236 DEPEND+=" app-arch/xz-utils"
241 ??.?.[6-9]? | ??.??.[6-9]? )
242 SRC_URI="mirror://kde/unstable/applications/${PV}/src/${_kmname}-${PV}.tar.xz"
246 SRC_URI="mirror://kde/stable/applications/${PV}/src/${_kmname}-${PV}.tar.xz" ;;
250 SRC_URI="mirror://kde/stable/frameworks/${PV%.*}/${_kmname}-${PV}.tar.xz" ;;
254 # Plasma 5 beta releases
255 SRC_URI="mirror://kde/unstable/plasma/${PV}/${_kmname}-${PV}.tar.xz"
259 # Plasma 5 stable releases
260 SRC_URI="mirror://kde/stable/plasma/${PV}/${_kmname}-${PV}.tar.xz" ;;
266 # Determine fetch location for live sources
267 _calculate_live_repo() {
268 debug-print-function ${FUNCNAME} "$@"
274 # @ECLASS-VARIABLE: ESVN_MIRROR
276 # This variable allows easy overriding of default kde mirror service
277 # (anonsvn) with anything else you might want to use.
278 ESVN_MIRROR=${ESVN_MIRROR:=svn://anonsvn.kde.org/home/kde}
280 local branch_prefix="trunk/KDE"
282 if [[ ${PV} == ??.??.49.9999 && ${CATEGORY} = kde-apps ]]; then
283 branch_prefix="branches/Applications/$(get_version_component_range 1-2)"
286 if [[ ${PV} != 9999 && ${CATEGORY} = kde-plasma ]]; then
287 branch_prefix="branches/plasma/$(get_version_component_range 1-2)"
292 if [[ -n ${KMNAME} ]]; then
298 ESVN_REPO_URI="${ESVN_MIRROR}/${branch_prefix}/${_kmname}"
301 # @ECLASS-VARIABLE: EGIT_MIRROR
303 # This variable allows easy overriding of default kde mirror service
304 # (anongit) with anything else you might want to use.
305 EGIT_MIRROR=${EGIT_MIRROR:=git://anongit.kde.org}
309 # @ECLASS-VARIABLE: EGIT_REPONAME
311 # This variable allows overriding of default repository
312 # name. Specify only if this differ from PN and KMNAME.
313 if [[ -n ${EGIT_REPONAME} ]]; then
314 # the repository and kmname different
315 _kmname=${EGIT_REPONAME}
316 elif [[ -n ${KMNAME} ]]; then
322 if [[ ${PV} != 9999 && ${CATEGORY} = kde-plasma ]]; then
323 EGIT_BRANCH="Plasma/$(get_version_component_range 1-2)"
326 EGIT_REPO_URI="${EGIT_MIRROR}/${_kmname}"
331 case ${KDE_BUILD_TYPE} in
332 live) _calculate_live_repo ;;
333 *) _calculate_src_uri ;;
336 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: SRC_URI is ${SRC_URI}"
338 # @FUNCTION: kde5_pkg_pretend
340 # Do some basic settings
342 debug-print-function ${FUNCNAME} "$@"
346 # @FUNCTION: kde5_pkg_setup
348 # Do some basic settings
350 debug-print-function ${FUNCNAME} "$@"
354 # @FUNCTION: kde5_src_unpack
356 # Function for unpacking KDE 5.
358 debug-print-function ${FUNCNAME} "$@"
360 if [[ ${KDE_BUILD_TYPE} = live ]]; then
363 subversion_src_unpack
374 # @FUNCTION: kde5_src_prepare
376 # Function for preparing the KDE 5 sources.
378 debug-print-function ${FUNCNAME} "$@"
380 # only build examples when required
381 if ! use_if_iuse examples || ! use examples ; then
382 comment_add_subdirectory examples
385 # only enable handbook when required
386 if ! use_if_iuse handbook ; then
387 comment_add_subdirectory ${KDE_DOC_DIR}
390 # enable only the requested translations
392 if [[ ${KDE_BUILD_TYPE} = release ]] ; then
393 if [[ -d po ]] ; then
396 if ! has ${lang} ${LINGUAS} ; then
397 if [[ ${lang} != CMakeLists.txt ]] ; then
400 if [[ -e CMakeLists.txt ]] ; then
401 comment_add_subdirectory ${lang}
408 if [[ ${KDE_HANDBOOK} = true && -d ${KDE_DOC_DIR} && ${CATEGORY} != kde-apps ]] ; then
409 pushd ${KDE_DOC_DIR} > /dev/null
411 if ! has ${lang} ${LINGUAS} ; then
412 comment_add_subdirectory ${lang}
421 # in frameworks, tests = manual tests so never
423 if [[ ${CATEGORY} = kde-frameworks ]]; then
424 comment_add_subdirectory tests
427 if [[ ${CATEGORY} = kde-frameworks || ${CATEGORY} = kde-plasma || ${CATEGORY} = kde-apps ]] ; then
428 # only build unit tests when required
429 if ! use_if_iuse test ; then
430 comment_add_subdirectory autotests
431 comment_add_subdirectory test
432 comment_add_subdirectory tests
436 case ${KDE_PUNT_BOGUS_DEPS} in
439 if ! use_if_iuse test ; then
440 punt_bogus_dep Qt5 Test
442 if ! use_if_iuse handbook ; then
443 punt_bogus_dep KF5 DocTools
448 cmake-utils_src_prepare
451 # @FUNCTION: kde5_src_configure
453 # Function for configuring the build of KDE 5.
454 kde5_src_configure() {
455 debug-print-function ${FUNCNAME} "$@"
457 # we rely on cmake-utils.eclass to append -DNDEBUG too
458 if ! use_if_iuse debug; then
459 append-cppflags -DQT_NO_DEBUG
464 if ! use_if_iuse test ; then
465 cmakeargs+=( -DBUILD_TESTING=OFF )
468 # install mkspecs in the same directory as qt stuff
469 cmakeargs+=(-DKDE_INSTALL_USE_QT_SYS_PATHS=ON)
471 # allow the ebuild to override what we set here
472 mycmakeargs=("${cmakeargs[@]}" "${mycmakeargs[@]}")
474 cmake-utils_src_configure
477 # @FUNCTION: kde5_src_compile
479 # Function for compiling KDE 5.
481 debug-print-function ${FUNCNAME} "$@"
483 cmake-utils_src_compile "$@"
485 # Build doxygen documentation if applicable
486 if use_if_iuse doc ; then
491 # @FUNCTION: kde5_src_test
493 # Function for testing KDE 5.
495 debug-print-function ${FUNCNAME} "$@"
498 if [[ -n "${VIRTUALDBUS_TEST}" ]]; then
499 export $(dbus-launch)
505 # When run as normal user during ebuild development with the ebuild command, the
506 # kde tests tend to access the session DBUS. This however is not possible in a real
507 # emerge or on the tinderbox.
508 # > make sure it does not happen, so bad tests can be recognized and disabled
509 unset DBUS_SESSION_BUS_ADDRESS DBUS_SESSION_BUS_PID
511 if [[ ${VIRTUALX_REQUIRED} = always || ${VIRTUALX_REQUIRED} = test ]]; then
512 VIRTUALX_COMMAND="_test_runner" virtualmake
517 if [[ -n "${DBUS_SESSION_BUS_PID}" ]] ; then
518 kill ${DBUS_SESSION_BUS_PID}
522 # @FUNCTION: kde5_src_install
524 # Function for installing KDE 5.
526 debug-print-function ${FUNCNAME} "$@"
528 # Install doxygen documentation if applicable
529 if use_if_iuse doc ; then
530 dodoc -r apidocs/html
533 cmake-utils_src_install
535 # We don't want ${PREFIX}/share/doc/HTML to be compressed,
536 # because then khelpcenter can't find the docs
537 if [[ -d ${ED}/${PREFIX}/share/doc/HTML ]]; then
538 docompress -x ${PREFIX}/share/doc/HTML
542 # @FUNCTION: kde5_pkg_preinst
544 # Function storing icon caches
546 debug-print-function ${FUNCNAME} "$@"
551 # @FUNCTION: kde5_pkg_postinst
553 # Function to rebuild the KDE System Configuration Cache after an application has been installed.
554 kde5_pkg_postinst() {
555 debug-print-function ${FUNCNAME} "$@"
557 gnome2_icon_cache_update
558 fdo-mime_desktop_database_update
561 # @FUNCTION: kde5_pkg_postrm
563 # Function to rebuild the KDE System Configuration Cache after an application has been removed.
565 debug-print-function ${FUNCNAME} "$@"
567 gnome2_icon_cache_update
568 fdo-mime_desktop_database_update