1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: kde5-functions.eclass
8 # @BLURB: Common ebuild functions for KDE 5 packages
10 # This eclass contains all functions shared by the different eclasses,
13 if [[ -z ${_KDE5_FUNCTIONS_ECLASS} ]]; then
14 _KDE5_FUNCTIONS_ECLASS=1
16 inherit toolchain-funcs versionator
18 # @ECLASS-VARIABLE: EAPI
20 # Currently EAPI 5 is supported.
23 *) die "EAPI=${EAPI:-0} is not supported" ;;
26 # @ECLASS-VARIABLE: FRAMEWORKS_MINIMAL
28 # Minimal Frameworks version to require for the package.
29 : ${FRAMEWORKS_MINIMAL:=5.13.0}
31 # @ECLASS-VARIABLE: PLASMA_MINIMAL
33 # Minimal Plasma version to require for the package.
34 : ${PLASMA_MINIMAL:=5.3.2}
36 # @ECLASS-VARIABLE: KDE_APPS_MINIMAL
38 # Minimal KDE Applicaions version to require for the package.
39 : ${KDE_APPS_MINIMAL:=14.12.0}
41 # @ECLASS-VARIABLE: KDEBASE
43 # This gets set to a non-zero value when a package is considered a kde or
45 if [[ ${CATEGORY} = kde-base ]]; then
47 elif [[ ${CATEGORY} = kde-frameworks ]]; then
48 KDEBASE=kde-frameworks
49 elif [[ ${KMNAME-${PN}} = kdevelop ]]; then
53 debug-print "${ECLASS}: ${KDEBASE} ebuild recognized"
55 # @ECLASS-VARIABLE: KDE_SCM
57 # SCM to use if this is a live ebuild.
62 *) die "KDE_SCM: ${KDE_SCM} is not supported" ;;
65 # determine the build type
66 if [[ ${PV} = *9999* ]]; then
69 KDE_BUILD_TYPE="release"
73 # @FUNCTION: _check_gcc_version
76 # Determine if the current GCC version is acceptable, otherwise die.
77 _check_gcc_version() {
78 if [[ ${MERGE_TYPE} != binary ]]; then
79 local version=$(gcc-version)
80 local major=${version%.*}
81 local minor=${version#*.}
83 [[ ${major} -lt 4 ]] || \
84 ( [[ ${major} -eq 4 && ${minor} -lt 8 ]] ) \
85 && die "Sorry, but gcc-4.8 or later is required for KDE 5."
89 # @FUNCTION: _add_kdecategory_dep
92 # Implementation of add_plasma_dep and add_frameworks_dep.
93 _add_kdecategory_dep() {
94 debug-print-function ${FUNCNAME} "$@"
102 if [[ -n ${use} ]] ; then
106 if [[ -n ${version} ]] ; then
108 local version="-$(get_version_component_range 1-3 ${version})"
111 if [[ ${SLOT} = 4 || ${SLOT} = 5 ]] && ! has kde5-meta-pkg ${INHERITED} ; then
115 echo " ${operator}${category}/${package}${version}${slot}${use}"
118 # @FUNCTION: add_frameworks_dep
119 # @USAGE: <package> [USE flags] [minimum version]
121 # Create proper dependency for kde-frameworks/ dependencies.
122 # This takes 1 to 3 arguments. The first being the package name, the optional
123 # second is additional USE flags to append, and the optional third is the
124 # version to use instead of the automatic version (use sparingly).
125 # The output of this should be added directly to DEPEND/RDEPEND, and may be
126 # wrapped in a USE conditional (but not an || conditional without an extra set
128 add_frameworks_dep() {
129 debug-print-function ${FUNCNAME} "$@"
133 if [[ -n ${3} ]]; then
135 elif [[ ${CATEGORY} = kde-frameworks ]]; then
136 version=$(get_version_component_range 1-2)
137 elif [[ -z "${version}" ]] ; then
138 version=${FRAMEWORKS_MINIMAL}
141 _add_kdecategory_dep kde-frameworks "${1}" "${2}" "${version}"
144 # @FUNCTION: add_plasma_dep
145 # @USAGE: <package> [USE flags] [minimum version]
147 # Create proper dependency for kde-base/ dependencies.
148 # This takes 1 to 3 arguments. The first being the package name, the optional
149 # second is additional USE flags to append, and the optional third is the
150 # version to use instead of the automatic version (use sparingly).
151 # The output of this should be added directly to DEPEND/RDEPEND, and may be
152 # wrapped in a USE conditional (but not an || conditional without an extra set
155 debug-print-function ${FUNCNAME} "$@"
159 if [[ -n ${3} ]]; then
161 elif [[ ${CATEGORY} = kde-plasma ]]; then
163 elif [[ -z "${version}" ]] ; then
164 version=${PLASMA_MINIMAL}
167 _add_kdecategory_dep kde-plasma "${1}" "${2}" "${version}"
170 # @FUNCTION: add_kdeapps_dep
171 # @USAGE: <package> [USE flags] [minimum version]
173 # Create proper dependency for kde-apps/ dependencies.
174 # This takes 1 to 3 arguments. The first being the package name, the optional
175 # second is additional USE flags to append, and the optional third is the
176 # version to use instead of the automatic version (use sparingly).
177 # The output of this should be added directly to DEPEND/RDEPEND, and may be
178 # wrapped in a USE conditional (but not an || conditional without an extra set
181 debug-print-function ${FUNCNAME} "$@"
185 if [[ -n ${3} ]]; then
187 elif [[ ${CATEGORY} = kde-apps ]]; then
189 elif [[ -z "${version}" ]] ; then
190 # In KDE applications world, 5.9999 > yy.mm.x
191 if [[ ${PV} = 5.9999 || ${PV} = 9999 ]]; then
194 version=${KDE_APPS_MINIMAL}
198 _add_kdecategory_dep kde-apps "${1}" "${2}" "${version}"
201 # @FUNCTION: get_kde_version
203 # Translates an ebuild version into a major.minor KDE SC
204 # release version. If no version is specified, ${PV} is used.
206 local ver=${1:-${PV}}
207 local major=$(get_major_version ${ver})
208 local minor=$(get_version_component_range 2 ${ver})
209 local micro=$(get_version_component_range 3 ${ver})
210 if [[ ${ver} == 9999 ]]; then
213 (( micro < 50 )) && echo ${major}.${minor} || echo ${major}.$((minor + 1))
217 # @FUNCTION: punt_bogus_dep
218 # @USAGE: <prefix> <dependency>
220 # Removes a specified dependency from a find_package call with multiple components.
225 pcregrep -Mn "(?s)find_package\s*\(\s*${prefix}.[^)]*?${dep}.*?\)" CMakeLists.txt > "${T}/bogus${dep}"
227 # pcregrep returns non-zero on no matches/error
228 if [[ $? != 0 ]] ; then
232 local length=$(wc -l "${T}/bogus${dep}" | cut -d " " -f 1)
233 local first=$(head -n 1 "${T}/bogus${dep}" | cut -d ":" -f 1)
234 local last=$(( ${length} + ${first} - 1))
236 sed -e "${first},${last}s/${dep}//" -i CMakeLists.txt || die
238 if [[ ${length} = 1 ]] ; then
239 sed -e "/find_package\s*(\s*${prefix}\s*REQUIRED\s*COMPONENTS\s*)/d" -i CMakeLists.txt || die