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

Contents of /eclass/kde4-functions.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.66 - (show annotations) (download)
Thu Aug 15 14:52:58 2013 UTC (13 months ago) by kensington
Branch: MAIN
Changes since 1.65: +1 -8 lines
Remove EAPI 3 support.

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

  ViewVC Help
Powered by ViewVC 1.1.20