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.2}
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_DOX_DIR
69 # Defaults to ".". Otherwise, use alternative KDE doxygen path.
72 # @ECLASS-VARIABLE: KDE_EXAMPLES
74 # If set to "false", unconditionally ignore a top-level examples subdirectory.
75 # Otherwise, add "examples" to IUSE to toggle adding that subdirectory.
76 : ${KDE_EXAMPLES:=false}
78 # @ECLASS-VARIABLE: KDE_HANDBOOK
80 # If set to "false", do nothing.
81 # Otherwise, add "+handbook" to IUSE, add the appropriate dependency, and
82 # generate and install KDE handbook.
83 : ${KDE_HANDBOOK:=false}
85 # @ECLASS-VARIABLE: KDE_DOC_DIR
87 # Defaults to "doc". Otherwise, use alternative KDE handbook path.
90 # @ECLASS-VARIABLE: KDE_TEST
92 # If set to "false", do nothing.
93 # For any other value, add test to IUSE and add a dependency on dev-qt/qttest:5.
94 if [[ ${CATEGORY} = kde-frameworks ]]; then
100 # @ECLASS-VARIABLE: KDE_PUNT_BOGUS_DEPS
102 # If set to "false", do nothing.
103 # For any other value, do black magic to make hardcoded-but-optional dependencies
104 # optional again. An upstream solution is preferable and this is a last resort.
105 : ${KDE_PUNT_BOGUS_DEPS:=false}
107 # @ECLASS-VARIABLE: KDE_SELINUX_MODULE
109 # If set to "none", do nothing.
110 # For any other value, add selinux to IUSE, and depending on that useflag
111 # add a dependency on sec-policy/selinux-${KDE_SELINUX_MODULE} to (R)DEPEND.
112 : ${KDE_SELINUX_MODULE:=none}
114 if [[ ${KDEBASE} = kdevelop ]]; then
115 HOMEPAGE="https://www.kdevelop.org/"
117 HOMEPAGE="https://www.kde.org/"
122 if [[ ${CATEGORY} = kde-frameworks ]]; then
123 SLOT=5/$(get_version_component_range 1-2)
128 case ${KDE_AUTODEPS} in
131 if [[ ${KDE_BUILD_TYPE} = live ]]; then
134 FRAMEWORKS_MINIMAL=9999
137 FRAMEWORKS_MINIMAL=9999
143 DEPEND+=" $(add_frameworks_dep extra-cmake-modules)"
144 RDEPEND+=" >=kde-frameworks/kf-env-3"
145 COMMONDEPEND+=" >=dev-qt/qtcore-${QT_MINIMAL}:5"
147 if [[ ${CATEGORY} = kde-frameworks || ${CATEGORY} = kde-plasma && ${PN} != polkit-kde-agent ]]; then
149 !kde-apps/kde4-l10n[-minimal(-)]
150 !<kde-apps/kde4-l10n-15.08.0-r1
154 if [[ ${KDE_BLOCK_SLOT4} = true && ${CATEGORY} = kde-apps ]]; then
155 RDEPEND+=" !kde-apps/${PN}:4"
160 case ${KDE_DOXYGEN} in
165 $(add_frameworks_dep kapidox)
178 case ${KDE_EXAMPLES} in
185 case ${KDE_HANDBOOK} in
189 DEPEND+=" handbook? ( $(add_frameworks_dep kdoctools) )"
197 DEPEND+=" test? ( >=dev-qt/qttest-${QT_MINIMAL}:5 )"
201 case ${KDE_SELINUX_MODULE} in
205 RDEPEND+=" selinux? ( sec-policy/selinux-${KDE_SELINUX_MODULE} )"
209 DEPEND+=" ${COMMONDEPEND} dev-util/desktop-file-utils"
210 RDEPEND+=" ${COMMONDEPEND}"
213 if [[ -n ${KMNAME} && ${KMNAME} != ${PN} && ${KDE_BUILD_TYPE} = release ]]; then
214 S=${WORKDIR}/${KMNAME}-${PV}
217 # Determine fetch location for released tarballs
218 _calculate_src_uri() {
219 debug-print-function ${FUNCNAME} "$@"
223 if [[ -n ${KMNAME} ]]; then
237 _kmname="portingAids/${_kmname}"
241 DEPEND+=" app-arch/xz-utils"
246 ??.?.[6-9]? | ??.??.[6-9]? )
247 SRC_URI="mirror://kde/unstable/applications/${PV}/src/${_kmname}-${PV}.tar.xz"
251 SRC_URI="mirror://kde/stable/applications/${PV}/src/${_kmname}-${PV}.tar.xz" ;;
255 SRC_URI="mirror://kde/stable/frameworks/${PV%.*}/${_kmname}-${PV}.tar.xz" ;;
259 # Plasma 5 beta releases
260 SRC_URI="mirror://kde/unstable/plasma/${PV}/${_kmname}-${PV}.tar.xz"
264 # Plasma 5 stable releases
265 SRC_URI="mirror://kde/stable/plasma/${PV}/${_kmname}-${PV}.tar.xz" ;;
271 # Determine fetch location for live sources
272 _calculate_live_repo() {
273 debug-print-function ${FUNCNAME} "$@"
279 # @ECLASS-VARIABLE: ESVN_MIRROR
281 # This variable allows easy overriding of default kde mirror service
282 # (anonsvn) with anything else you might want to use.
283 ESVN_MIRROR=${ESVN_MIRROR:=svn://anonsvn.kde.org/home/kde}
285 local branch_prefix="trunk/KDE"
287 if [[ ${PV} == ??.??.49.9999 && ${CATEGORY} = kde-apps ]]; then
288 branch_prefix="branches/Applications/$(get_version_component_range 1-2)"
291 if [[ ${PV} != 9999 && ${CATEGORY} = kde-plasma ]]; then
292 branch_prefix="branches/plasma/$(get_version_component_range 1-2)"
297 if [[ -n ${KMNAME} ]]; then
303 ESVN_REPO_URI="${ESVN_MIRROR}/${branch_prefix}/${_kmname}"
306 # @ECLASS-VARIABLE: EGIT_MIRROR
308 # This variable allows easy overriding of default kde mirror service
309 # (anongit) with anything else you might want to use.
310 EGIT_MIRROR=${EGIT_MIRROR:=git://anongit.kde.org}
314 # @ECLASS-VARIABLE: EGIT_REPONAME
316 # This variable allows overriding of default repository
317 # name. Specify only if this differ from PN and KMNAME.
318 if [[ -n ${EGIT_REPONAME} ]]; then
319 # the repository and kmname different
320 _kmname=${EGIT_REPONAME}
321 elif [[ -n ${KMNAME} ]]; then
327 if [[ ${PV} == ??.??.49.9999 && ${CATEGORY} = kde-apps ]]; then
328 EGIT_BRANCH="Applications/$(get_version_component_range 1-2)"
331 if [[ ${PV} != 9999 && ${CATEGORY} = kde-plasma ]]; then
332 EGIT_BRANCH="Plasma/$(get_version_component_range 1-2)"
335 EGIT_REPO_URI="${EGIT_MIRROR}/${_kmname}"
340 case ${KDE_BUILD_TYPE} in
341 live) _calculate_live_repo ;;
342 *) _calculate_src_uri ;;
345 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: SRC_URI is ${SRC_URI}"
347 # @FUNCTION: kde5_pkg_pretend
349 # Do some basic settings
351 debug-print-function ${FUNCNAME} "$@"
352 if [[ ${MERGE_TYPE} != binary ]]; then
357 # @FUNCTION: kde5_pkg_setup
359 # Do some basic settings
361 debug-print-function ${FUNCNAME} "$@"
362 if [[ ${MERGE_TYPE} != binary ]]; then
367 # @FUNCTION: kde5_src_unpack
369 # Function for unpacking KDE 5.
371 debug-print-function ${FUNCNAME} "$@"
373 if [[ ${KDE_BUILD_TYPE} = live ]]; then
376 subversion_src_unpack
387 # @FUNCTION: kde5_src_prepare
389 # Function for preparing the KDE 5 sources.
391 debug-print-function ${FUNCNAME} "$@"
393 # only build examples when required
394 if ! use_if_iuse examples || ! use examples ; then
395 comment_add_subdirectory examples
398 # only enable handbook when required
399 if ! use_if_iuse handbook ; then
400 comment_add_subdirectory ${KDE_DOC_DIR}
403 # enable only the requested translations
405 if [[ ${KDE_BUILD_TYPE} = release ]] ; then
406 if [[ -d po ]] ; then
407 pushd po > /dev/null || die
409 if ! has ${lang} ${LINGUAS} ; then
410 if [[ ${lang} != CMakeLists.txt ]] ; then
413 if [[ -e CMakeLists.txt ]] ; then
414 comment_add_subdirectory ${lang}
418 popd > /dev/null || die
421 if [[ ${KDE_HANDBOOK} = true && -d ${KDE_DOC_DIR} && ${CATEGORY} != kde-apps ]] ; then
422 pushd ${KDE_DOC_DIR} > /dev/null || die
424 if ! has ${lang} ${LINGUAS} ; then
425 comment_add_subdirectory ${lang}
428 popd > /dev/null || die
434 # in frameworks, tests = manual tests so never
436 if [[ ${CATEGORY} = kde-frameworks ]]; then
437 comment_add_subdirectory tests
440 if [[ ${CATEGORY} = kde-frameworks || ${CATEGORY} = kde-plasma || ${CATEGORY} = kde-apps ]] ; then
441 # only build unit tests when required
442 if ! use_if_iuse test ; then
443 comment_add_subdirectory autotests
444 comment_add_subdirectory test
445 comment_add_subdirectory tests
449 case ${KDE_PUNT_BOGUS_DEPS} in
452 if ! use_if_iuse test ; then
453 punt_bogus_dep Qt5 Test
455 if ! use_if_iuse handbook ; then
456 punt_bogus_dep KF5 DocTools
461 cmake-utils_src_prepare
464 # @FUNCTION: kde5_src_configure
466 # Function for configuring the build of KDE 5.
467 kde5_src_configure() {
468 debug-print-function ${FUNCNAME} "$@"
470 # we rely on cmake-utils.eclass to append -DNDEBUG too
471 if ! use_if_iuse debug; then
472 append-cppflags -DQT_NO_DEBUG
477 if ! use_if_iuse test ; then
478 cmakeargs+=( -DBUILD_TESTING=OFF )
481 # install mkspecs in the same directory as qt stuff
482 cmakeargs+=(-DKDE_INSTALL_USE_QT_SYS_PATHS=ON)
484 # allow the ebuild to override what we set here
485 mycmakeargs=("${cmakeargs[@]}" "${mycmakeargs[@]}")
487 cmake-utils_src_configure
490 # @FUNCTION: kde5_src_compile
492 # Function for compiling KDE 5.
494 debug-print-function ${FUNCNAME} "$@"
496 cmake-utils_src_compile "$@"
498 # Build doxygen documentation if applicable
499 if use_if_iuse doc ; then
500 kgenapidox ${KDE_DOX_DIR} || die
504 # @FUNCTION: kde5_src_test
506 # Function for testing KDE 5.
508 debug-print-function ${FUNCNAME} "$@"
511 if [[ -n "${VIRTUALDBUS_TEST}" ]]; then
512 export $(dbus-launch)
518 # When run as normal user during ebuild development with the ebuild command, the
519 # kde tests tend to access the session DBUS. This however is not possible in a real
520 # emerge or on the tinderbox.
521 # > make sure it does not happen, so bad tests can be recognized and disabled
522 unset DBUS_SESSION_BUS_ADDRESS DBUS_SESSION_BUS_PID
524 if [[ ${VIRTUALX_REQUIRED} = always || ${VIRTUALX_REQUIRED} = test ]]; then
525 VIRTUALX_COMMAND="_test_runner" virtualmake
530 if [[ -n "${DBUS_SESSION_BUS_PID}" ]] ; then
531 kill ${DBUS_SESSION_BUS_PID}
535 # @FUNCTION: kde5_src_install
537 # Function for installing KDE 5.
539 debug-print-function ${FUNCNAME} "$@"
541 # Install doxygen documentation if applicable
542 if use_if_iuse doc ; then
543 dodoc -r apidocs/html
546 cmake-utils_src_install
548 # We don't want ${PREFIX}/share/doc/HTML to be compressed,
549 # because then khelpcenter can't find the docs
550 if [[ -d ${ED}/${PREFIX}/share/doc/HTML ]]; then
551 docompress -x ${PREFIX}/share/doc/HTML
555 # @FUNCTION: kde5_pkg_preinst
557 # Function storing icon caches
559 debug-print-function ${FUNCNAME} "$@"
564 # @FUNCTION: kde5_pkg_postinst
566 # Function to rebuild the KDE System Configuration Cache after an application has been installed.
567 kde5_pkg_postinst() {
568 debug-print-function ${FUNCNAME} "$@"
570 gnome2_icon_cache_update
571 fdo-mime_desktop_database_update
574 # @FUNCTION: kde5_pkg_postrm
576 # Function to rebuild the KDE System Configuration Cache after an application has been removed.
578 debug-print-function ${FUNCNAME} "$@"
580 gnome2_icon_cache_update
581 fdo-mime_desktop_database_update