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

Contents of /eclass/kde4-functions.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.45 - (hide annotations) (download)
Wed Apr 6 14:22:14 2011 UTC (3 years, 5 months ago) by scarabeus
Branch: MAIN
Changes since 1.44: +152 -112 lines
Move fixes for kde4-* eclasses from overlay here:
Removal of eapi2 support.
Removal of quirks for eapi2 and koffice.
Additon of fdo/gnome-func eclasses to nicely update mime info.
Various whitespace and tiny bugs cleanups.
Addition of git to support upstream slowly moving to git.

Add new eclass for kde4-meta packages. Written by ABCD. Allows us smaller
meta packages.

1 scarabeus 1.45 # Copyright 1999-2011 Gentoo Foundation
2 ingmar 1.1 # Distributed under the terms of the GNU General Public License v2
3 scarabeus 1.45 # $Header: /var/cvsroot/gentoo-x86/eclass/kde4-functions.eclass,v 1.41 2010/12/29 17:56:34 tampakrap Exp $
4 ingmar 1.1
5 alexxy 1.25 inherit versionator
6    
7 ingmar 1.1 # @ECLASS: kde4-functions.eclass
8     # @MAINTAINER:
9     # kde@gentoo.org
10 scarabeus 1.10 # @BLURB: Common ebuild functions for KDE 4 packages
11 ingmar 1.1 # @DESCRIPTION:
12     # This eclass contains all functions shared by the different eclasses,
13 scarabeus 1.10 # for KDE 4 ebuilds.
14    
15     # @ECLASS-VARIABLE: EAPI
16     # @DESCRIPTION:
17 scarabeus 1.45 # Currently kde4 eclasses support EAPI 3 and 4.
18 scarabeus 1.14 case ${EAPI:-0} in
19 scarabeus 1.45 4|3) : ;;
20 reavertm 1.32 *) die "EAPI=${EAPI} is not supported" ;;
21 scarabeus 1.10 esac
22 ingmar 1.1
23 scarabeus 1.45 # @ECLASS-VARIABLE: KDE_OVERRIDE_MINIMAL
24     # @DESCRIPTION:
25     # For use only in very few well-defined cases; normally it should be unset.
26     # If this variable is set, all calls to add_kdebase_dep return a dependency on
27     # at least this version, independent of the version of the package itself.
28     # If you know exactly that one specific NEW KDE component builds and runs fine
29     # with all the rest of KDE at an OLDER version, you can set this old version here.
30     # Warning- may lead to general instability and kill your pet targh.
31    
32 ingmar 1.1 # @ECLASS-VARIABLE: KDEBASE
33     # @DESCRIPTION:
34     # This gets set to a non-zero value when a package is considered a kde or
35     # koffice ebuild.
36 scarabeus 1.15 if [[ ${CATEGORY} = kde-base ]]; then
37 ingmar 1.1 debug-print "${ECLASS}: KDEBASE ebuild recognized"
38 scarabeus 1.10 KDEBASE=kde-base
39 scarabeus 1.45 elif [[ ${KMNAME-${PN}} = koffice ]]; then
40 ingmar 1.1 debug-print "${ECLASS}: KOFFICE ebuild recognized"
41 scarabeus 1.10 KDEBASE=koffice
42 scarabeus 1.45 elif [[ ${KMNAME-${PN}} = kdevelop ]]; then
43 reavertm 1.31 debug-print "${ECLASS}: KDEVELOP ebuild recognized"
44 scarabeus 1.45 KDEBASE=kdevelop
45 ingmar 1.1 fi
46    
47 jmbsvicetto 1.8 # @ECLASS-VARIABLE: KDE_SLOTS
48     # @DESCRIPTION:
49 scarabeus 1.15 # The slots used by all KDE versions later than 4.0. The live KDE releases use
50     # KDE_LIVE_SLOTS instead. Values should be ordered.
51 reavertm 1.33 KDE_SLOTS=( "4.1" "4.2" "4.3" "4.4" "4.5" "4.6" )
52 jmbsvicetto 1.8
53     # @ECLASS-VARIABLE: KDE_LIVE_SLOTS
54     # @DESCRIPTION:
55 scarabeus 1.15 # The slots used by KDE live versions. Values should be ordered.
56     KDE_LIVE_SLOTS=( "live" )
57 ingmar 1.1
58 scarabeus 1.45 # determine the build type
59     if [[ ${SLOT} = live || ${PV} = *9999* ]]; then
60     BUILD_TYPE="live"
61     else
62     BUILD_TYPE="release"
63     fi
64     export BUILD_TYPE
65    
66     # Set reponame and SCM for moduleses that have fully migrated to git
67     # (hack - it's here because it needs to be before SCM inherits from kde4-base)
68     if [[ ${BUILD_TYPE} == live ]]; then
69     case "${KMNAME}" in
70     kdebase-workspace)
71     KDE_SCM="git"
72     EGIT_REPONAME=${EGIT_REPONAME:=kde-workspace}
73     ;;
74     kdebase-runtime)
75     KDE_SCM="git"
76     EGIT_REPONAME=${EGIT_REPONAME:=kde-runtime}
77     ;;
78     kdebase-apps)
79     KDE_SCM="git"
80     EGIT_REPONAME=${EGIT_REPONAME:=kde-baseapps}
81     ;;
82     esac
83     fi
84    
85     # @ECLASS-VARIABLE: KDE_SCM
86     # @DESCRIPTION:
87     # If this is a live package which scm does it use
88     # Everything else uses svn by default
89     KDE_SCM="${KDE_SCM:-svn}"
90     case ${KDE_SCM} in
91     svn|git) ;;
92     *) die "KDE_SCM: ${KDE_SCM} is not supported" ;;
93     esac
94    
95     # @ECLASS-VARIABLE: KDE_LINGUAS
96     # @DESCRIPTION:
97     # This is a whitespace-separated list of translations this ebuild supports.
98     # These translations are automatically added to IUSE. Therefore ebuilds must set
99     # this variable before inheriting any eclasses. To enable only selected
100     # translations, ebuilds must call enable_selected_linguas(). kde4-{base,meta}.eclass does
101     # this for you.
102     #
103     # Example: KDE_LINGUAS="en_GB de nl"
104     if [[ ${BUILD_TYPE} != live || -n ${KDE_LINGUAS_LIVE_OVERRIDE} ]]; then
105     for _lingua in ${KDE_LINGUAS}; do
106     IUSE="${IUSE} linguas_${_lingua}"
107     done
108     fi
109    
110 scarabeus 1.24 # @FUNCTION: slot_is_at_least
111     # @USAGE: <want> <have>
112     # @DESCRIPTION:
113     # Version aware slot comparator.
114     # Current implementation relies on the fact, that slots can be compared like
115     # string literals (and let's keep it this way).
116     slot_is_at_least() {
117     [[ "${2}" > "${1}" || "${2}" = "${1}" ]]
118     }
119    
120 ingmar 1.1 # @FUNCTION: buildsycoca
121     # @DESCRIPTION:
122     # Function to rebuild the KDE System Configuration Cache.
123     # All KDE ebuilds should run this in pkg_postinst and pkg_postrm.
124     buildsycoca() {
125     debug-print-function ${FUNCNAME} "$@"
126 scarabeus 1.19
127 alexxy 1.25 # We no longer need to run kbuildsycoca4, as kded does that automatically, as needed
128 scarabeus 1.15
129     # fix permission for some directories
130 wired 1.22 for x in share/{config,kde4}; do
131 abcd 1.29 [[ ${KDEDIR} == /usr ]] && DIRS=${EROOT}usr || DIRS="${EROOT}usr ${EROOT}${KDEDIR}"
132 scarabeus 1.17 for y in ${DIRS}; do
133     [[ -d "${y}/${x}" ]] || break # nothing to do if directory does not exist
134     if [[ $(stat --format=%a "${y}/${x}") != 755 ]]; then
135     ewarn "QA Notice:"
136     ewarn "Package ${PN} is breaking ${y}/${x} permissions."
137     ewarn "Please report this issue to gentoo bugzilla."
138     einfo "Permissions will get adjusted automatically now."
139     find "${y}/${x}" -type d -print0 | xargs -0 chmod 755
140     fi
141     done
142 scarabeus 1.15 done
143 ingmar 1.1 }
144    
145     # @FUNCTION: comment_all_add_subdirectory
146     # @USAGE: [list of directory names]
147     # @DESCRIPTION:
148 scarabeus 1.10 # Recursively comment all add_subdirectory instructions in listed directories,
149     # except those in cmake/.
150 ingmar 1.1 comment_all_add_subdirectory() {
151     find "$@" -name CMakeLists.txt -print0 | grep -vFzZ "./cmake" | \
152 wired 1.22 xargs -0 sed -i \
153     -e '/^[[:space:]]*add_subdirectory/s/^/#DONOTCOMPILE /' \
154     -e '/^[[:space:]]*ADD_SUBDIRECTORY/s/^/#DONOTCOMPILE /' \
155     -e '/^[[:space:]]*macro_optional_add_subdirectory/s/^/#DONOTCOMPILE /' \
156     -e '/^[[:space:]]*MACRO_OPTIONAL_ADD_SUBDIRECTORY/s/^/#DONOTCOMPILE /' \
157     || die "${LINENO}: Initial sed died"
158 ingmar 1.1 }
159    
160 zlin 1.5 # @FUNCTION: enable_selected_linguas
161     # @DESCRIPTION:
162 scarabeus 1.10 # Enable translations based on LINGUAS settings and translations supported by
163     # the package (see KDE_LINGUAS). By default, translations are found in "${S}"/po
164 zlin 1.5 # but this default can be overridden by defining KDE_LINGUAS_DIR.
165     enable_selected_linguas() {
166 wired 1.22 debug-print-function ${FUNCNAME} "$@"
167    
168 alexxy 1.37 local x
169 scarabeus 1.10
170 scarabeus 1.19 # if there is no linguas defined we enable everything
171 scarabeus 1.20 if ! $(env | grep -q "^LINGUAS="); then
172     return 0
173     fi
174 wired 1.22
175     # @ECLASS-VARIABLE: KDE_LINGUAS_DIR
176     # @DESCRIPTION:
177     # Specified folder where application translations are located.
178 alexxy 1.37 # Can be defined as array of folders where translations are located.
179     # Note that space separated list of dirs is not supported.
180     # Default value is set to "po".
181     if [[ "$(declare -p KDE_LINGUAS_DIR 2>/dev/null 2>&1)" == "declare -a"* ]]; then
182     debug-print "$FUNCNAME: we have these subfolders defined: ${KDE_LINGUAS_DIR}"
183 scarabeus 1.45 for x in ${KDE_LINGUAS_DIR[@]}; do
184 alexxy 1.37 _enable_selected_linguas_dir ${x}
185     done
186     else
187     KDE_LINGUAS_DIR=${KDE_LINGUAS_DIR:="po"}
188     _enable_selected_linguas_dir ${KDE_LINGUAS_DIR}
189     fi
190 wired 1.22 }
191    
192     # @FUNCTION: enable_selected_doc_linguas
193     # @DESCRIPTION:
194     # Enable only selected linguas enabled doc folders.
195     enable_selected_doc_linguas() {
196     debug-print-function ${FUNCNAME} "$@"
197    
198     # if there is no linguas defined we enable everything
199     if ! $(env | grep -q "^LINGUAS="); then
200     return 0
201     fi
202    
203     # @ECLASS-VARIABLE: KDE_DOC_DIRS
204     # @DESCRIPTION:
205     # Variable specifying whitespace separated patterns for documentation locations.
206     # Default is "doc/%lingua"
207     KDE_DOC_DIRS=${KDE_DOC_DIRS:='doc/%lingua'}
208     local linguas
209     for pattern in ${KDE_DOC_DIRS}; do
210    
211     local handbookdir=`dirname ${pattern}`
212     local translationdir=`basename ${pattern}`
213     # Do filename pattern supplied, treat as directory
214 scarabeus 1.45 [[ ${handbookdir} = '.' ]] && handbookdir=${translationdir} && translationdir=
215     [[ -d ${handbookdir} ]] || die 'wrong doc dir specified'
216 wired 1.22
217     if ! use handbook; then
218     # Disable whole directory
219     sed -e "/add_subdirectory[[:space:]]*([[:space:]]*${handbookdir}[[:space:]]*)/s/^/#DONOTCOMPILE /" \
220     -e "/ADD_SUBDIRECTORY[[:space:]]*([[:space:]]*${handbookdir}[[:space:]]*)/s/^/#DONOTCOMPILE /" \
221     -i CMakeLists.txt || die 'failed to comment out all handbooks'
222     else
223     # Disable subdirectories recursively
224     comment_all_add_subdirectory "${handbookdir}"
225     # Add requested translations
226     local lingua
227     for lingua in en ${KDE_LINGUAS}; do
228 scarabeus 1.45 if [[ ${lingua} = en ]] || use linguas_${lingua}; then
229     if [[ -d ${handbookdir}/${translationdir//%lingua/${lingua}} ]]; then
230 wired 1.22 sed -e "/add_subdirectory[[:space:]]*([[:space:]]*${translationdir//%lingua/${lingua}}/s/^#DONOTCOMPILE //" \
231     -e "/ADD_SUBDIRECTORY[[:space:]]*([[:space:]]*${translationdir//%lingua/${lingua}}/s/^#DONOTCOMPILE //" \
232     -i "${handbookdir}"/CMakeLists.txt && ! has ${lingua} ${linguas} && linguas="${linguas} ${lingua}"
233     fi
234     fi
235     done
236     fi
237    
238     done
239     [[ -n "${linguas}" ]] && einfo "Enabling handbook translations:${linguas}"
240 zlin 1.5 }
241    
242 scarabeus 1.11 # @FUNCTION: migrate_store_dir
243     # @DESCRIPTION:
244 scarabeus 1.15 # Universal store dir migration
245     # * performs split of kdebase to kdebase-apps when needed
246     # * moves playground/extragear kde4-base-style to toplevel dir
247 scarabeus 1.11 migrate_store_dir() {
248 scarabeus 1.45 if [[ ${KDE_SCM} != svn ]]; then
249     die "migrate_store_dir() only makes sense for subversion"
250     fi
251    
252 scarabeus 1.15 local cleandir="${ESVN_STORE_DIR}/KDE"
253 scarabeus 1.45
254     if [[ -d ${cleandir} ]]; then
255 scarabeus 1.11 ewarn "'${cleandir}' has been found. Moving contents to new location."
256     addwrite "${ESVN_STORE_DIR}"
257     # Split kdebase
258     local module
259     if pushd "${cleandir}"/kdebase/kdebase > /dev/null; then
260     for module in `find . -maxdepth 1 -type d -name [a-z0-9]\*`; do
261     module="${module#./}"
262     mkdir -p "${ESVN_STORE_DIR}/kdebase-${module}" && mv -f "${module}" "${ESVN_STORE_DIR}/kdebase-${module}" || \
263     die "Failed to move to '${ESVN_STORE_DIR}/kdebase-${module}'."
264     done
265     popd > /dev/null
266     rm -fr "${cleandir}/kdebase" || \
267     die "Failed to remove ${cleandir}/kdebase. You need to remove it manually."
268     fi
269     # Move the rest
270     local pkg
271     for pkg in "${cleandir}"/*; do
272 scarabeus 1.15 mv -f "${pkg}" "${ESVN_STORE_DIR}"/ || eerror "Failed to move '${pkg}'"
273 scarabeus 1.11 done
274 scarabeus 1.45 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."
275 scarabeus 1.11 fi
276 scarabeus 1.15
277     if ! hasq kde4-meta ${INHERITED}; then
278     case ${KMNAME} in
279     extragear*|playground*)
280 scarabeus 1.45 local scmlocalpath="${ESVN_STORE_DIR}"/"${KMNAME}"/"${PN}"
281     if [[ -d "${scmlocalpath}" ]]; then
282 scarabeus 1.15 local destdir="${ESVN_STORE_DIR}"/"${ESVN_PROJECT}"/"`basename "${ESVN_REPO_URI}"`"
283 scarabeus 1.45 ewarn "'${scmlocalpath}' has been found."
284 scarabeus 1.15 ewarn "Moving contents to new location: ${destdir}"
285     addwrite "${ESVN_STORE_DIR}"
286 scarabeus 1.45 mkdir -p "${ESVN_STORE_DIR}"/"${ESVN_PROJECT}" && mv -f "${scmlocalpath}" "${destdir}" \
287     || die "Failed to move to '${scmlocalpath}'"
288 scarabeus 1.15 # Try cleaning empty directories
289 scarabeus 1.45 rmdir "`dirname "${scmlocalpath}"`" 2> /dev/null
290 scarabeus 1.15 fi
291     ;;
292     esac
293     fi
294 scarabeus 1.11 }
295    
296 scarabeus 1.10 # Functions handling KMLOADLIBS and KMSAVELIBS
297 ingmar 1.1
298 scarabeus 1.10 # @FUNCTION: save_library_dependencies
299     # @DESCRIPTION:
300     # Add exporting CMake dependencies for current package
301     save_library_dependencies() {
302     local depsfile="${T}/${PN}:${SLOT}"
303    
304 scarabeus 1.15 ebegin "Saving library dependencies in ${depsfile##*/}"
305 scarabeus 1.10 echo "EXPORT_LIBRARY_DEPENDENCIES(\"${depsfile}\")" >> "${S}/CMakeLists.txt" || \
306     die "Failed to save the library dependencies."
307     eend $?
308 ingmar 1.1 }
309    
310 scarabeus 1.10 # @FUNCTION: install_library_dependencies
311 ingmar 1.1 # @DESCRIPTION:
312 scarabeus 1.10 # Install generated CMake library dependencies to /var/lib/kde
313     install_library_dependencies() {
314 scarabeus 1.15 local depsfile="${T}/${PN}:${SLOT}"
315    
316     ebegin "Installing library dependencies as ${depsfile##*/}"
317 abcd 1.28 insinto /var/lib/kde
318 scarabeus 1.10 doins "${depsfile}" || die "Failed to install library dependencies."
319     eend $?
320     }
321 ingmar 1.1
322 scarabeus 1.10 # @FUNCTION: load_library_dependencies
323     # @DESCRIPTION:
324     # Inject specified library dependencies in current package
325     load_library_dependencies() {
326     local pn i depsfile
327 scarabeus 1.15 ebegin "Injecting library dependencies from '${KMLOADLIBS}'"
328 scarabeus 1.10
329     i=0
330     for pn in ${KMLOADLIBS} ; do
331     ((i++))
332 abcd 1.28 depsfile="${EPREFIX}/var/lib/kde/${pn}:${SLOT}"
333 scarabeus 1.45 [[ -r ${depsfile} ]] || die "Depsfile '${depsfile}' not accessible. You probably need to reinstall ${pn}."
334 scarabeus 1.10 sed -i -e "${i}iINCLUDE(\"${depsfile}\")" "${S}/CMakeLists.txt" || \
335     die "Failed to include library dependencies for ${pn}"
336     done
337     eend $?
338 ingmar 1.1 }
339 scarabeus 1.23
340     # @FUNCTION: block_other_slots
341     # @DESCRIPTION:
342     # Create blocks for the current package in other slots when
343     # installed with USE=-kdeprefix
344     block_other_slots() {
345     debug-print-function ${FUNCNAME} "$@"
346    
347 alexxy 1.25 _do_blocker ${PN} 0:${SLOT}
348 scarabeus 1.23 }
349    
350     # @FUNCTION: add_blocker
351     # @DESCRIPTION:
352     # Create correct RDEPEND value for blocking correct package.
353 alexxy 1.25 # Useful for file-collision blocks.
354     # Parameters are package and version(s) to block.
355     # add_blocker kdelibs 4.2.4
356     # If no version is specified, then all versions will be blocked
357     # If any arguments (from 2 on) contain a ":", then different versions
358     # are blocked in different slots. (Unlisted slots get the version without
359     # a ":", if none, then all versions are blocked). The parameter is then of
360     # the form VERSION:SLOT. Any VERSION of 0 means that no blocker will be
361     # added for that slot (or, if no slot, then for any unlisted slot).
362     # A parameter of the form :SLOT means to block all versions from that slot.
363     # If VERSION begins with "<", then "!<foo" will be used instead of "!<=foo".
364     # As a special case, if a parameter with slot "3.5" is passed, then that slot
365     # may also be blocked.
366     #
367     # Versions that match "4.x.50" are equivalent to all slots up to (and including)
368     # "4.x", but nothing following slot "4.x"
369     #
370     # As an example, if SLOT=live, then
371     # add_blocker kdelibs 0 :4.3 '<4.3.96:4.4' 9999:live
372     # will add the following to RDEPEND:
373     # !kdeprefix? ( !kde-base/kdelibs:4.3[-kdeprefix] )
374     # !kdeprefix? ( !<kde-base/kdelibs-4.3.96:4.4[-kdeprefix] )
375 scarabeus 1.27 # !<=kde-base/kdelibs-9999:live
376 scarabeus 1.23 add_blocker() {
377     debug-print-function ${FUNCNAME} "$@"
378    
379 alexxy 1.25 RDEPEND+=" $(_do_blocker "$@")"
380     }
381    
382 alexxy 1.37 # @FUNCTION: add_kdebase_dep
383     # @DESCRIPTION:
384 scarabeus 1.45 # Create proper dependency for kde-base/ dependencies, adding SLOT when needed
385     # (and *only* when needed).
386     # This takes 1 to 3 arguments. The first being the package name, the optional
387     # second is additional USE flags to append, and the optional third is the
388     # version to use instead of the automatic version (use sparingly).
389     # The output of this should be added directly to DEPEND/RDEPEND, and may be
390     # wrapped in a USE conditional (but not an || conditional without an extra set
391     # of parentheses).
392 alexxy 1.37 add_kdebase_dep() {
393     debug-print-function ${FUNCNAME} "$@"
394    
395 scarabeus 1.45 local ver
396    
397     if [[ -n ${3} ]]; then
398     ver=${3}
399     elif [[ -n ${KDE_OVERRIDE_MINIMAL} ]]; then
400     ver=${KDE_OVERRIDE_MINIMAL}
401     elif [[ ${KDEBASE} != kde-base ]]; then
402     ver=${KDE_MINIMAL}
403     # FIXME remove hack when kdepim-4.4.* is gone
404     elif [[ ( ${KMNAME} == kdepim || ${PN} == kdepim-runtime ) && ${SLOT} == 4.4 && ${1} =~ ^(kde(pim)?libs|oxygen-icons)$ ]]; then
405     ver=4.4.5
406     # FIXME remove hack when kdepim-4.6beta is gone
407     elif [[ ( ${KMNAME} == kdepim || ${PN} == kdepim-runtime ) && ${PV} == 4.5.98 && ${1} =~ ^(kde(pim)?libs|oxygen-icons)$ ]]; then
408     ver=4.5.90
409     # if building stable-live version depend just on slot
410     # to allow merging packages against more stable basic stuff
411     elif [[ ${PV} == *.9999 ]]; then
412     ver=${SLOT}
413     else
414     ver=${PV}
415     fi
416    
417 alexxy 1.37 [[ -z ${1} ]] && die "Missing parameter"
418    
419     local use=${2:+,${2}}
420    
421     if [[ ${KDEBASE} = kde-base ]]; then
422 scarabeus 1.45 echo " !kdeprefix? ( >=kde-base/${1}-${ver}[aqua=,-kdeprefix${use}] )"
423     echo " kdeprefix? ( >=kde-base/${1}-${ver}:${SLOT}[aqua=,kdeprefix${use}] )"
424     elif [[ ${ver} == live ]]; then
425     echo " kde-base/${1}:live[aqua=${use}]"
426 alexxy 1.37 else
427 scarabeus 1.45 echo " >=kde-base/${1}-${ver}[aqua=${use}]"
428 alexxy 1.37 fi
429     }
430    
431 alexxy 1.25 # _greater_max_in_slot ver slot
432     # slot must be 4.x or live
433     # returns true if ver is >= the maximum possibile version in slot
434     _greater_max_in_slot() {
435     local ver=$1
436     local slot=$2
437     # If slot is live, then return false
438     # (nothing is greater than the maximum live version)
439     [[ $slot == live ]] && return 1
440     # Otherwise, for slot X.Y, test against X.Y.50
441     local test=${slot}.50
442     version_compare $1 ${test}
443     # 1 = '<', 2 = '=', 3 = '>'
444 scarabeus 1.27 (( $? != 1 ))
445 alexxy 1.25 }
446    
447     # _less_min_in_slot ver slot
448     # slot must be 4.x or live
449     # returns true if ver is <= the minimum possibile version in slot
450     _less_min_in_slot() {
451     local ver=$1
452     local slot=$2
453     # If slot == live, then test with "9999_pre", so that 9999 tests false
454     local test=9999_pre
455     # If slot == X.Y, then test with X.(Y-1).50
456 scarabeus 1.27 [[ $slot != live ]] && test=${slot%.*}.$((${slot#*.} - 1)).50
457 alexxy 1.25 version_compare $1 ${test}
458     # 1 = '<', 2 = '=', 3 = '>'
459 scarabeus 1.27 (( $? != 3 ))
460 alexxy 1.25 }
461    
462     # Internal function used for add_blocker and block_other_slots
463     # This takes the same parameters as add_blocker, but echos to
464     # stdout instead of updating a variable.
465     _do_blocker() {
466     debug-print-function ${FUNCNAME} "$@"
467    
468     [[ -z ${1} ]] && die "Missing parameter"
469 scarabeus 1.45 local pkg=kde-base/$1 use
470 alexxy 1.25 shift
471 scarabeus 1.45 if [[ $pkg == *\[*\] ]]; then
472     use=${pkg#*\[}
473     use=${use%\]}
474     pkg=${pkg%\[*\]}
475     fi
476    
477 alexxy 1.25 local param slot def="unset" var atom
478     # The following variables will hold parameters that contain ":"
479     # - block_3_5
480     # - block_4_1
481     # - block_4_2
482     # - block_4_3
483     # - block_4_4
484     # - block_live
485     for slot in 3.5 ${KDE_SLOTS[@]} ${KDE_LIVE_SLOTS[@]}; do
486     local block_${slot//./_}="unset"
487     done
488    
489     # This construct goes through each parameter passed, and sets
490     # either def or block_* to the version passed
491     for param; do
492     # If the parameter does not have a ":" in it...
493     if [[ ${param/:} == ${param} ]]; then
494     def=${param}
495     else # the parameter *does* have a ":" in it
496 scarabeus 1.26 # so everything after the : is the slot...
497 alexxy 1.25 slot=${param#*:}
498     # ...and everything before the : is the version
499     local block_${slot//./_}=${param%:*}
500     fi
501     done
502    
503 scarabeus 1.23 for slot in ${KDE_SLOTS[@]} ${KDE_LIVE_SLOTS[@]}; do
504 alexxy 1.25 # ${var} contains the name of the variable we care about for this slot
505     # ${!var} is it's value
506     var=block_${slot//./_}
507     # if we didn't pass *:${slot}, then use the unsloted value
508     [[ ${!var} == "unset" ]] && var=def
509    
510 scarabeus 1.26 # If no version was passed, or the version is greater than the maximum
511     # possible version in this slot, block all versions in this slot
512     if [[ ${!var} == "unset" ]] || [[ -z ${!var} ]] || _greater_max_in_slot ${!var#<} ${slot}; then
513 alexxy 1.25 atom=${pkg}
514     # If the version is "0" or less than the minimum possible version in
515     # this slot, do nothing
516     elif [[ ${!var} == "0" ]] || _less_min_in_slot ${!var#<} ${slot}; then
517     continue
518     # If the version passed begins with a "<", then use "<" instead of "<="
519     elif [[ ${!var:0:1} == "<" ]]; then
520     # this also removes the first character of the version, which is a "<"
521     atom="<${pkg}-${!var:1}"
522     else
523     atom="<=${pkg}-${!var}"
524     fi
525 scarabeus 1.27 # we always block our own slot, ignoring kdeprefix
526 alexxy 1.25 if [[ ${SLOT} == ${slot} ]]; then
527 scarabeus 1.45 echo " !${atom}:${slot}${use:+[${use}]}"
528 scarabeus 1.27 else
529     # we only block other slots on -kdeprefix
530 scarabeus 1.45 echo " !kdeprefix? ( !${atom}:${slot}[-kdeprefix${use:+,${use}}] )"
531 alexxy 1.25 fi
532 scarabeus 1.23 done
533 alexxy 1.25
534     # This is a special case block for :3.5; it does not use the
535     # default version passed, and no blocker is output *unless* a version
536     # is passed, or ":3.5" is passed to explicitly request a block on all
537     # 3.5 versions.
538     if [[ ${block_3_5} != "unset" && ${block_3_5} != "0" ]]; then
539     if [[ -z ${block_3_5} ]]; then
540     atom=${pkg}
541     elif [[ ${block_3_5:0:1} == "<" ]]; then
542     atom="<${pkg}-${block_3_5:1}"
543     else
544     atom="<=${pkg}-${block_3_5}"
545     fi
546 scarabeus 1.45 echo " !${atom}:3.5${use:+[${use}]}"
547 alexxy 1.25 fi
548     }
549    
550 alexxy 1.37 # local function to enable specified translations for specified directory
551     # used from kde4-functions_enable_selected_linguas function
552     _enable_selected_linguas_dir() {
553     local lingua linguas sr_mess wp
554     local dir=${1}
555 alexxy 1.25
556 scarabeus 1.45 [[ -d ${dir} ]] || die "linguas dir \"${dir}\" does not exist"
557 alexxy 1.37 comment_all_add_subdirectory "${dir}"
558     pushd "${dir}" > /dev/null
559 alexxy 1.25
560 alexxy 1.37 # fix all various crazy sr@Latn variations
561     # this part is only ease for ebuilds, so there wont be any die when this
562     # fail at any point
563     sr_mess="sr@latn sr@latin sr@Latin"
564     for wp in ${sr_mess}; do
565 scarabeus 1.45 [[ -e ${wp}.po ]] && mv "${wp}.po" "sr@Latn.po"
566     if [[ -d ${wp} ]]; then
567 alexxy 1.37 # move dir and fix cmakelists
568     mv "${wp}" "sr@Latn"
569     sed -i \
570 scarabeus 1.45 -e "s:${wp}:sr@Latn:g" \
571 alexxy 1.37 CMakeLists.txt
572     fi
573     done
574 alexxy 1.25
575 alexxy 1.37 for lingua in ${KDE_LINGUAS}; do
576 scarabeus 1.45 if [[ -e ${lingua}.po ]]; then
577 alexxy 1.37 mv "${lingua}.po" "${lingua}.po.old"
578 reavertm 1.35 fi
579 alexxy 1.37 done
580    
581     for lingua in ${KDE_LINGUAS}; do
582     if use linguas_${lingua} ; then
583 scarabeus 1.45 if [[ -d ${lingua} ]]; then
584 alexxy 1.37 linguas="${linguas} ${lingua}"
585     sed -e "/add_subdirectory([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \
586     -e "/ADD_SUBDIRECTORY([[:space:]]*${lingua}[[:space:]]*)[[:space:]]*$/ s/^#DONOTCOMPILE //" \
587     -i CMakeLists.txt || die "Sed to uncomment linguas_${lingua} failed."
588     fi
589 scarabeus 1.45 if [[ -e ${lingua}.po.old ]]; then
590 alexxy 1.37 linguas="${linguas} ${lingua}"
591     mv "${lingua}.po.old" "${lingua}.po"
592     fi
593 reavertm 1.34 fi
594 alexxy 1.37 done
595 scarabeus 1.45 [[ -n ${linguas} ]] && echo ">>> Enabling languages: ${linguas}"
596 alexxy 1.37
597     popd > /dev/null
598 scarabeus 1.23 }
599 scarabeus 1.45
600     _calculate_kde_slot() {
601     local ver=${1:-${PV}}
602     local major=$(get_major_version ${ver})
603     local minor=$(get_version_component_range 2 ${ver})
604     local micro=$(get_version_component_range 3 ${ver})
605     [[ ${ver} == 9999 ]] && echo live
606     (( major == 4 && micro == 9999 )) && echo ${major}.${minor}
607     if (( major == 4 && micro != 9999 )); then
608     (( micro < 50 )) && echo ${major}.${minor} || echo ${major}.$((minor + 1))
609     fi
610     }

  ViewVC Help
Powered by ViewVC 1.1.20