3c2028446c7755412789bb1c1359472939346798
[gentoo.git] / eclass / kde5.eclass
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 # @ECLASS: kde5.eclass
6 # @MAINTAINER:
7 # kde@gentoo.org
8 # @BLURB: Support eclass for KDE 5-related packages.
9 # @DESCRIPTION:
10 # The kde5.eclass provides support for building KDE 5-related packages.
11
12 if [[ -z ${_KDE5_ECLASS} ]]; then
13 _KDE5_ECLASS=1
14
15 # @ECLASS-VARIABLE: VIRTUALX_REQUIRED
16 # @DESCRIPTION:
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}
21
22 inherit cmake-utils eutils flag-o-matic gnome2-utils kde5-functions versionator virtualx xdg
23
24 if [[ ${KDE_BUILD_TYPE} = live ]]; then
25         case ${KDE_SCM} in
26                 git) inherit git-r3 ;;
27         esac
28 fi
29
30 if [[ -v KDE_GCC_MINIMAL ]]; then
31         EXPORT_FUNCTIONS pkg_pretend
32 fi
33
34 EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_test src_install pkg_preinst pkg_postinst pkg_postrm
35
36 # @ECLASS-VARIABLE: QT_MINIMAL
37 # @DESCRIPTION:
38 # Minimal Qt version to require for the package.
39 : ${QT_MINIMAL:=5.6.1}
40
41 # @ECLASS-VARIABLE: KDE_AUTODEPS
42 # @DESCRIPTION:
43 # If set to "false", do nothing.
44 # For any other value, add a dependency on dev-qt/qtcore:5 and kde-frameworks/extra-cmake-modules:5.
45 : ${KDE_AUTODEPS:=true}
46
47 # @ECLASS-VARIABLE: KDE_BLOCK_SLOT4
48 # @DESCRIPTION:
49 # This variable is used when KDE_AUTODEPS is set.
50 # If set to "true", add RDEPEND block on kde-apps/${PN}:4
51 : ${KDE_BLOCK_SLOT4:=true}
52
53 # @ECLASS-VARIABLE: KDE_DEBUG
54 # @DESCRIPTION:
55 # If set to "false", unconditionally build with -DNDEBUG.
56 # Otherwise, add debug to IUSE to control building with that flag.
57 : ${KDE_DEBUG:=true}
58
59 # @ECLASS-VARIABLE: KDE_DESIGNERPLUGIN
60 # @DESCRIPTION:
61 # If set to "false", do nothing.
62 # Otherwise, add "designer" to IUSE to toggle build of designer plugins
63 # and add the necessary DEPENDs.
64 : ${KDE_DESIGNERPLUGIN:=false}
65
66 # @ECLASS-VARIABLE: KDE_EXAMPLES
67 # @DESCRIPTION:
68 # If set to "false", unconditionally ignore a top-level examples subdirectory.
69 # Otherwise, add "examples" to IUSE to toggle adding that subdirectory.
70 : ${KDE_EXAMPLES:=false}
71
72 # @ECLASS-VARIABLE: KDE_HANDBOOK
73 # @DESCRIPTION:
74 # If set to "false", do nothing.
75 # Otherwise, add "+handbook" to IUSE, add the appropriate dependency, and
76 # generate and install KDE handbook.
77 # If set to "optional", config with -DCMAKE_DISABLE_FIND_PACKAGE_KF5DocTools=ON
78 # when USE=!handbook. In case package requires KF5KDELibs4Support, see next:
79 # If set to "forceoptional", remove a KF5DocTools dependency from the root
80 # CMakeLists.txt in addition to the above.
81 : ${KDE_HANDBOOK:=false}
82
83 # @ECLASS-VARIABLE: KDE_DOC_DIR
84 # @DESCRIPTION:
85 # Defaults to "doc". Otherwise, use alternative KDE handbook path.
86 : ${KDE_DOC_DIR:=doc}
87
88 # @ECLASS-VARIABLE: KDE_TEST
89 # @DESCRIPTION:
90 # If set to "false", do nothing.
91 # For any other value, add test to IUSE and add a dependency on dev-qt/qttest:5.
92 # If set to "optional", configure with -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Test=ON
93 # when USE=!test.
94 # If set to "forceoptional", remove a Qt5Test dependency and comment test
95 # subdirs from the root CMakeLists.txt in addition to the above.
96 # If set to "forceoptional-recursive", remove a Qt5Test dependency and comment
97 # test subdirs from *any* CMakeLists.txt in addition to the above.
98 if [[ ${CATEGORY} = kde-frameworks ]]; then
99         : ${KDE_TEST:=true}
100 else
101         : ${KDE_TEST:=false}
102 fi
103
104 # @ECLASS-VARIABLE: KDE_L10N
105 # @DESCRIPTION:
106 # This is an array of translations this ebuild supports. These translations
107 # are automatically added to IUSE.
108 if [[ ${KDEBASE} = kdel10n ]]; then
109         if [[ -n ${KDE_L10N} ]]; then
110                 IUSE="${IUSE} $(printf 'l10n_%s ' ${KDE_L10N[@]})"
111         fi
112 fi
113
114 # @ECLASS-VARIABLE: KDE_SELINUX_MODULE
115 # @DESCRIPTION:
116 # If set to "none", do nothing.
117 # For any other value, add selinux to IUSE, and depending on that useflag
118 # add a dependency on sec-policy/selinux-${KDE_SELINUX_MODULE} to (R)DEPEND.
119 : ${KDE_SELINUX_MODULE:=none}
120
121 if [[ ${KDEBASE} = kdevelop ]]; then
122         HOMEPAGE="https://www.kdevelop.org/"
123 elif [[ ${KDEBASE} = kdel10n ]]; then
124         HOMEPAGE="http://l10n.kde.org"
125 elif [[ ${KMNAME} = kdepim ]]; then
126         HOMEPAGE="https://www.kde.org/applications/office/kontact/"
127 else
128         HOMEPAGE="https://www.kde.org/"
129 fi
130
131 LICENSE="GPL-2"
132
133 if [[ ${CATEGORY} = kde-frameworks ]]; then
134         SLOT=5/$(get_version_component_range 1-2)
135 else
136         SLOT=5
137 fi
138
139 case ${KDE_AUTODEPS} in
140         false)  ;;
141         *)
142                 if [[ ${KDE_BUILD_TYPE} = live ]]; then
143                         case ${CATEGORY} in
144                                 kde-frameworks)
145                                         FRAMEWORKS_MINIMAL=9999
146                                 ;;
147                                 kde-plasma)
148                                         FRAMEWORKS_MINIMAL=9999
149                                 ;;
150                                 *) ;;
151                         esac
152                 fi
153
154                 DEPEND+=" $(add_frameworks_dep extra-cmake-modules)"
155                 RDEPEND+=" >=kde-frameworks/kf-env-3"
156                 COMMONDEPEND+=" $(add_qt_dep qtcore)"
157
158                 if [[ ${CATEGORY} = kde-frameworks || ${CATEGORY} = kde-plasma && ${PN} != polkit-kde-agent ]]; then
159                         RDEPEND+="
160                                 !kde-apps/kde4-l10n[-minimal(+)]
161                                 !<kde-apps/kde4-l10n-15.12.3-r1
162                         "
163                 fi
164
165                 if [[ ${KDE_BLOCK_SLOT4} = true && ${CATEGORY} = kde-apps ]]; then
166                         RDEPEND+=" !kde-apps/${PN}:4"
167                 fi
168                 ;;
169 esac
170
171 case ${KDE_DEBUG} in
172         false)  ;;
173         *)
174                 IUSE+=" debug"
175                 ;;
176 esac
177
178 case ${KDE_DESIGNERPLUGIN} in
179         false)  ;;
180         *)
181                 IUSE+=" designer"
182                 DEPEND+=" designer? (
183                         $(add_frameworks_dep kdesignerplugin)
184                         $(add_qt_dep designer)
185                 )"
186                 ;;
187 esac
188
189 case ${KDE_EXAMPLES} in
190         false)  ;;
191         *)
192                 IUSE+=" examples"
193                 ;;
194 esac
195
196 case ${KDE_HANDBOOK} in
197         false)  ;;
198         *)
199                 IUSE+=" +handbook"
200                 DEPEND+=" handbook? ( $(add_frameworks_dep kdoctools) )"
201                 ;;
202 esac
203
204 case ${KDE_TEST} in
205         false)  ;;
206         *)
207                 IUSE+=" test"
208                 DEPEND+=" test? ( $(add_qt_dep qttest) )"
209                 ;;
210 esac
211
212 case ${KDE_SELINUX_MODULE} in
213         none)   ;;
214         *)
215                 IUSE+=" selinux"
216                 RDEPEND+=" selinux? ( sec-policy/selinux-${KDE_SELINUX_MODULE} )"
217                 ;;
218 esac
219
220 DEPEND+=" ${COMMONDEPEND} dev-util/desktop-file-utils"
221 RDEPEND+=" ${COMMONDEPEND}"
222 unset COMMONDEPEND
223
224 if [[ -n ${KMNAME} && ${KMNAME} != ${PN} && ${KDE_BUILD_TYPE} = release ]]; then
225         S=${WORKDIR}/${KMNAME}-${PV}
226 fi
227
228 # Drop this when kdepim is finally split upstream
229 if [[ -n ${KMNAME} && ${KMNAME} != ${PN} && ${KMNAME} = kdepim ]]; then
230         S="${S}/${PN}"
231 fi
232
233 if [[ -n ${KDEBASE} && ${KDEBASE} = kdevelop && ${KDE_BUILD_TYPE} = release ]]; then
234         if [[ -n ${KMNAME} ]]; then
235                 S=${WORKDIR}/${KMNAME}-${PV%.0} # kdevelop missing trailing .0 in first release
236         else
237                 S=${WORKDIR}/${PN}-${PV%.0}     # kdevelop missing trailing .0 in first release
238         fi
239 fi
240
241 # Determine fetch location for released tarballs
242 _calculate_src_uri() {
243         debug-print-function ${FUNCNAME} "$@"
244
245         local _kmname
246
247         if [[ -n ${KMNAME} ]]; then
248                 _kmname=${KMNAME}
249         else
250                 _kmname=${PN}
251         fi
252
253         case ${PN} in
254                 kdelibs4support | \
255                 khtml | \
256                 kjs | \
257                 kjsembed | \
258                 kmediaplayer | \
259                 kross)
260                         _kmname="portingAids/${_kmname}"
261                         ;;
262         esac
263
264         DEPEND+=" app-arch/xz-utils"
265
266         case ${CATEGORY} in
267                 kde-apps)
268                         case ${PV} in
269                                 ??.?.[6-9]? | ??.??.[6-9]? )
270                                         SRC_URI="mirror://kde/unstable/applications/${PV}/src/${_kmname}-${PV}.tar.xz"
271                                         RESTRICT+=" mirror"
272                                         ;;
273                                 *)
274                                         SRC_URI="mirror://kde/stable/applications/${PV}/src/${_kmname}-${PV}.tar.xz" ;;
275                         esac
276                         ;;
277                 kde-frameworks)
278                         SRC_URI="mirror://kde/stable/frameworks/${PV%.*}/${_kmname}-${PV}.tar.xz" ;;
279                 kde-plasma)
280                         local plasmapv=$(get_version_component_range 1-3)
281
282                         case ${PV} in
283                                 5.?.[6-9]? )
284                                         # Plasma 5 beta releases
285                                         SRC_URI="mirror://kde/unstable/plasma/${plasmapv}/${_kmname}-${PV}.tar.xz"
286                                         RESTRICT+=" mirror"
287                                         ;;
288                                 *)
289                                         # Plasma 5 stable releases
290                                         SRC_URI="mirror://kde/stable/plasma/${plasmapv}/${_kmname}-${PV}.tar.xz" ;;
291                         esac
292                         ;;
293         esac
294
295         if [[ -z ${SRC_URI} && -n ${KDEBASE} ]] ; then
296                 local _kdebase
297                 case ${PN} in
298                         kdevelop-pg-qt)
299                                 _kdebase=${PN} ;;
300                         *)
301                                 _kdebase=${KDEBASE} ;;
302                 esac
303                 case ${PV} in
304                         *.*.[6-9]? )
305                                 SRC_URI="mirror://kde/unstable/${_kdebase}/${PV}/src/${_kmname}-${PV}.tar.xz"
306                                 RESTRICT+=" mirror"
307                                 ;;
308                         *)
309                                 SRC_URI="mirror://kde/stable/${_kdebase}/${PV}/src/${_kmname}-${PV%.0}.tar.xz" ;;
310                 esac
311                 unset _kdebase
312         fi
313
314         if [[ ${KDEBASE} = kdel10n ]] ; then
315                 local uri_base="${SRC_URI/${_kmname}-${PV}.tar.xz/}kde-l10n/kde-l10n"
316                 SRC_URI=""
317                 for my_l10n in ${KDE_L10N[@]} ; do
318                         case ${my_l10n} in
319                                 sr | sr-ijekavsk | sr-Latn-ijekavsk | sr-Latn)
320                                         SRC_URI="${SRC_URI} l10n_${my_l10n}? ( ${uri_base}-sr-${PV}.tar.xz )"
321                                         ;;
322                                 *)
323                                         SRC_URI="${SRC_URI} l10n_${my_l10n}? ( ${uri_base}-$(kde_l10n2lingua ${my_l10n})-${PV}.tar.xz )"
324                                         ;;
325                         esac
326                 done
327         fi
328 }
329
330 # Determine fetch location for live sources
331 _calculate_live_repo() {
332         debug-print-function ${FUNCNAME} "$@"
333
334         SRC_URI=""
335
336         case ${KDE_SCM} in
337                 git)
338                         # @ECLASS-VARIABLE: EGIT_MIRROR
339                         # @DESCRIPTION:
340                         # This variable allows easy overriding of default kde mirror service
341                         # (anongit) with anything else you might want to use.
342                         EGIT_MIRROR=${EGIT_MIRROR:=https://anongit.kde.org}
343
344                         local _kmname
345
346                         # @ECLASS-VARIABLE: EGIT_REPONAME
347                         # @DESCRIPTION:
348                         # This variable allows overriding of default repository
349                         # name. Specify only if this differ from PN and KMNAME.
350                         if [[ -n ${EGIT_REPONAME} ]]; then
351                                 # the repository and kmname different
352                                 _kmname=${EGIT_REPONAME}
353                         elif [[ -n ${KMNAME} ]]; then
354                                 _kmname=${KMNAME}
355                         else
356                                 _kmname=${PN}
357                         fi
358
359                         if [[ ${PV} == ??.??.49.9999 && ${CATEGORY} = kde-apps ]]; then
360                                 EGIT_BRANCH="Applications/$(get_version_component_range 1-2)"
361                         fi
362
363                         if [[ ${PV} != 9999 && ${CATEGORY} = kde-plasma ]]; then
364                                 EGIT_BRANCH="Plasma/$(get_version_component_range 1-2)"
365                         fi
366
367                         EGIT_REPO_URI="${EGIT_MIRROR}/${_kmname}"
368                         ;;
369         esac
370 }
371
372 case ${KDE_BUILD_TYPE} in
373         live) _calculate_live_repo ;;
374         *) _calculate_src_uri ;;
375 esac
376
377 debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: SRC_URI is ${SRC_URI}"
378
379 # @FUNCTION: kde5_pkg_pretend
380 # @DESCRIPTION:
381 # Do some basic settings
382 kde5_pkg_pretend() {
383         debug-print-function ${FUNCNAME} "$@"
384         _check_gcc_version
385 }
386
387 # @FUNCTION: kde5_pkg_setup
388 # @DESCRIPTION:
389 # Do some basic settings
390 kde5_pkg_setup() {
391         debug-print-function ${FUNCNAME} "$@"
392         _check_gcc_version
393 }
394
395 # @FUNCTION: kde5_src_unpack
396 # @DESCRIPTION:
397 # Function for unpacking KDE 5.
398 kde5_src_unpack() {
399         debug-print-function ${FUNCNAME} "$@"
400
401         if [[ ${KDE_BUILD_TYPE} = live ]]; then
402                 case ${KDE_SCM} in
403                         git)
404                                 git-r3_src_unpack
405                                 ;;
406                 esac
407         elif [[ ${KDEBASE} = kdel10n ]]; then
408                 local l10npart=5
409                 [[ ${PN} = kde4-l10n ]] && l10npart=4
410                 mkdir -p "${S}" || die "Failed to create source dir ${S}"
411                 cd "${S}"
412                 for my_tar in ${A}; do
413                         tar -xpf "${DISTDIR}/${my_tar}" --xz \
414                                 "${my_tar/.tar.xz/}/CMakeLists.txt" "${my_tar/.tar.xz/}/${l10npart}" 2> /dev/null ||
415                                 elog "${my_tar}: tar extract command failed at least partially - continuing"
416                 done
417         else
418                 default
419         fi
420 }
421
422 # @FUNCTION: kde5_src_prepare
423 # @DESCRIPTION:
424 # Function for preparing the KDE 5 sources.
425 kde5_src_prepare() {
426         debug-print-function ${FUNCNAME} "$@"
427
428         if [[ ${KDEBASE} = kdel10n ]]; then
429                 local l10npart=5
430                 [[ ${PN} = kde4-l10n ]] && l10npart=4
431                 # move known variant subdirs to root dir, currently sr@*
432                 use_if_iuse l10n_sr-ijekavsk && _l10n_variant_subdir2root sr-ijekavsk sr
433                 use_if_iuse l10n_sr-Latn-ijekavsk && _l10n_variant_subdir2root sr-Latn-ijekavsk sr
434                 use_if_iuse l10n_sr-Latn && _l10n_variant_subdir2root sr-Latn sr
435                 if use_if_iuse l10n_sr; then
436                         rm -rf kde-l10n-sr-${PV}/${l10npart}/sr/sr@* || die "Failed to cleanup L10N=sr"
437                         _l10n_variant_subdir_buster sr
438                 elif [[ -d kde-l10n-sr-${PV} ]]; then
439                         # having any variant selected means parent lingua will be unpacked as well
440                         rm -r kde-l10n-sr-${PV} || die "Failed to remove sr parent lingua"
441                 fi
442
443                 # add all l10n directories to cmake
444                 cat <<-EOF > CMakeLists.txt || die
445 project(${PN})
446 cmake_minimum_required(VERSION 2.8.12)
447 $(printf "add_subdirectory( %s )\n" \
448         `find . -mindepth 1 -maxdepth 1 -type d | sed -e "s:^\./::"`)
449 EOF
450
451                 # for KF5: drop KDE4-based part; for KDE4: drop KF5-based part
452                 case ${l10npart} in
453                         5) find -maxdepth 2 -type f -name CMakeLists.txt -exec \
454                                 sed -i -e "/add_subdirectory(4)/ s/^/#DONT/" {} + || die ;;
455                         4) find -maxdepth 2 -type f -name CMakeLists.txt -exec \
456                                 sed -i -e "/add_subdirectory(5)/ s/^/#DONT/" {} + || die ;;
457                 esac
458         fi
459
460         cmake-utils_src_prepare
461
462         # only build examples when required
463         if ! use_if_iuse examples || ! use examples ; then
464                 cmake_comment_add_subdirectory examples
465         fi
466
467         # only enable handbook when required
468         if ! use_if_iuse handbook ; then
469                 cmake_comment_add_subdirectory ${KDE_DOC_DIR}
470
471                 if [[ ${KDE_HANDBOOK} = forceoptional ]] ; then
472                         punt_bogus_dep KF5 DocTools
473                 fi
474         fi
475
476         # drop translations when nls is not wanted
477         if [[ -d po ]] && in_iuse nls && ! use nls ; then
478                 rm -r po || die
479         fi
480
481         # enable only the requested translations
482         # when required
483         if [[ -d po && -v LINGUAS ]] ; then
484                 pushd po > /dev/null || die
485                 local lang
486                 for lang in *; do
487                         if [[ -d ${lang} ]] && ! has ${lang} ${LINGUAS} ; then
488                                 rm -r ${lang} || die
489                                 if [[ -e CMakeLists.txt ]] ; then
490                                         cmake_comment_add_subdirectory ${lang}
491                                 fi
492                         elif ! has ${lang/.po/} ${LINGUAS} ; then
493                                 if [[ ${lang} != CMakeLists.txt && ${lang} != ${PN}.pot ]] ; then
494                                         rm ${lang} || die
495                                 fi
496                         fi
497                 done
498                 popd > /dev/null || die
499         fi
500
501         if [[ ${KDE_BUILD_TYPE} = release && ${CATEGORY} != kde-apps ]] ; then
502                 if [[ ${KDE_HANDBOOK} != false && -d ${KDE_DOC_DIR} && -v LINGUAS ]] ; then
503                         pushd ${KDE_DOC_DIR} > /dev/null || die
504                         local lang
505                         for lang in *; do
506                                 if ! has ${lang} ${LINGUAS} ; then
507                                         cmake_comment_add_subdirectory ${lang}
508                                 fi
509                         done
510                         popd > /dev/null || die
511                 fi
512         fi
513
514         # in frameworks, tests = manual tests so never build them
515         if [[ ${CATEGORY} = kde-frameworks ]] && [[ ${PN} != extra-cmake-modules ]]; then
516                 cmake_comment_add_subdirectory tests
517         fi
518
519         # only build unit tests when required
520         if ! use_if_iuse test ; then
521                 if [[ ${KDE_TEST} = forceoptional ]] ; then
522                         punt_bogus_dep Qt5 Test
523                         # if forceoptional, also cover non-kde categories
524                         cmake_comment_add_subdirectory autotests test tests
525                 elif [[ ${KDE_TEST} = forceoptional-recursive ]] ; then
526                         punt_bogus_dep Qt5 Test
527                         local d
528                         for d in $(find . -type d -name "autotests" -or -name "tests" -or -name "test" -or -name "unittests"); do
529                                 pushd ${d%/*} > /dev/null || die
530                                         punt_bogus_dep Qt5 Test
531                                         cmake_comment_add_subdirectory autotests test tests
532                                 popd > /dev/null || die
533                         done
534                 elif [[ ${CATEGORY} = kde-frameworks || ${CATEGORY} = kde-plasma || ${CATEGORY} = kde-apps ]] ; then
535                         cmake_comment_add_subdirectory autotests test tests
536                 fi
537         fi
538 }
539
540 # @FUNCTION: kde5_src_configure
541 # @DESCRIPTION:
542 # Function for configuring the build of KDE 5.
543 kde5_src_configure() {
544         debug-print-function ${FUNCNAME} "$@"
545
546         # we rely on cmake-utils.eclass to append -DNDEBUG too
547         if ! use_if_iuse debug; then
548                 append-cppflags -DQT_NO_DEBUG
549         fi
550
551         local cmakeargs
552
553         if ! use_if_iuse test ; then
554                 cmakeargs+=( -DBUILD_TESTING=OFF )
555
556                 if [[ ${KDE_TEST} = optional ]] ; then
557                         cmakeargs+=( -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Test=ON )
558                 fi
559         fi
560
561         if ! use_if_iuse handbook && [[ ${KDE_HANDBOOK} = optional ]] ; then
562                 cmakeargs+=( -DCMAKE_DISABLE_FIND_PACKAGE_KF5DocTools=ON )
563         fi
564
565         if ! use_if_iuse designer && [[ ${KDE_DESIGNERPLUGIN} != false ]] ; then
566                 cmakeargs+=( -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Designer=ON )
567         fi
568
569         # install mkspecs in the same directory as qt stuff
570         cmakeargs+=(-DKDE_INSTALL_USE_QT_SYS_PATHS=ON)
571
572         # allow the ebuild to override what we set here
573         mycmakeargs=("${cmakeargs[@]}" "${mycmakeargs[@]}")
574
575         cmake-utils_src_configure
576 }
577
578 # @FUNCTION: kde5_src_compile
579 # @DESCRIPTION:
580 # Function for compiling KDE 5.
581 kde5_src_compile() {
582         debug-print-function ${FUNCNAME} "$@"
583
584         cmake-utils_src_compile "$@"
585 }
586
587 # @FUNCTION: kde5_src_test
588 # @DESCRIPTION:
589 # Function for testing KDE 5.
590 kde5_src_test() {
591         debug-print-function ${FUNCNAME} "$@"
592
593         _test_runner() {
594                 if [[ -n "${VIRTUALDBUS_TEST}" ]]; then
595                         export $(dbus-launch)
596                 fi
597
598                 cmake-utils_src_test
599         }
600
601         # When run as normal user during ebuild development with the ebuild command, the
602         # kde tests tend to access the session DBUS. This however is not possible in a real
603         # emerge or on the tinderbox.
604         # > make sure it does not happen, so bad tests can be recognized and disabled
605         unset DBUS_SESSION_BUS_ADDRESS DBUS_SESSION_BUS_PID
606
607         if [[ ${VIRTUALX_REQUIRED} = always || ${VIRTUALX_REQUIRED} = test ]]; then
608                 virtx _test_runner
609         else
610                 _test_runner
611         fi
612
613         if [[ -n "${DBUS_SESSION_BUS_PID}" ]] ; then
614                 kill ${DBUS_SESSION_BUS_PID}
615         fi
616 }
617
618 # @FUNCTION: kde5_src_install
619 # @DESCRIPTION:
620 # Function for installing KDE 5.
621 kde5_src_install() {
622         debug-print-function ${FUNCNAME} "$@"
623
624         cmake-utils_src_install
625
626         # We don't want ${PREFIX}/share/doc/HTML to be compressed,
627         # because then khelpcenter can't find the docs
628         if [[ -d ${ED}/${PREFIX}/share/doc/HTML ]]; then
629                 docompress -x ${PREFIX}/share/doc/HTML
630         fi
631 }
632
633 # @FUNCTION: kde5_pkg_preinst
634 # @DESCRIPTION:
635 # Function storing icon caches
636 kde5_pkg_preinst() {
637         debug-print-function ${FUNCNAME} "$@"
638
639         gnome2_icon_savelist
640         xdg_pkg_preinst
641 }
642
643 # @FUNCTION: kde5_pkg_postinst
644 # @DESCRIPTION:
645 # Function to rebuild the KDE System Configuration Cache after an application has been installed.
646 kde5_pkg_postinst() {
647         debug-print-function ${FUNCNAME} "$@"
648
649         gnome2_icon_cache_update
650         xdg_pkg_postinst
651 }
652
653 # @FUNCTION: kde5_pkg_postrm
654 # @DESCRIPTION:
655 # Function to rebuild the KDE System Configuration Cache after an application has been removed.
656 kde5_pkg_postrm() {
657         debug-print-function ${FUNCNAME} "$@"
658
659         gnome2_icon_cache_update
660         xdg_pkg_postrm
661 }
662
663 _l10n_variant_subdir2root() {
664         local l10npart=5
665         [[ ${PN} = kde4-l10n ]] && l10npart=4
666         local lingua=$(kde_l10n2lingua ${1})
667         local src=kde-l10n-${2}-${PV}
668         local dest=kde-l10n-${lingua}-${PV}/${l10npart}
669
670         # create variant rootdir structure from parent lingua and adapt it
671         mkdir -p ${dest} || die "Failed to create ${dest}"
672         mv ${src}/${l10npart}/${2}/${lingua} ${dest}/${lingua} || die "Failed to create ${dest}/${lingua}"
673         cp -f ${src}/CMakeLists.txt kde-l10n-${lingua}-${PV} || die "Failed to prepare L10N=${1} subdir"
674         echo "add_subdirectory(${lingua})" > ${dest}/CMakeLists.txt ||
675                 die "Failed to prepare ${dest}/CMakeLists.txt"
676         cp -f ${src}/${l10npart}/${2}/CMakeLists.txt ${dest}/${lingua} ||
677                 die "Failed to create ${dest}/${lingua}/CMakeLists.txt"
678         sed -e "s/${2}/${lingua}/" -i ${dest}/${lingua}/CMakeLists.txt ||
679                 die "Failed to prepare ${dest}/${lingua}/CMakeLists.txt"
680
681         _l10n_variant_subdir_buster ${1}
682 }
683
684 _l10n_variant_subdir_buster() {
685         local l10npart=5
686         [[ ${PN} = kde4-l10n ]] && l10npart=4
687         local dir=kde-l10n-$(kde_l10n2lingua ${1})-${PV}/${l10npart}/$(kde_l10n2lingua ${1})
688
689         case ${l10npart} in
690                 5) sed -e "/^add_subdirectory(/d" -i ${dir}/CMakeLists.txt || die "Failed to cleanup ${dir} subdir" ;;
691                 4) sed -e "/^macro.*subdirectory(/d" -i ${dir}/CMakeLists.txt || die "Failed to cleanup ${dir} subdir" ;;
692         esac
693
694         for subdir in $(find ${dir} -mindepth 1 -maxdepth 1 -type d | sed -e "s:^\./::"); do
695                 echo "add_subdirectory(${subdir##*/})" >> ${dir}/CMakeLists.txt
696         done
697 }
698
699 fi