All pastes #618044 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-07-13 18:22 UTC
rendered paste body
append-features() {
        export FEATURES="${FEATURES} $*"
        return 0
}

package-features() {
        local target features feature i;

        # bail if file does not exist or is not readable.
        [ -r ${ROOT}/etc/portage/package.features ] || return 0

        # need bash >= 3
        if [ "${BASH_VERSINFO[0]}" -le 2 ]; then
                eecho "Need bash3 for this bashrc script to work"
                return 0
        fi

        while read -a target; do
                if [[ ${target[@]%%#*} ]]; then

                        # valid syntax no >=<! operators
                        # category FEATURES
                        # category/packagename FEATURES
                        if [[ ${target%%#*} && ${target%% *} =~ "^(${CATEGORY}|${CATEGORY}/${PN})\>" ]]; then
                                skip=0
                                if [[ ${target} != ${CATEGORY} ]] ; then
                                        if [[ ${target} != ${CATEGORY}/${PN} ]] ; then
                                                skip=1
                                        fi
                                fi
                                if [ "${skip}" == 0 ] ; then
                                        flags=(${target[@]:1})
                                        if [[ ${features[@]} =~ 'FEATURES' ]]; then
                                                for (( i = 0; i < ${#features[@]}; i++ )); do
                                                        if [[ ${features[$i]} =~ 'FEATURES' ]]; then
                                                                append-features $(eval echo "${features[$i]}")
                                                                unset features[$i]
                                                        fi
                                                done
                                        fi
                                        for feature in ${features[@]}; do
                                                if [[ ${FEATURES} =~ ${feature} ]]; then
                                                        continue 1
                                                else
                                                        append-features "${feature}"
                                                fi
                                        done
                                        export -n FEATURES
                                        #eecho "Using package.features entry for target ${target} for ${CATEGORY}/${PN}"
                                fi
                        fi
                fi
        done < ${ROOT}/etc/portage/package.features
}