diff options
| author | Jonathan Callen <abcd@gentoo.org> | 2009-09-11 22:50:37 -0400 |
|---|---|---|
| committer | Jonathan Callen <abcd@gentoo.org> | 2009-09-13 06:53:39 -0400 |
| commit | 4f25ad6974895fa286b79d0c9ef965166328fb2c (patch) | |
| tree | df8641da00169f5c718b8c66d34029759b936696 | |
| parent | 44c4d622996a1c48f11c3212d6c1d3243a686c99 (diff) | |
| download | kde-4f25ad6974895fa286b79d0c9ef965166328fb2c.tar.gz kde-4f25ad6974895fa286b79d0c9ef965166328fb2c.tar.bz2 kde-4f25ad6974895fa286b79d0c9ef965166328fb2c.zip | |
[eclass] Add features to add_blocker() in kde4-functions.eclass
This now allows add_blocker to add just about any blocker that you would
need for kde-base/ packages (that is, kde-base/ packages blocking other
kde-base/ packages). In its simplest form, you can use
add_blocker pkg-name
to add a blocker on all kde-4 versions of kde-base/pkg-name. If further
arguments are supplied, then those indicate which versions to block.
There are 2 versions with special properties: 0 indicates that no version
is to be blocked, and 4.x.50 indicates that all versions in slots <= 4.x
are to be blocked. A version can also be specified with a slot, like
"4.2.96:4.3", indicating that for that slot, that version is to be blocked.
If no version is given with a slot (like ":4.3"), then all versions from
that slot are blocked. By default, versions <= the given version are
blocked. If the given version begins with "<", however, then versions < the
given version are blocked.
| -rw-r--r-- | eclass/kde4-functions.eclass | 144 |
1 files changed, 130 insertions, 14 deletions
diff --git a/eclass/kde4-functions.eclass b/eclass/kde4-functions.eclass index 419272a6f58..1581edbeeef 100644 --- a/eclass/kde4-functions.eclass +++ b/eclass/kde4-functions.eclass @@ -2,6 +2,8 @@ # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/eclass/kde4-functions.eclass,v 1.18 2009/05/09 13:23:15 scarabeus Exp $ +inherit versionator + # Prefix compat: : ${EROOT:=${ROOT}} # Append missing trailing slash character @@ -372,32 +374,146 @@ load_library_dependencies() { block_other_slots() { debug-print-function ${FUNCNAME} "$@" - local slot - for slot in ${KDE_SLOTS[@]} ${KDE_LIVE_SLOTS[@]}; do - # Block non kdeprefix ${PN} on other slots - if [[ ${SLOT} != ${slot} ]]; then - echo "!kdeprefix? ( !kde-base/${PN}:${slot}[-kdeprefix] )" - fi - done + _do_blocker ${PN} 0:${SLOT} } # @FUNCTION: add_blocker # @DESCRIPTION: # Create correct RDEPEND value for blocking correct package. -# Usefull for file-collision blocks. -# Parameters are package and version to block. +# Useful for file-collision blocks. +# Parameters are package and version(s) to block. # add_blocker kdelibs 4.2.4 +# If no version is specified, then all versions will be blocked +# If any arguments (from 2 on) contain a ":", then different versions +# are blocked in different slots. (Unlisted slots get the version without +# a ":", if none, then all versions are blocked). The parameter is then of +# the form VERSION:SLOT. Any VERSION of 0 means that no blocker will be +# added for that slot (or, if no slot, then for any unlisted slot). +# A parameter of the form :SLOT means to block all versions from that slot. +# If VERSION begins with "<", then "!<foo" will be used instead of "!<=foo". +# As a special case, if a parameter with slot "3.5" is passed, then that slot +# may also be blocked. +# +# Versions that match "4.x.50" are equivalent to all slots up to (and including) +# "4.x", but nothing following slot "4.x" +# +# As an example, if SLOT=live, then +# add_blocker kdelibs 0 :4.3 '<4.3.96:4.4' 9999:live +# will add the following to RDEPEND: +# !kdeprefix? ( !kde-base/kdelibs:4.3[-kdeprefix] ) +# !kdeprefix? ( !<kde-base/kdelibs-4.3.96:4.4[-kdeprefix] ) +# !kdeprefix? ( !<=kde-base/kdelibs-9999:live[-kdeprefix] ) +# kdeprefix? ( !<=kde-base/kdelibs-9999:live[kdeprefix] ) add_blocker() { debug-print-function ${FUNCNAME} "$@" - [[ ${1} = "" || ${2} = "" ]] && die "Missing parameter" - local slot + RDEPEND+=" $(_do_blocker "$@")" +} + +# _greater_max_in_slot ver slot +_greater_max_in_slot() { + local ver=$1 + local slot=$2 + [[ $slot == live ]] && return 1 + local test=${slot}.50 + version_compare $1 ${test} + [[ $? -ne 1 ]] +} + +# _less_min_in_slot ver slot +# slot must be 4.x or live +_less_min_in_slot() { + local ver=$1 + local slot=$2 + local test=9999 + [[ $slot == live ]] || test=${slot%.*}.$((${slot#*.} - 1)).50 + version_compare $1 ${test} + [[ $? -eq 1 ]] +} + +# Internal function used for add_blocker and block_other_slots +# This takes the same parameters as add_blocker, but echos to +# stdout instead of updating a variable. +_do_blocker() { + debug-print-function ${FUNCNAME} "$@" + + [[ -z ${1} ]] && die "Missing parameter" + local pkg=kde-base/$1 + shift + local param slot def="unset" var atom + # The following variables are set to "unset" in this block: + # - block_3_5 + # - block_4_1 + # - block_4_2 + # - block_4_3 + # - block_4_4 + # - block_live + # Those variables will hold the parameters that end in :3.5 + # (resp. :4.1, :4.2, :4.3, :4.4, :live) + for slot in 3.5 ${KDE_SLOTS[@]} ${KDE_LIVE_SLOTS[@]}; do + slot=${slot//[.-]/_} + local block_${slot}="unset" + done + + # This construct goes through each parameter passed, and sets + # either def or block_* to the version passed + for param; do + # If the parameter does not have a ":" in it... + if [[ ${param/:} == ${param} ]]; then + def=${param} + else # the parameter *does* have a ":" in it + # so everythin after the : is the slot... + slot=${param#*:} + # ...and everything before the : is the version + local block_${slot//[.-]/_}=${param%:*} + fi + done + for slot in ${KDE_SLOTS[@]} ${KDE_LIVE_SLOTS[@]}; do + # ${var} contains the name of the variable we care about for this slot + # ${!var} is it's value + var=block_${slot//[.-]/_} + # if we didn't pass *:${slot}, then use the unsloted value + [[ ${!var} == "unset" ]] && var=def + + # If the version is "0" or less than the minimum possible version in + # this slot, do nothing + if [[ ${!var} == "0" ]] || _less_min_in_slot ${!var#<} ${slot}; then + continue + # If the no version was passed, or the version is greater than the + # maximum possible version in this slot, block all versions in this + # slot + elif [[ ${!var} == "unset" || -z ${!var} ]] || _greater_max_in_slot ${!var#<} ${slot}; then + atom=${pkg} + # If the version passed begins with a "<", then use "<" instead of "<=" + elif [[ ${!var:0:1} == "<" ]]; then + # this also removes the first character of the version, which is a "<" + atom="<${pkg}-${!var:1}" + else + atom="<=${pkg}-${!var}" + fi # on -kdeprefix we block every slot - RDEPEND+=" !kdeprefix? ( !<=kde-base/${1}-${2}:${slot}[-kdeprefix] )" + echo " !kdeprefix? ( !${atom}:${slot}[-kdeprefix] )" + # on kdeprefix we block only our slot + if [[ ${SLOT} == ${slot} ]]; then + echo " kdeprefix? ( !${atom}:${SLOT}[kdeprefix] )" + fi done - # on kdeprefix we block only our slot - RDEPEND+=" kdeprefix? ( !<=kde-base/${1}-${2}:${SLOT}[kdeprefix] )" + + # This is a special case block for :3.5; it does not use the + # default version passed, and no blocker is output *unless* a version + # is passed, or ":3.5" is passed to explicitly request a block on all + # 3.5 versions. + if [[ ${block_3_5} != "unset" && ${block_3_5} != "0" ]]; then + if [[ -z ${block_3_5} ]]; then + atom=${pkg} + elif [[ ${block_3_5:0:1} == "<" ]]; then + atom="<${pkg}-${block_3_5:1}" + else + atom="<=${pkg}-${block_3_5}" + fi + echo " !${atom}:3.5" + fi } # @FUNCTION: add_kdebase_dep |
