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