/[gentoo-x86]/eclass/kde4-functions.eclass
Gentoo

Contents of /eclass/kde4-functions.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.76 - (show annotations) (download)
Sun Mar 29 10:29:42 2015 UTC (4 months ago) by johu
Branch: MAIN
CVS Tags: HEAD
Changes since 1.75: +3 -3 lines
Drop EAPI 4 support.

1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/kde4-functions.eclass,v 1.75 2015/02/11 04:29:06 patrick Exp $
4
5 # @ECLASS: kde4-functions.eclass
6 # @MAINTAINER:
7 # kde@gentoo.org
8 # @BLURB: Common ebuild functions for KDE 4 packages
9 # @DESCRIPTION:
10 # This eclass contains all functions shared by the different eclasses,
11 # for KDE 4 ebuilds.
12
13 if [[ -z ${_KDE4_FUNCTIONS_ECLASS} ]]; then
14 _KDE4_FUNCTIONS_ECLASS=1
15
16 inherit versionator
17
18 # @ECLASS-VARIABLE: EAPI
19 # @DESCRIPTION:
20 # Currently kde4 eclasses support EAPI 5.
21 case ${EAPI} in
22 5) : ;;
23 *) die "EAPI=${EAPI:-0} is not supported" ;;
24 esac
25
26 # @ECLASS-VARIABLE: KDE_OVERRIDE_MINIMAL
27 # @DESCRIPTION:
28 # For use only in very few well-defined cases; normally it should be unset.
29 # If this variable is set, all calls to add_kdebase_dep return a dependency on
30 # at least this version, independent of the version of the package itself.
31 # If you know exactly that one specific NEW KDE component builds and runs fine
32 # with all the rest of KDE at an OLDER version, you can set this old version here.
33 # Warning- may lead to general instability and kill your pet targh.
34
35 # @ECLASS-VARIABLE: KDEBASE
36 # @DESCRIPTION:
37 # This gets set to a non-zero value when a package is considered a kde or
38 # kdevelop ebuild.
39 if [[ ${CATEGORY} = kde-base || ${CATEGORY} = kde-apps ]]; then
40 debug-print "${ECLASS}: KDEBASE ebuild recognized"
41 KDEBASE=kde-base
42 elif [[ ${KMNAME-${PN}} = kdevelop ]]; then
43 KDEBASE=kdevelop
44 fi
45
46 debug-print "${ECLASS}: ${KDEBASE} ebuild recognized"
47
48 # determine the build type
49 if [[ ${PV} = *9999* ]]; then
50 KDE_BUILD_TYPE="live"
51 else
52 KDE_BUILD_TYPE="release"
53 fi
54 export KDE_BUILD_TYPE
55
56 # Set reponame and SCM for modules that have fully migrated to git
57 # (hack - it's here because it needs to be before SCM inherits from kde4-base)
58 if [[ ${KDE_BUILD_TYPE} == live ]]; then
59 case "${KMNAME}" in
60 kdebase-workspace)
61 EGIT_REPONAME=${EGIT_REPONAME:=kde-workspace}
62 ;;
63 kdebase-runtime)
64 EGIT_REPONAME=${EGIT_REPONAME:=kde-runtime}
65 ;;
66 esac
67 fi
68
69 # @ECLASS-VARIABLE: KDE_SCM
70 # @DESCRIPTION:
71 # If this is a live package which scm does it use
72 # Everything else uses git by default
73 KDE_SCM="${KDE_SCM:-git}"
74 case ${KDE_SCM} in
75 svn|git) ;;
76 *) die "KDE_SCM: ${KDE_SCM} is not supported" ;;
77 esac
78
79 # @ECLASS-VARIABLE: KDE_LINGUAS
80 # @DESCRIPTION:
81 # This is a whitespace-separated list of translations this ebuild supports.
82 # These translations are automatically added to IUSE. Therefore ebuilds must set
83 # this variable before inheriting any eclasses. To enable only selected
84 # translations, ebuilds must call enable_selected_linguas(). kde4-{base,meta}.eclass does
85 # this for you.
86 #
87 # Example: KDE_LINGUAS="de en_GB nl"
88 if [[ ${KDE_BUILD_TYPE} != live || -n ${KDE_LINGUAS_LIVE_OVERRIDE} ]]; then
89 for _lingua in ${KDE_LINGUAS}; do
90 IUSE="${IUSE} linguas_${_lingua}"
91 done
92 fi
93
94 # @FUNCTION: buildsycoca
95 # @DESCRIPTION:
96 # Function to rebuild the KDE System Configuration Cache.
97 # All KDE ebuilds should run this in pkg_postinst and pkg_postrm.
98 buildsycoca() {
99 debug-print-function ${FUNCNAME} "$@"
100
101 # We no longer need to run kbuildsycoca4, as kded does that automatically, as needed
102
103 # fix permission for some directories
104 for x in usr/share/{config,kde4}; do
105 DIRS=${EROOT}usr
106 [[ -d "${EROOT}${x}" ]] || break # nothing to do if directory does not exist
107 # fixes Bug 318237
108 if use userland_BSD ; then
109 [[ $(stat -f %p "${EROOT}${x}") != 40755 ]]
110 local stat_rtn="$?"
111 else
112 [[ $(stat --format=%a "${EROOT}${x}") != 755 ]]
113 local stat_rtn=$?
114 fi
115 if [[ $stat_rtn != 1 ]] ; then
116 ewarn "QA Notice:"
117 ewarn "Package ${PN} is breaking ${EROOT}${x} permissions."
118 ewarn "Please report this issue to gentoo bugzilla."
119 einfo "Permissions will get adjusted automatically now."
120 find "${EROOT}${x}" -type d -print0 | xargs -0 chmod 755
121 fi
122 done
123 }
124
125 # @FUNCTION: comment_all_add_subdirectory
126 # @USAGE: [list of directory names]
127 # @DESCRIPTION:
128 # Recursively comment all add_subdirectory instructions in listed directories,
129 # except those in cmake/.
130 comment_all_add_subdirectory() {
131 find "$@" -name CMakeLists.txt -print0 | grep -vFzZ "./cmake" | \
132 xargs -0 sed -i \
133 -e '/^[[:space:]]*add_subdirectory/s/^/#DONOTCOMPILE /' \
134 -e '/^[[:space:]]*ADD_SUBDIRECTORY/s/^/#DONOTCOMPILE /' \
135 -e '/^[[:space:]]*macro_optional_add_subdirectory/s/^/#DONOTCOMPILE /' \
136 -e '/^[[:space:]]*MACRO_OPTIONAL_ADD_SUBDIRECTORY/s/^/#DONOTCOMPILE /' \
137 || die "${LINENO}: Initial sed died"
138 }
139
140 # @FUNCTION: enable_selected_linguas
141 # @DESCRIPTION:
142 # Enable translations based on LINGUAS settings and translations supported by
143 # the package (see KDE_LINGUAS). By default, translations are found in "${S}"/po
144 # but this default can be overridden by defining KDE_LINGUAS_DIR.
145 enable_selected_linguas() {
146 debug-print-function ${FUNCNAME} "$@"
147
148 local x
149
150 # if there is no linguas defined we enable everything
151 if ! $(env | grep -q "^LINGUAS="); then
152 return 0
153 fi
154
155 # @ECLASS-VARIABLE: KDE_LINGUAS_DIR
156 # @DESCRIPTION:
157 # Specified folder where application translations are located.
158 # Can be defined as array of folders where translations are located.
159 # Note that space separated list of dirs is not supported.
160 # Default value is set to "po".
161 if [[ "$(declare -p KDE_LINGUAS_DIR 2>/dev/null 2>&1)" == "declare -a"* ]]; then
162 debug-print "$FUNCNAME: we have these subfolders defined: ${KDE_LINGUAS_DIR}"
163 for x in ${KDE_LINGUAS_DIR[@]}; do
164 _enable_selected_linguas_dir ${x}
165 done
166 else
167 KDE_LINGUAS_DIR=${KDE_LINGUAS_DIR:="po"}
168 _enable_selected_linguas_dir ${KDE_LINGUAS_DIR}
169 fi
170 }
171
172 # @FUNCTION: enable_selected_doc_linguas
173 # @DESCRIPTION:
174 # Enable only selected linguas enabled doc folders.
175 enable_selected_doc_linguas() {
176 debug-print-function ${FUNCNAME} "$@"
177
178 # @ECLASS-VARIABLE: KDE_DOC_DIRS
179 # @DESCRIPTION:
180 # Variable specifying whitespace separated patterns for documentation locations.
181 # Default is "doc/%lingua"
182 KDE_DOC_DIRS=${KDE_DOC_DIRS:='doc/%lingua'}
183 local linguas
184 for pattern in ${KDE_DOC_DIRS}; do
185
186 local handbookdir=`dirname ${pattern}`
187 local translationdir=`basename ${pattern}`
188 # Do filename pattern supplied, treat as directory
189 [[ ${handbookdir} = '.' ]] && handbookdir=${translationdir} && translationdir=
190 [[ -d ${handbookdir} ]] || die 'wrong doc dir specified'
191
192 if ! use handbook; then
193 # Disable whole directory
194 sed -e "/add_subdirectory[[:space:]]*([[:space:]]*${handbookdir}[[:space:]]*)/s/^/#DONOTCOMPILE /" \
195 -e "/ADD_SUBDIRECTORY[[:space:]]*([[:space:]]*${handbookdir}[[:space:]]*)/s/^/#DONOTCOMPILE /" \
196 -i CMakeLists.txt || die 'failed to comment out all handbooks'
197 else
198 # if there is no linguas defined we enable everything (i.e. comment out nothing)
199 if ! $(env | grep -q "^LINGUAS="); then
200 return 0
201 fi
202
203 # Disable subdirectories recursively
204 comment_all_add_subdirectory "${handbookdir}"
205
206 # In certain packages, the default handbook is en_US instead of the usual en. Since there is no en_US 'translation',
207 # it makes no sense to add to KDE_LINGUAS which causes this type of handbook to not be installed.
208 if [[ -d "${handbookdir}/en_US" && ! -d "${handbookdir}/en" ]]; then
209 mv "${handbookdir}/en_US" "${handbookdir}/en" || die
210 sed -e "s/en_US/en/" -i "${handbookdir}/CMakeLists.txt"
211 fi
212
213 # Add requested translations
214 local lingua
215 for lingua in en ${KDE_LINGUAS}; do
216 if [[ ${lingua} = en ]] || use linguas_${lingua}; then
217 if [[ -d ${handbookdir}/${translationdir//%lingua/${lingua}} ]]; then
218 sed -e "/add_subdirectory[[:space:]]*([[:space:]]*${translationdir//%lingua/${lingua}}/s/^#DONOTCOMPILE //" \
219 -e "/ADD_SUBDIRECTORY[[:space:]]*([[:space:]]*${translationdir//%lingua/${lingua}}/s/^#DONOTCOMPILE //" \
220 -i "${handbookdir}"/CMakeLists.txt && ! has ${lingua} ${linguas} && linguas="${linguas} ${lingua}"
221 fi
222 fi
223 done
224 fi
225
226 done
227 [[ -n "${linguas}" ]] && einfo "Enabling handbook translations:${linguas}"
228 }
229
230 # Functions handling KMLOADLIBS and KMSAVELIBS
231
232 # @FUNCTION: save_library_dependencies
233 # @DESCRIPTION:
234 # Add exporting CMake dependencies for current package
235 save_library_dependencies() {
236 local depsfile="${T}/${PN}"
237
238 ebegin "Saving library dependencies in ${depsfile##*/}"
239 echo "EXPORT_LIBRARY_DEPENDENCIES(\"${depsfile}\")" >> "${S}/CMakeLists.txt" || \
240 die "Failed to save the library dependencies."
241 eend $?
242 }
243
244 # @FUNCTION: install_library_dependencies
245 # @DESCRIPTION:
246 # Install generated CMake library dependencies to /var/lib/kde
247 install_library_dependencies() {
248 local depsfile="${T}/${PN}"
249
250 ebegin "Installing library dependencies as ${depsfile##*/}"
251 insinto /var/lib/kde
252 doins "${depsfile}" || die "Failed to install library dependencies."
253 eend $?
254 }
255
256 # @FUNCTION: load_library_dependencies
257 # @DESCRIPTION:
258 # Inject specified library dependencies in current package
259 load_library_dependencies() {
260 local pn i depsfile
261 ebegin "Injecting library dependencies from '${KMLOADLIBS}'"
262
263 i=0
264 for pn in ${KMLOADLIBS} ; do
265 ((i++))
266 depsfile="${EPREFIX}/var/lib/kde/${pn}"
267 [[ -r ${depsfile} ]] || depsfile="${EPREFIX}/var/lib/kde/${pn}:$(get_kde_version)"
268 [[ -r ${depsfile} ]] || die "Depsfile '${depsfile}' not accessible. You probably need to reinstall ${pn}."
269 sed -i -e "${i}iINCLUDE(\"${depsfile}\")" "${S}/CMakeLists.txt" || \
270 die "Failed to include library dependencies for ${pn}"
271 done
272 eend $?
273 }
274
275 # @FUNCTION: add_kdeapps_dep
276 # @DESCRIPTION:
277 # Create proper dependency for kde-apps/ dependencies.
278 # This takes 1 to 3 arguments. The first being the package name, the optional
279 # second is additional USE flags to append, and the optional third is the
280 # version to use instead of the automatic version (use sparingly).
281 # The output of this should be added directly to DEPEND/RDEPEND, and may be
282 # wrapped in a USE conditional (but not an || conditional without an extra set
283 # of parentheses).
284 add_kdeapps_dep() {
285 debug-print-function ${FUNCNAME} "$@"
286
287 local ver
288
289 if [[ -n ${3} ]]; then
290 ver=${3}
291 elif [[ -n ${KDE_OVERRIDE_MINIMAL} ]]; then
292 ver=${KDE_OVERRIDE_MINIMAL}
293 elif [[ ${KDEBASE} != kde-base ]]; then
294 ver=${KDE_MINIMAL}
295 # if building stable-live version depend just on the raw KDE version
296 # to allow merging packages against more stable basic stuff
297 elif [[ ${PV} == *.9999 ]]; then
298 ver=$(get_kde_version)
299 else
300 ver=${PV}
301 fi
302
303 [[ -z ${1} ]] && die "Missing parameter"
304
305 #FIXME
306 # Drop aqua= from kf5 packages
307 echo " >=kde-apps/${1}-${ver}:4[aqua=${2:+,${2}}]"
308 }
309
310 # @FUNCTION: add_kdebase_dep
311 # @DESCRIPTION:
312 # Create proper dependency for kde-base/ dependencies.
313 # This takes 1 to 3 arguments. The first being the package name, the optional
314 # second is additional USE flags to append, and the optional third is the
315 # version to use instead of the automatic version (use sparingly).
316 # The output of this should be added directly to DEPEND/RDEPEND, and may be
317 # wrapped in a USE conditional (but not an || conditional without an extra set
318 # of parentheses).
319 add_kdebase_dep() {
320 debug-print-function ${FUNCNAME} "$@"
321
322 local ver
323
324 if [[ -n ${3} ]]; then
325 ver=${3}
326 elif [[ -n ${KDE_OVERRIDE_MINIMAL} ]]; then
327 ver=${KDE_OVERRIDE_MINIMAL}
328 elif [[ -n ${KDE_MINIMAL} ]]; then
329 ver=${KDE_MINIMAL}
330 # if building live version depend on the final release since there will
331 # not be any more major development. this solves dep errors as not all
332 # packages have kde-base live versions now
333
334 # depend on the last sane released version where the normal >=${PV} dep
335 # is not possible
336 elif [[ ${CATEGORY} == kde-apps || ${PV} == *9999 ]]; then
337 ver=4.14.3
338 else
339 ver=${PV}
340 fi
341
342 [[ -z ${1} ]] && die "Missing parameter"
343
344 echo " >=kde-base/${1}-${ver}:4[aqua=${2:+,${2}}]"
345 }
346
347 # local function to enable specified translations for specified directory
348 # used from kde4-functions_enable_selected_linguas function
349 _enable_selected_linguas_dir() {
350 local lingua linguas sr_mess wp
351 local dir=${1}
352
353 [[ -d ${dir} ]] || die "linguas dir \"${dir}\" does not exist"
354 comment_all_add_subdirectory "${dir}"
355 pushd "${dir}" > /dev/null
356
357 # fix all various crazy sr@Latn variations
358 # this part is only ease for ebuilds, so there wont be any die when this
359 # fail at any point
360 sr_mess="sr@latn sr@latin sr@Latin"
361 for wp in ${sr_mess}; do
362 [[ -e ${wp}.po ]] && mv "${wp}.po" "sr@Latn.po"
363 if [[ -d ${wp} ]]; then
364 # move dir and fix cmakelists
365 mv "${wp}" "sr@Latn"
366 sed -i \
367 -e "s:${wp}:sr@Latn:g" \
368 CMakeLists.txt
369 fi
370 done
371
372 for lingua in ${KDE_LINGUAS}; do
373 if [[ -e ${lingua}.po ]]; then
374 mv "${lingua}.po" "${lingua}.po.old"
375 fi
376 done
377
378 for lingua in ${KDE_LINGUAS}; do
379 if use linguas_${lingua} ; then
380 if [[ -d ${lingua} ]]; then
381 linguas="${linguas} ${lingua}"
382 sed -e "/add_subdirectory([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \
383 -e "/ADD_SUBDIRECTORY([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \
384 -i CMakeLists.txt || die "Sed to uncomment linguas_${lingua} failed."
385 fi
386 if [[ -e ${lingua}.po.old ]]; then
387 linguas="${linguas} ${lingua}"
388 mv "${lingua}.po.old" "${lingua}.po"
389 fi
390 fi
391 done
392 [[ -n ${linguas} ]] && echo ">>> Enabling languages: ${linguas}"
393
394 popd > /dev/null
395 }
396
397 # @FUNCTION: get_kde_version
398 # @DESCRIPTION:
399 # Translates an ebuild version into a major.minor KDE SC
400 # release version. If no version is specified, ${PV} is used.
401 get_kde_version() {
402 local ver=${1:-${PV}}
403 local major=$(get_major_version ${ver})
404 local minor=$(get_version_component_range 2 ${ver})
405 local micro=$(get_version_component_range 3 ${ver})
406 if [[ ${ver} == 9999 ]]; then
407 echo live
408 else
409 (( micro < 50 )) && echo ${major}.${minor} || echo ${major}.$((minor + 1))
410 fi
411 }
412
413 fi

  ViewVC Help
Powered by ViewVC 1.1.20