diff options
| author | Tomas Chvatal <scarabeus@gentoo.org> | 2008-12-20 15:13:05 +0100 |
|---|---|---|
| committer | Tomas Chvatal <scarabeus@gentoo.org> | 2008-12-20 15:13:05 +0100 |
| commit | ba65eca15be7d33479d1f4629a6934b758b0b025 (patch) | |
| tree | 28f789346292ef414dda34b4e2661934864ab54e | |
| parent | 5f19f5c17561aacccac9e70e6f3962b28429f294 (diff) | |
| download | kde-ba65eca15be7d33479d1f4629a6934b758b0b025.tar.gz kde-ba65eca15be7d33479d1f4629a6934b758b0b025.tar.bz2 kde-ba65eca15be7d33479d1f4629a6934b758b0b025.zip | |
Kde4 eclasses.
| -rw-r--r-- | eclass/kde4-base.eclass | 686 | ||||
| -rw-r--r-- | eclass/kde4-functions.eclass | 291 | ||||
| -rw-r--r-- | eclass/kde4-meta.eclass | 639 | ||||
| -rw-r--r-- | eclass/qt4-build.eclass | 495 |
4 files changed, 2111 insertions, 0 deletions
diff --git a/eclass/kde4-base.eclass b/eclass/kde4-base.eclass new file mode 100644 index 00000000000..143e4902ecc --- /dev/null +++ b/eclass/kde4-base.eclass @@ -0,0 +1,686 @@ +# Copyright 2007-2008 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# @ECLASS: kde4-base.eclass +# @MAINTAINER: +# kde@gentoo.org +# @BLURB: This eclass provides functions for kde 4.X ebuilds +# @DESCRIPTION: +# The kde4-base.eclass provides support for building KDE4 monolithic ebuilds +# and KDE4 applications. +# +# NOTE: This eclass NEEDS EAPI="2" or greater defined in ebuild. + +inherit base cmake-utils eutils multilib kde4-functions +#live/normal +get_build_type +if [[ "${BUILD_TYPE}" == "live" ]]; then + inherit subversion +fi + +EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_test src_install pkg_postinst pkg_postrm + +# Set the qt dependencies +kde4-base_set_qt_dependencies() { + local qt qtcore qtgui qt3support qtdepend qtopengldepend + + qt="[" + case "${OPENGL_REQUIRED}" in + always) + qt="${qt}opengl," + ;; + optional) + qt="${qt}opengl?," + ;; + esac + qt="${qt}accessibility,dbus,gif,jpeg,png,qt3support,ssl,zlib]" + qtcore="[qt3support,ssl]" + qtgui="[accessibility,dbus]" + qt3support="[accessibility]" + + # split qt + qtdepend=" + x11-libs/qt-core:4${qtcore} + x11-libs/qt-gui:4${qtgui} + x11-libs/qt-qt3support:4${qt3support} + x11-libs/qt-script:4 + x11-libs/qt-svg:4 + x11-libs/qt-test:4" + qtopengldepend="x11-libs/qt-opengl:4" + + # KDE > 4.1.71 needs qt-webkit + case "${PV}" in + scm|9999*|4.2*|4.1.9*|4.1.8*|4.1.7*) + qtdepend="${qtdepend} + x11-libs/qt-webkit:4" + ;; + esac + + # opengl dependencies + case "${OPENGL_REQUIRED}" in + always) + qtdepend="${qtdepend} + ${qtopengldepend}" + ;; + optional) + IUSE="${IUSE} opengl" + qtdepend="${qtdepend} + opengl? ( ${qtopengldepend} )" + ;; + *) + OPENGL_REQUIRED="never" + ;; + esac + + COMMONDEPEND="${COMMONDEPEND} ${qtdepend} !x11-libs/qt-phonon" +} +kde4-base_set_qt_dependencies + +# Set the cmake dependencies +case "${PV}" in + 9999*) + CMAKEDEPEND=">=dev-util/cmake-2.6.2" + ;; + 4.2*|4.1.9*|4.1.8*|4.1.7*|4.1.6*) + CMAKEDEPEND=">=dev-util/cmake-2.6" + ;; + *) + CMAKEDEPEND=">=dev-util/cmake-2.4.7-r1" + ;; +esac + +# Set the common dependencies +DEPEND="${DEPEND} ${COMMONDEPEND} ${CMAKEDEPEND} + dev-util/pkgconfig + x11-libs/libXt + x11-proto/xf86vidmodeproto" +RDEPEND="${RDEPEND} ${COMMONDEPEND}" + +# Add the kdeprefix use flag +IUSE="${IUSE} kdeprefix" + +# Do not allow to run test on live ebuilds +if [[ "${BUILD_TYPE}" == "live" ]]; then + RESTRICT="${RESTRICT} test" +fi + +# @ECLASS-VARIABLE: OPENGL_REQUIRED +# @DESCRIPTION: +# Is qt-opengl required? Possible values are 'always', 'optional' and 'never'. +# This variable must be set before inheriting any eclasses. Defaults to 'never'. +OPENGL_REQUIRED="${OPENGL_REQUIRED:-never}" + +# @ECLASS-VARIABLE: CPPUNIT_REQUIRED +# @DESCRIPTION: +# Is cppunit required for tests? Possible values are 'always', 'optional' and 'never'. +# This variable must be set before inheriting any eclasses. Defaults to 'never'. +CPPUNIT_REQUIRED="${CPPUNIT_REQUIRED:-never}" + +case "${CPPUNIT_REQUIRED}" in + always) + DEPEND="${DEPEND} dev-util/cppunit" + ;; + optional) + IUSE="${IUSE} test" + DEPEND="${DEPEND} + test? ( dev-util/cppunit )" + ;; + *) + CPPUNIT_REQUIRED="never" + ;; +esac + +# @ECLASS-VARIABLE: NEED_KDE +# @DESCRIPTION: +# This variable sets the version of KDE4 which will be used by the eclass. +# For kde-base packages, if it is not set by the ebuild, +# it's assumed that the required KDE4 version is the latest available. +# For non kde-base packages, it is also set to the latest by default. +# +# For more precise adjustments or for specifying particular kde version, +# KDE_MINIMAL variable can be used. +# +# @CODE +# Acceptable values are: +# - latest - Use latest version in the portage tree +# Default for kde-base ebuilds. +# - live - Use live release (live ebuilds) +# - none - Let the ebuild handle SLOT, kde dependencies, KDEDIR, ... +# - 4.2, 4.1, kde-4 - respective slots for kde versions +# @CODE +# Note: default NEED_KDE is latest +NEED_KDE="${NEED_KDE:-latest}" +export NEED_KDE + +# FIXME: look at the description, please, somehow illegible +# @ECLASS-VARIABLE: KDE_MINIMAL +# @DESCRIPTION: +# This wariable is used when NEED_KDE="latest" is set, +# to specify minimal version with which apps will work. +# it is used in set manner. +# @CODE +# KDE_MINIMAL="-4.1" +# specify minimal version as kde-4.1, can be mostly anything which can be put as +# >=${PN}-${KDE_MINIMAL} +KDE_MINIMAL="${KDE_MINIMAL:-3.9}" +export KDE_MINIMAL + +# FIXME: the code section, explanation of live. The last sentence needs other +# formulation too. +# +# @ECLASS-VARIABLE: KDE_WANTED +# @DESCRIPTION: +# When NEED_KDE=latest is inherited, KDE_WANTED serves to indicate the prefered kde +# version. It's value is looked for before any other. Useful when having more +# +kdeprefix installs: you can choose which kde version, if present, to link +# against. +# +# @CODE +# Acceptable values are: +# stable = whatever is main tree (now 4.1) +# testing = whatever is in testing on main tree +# snapshot = whatever is released under snapshots (4.2 at present) +# live = live svn ebuilds, also default value, do not be scared it goes in this +# +# order: live->snapshot->testing->stable, when searching for kde. This way we +# allow users to use just kde4snapshots and use software from the tree. +if [[ -z ${KDE_WANTED} ]]; then + KDE_WANTED="live" +fi +export KDE_WANTED + +case ${NEED_KDE} in + latest) + if [[ "${KDEBASE}" == "kde-base" ]]; then + case ${PV} in + 4.2* | 4.1.9* | 4.1.8* | 4.1.7* | 4.1.6*) + _kdedir="4.2" + _pv="-${PV}:4.2" ;; + 4.1*| 4.0.9* | 4.0.8*) + _kdedir="4.1" + _pv="-${PV}:4.1" ;; + 4.0*) + _kdedir="4.0" + _pv="-${PV}:kde-4" ;; + 3.9*) + _kdedir="3.9" + _pv="-${PV}:kde-4" ;; + 9999*) + _kdedir="live" + _pv="-${PV}:live" ;; + *) + die "NEED_KDE=latest not supported for PV=${PV}" ;; + esac + _operator=">=" + else + # this creates dependency on any version of kde4 + _operator=">=" + _pv="-${KDE_MINIMAL}" + fi + ;; + + # NEED_KDE="${PV}" + scm|svn|live|9999*) + _kdedir="live" + _operator=">=" + _pv="-${NEED_KDE}:live" + export NEED_KDE="live" + ;; + 4.2 | 4.1.9* | 4.1.8* | 4.1.7* | 4.1.6*) + _kdedir="4.2" + _operator=">=" + _pv="-${NEED_KDE}:4.2" + ;; + 4.1 | 4.0.9* | 4.0.8*) + _kdedir="4.1" + _operator=">=" + _pv="-${NEED_KDE}:4.1" + ;; + 4.0* | 4) + _kdedir="4.0" + _operator=">=" + _pv="-${NEED_KDE}:kde-4" + ;; + 3.9*) + _kdedir="3.9" + _operator=">=" + _pv="-${NEED_KDE}:kde-4" + ;; + + # The ebuild handles dependencies, KDEDIR, SLOT. + none) + : + ;; + + *) + die "NEED_KDE=${NEED_KDE} currently not supported." + ;; +esac + +if [[ ${NEED_KDE} != none ]]; then + + #Set the SLOT + if [[ -n ${KDEBASE} ]]; then + if [[ ${NEED_KDE} = live ]]; then + SLOT="live" + else + case ${KMNAME} in + koffice) + case ${PV} in + 9999*) SLOT="live" ;; + *) SLOT="2" ;; + esac + ;; + kdevelop) + case ${PV} in + 9999*) SLOT="live" ;; + 4.0*|3.9*) SLOT="4" ;; + esac + ;; + kdevplatform) + case ${PV} in + 9999*) SLOT="live" ;; + 1.0*|0.9*) SLOT="1" ;; + esac + ;; + *) + case ${PV} in + 9999*) SLOT="live" ;; + 4.2* | 4.1.9* | 4.1.8* | 4.1.7* | 4.1.6*) SLOT="4.2" ;; + 4.1* | 4.0.9* | 4.0.8*) SLOT="4.1" ;; + *) SLOT="kde-4" ;; + esac + ;; + esac + fi + fi + + # Block installation of other SLOTS unless kdeprefix + for KDE_SLOT in ${KDE_SLOTS[@]}; do + # block non kdeprefix ${PN} on other slots + # we do this only if we do not depend on any version of kde + if [[ ${SLOT} != ${KDE_SLOT} ]]; then + DEPEND="${DEPEND} + !kdeprefix? ( !kde-base/${PN}:${KDE_SLOT}[-kdeprefix] )" + RDEPEND="${RDEPEND} + !kdeprefix? ( !kde-base/${PN}:${KDE_SLOT}[-kdeprefix] )" + fi + done + + # Adding kdelibs, kdepimlibs and kdebase-data deps to all other packages. + # We only need to add the dependencies if ${PN} is not "kdelibs" or "kdepimlibs" + if [[ ${PN} != "kdelibs" ]]; then + DEPEND="${DEPEND} ${_operator}kde-base/kdelibs${_pv}[kdeprefix=]" + RDEPEND="${RDEPEND} ${_operator}kde-base/kdelibs${_pv}[kdeprefix=]" + if [[ ${PN} != "kdepimlibs" ]]; then + DEPEND="${DEPEND} ${_operator}kde-base/kdepimlibs${_pv}[kdeprefix=]" + RDEPEND="${RDEPEND} ${_operator}kde-base/kdepimlibs${_pv}[kdeprefix=]" + if [[ ${PN} != "kdebase-data" ]]; then + RDEPEND="${RDEPEND} ${_operator}kde-base/kdebase-data${_pv}[kdeprefix=]" + fi + fi + fi + unset _operator _pv +fi + +# Fetch section - If the ebuild's category is not 'kde-base' and if it is not a +# koffice ebuild, the URI should be set in the ebuild itself +case ${SLOT} in + live) + ESVN_MIRROR=${ESVN_MIRROR:-svn://anonsvn.kde.org/home/kde} + # Split ebuild, or extragear stuff + if [[ -n ${KMNAME} ]]; then + ESVN_PROJECT="KDE/${KMNAME}" + if [[ -z ${KMNOMODULE} && -z ${KMMODULE} ]]; then + KMMODULE="${PN}/" + fi + # Split kde-base/ ebuilds: (they reside in trunk/KDE) + case ${KMNAME} in + kdebase-*) + ESVN_REPO_URI="${ESVN_MIRROR}/trunk/KDE/kdebase" + ESVN_PROJECT="KDE/kdebase" + ;; + kdereview) + ESVN_REPO_URI="${ESVN_MIRROR}/trunk/${KMNAME}/${KMMODULE}" + ;; + kde*) + ESVN_REPO_URI="${ESVN_MIRROR}/trunk/KDE/${KMNAME}" + ;; + extragear*|playground*) + case ${PN} in + *-plasma) + ESVN_REPO_URI="${ESVN_MIRROR}/trunk/${KMNAME}/${KMMODULE}" + ESVN_PROJECT="KDE/${KMNAME}/${KMMODULE}" + ;; + *) + ESVN_REPO_URI="${ESVN_MIRROR}/trunk/${KMNAME}/${KMMODULE}" + ;; + esac + ;; + koffice) + ESVN_REPO_URI="${ESVN_MIRROR}/trunk/${KMNAME}" + ;; + *) + # Extragear material + ESVN_REPO_URI="${ESVN_MIRROR}/trunk/${KMNAME}/${KMMODULE}/" + ;; + esac + else + # kdelibs, kdepimlibs + ESVN_REPO_URI="${ESVN_MIRROR}/trunk/KDE/${PN}" + ESVN_PROJECT="KDE/${PN}" + fi + # limit syncing to 1 hour. + ESVN_UP_FREQ=${ESVN_UP_FREQ:-1} + ;; + *) + if [[ -n ${KDEBASE} ]]; then + if [[ -n ${KMNAME} ]]; then + _kmname=${KMNAME} + else + _kmname=${PN} + fi + _kmname_pv="${_kmname}-${PV}" + if [[ ${NEED_KDE} != "live" ]]; then + case ${KDEBASE} in + kde-base) + case ${PV} in + 4.1.9* | 4.1.8* | 4.1.7* | 4.1.6* | 4.0.9* | 4.0.8*) + SRC_URI="mirror://kde/unstable/${PV}/src/${_kmname_pv}.tar.bz2" ;; + *) SRC_URI="mirror://kde/stable/${PV}/src/${_kmname_pv}.tar.bz2" ;; + esac + ;; + koffice) + SRC_URI="mirror://kde/unstable/${_kmname_pv}/src/${_kmname_pv}.tar.bz2" + ;; + esac + fi + unset _kmname _kmname_pv + fi + ;; +esac + +debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: SRC_URI is ${SRC_URI}" + +# @ECLASS-VARIABLE: PREFIX +# @DESCRIPTION: +# Set the installation PREFIX. All kde-base ebuilds go into the KDE4 installation directory. +# Applications installed by the other ebuilds go into ${KDEDIR} by default, this value +# can be superseded by defining PREFIX before inheriting kde4-base. +# This value is set on pkg_setup +PREFIX="" + +debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: SLOT ${SLOT} - NEED_KDE ${NEED_KDE}" + +# @FUNCTION: kde4-base_pkg_setup +# @DESCRIPTION: +# Adds flags needed by all of KDE 4 to $QT4_BUILT_WITH_USE_CHECK. Uses +# kde4-functions_check_use from kde4-functions.eclass to print appropriate +# errors and die if any required flags listed in $QT4_BUILT_WITH_USE_CHECK or +# $KDE4_BUILT_WITH_USE_CHECK are missing. +kde4-base_pkg_setup() { + debug-print-function $FUNCNAME "$@" + + # Don't set KDEHOME during compile, it will cause access violations + unset KDEHOME + + # Search for best suitable kde installation for misc kde package. + # Computation based on NEED_KDE and KDE_MINIMAL + get_latest_kdedir + + if [[ ${NEED_KDE} != none ]]; then + # Set PREFIX + if use kdeprefix; then + KDEDIR="/usr/kde/${_kdedir}" + KDEDIRS="/usr/local/:/usr:${KDEDIR}" + else + KDEDIR="/usr" + KDEDIRS="/usr/local/:/usr" + fi + fi + # Set the prefix based on KDEDIR + # Make it a consequence of kdeprefix + PREFIX=${KDEDIR} + + unset _kdedir + + # FIXME: reformulate, please + # check if useflags were checked. (ugly description i know...) + [[ -n ${QT4_BUILT_WITH_USE_CHECK} || -n ${KDE4_BUILT_WITH_USE_CHECK[@]} ]] && \ + die "built_with_use illegal in this EAPI!" + + if [[ ${SLOT} == "live" || ${PV} == "9999*" ]]; then + if [[ -z ${I_KNOW_WHAT_I_AM_DOING} ]]; then + elog + elog "WARNING! This is an experimental ebuild of the ${KMNAME:-${PN}} KDE4 SVN tree." + elog "Use at your own risk. Do _NOT_ file bugs at bugs.gentoo.org because" + elog "of this ebuild!" + fi + fi +} + +# @FUNCTION: kde4-base_src_unpack +# @DESCRIPTION: +# This function unpacks the source tarballs for KDE4 applications. +# +# If no argument is passed to this function, then standard src_unpack is +# executed. Otherwise, options are passed to base_src_unpack. +kde4-base_src_unpack() { + debug-print-function $FUNCNAME "$@" + + if [[ "${BUILD_TYPE}" == "live" ]]; then + local cleandir + cleandir="${ESVN_STORE_DIR}/KDE/KDE" + if [[ -d ${cleandir} ]]; then + eerror "'${cleandir}' should never have been created. Either move it to" + eerror "${ESVN_STORE_DIR}/${ESVN_PROJECT}/${ESVN_REPO_URI##*/} or remove" + eerror "completely." + die "'${cleandir}' is in the way." + fi + subversion_src_unpack + else + [[ -z "${KDE_S}" ]] && KDE_S="${S}" + if [[ -z $* ]]; then + # Unpack first and deal with KDE patches after examing possible patch sets. + # To be picked up, patches need to conform to the guidelines stated before. + # Monolithic ebuilds will use the split ebuild patches. + [[ -d "${KDE_S}" ]] || unpack ${A} + fi + # Updated cmake dir + if [[ -d "${WORKDIR}/cmake" ]] && [[ -d "${KDE_S}/cmake" ]]; then + ebegin "Updating cmake/ directory..." + rm -rf "${KDE_S}/cmake" || die "Unable to remove old cmake/ directory" + ln -s "${WORKDIR}/cmake" "${KDE_S}/cmake" || die "Unable to symlink the new cmake/ directory" + eend 0 + fi + fi +} + +# @FUNCTION: kde4-base_src_compile +# @DESCRIPTION: +# General pre-configure and pre-compile function for KDE4 applications. +# It also handles translations if KDE_LINGUAS is defined. See KDE_LINGUAS and +# enable_selected_linguas() in kde4-functions.eclass(5) for further details. +kde4-base_src_prepare() { + debug-print-function ${FUNCNAME} "$@" + + # Only enable selected languages, used for KDE extragear apps. + if [[ -n ${KDE_LINGUAS} ]]; then + enable_selected_linguas + fi + + + # Autopatch + base_src_prepare + + # Save library dependencies + if [[ -n ${KMSAVELIBS} ]] ; then + save_library_dependencies + fi + + # Inject library dependencies + if [[ -n ${KMLOADLIBS} ]] ; then + load_library_dependencies + fi +} + +# @FUNCTION: kde4-base_src_configure +# @DESCRIPTION: +# Function for configuring the build of KDE4 applications. +kde4-base_src_configure() { + debug-print-function ${FUNCNAME} "$@" + + # We prefer KDE's own Debugfull mode over the standard Debug + if has debug ${IUSE//+} && use debug ; then + mycmakeargs="${mycmakeargs} -DCMAKE_BUILD_TYPE=Debugfull" + fi + + # Final flag handling + if has kdeenablefinal ${IUSE//+} && use kdeenablefinal; then + echo "Activating enable-final flag" + mycmakeargs="${mycmakeargs} -DKDE4_ENABLE_FINAL=ON" + fi + + # Enable generation of HTML handbook + if has htmlhandbook ${IUSE//+} && use htmlhandbook; then + echo "Enabling building of HTML handbook" + mycmakeargs="${mycmakeargs} -DKDE4_ENABLE_HTMLHANDBOOK=ON" + fi + + # Build tests in src_test only, where we override this value + mycmakeargs="${mycmakeargs} -DKDE4_BUILD_TESTS=OFF" + + # Set distribution name + [[ ${PN} == "kdelibs" ]] && mycmakeargs="${mycmakeargs} -DKDE_DISTRIBUTION_TEXT=Gentoo" + + # runpath linking + mycmakeargs="${mycmakeargs} -DKDE4_USE_ALWAYS_FULL_RPATH=ON" + + # Here we set the install prefix + mycmakeargs="${mycmakeargs} -DCMAKE_INSTALL_PREFIX=${PREFIX}" + + # If prefix is /usr, sysconf needs to be /etc, not /usr/etc + use kdeprefix || mycmakeargs="${mycmakeargs} -DSYSCONF_INSTALL_DIR=/etc" + + # Set environment + QTEST_COLORED=1 + QT_PLUGIN_PATH=${KDEDIR}/$(get_libdir)/kde4/plugins/ + + # hardcode path to *.cmake KDE files + PKG_CONFIG_PATH="${PKG_CONFIG_PATH:+${PKG_CONFIG_PATH}:}${KDEDIR}/$(get_libdir)/pkgconfig" + + # additonal arguments for KOFFICE + if [[ "${KMNAME}" == "koffice" ]]; then + case ${PN} in + koffice-data) : ;; + *) + mycmakeargs="${mycmakeargs} + -DWITH_OpenEXR=ON + $(cmake-utils_use_with crypt QCA2) + $(cmake-utils_use_with opengl OpenGL)" + if use crypt; then + mycmakeargs="${mycmakeargs} + -DQCA2_LIBRARIES=/usr/$(get_libdir)/qca2/libqca.so.2" + fi + ;; + esac + fi + + [ -e CMakeLists.txt ] && cmake-utils_src_configure +} + +# @FUNCTION: kde4-base_src_compile +# @DESCRIPTION: +# General function for compiling KDE4 applications. +kde4-base_src_compile() { + debug-print-function ${FUNCNAME} "$@" + + kde4-base_src_make +} + +# @FUNCTION: kde4-base_src_make +# @DESCRIPTION: +# Function for building KDE4 applications. +# Options are passed to cmake-utils_src_make. +kde4-base_src_make() { + debug-print-function ${FUNCNAME} "$@" + + if [[ -d ${WORKDIR}/${PN}_build ]]; then + pushd "${WORKDIR}"/${PN}_build > /dev/null + fi + [ -e [Mm]akefile ] && cmake-utils_src_make "$@" +} + +# @FUNCTION: kde4-base_src_test +# @DESCRIPTION: +# Function for testing KDE4 applications. +kde4-base_src_test() { + debug-print-function ${FUNCNAME} "$@" + + # Override this value, set in kde4-base_src_configure() + mycmakeargs="${mycmakeargs} -DKDE4_BUILD_TESTS=ON" + cmake-utils_src_compile + + cmake-utils_src_test +} + +# @FUNCTION: kde4-base_src_install +# @DESCRIPTION: +# Function for installing KDE4 applications. +kde4-base_src_install() { + debug-print-function ${FUNCNAME} "$@" + + if [[ -n ${KMSAVELIBS} ]] ; then + install_library_dependencies + fi + + kde4-base_src_make_doc + if [[ -d ${WORKDIR}/${PN}_build ]]; then + pushd "${WORKDIR}"/${PN}_build > /dev/null + fi + [ -e [Mm]akefile ] && cmake-utils_src_install +} + +# @FUNCTION: kde4-base_src_make_doc +# @DESCRIPTION: +# Function for installing the documentation of KDE4 applications. +kde4-base_src_make_doc() { + debug-print-function ${FUNCNAME} "$@" + + local doc + for doc in AUTHORS ChangeLog* README* NEWS TODO; do + [[ -s $doc ]] && dodoc ${doc} + done + + if [[ -z ${KMNAME} ]]; then + for doc in {apps,runtime,workspace,.}/*/{AUTHORS,README*}; do + if [[ -s $doc ]]; then + local doc_complete=${doc} + doc="${doc#*/}" + newdoc "$doc_complete" "${doc%/*}.${doc##*/}" + fi + done + fi + + if [[ -n ${KDEBASE} && -d "${D}"/usr/share/doc/${PF} ]]; then + # work around bug #97196 + dodir /usr/share/doc/kde && \ + mv "${D}"/usr/share/doc/${PF} "${D}"/usr/share/doc/kde/ || \ + die "Failed to move docs to kde/ failed." + fi +} + +# @FUNCTION: kde4-base_pkg_postinst +# @DESCRIPTION: +# Function to rebuild the KDE System Configuration Cache after an application has been installed. +kde4-base_pkg_postinst() { + buildsycoca +} + +# @FUNCTION: kde4-base_pkg_postrm +# @DESCRIPTION: +# Function to rebuild the KDE System Configuration Cache after an application has been removed. +kde4-base_pkg_postrm() { + buildsycoca +} diff --git a/eclass/kde4-functions.eclass b/eclass/kde4-functions.eclass new file mode 100644 index 00000000000..5eda981592f --- /dev/null +++ b/eclass/kde4-functions.eclass @@ -0,0 +1,291 @@ +# Copyright 1999-2008 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# @ECLASS: kde4-functions.eclass +# @MAINTAINER: +# kde@gentoo.org +# @BLURB: Common ebuild functions for monolithic and split KDE 4 packages +# @DESCRIPTION: +# This eclass contains all functions shared by the different eclasses, +# for KDE 4 monolithic and split ebuilds. +# +# NOTE: This eclass uses the SLOT dependencies from EAPI="1" or compatible, +# hence you must define EAPI="1" in the ebuild, before inheriting any eclasses. + +# BLOCK FOR EAPI OLDER THAN 2. +case ${EAPI} in + 2) : ;; + *) die "No way! EAPI older than 2 is not supported." ;; +esac + +# @ECLASS-VARIABLE: KDEBASE +# @DESCRIPTION: +# This gets set to a non-zero value when a package is considered a kde or +# koffice ebuild. + +if [[ "${CATEGORY}" == "kde-base" ]]; then + debug-print "${ECLASS}: KDEBASE ebuild recognized" + KDEBASE="kde-base" +fi + +# is this a koffice ebuild? +if [[ "${KMNAME}" == "koffice" || "${PN}" == "koffice" ]]; then + debug-print "${ECLASS}: KOFFICE ebuild recognized" + KDEBASE="koffice" +fi + +# @ECLASS-VARIABLE: KDE_SLOTS +# @DESCRIPTION: +# The slots used by all KDE versions later than 4.0. The live-ebuilds use +# KDE_LIVE_SLOTS instead. +KDE_SLOTS=( "kde-4" "4.1" "4.2" ) + +# @ECLASS-VARIABLE: KDE_LIVE_SLOTS +# @DESCRIPTION: +# The slots used by all KDE live versions. +KDE_LIVE_SLOTS=( "live" ) + +# @FUNCTION: buildsycoca +# @DESCRIPTION: +# Function to rebuild the KDE System Configuration Cache. +# All KDE ebuilds should run this in pkg_postinst and pkg_postrm. +# +# Note that kde4-base.eclass already does this. +buildsycoca() { + debug-print-function ${FUNCNAME} "$@" + + if [[ -x ${KDEDIR}/bin/kbuildsycoca4 && -z "${ROOT%%/}" ]]; then + # Make sure tha cache file exists, or kbuildsycoca4 will fail + touch "${KDEDIR}/share/kde4/services/ksycoca4" + + # We have to unset DISPLAY and DBUS_SESSION_BUS_ADDRESS, the ones + # in the user's environment (through su [without '-']) may cause + # kbuildsycoca4 to hang. + + ebegin "Running kbuildsycoca4 to build global database" + # This is needed because we support multiple kde versions installed together. + XDG_DATA_DIRS="/usr/share:${KDEDIRS//:/\/share:}/share:/usr/local/share" \ + DISPLAY="" DBUS_SESSION_BUS_ADDRESS="" \ + ${KDEDIR}/bin/kbuildsycoca4 --global --noincremental &> /dev/null + eend $? + fi +} + +# @FUNCTION: comment_all_add_subdirectory +# @USAGE: [list of directory names] +# @DESCRIPTION: +# Recursively comment all add_subdirectory instructions in listed directories, +# except those in cmake/. +comment_all_add_subdirectory() { + find "$@" -name CMakeLists.txt -print0 | grep -vFzZ "./cmake" | \ + xargs -0 sed -i -e '/add_subdirectory/s/^/#DONOTCOMPILE /' -e '/ADD_SUBDIRECTORY/s/^/#DONOTCOMPILE /' || \ + die "${LINENO}: Initial sed died" +} + +# @ECLASS-VARIABLE: KDE_LINGUAS +# @DESCRIPTION: +# This is a whitespace-separated list of translations this ebuild supports. +# These translations are automatically added to IUSE. Therefore ebuilds must set +# this variable before inheriting any eclasses. To enable only selected +# translations, ebuilds must call enable_selected_linguas(). kde4-base.eclass does +# this for you. +# +# Example: KDE_LINGUAS="en_GB de nl" +for _lingua in ${KDE_LINGUAS}; do + IUSE="${IUSE} linguas_${_lingua}" +done + +# @FUNCTION: enable_selected_linguas +# @DESCRIPTION: +# Enable translations based on LINGUAS settings and translations supported by +# the package (see KDE_LINGUAS). By default, translations are found in "${S}"/po +# but this default can be overridden by defining KDE_LINGUAS_DIR. +enable_selected_linguas() { + local lingua + + for lingua in ${KDE_LINGUAS}; do + if [ -e "${S}"/po/"${lingua}".po ]; then + mv "${S}"/po/"${lingua}".po "${S}"/po/"${lingua}".po.old + fi + done + comment_all_add_subdirectory "${KDE_LINGUAS_DIR:-${S}/po}" + for lingua in ${LINGUAS}; do + if [ -d "${S}"/po/"${lingua}" ]; then + sed -e "/add_subdirectory([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \ + -e "/ADD_SUBDIRECTORY([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \ + -i "${KDE_LINGUAS_DIR:-${S}/po}"/CMakeLists.txt || die "Sed to uncomment linguas_${lingua} failed." + fi + if [ -e "${S}"/po/"${lingua}".po.old ]; then + mv "${S}"/po/"${lingua}".po.old "${S}"/po/"${lingua}".po + fi + done +} + +# FIXME: descripton too brief? +# @FUNCTION: kdebase_toplevel_cmakelists +# @DESCRIPTION: +# replace includes for live ebuilds with optional requests +kdebase_toplevel_cmakelist() { + insert=$(sed -e '/macro_optional_find_package/!d' < "${ESVN_WC_PATH}"/CMakeLists.txt) + at=$(sed -n '/^include[[:space:]]*(/=' < "${S}"/CMakeLists.txt | sed -n '$p') + for line in ${insert}; do + sed "${at}a${line}" -i "${S}"/CMakeLists.txt + done +} + +# @FUNCTION: koffice_fix_libraries +# @DESCRIPTION: +# replace the weird koffice lib search with hardcoded one, so it +# actually builds and works. +koffice_fix_libraries() { + local LIB_ARRAY R_QT_kostore R_BAS_kostore R_BAS_koodf R_KROSS_kokross R_QT_komain + local R_CMS_pigmentcms R_BAS_pigmentcms R_BAS_koresources R_BAS_flake R_BAS_koguiutils + local R_BAS_kopageapp R_BAS_kotext R_BAS_kowmf libname R + case ${PN} in + koffice-data|koffice-libs) + ;; + *) + ### basic array + LIB_ARRAY="kostore koodf kokross komain pigmentcms koresources flake koguiutils kopageapp kotext kowmf" + ### dep array + R_QT_kostore="\"/usr/$(get_libdir)/qt4/libQtCore.so\" + \"/usr/$(get_libdir)/qt4/libQtXml.so\" + \"${KDEDIR}/$(get_libdir)/libkdecore.so\"" + R_BAS_kostore="libkostore ${R_QT_kostore}" + R_BAS_koodf="libkoodf ${R_BAS_kostore}" + R_KROSS_kokross=" + \"${KDEDIR}/$(get_libdir)/libkrossui.so\" + \"${KDEDIR}/$(get_libdir)/libkrosscore.so\"" + R_BAS_kokross="libkokross ${R_BAS_koodf} ${R_KROSS_kokross}" + R_QT_komain="\"/usr/$(get_libdir)/qt4/libQtGui.so\"" + R_BAS_komain="libkomain ${R_BAS_koodf} ${R_QT_komain}" + R_CMS_pigmentcms="\"/usr/$(get_libdir)/liblcms.so\"" + R_BAS_pigmentcms="libpigmentcms ${R_BAS_komain} ${R_CMS_pigmentcms}" + R_BAS_koresources="libkoresources ${R_BAS_pigmentcms}" + R_BAS_flake="libflake ${R_BAS_pigmentcms}" + R_BAS_koguiutils="libkoguiutils libkoresources libflake ${R_BAS_pigmentcms}" + R_BAS_kopageapp="libkopageapp ${R_BAS_koguitls}" + R_BAS_kotext="libkotext libkoresources libflake ${R_BAS_pigmentcms}" + ### additional unmentioned stuff + R_BAS_kowmf="libkowmf" + for libname in ${LIB_ARRAY}; do + echo "Fixing library ${libname} with hardcoded path" + for libpath in $(eval "echo \$R_BAS_${libname}"); do + if [[ "${libpath}" != "\"/usr/"* ]]; then + R="${R} \"${KDEDIR}/$(get_libdir)/${libpath}.so\"" + else + R="${R} ${libpath}" + fi + done + find ${S} -name CMakeLists.txt -print| xargs -i \ + sed -i \ + -e "s: ${libname} : ${R} :g" \ + -e "s: ${libname}): ${R}):g" \ + -e "s:(${libname} :(${R} :g" \ + -e "s:(${libname}):(${R}):g" \ + -e "s: ${libname}$: ${R}:g" \ + {} || die "Fixing library names failed." + done + ;; + esac +} +# @FUNCTION: get_build_type +# @DESCRIPTION: +# Determine whether we are using live ebuild or normal tbzs. +get_build_type() { + if [[ "${SLOT}" == "live" || "${PV}" == 9999* ]]; then + BUILD_TYPE="live" + else + BUILD_TYPE="normal" + fi + export BUILD_TYPE +} + +# @FUNCTION: get_latest_kdedir +# @DESCRIPTION: +# We set up KDEDIR according to the latest KDE version installed; installing our +# package for all available installs is just insane. +# We can check for kdelibs because it is the most basic package; no KDE package +# working without it. This might be changed in future. +get_latest_kdedir() { + if [[ "${NEED_KDE}" == "latest" && "${KDEBASE}" != "kde-base" ]]; then + case ${KDE_WANTED} in + # note this will need to be updated as stable moves and so on + live) + _versions="9999 4.1.69 4.1.0" + ;; + snapshot) + _versions="4.1.69 4.1.0 9999" + ;; + testing) + _versions="4.1.0 4.1.69 9999" + ;; + stable) + _versions="4.1.0 4.1.69 9999" + ;; + *) die "KDE_WANTED=${KDE_WANTED} not supported here." ;; + esac + # check if exists and fallback as we go + for X in ${_versions}; do + if has_version ">=kde-base/kdelibs-${X}"; then + # figure out which X we are in and set it into _kdedir + case ${X} in + # also keep track here same for kde_wanted + 9999) + _kdedir="live" + break + ;; + 4.1.69) + _kdedir="4.2" + break + ;; + 4.1.0) + _kdedir="4.1" + break + ;; + esac + fi + done + fi +} + +# Functions handling KMLOADLIBS and KMSAVELIBS + +# @FUNCTION: save_library_dependencies +# @DESCRIPTION: +# Add exporting CMake dependencies for current package +save_library_dependencies() { + local depsfile="${T}/${PN}:${SLOT}" + + echo "Saving library dependendencies in ${depsfile##*/}" + echo "EXPORT_LIBRARY_DEPENDENCIES(\"${depsfile}\")" >> "${S}/CMakeLists.txt" || \ + die "Failed to save the library dependencies." +} + +# @FUNCTION: install_library_dependencies +# @DESCRIPTION: +# Install generated CMake library dependencies to /var/lib/kde +install_library_dependencies() { + local depsfile="${T}/${PN}:${SLOT}" + echo "Installing library dependendencies as ${depsfile##*/}" + insinto /var/lib/kde + doins "${depsfile}" || die "Failed to install library dependencies." +} + +# @FUNCTION: load_library_dependencies +# @DESCRIPTION: +# Inject specified library dependencies in current package +load_library_dependencies() { + local pn i depsfile + echo "Injecting library dependendencies from '${KMLOADLIBS}'" + + i=0 + for pn in ${KMLOADLIBS} ; do + ((i++)) + depsfile="/var/lib/kde/${pn}:${SLOT}" + [[ -r "${depsfile}" ]] || die "Depsfile '${depsfile}' not accessible. You probably need to reinstall ${pn}." + sed -i -e "${i}iINCLUDE(\"${depsfile}\")" "${S}/CMakeLists.txt" || \ + die "Failed to include library dependencies for ${pn}" + done +} diff --git a/eclass/kde4-meta.eclass b/eclass/kde4-meta.eclass new file mode 100644 index 00000000000..96c1b9b15ea --- /dev/null +++ b/eclass/kde4-meta.eclass @@ -0,0 +1,639 @@ +# Copyright 1999-2008 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ +# +# @ECLASS: kde4-meta.eclass +# @MAINTAINER: +# kde@gentoo.org +# @BLURB: Eclass for writing "split" KDE packages. +# @DESCRIPTION: +# This eclass provides all necessary functions for writing split KDE ebuilds. +# +# You must define KMNAME to use this eclass, and do so before inheriting it. All other variables are optional. +# Do not include the same item in more than one of KMMODULE, KMMEXTRA, KMCOMPILEONLY, KMEXTRACTONLY. +# +# NOTE: This eclass NEEDS EAPI="2" or greater defined in ebuild. + +# we want opengl optional in each koffice package +if [[ "${KMNAME}" == "koffice" ]]; then + case ${PN} in + koffice-data) + ;; + *) + OPENGL_REQUIRED="optional" + ;; + esac +fi + +inherit kde4-base versionator + +EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_test src_install pkg_postinst pkg_postrm + +if [[ -z ${KMNAME} ]]; then + die "kde4-meta.eclass inherited but KMNAME not defined - broken ebuild" +fi + +case ${KDEBASE} in + kde-base) + HOMEPAGE="http://www.kde.org/" + LICENSE="GPL-2" + ;; + koffice) + HOMEPAGE="http://www.koffice.org/" + LICENSE="GPL-2" + ;; +esac + +# Add dependencies that all packages in a certain module share. +case ${KMNAME} in + kdebase|kdebase-workspace|kdebase-runtime) + DEPEND="${DEPEND} >=kde-base/qimageblitz-0.0.4" + RDEPEND="${RDEPEND} >=kde-base/qimageblitz-0.0.4" + ;; + kdepim) + DEPEND="${DEPEND} dev-libs/boost app-office/akonadi-server" + RDEPEND="${RDEPEND} dev-libs/boost" + if [[ ${PN} != kode ]]; then + DEPEND="${DEPEND} >=kde-base/kode-${PV}:${SLOT}" + RDEPEND="${RDEPEND} >=kde-base/kode-${PV}:${SLOT}" + fi + case ${PN} in + akregator|kaddressbook|kjots|kmail|kmobiletools|knode|knotes|korganizer|ktimetracker) + IUSE="+kontact" + DEPEND="${DEPEND} kontact? ( >=kde-base/kontactinterfaces-${PV}:${SLOT} )" + RDEPEND="${RDEPEND} kontact? ( >=kde-base/kontactinterfaces-${PV}:${SLOT} )" + ;; + esac + ;; + kdegames) + if [[ ${PN} != "libkdegames" ]]; then + DEPEND="${DEPEND} >=kde-base/libkdegames-${PV}:${SLOT}" + RDEPEND="${RDEPEND} >=kde-base/libkdegames-${PV}:${SLOT}" + fi + ;; + koffice) + case ${PV} in + 9999*) DEPEND="${DEPEND} !app-office/${PN}:2" ;; + 1.9*|2*) DEPEND="${DEPEND} !app-office/${PN}:live" ;; + esac + DEPEND="${DEPEND} + !app-office/${PN}:0 + !app-office/koffice:0 + !app-office/koffice-meta:0" + case ${PN} in + koffice-data) + DEPEND="${DEPEND} media-libs/lcms" + RDEPEND="${RDEPEND} media-libs/lcms" + ;; + *) + IUSE="+crypt" + DEPEND="${DEPEND} crypt? ( >=app-crypt/qca-2 )" + RDEPEND="${RDEPEND} crypt? ( >=app-crypt/qca-2 )" + if [[ ${PN} != "koffice-libs" ]]; then + DEPEND="${DEPEND} >=app-office/koffice-libs-${PV}:${SLOT}" + RDEPEND="${RDEPEND} >=app-office/koffice-libs-${PV}:${SLOT}" + fi + ;; + esac + ;; +esac + +debug-print "line ${LINENO} ${ECLASS}: DEPEND ${DEPEND} - after metapackage-specific dependencies" +debug-print "line ${LINENO} ${ECLASS}: RDEPEND ${RDEPEND} - after metapackage-specific dependencies" + +# @ECLASS-VARIABLE: KMNAME +# @DESCRIPTION: +# Name of the parent-module (e.g. kdebase, kdepim, ...). You _must_ set it +# _before_ inheriting this eclass, (unlike the other parameters), since it's +# used to set $SRC_URI. + +# @ECLASS-VARIABLE: KMMODULE +# @DESCRIPTION: +# Specify exactly one subdirec |
