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

Diff of /eclass/kde4-functions.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.24 Revision 1.25
1# Copyright 1999-2008 Gentoo Foundation 1# Copyright 1999-2008 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/kde4-functions.eclass,v 1.24 2009/09/01 09:32:08 scarabeus Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/kde4-functions.eclass,v 1.25 2009/10/06 18:02:12 alexxy Exp $
4
5inherit versionator
4 6
5# Prefix compat: 7# Prefix compat:
6: ${EROOT:=${ROOT}} 8: ${EROOT:=${ROOT}}
7# Append missing trailing slash character 9# Append missing trailing slash character
8[[ ${EROOT} = */ ]] || EROOT+="/" 10[[ ${EROOT} = */ ]] || EROOT+="/"
80 DISPLAY="" \ 82 DISPLAY="" \
81 "${KDE3DIR}"/bin/kbuildsycoca --global --noincremental &> /dev/null 83 "${KDE3DIR}"/bin/kbuildsycoca --global --noincremental &> /dev/null
82 eend $? 84 eend $?
83 fi 85 fi
84 86
85 if [[ -z ${EROOT%%/} && -x "${KDEDIR}"/bin/kbuildsycoca4 ]]; then 87 # We no longer need to run kbuildsycoca4, as kded does that automatically, as needed
86 # Make sure tha cache file exists, writable by root and readable by
87 # others. Otherwise kbuildsycoca4 will fail.
88 touch "${KDEDIR}/share/kde4/services/ksycoca4"
89 chmod 644 "${KDEDIR}/share/kde4/services/ksycoca4"
90
91 # We have to unset DISPLAY and DBUS_SESSION_BUS_ADDRESS, the ones
92 # in the user's environment (through su [without '-']) may cause
93 # kbuildsycoca4 to hang.
94
95 ebegin "Running kbuildsycoca4 to build global database"
96 # This is needed because we support multiple kde versions installed together.
97 # Lookup in order - local, KDEDIR, /usr, do not duplicate entries btw.
98 local KDEDIRS="${EROOT}usr/share"
99 [[ ${KDEDIR} != "${EROOT}usr" ]] && KDEDIRS="${KDEDIR}/share:${KDEDIRS}"
100 XDG_DATA_DIRS="${EROOT}usr/local/share:${KDEDIRS}" \
101 DISPLAY="" DBUS_SESSION_BUS_ADDRESS="" \
102 "${KDEDIR}"/bin/kbuildsycoca4 --global --noincremental &> /dev/null
103 eend $?
104 fi
105 88
106 # fix permission for some directories 89 # fix permission for some directories
107 for x in share/{config,kde4}; do 90 for x in share/{config,kde4}; do
108 [[ ${KDEDIR} = ${EROOT}usr ]] && DIRS=${EROOT}usr || DIRS="${EROOT}usr ${KDEDIR}" 91 [[ ${KDEDIR} = ${EROOT}usr ]] && DIRS=${EROOT}usr || DIRS="${EROOT}usr ${KDEDIR}"
109 for y in ${DIRS}; do 92 for y in ${DIRS}; do
370# Create blocks for the current package in other slots when 353# Create blocks for the current package in other slots when
371# installed with USE=-kdeprefix 354# installed with USE=-kdeprefix
372block_other_slots() { 355block_other_slots() {
373 debug-print-function ${FUNCNAME} "$@" 356 debug-print-function ${FUNCNAME} "$@"
374 357
358 _do_blocker ${PN} 0:${SLOT}
359}
360
361# @FUNCTION: add_blocker
362# @DESCRIPTION:
363# Create correct RDEPEND value for blocking correct package.
364# Useful for file-collision blocks.
365# Parameters are package and version(s) to block.
366# add_blocker kdelibs 4.2.4
367# If no version is specified, then all versions will be blocked
368# If any arguments (from 2 on) contain a ":", then different versions
369# are blocked in different slots. (Unlisted slots get the version without
370# a ":", if none, then all versions are blocked). The parameter is then of
371# the form VERSION:SLOT. Any VERSION of 0 means that no blocker will be
372# added for that slot (or, if no slot, then for any unlisted slot).
373# A parameter of the form :SLOT means to block all versions from that slot.
374# If VERSION begins with "<", then "!<foo" will be used instead of "!<=foo".
375# As a special case, if a parameter with slot "3.5" is passed, then that slot
376# may also be blocked.
377#
378# Versions that match "4.x.50" are equivalent to all slots up to (and including)
379# "4.x", but nothing following slot "4.x"
380#
381# As an example, if SLOT=live, then
382# add_blocker kdelibs 0 :4.3 '<4.3.96:4.4' 9999:live
383# will add the following to RDEPEND:
384# !kdeprefix? ( !kde-base/kdelibs:4.3[-kdeprefix] )
385# !kdeprefix? ( !<kde-base/kdelibs-4.3.96:4.4[-kdeprefix] )
386# !kdeprefix? ( !<=kde-base/kdelibs-9999:live[-kdeprefix] )
387# kdeprefix? ( !<=kde-base/kdelibs-9999:live[kdeprefix] )
388add_blocker() {
389 debug-print-function ${FUNCNAME} "$@"
390
391 RDEPEND+=" $(_do_blocker "$@")"
392}
393
394# _greater_max_in_slot ver slot
395# slot must be 4.x or live
396# returns true if ver is >= the maximum possibile version in slot
397_greater_max_in_slot() {
398 local ver=$1
375 local slot 399 local slot=$2
400 # If slot is live, then return false
401 # (nothing is greater than the maximum live version)
402 [[ $slot == live ]] && return 1
403 # Otherwise, for slot X.Y, test against X.Y.50
404 local test=${slot}.50
405 version_compare $1 ${test}
406 # 1 = '<', 2 = '=', 3 = '>'
407 [[ $? -ne 1 ]]
408}
409
410# _less_min_in_slot ver slot
411# slot must be 4.x or live
412# returns true if ver is <= the minimum possibile version in slot
413_less_min_in_slot() {
414 local ver=$1
415 local slot=$2
416 # If slot == live, then test with "9999_pre", so that 9999 tests false
417 local test=9999_pre
418 # If slot == X.Y, then test with X.(Y-1).50
419 [[ $slot == live ]] || test=${slot%.*}.$((${slot#*.} - 1)).50
420 version_compare $1 ${test}
421 # 1 = '<', 2 = '=', 3 = '>'
422 [[ $? -ne 3 ]]
423}
424
425# Internal function used for add_blocker and block_other_slots
426# This takes the same parameters as add_blocker, but echos to
427# stdout instead of updating a variable.
428_do_blocker() {
429 debug-print-function ${FUNCNAME} "$@"
430
431 [[ -z ${1} ]] && die "Missing parameter"
432 local pkg=kde-base/$1
433 shift
434 local param slot def="unset" var atom
435 # The following variables will hold parameters that contain ":"
436 # - block_3_5
437 # - block_4_1
438 # - block_4_2
439 # - block_4_3
440 # - block_4_4
441 # - block_live
442 for slot in 3.5 ${KDE_SLOTS[@]} ${KDE_LIVE_SLOTS[@]}; do
443 local block_${slot//./_}="unset"
444 done
445
446 # This construct goes through each parameter passed, and sets
447 # either def or block_* to the version passed
448 for param; do
449 # If the parameter does not have a ":" in it...
450 if [[ ${param/:} == ${param} ]]; then
451 def=${param}
452 else # the parameter *does* have a ":" in it
453 # so everythin after the : is the slot...
454 slot=${param#*:}
455 # ...and everything before the : is the version
456 local block_${slot//./_}=${param%:*}
457 fi
458 done
459
376 for slot in ${KDE_SLOTS[@]} ${KDE_LIVE_SLOTS[@]}; do 460 for slot in ${KDE_SLOTS[@]} ${KDE_LIVE_SLOTS[@]}; do
377 # Block non kdeprefix ${PN} on other slots 461 # ${var} contains the name of the variable we care about for this slot
378 if [[ ${SLOT} != ${slot} ]]; then 462 # ${!var} is it's value
379 echo "!kdeprefix? ( !kde-base/${PN}:${slot}[-kdeprefix] )" 463 var=block_${slot//./_}
380 fi 464 # if we didn't pass *:${slot}, then use the unsloted value
381 done 465 [[ ${!var} == "unset" ]] && var=def
382}
383 466
384# @FUNCTION: add_blocker 467 # If the no version was passed, or the version is greater than the
385# @DESCRIPTION: 468 # maximum possible version in this slot, block all versions in this
386# Create correct RDEPEND value for blocking correct package. 469 # slot
387# Usefull for file-collision blocks. 470 if [[ ${!var} == "unset" ]] || _greater_max_in_slot ${!var#<} ${slot}; then
388# Parameters are package and version to block. 471 atom=${pkg}
389# add_blocker kde-base/kdelibs 4.2.4 472 # If the version is "0" or less than the minimum possible version in
390add_blocker() { 473 # this slot, do nothing
391 debug-print-function ${FUNCNAME} "$@" 474 elif [[ ${!var} == "0" ]] || _less_min_in_slot ${!var#<} ${slot}; then
392 475 continue
393 [[ ${1} = "" || ${2} = "" ]] && die "Missing parameter" 476 # If the version passed begins with a "<", then use "<" instead of "<="
394 local slot 477 elif [[ ${!var:0:1} == "<" ]]; then
395 for slot in ${KDE_SLOTS[@]} ${KDE_LIVE_SLOTS[@]}; do 478 # this also removes the first character of the version, which is a "<"
479 atom="<${pkg}-${!var:1}"
480 else
481 atom="<=${pkg}-${!var}"
482 fi
396 # on -kdeprefix we block every slot 483 # on -kdeprefix we block every slot
397 RDEPEND+=" !kdeprefix? ( !<=${1}-${2}:${slot}[-kdeprefix] )" 484 echo " !kdeprefix? ( !${atom}:${slot}[-kdeprefix] )"
398 done
399 # on kdeprefix we block only our slot 485 # on kdeprefix we block only our slot
486 if [[ ${SLOT} == ${slot} ]]; then
400 RDEPEND+=" kdeprefix? ( !<=${1}-${2}:${SLOT}[kdeprefix] )" 487 echo " kdeprefix? ( !${atom}:${SLOT}[kdeprefix] )"
488 fi
489 done
490
491 # This is a special case block for :3.5; it does not use the
492 # default version passed, and no blocker is output *unless* a version
493 # is passed, or ":3.5" is passed to explicitly request a block on all
494 # 3.5 versions.
495 if [[ ${block_3_5} != "unset" && ${block_3_5} != "0" ]]; then
496 if [[ -z ${block_3_5} ]]; then
497 atom=${pkg}
498 elif [[ ${block_3_5:0:1} == "<" ]]; then
499 atom="<${pkg}-${block_3_5:1}"
500 else
501 atom="<=${pkg}-${block_3_5}"
502 fi
503 echo " !${atom}:3.5"
504 fi
401} 505}
506
507# @FUNCTION: add_kdebase_dep
508# @DESCRIPTION:
509# Create proper dependency for kde-base/ dependencies,
510# adding SLOT when needed (and *only* when needed).
511# This takes 1 or 2 arguments. The first being the package
512# name, the optional second, is additional USE flags to append.
513# The output of this should be added directly to DEPEND/RDEPEND, and
514# may be wrapped in a USE conditional (but not an || conditional
515# without an extra set of parentheses.
516add_kdebase_dep() {
517 debug-print-function ${FUNCNAME} "$@"
518
519 [[ -z ${1} ]] && die "Missing parameter"
520
521 local use=${2:+,${2}}
522
523 echo "!kdeprefix? ( >=kde-base/${1}-${PV}[-kdeprefix${use}] )"
524 echo "kdeprefix? ( >=kde-base/${1}-${PV}:${SLOT}[kdeprefix${use}] )"
525}

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

  ViewVC Help
Powered by ViewVC 1.1.20