kde5.eclass 21 KB

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