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

Contents of /eclass/kde4-functions.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.65 - (show annotations) (download)
Wed Jul 3 09:22:39 2013 UTC (15 months, 4 weeks ago) by kensington
Branch: MAIN
Changes since 1.64: +10 -3 lines
Deprecate EAPI 3.

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

  ViewVC Help
Powered by ViewVC 1.1.20