commit:     21ed8ad45d2230598fb31652ba080e4cbb9daa28
Author:     Justin Lecher <jlec <AT> gentoo <DOT> org>
AuthorDate: Sun May 24 07:56:02 2015 +0000
Commit:     Justin Lecher <jlec <AT> gentoo <DOT> org>
CommitDate: Sun May 24 07:56:02 2015 +0000
URL:        https://gitweb.gentoo.org/proj/sci.git/commit/?id=21ed8ad4

Fix style

Signed-off-by: Justin Lecher <jlec <AT> gentoo.org>

 eclass/alternatives-2.eclass | 46 +++++++++++++++++++++++++++++---------------
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/eclass/alternatives-2.eclass b/eclass/alternatives-2.eclass
index 53d1881..5a7eb6c 100644
--- a/eclass/alternatives-2.eclass
+++ b/eclass/alternatives-2.eclass
@@ -1,4 +1,4 @@
-# Copyright 2010-2014 Gentoo Foundation
+# Copyright 2010-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Header: $
 
@@ -37,8 +37,6 @@ RDEPEND="${DEPEND}
        !app-admin/eselect-cblas
        !app-admin/eselect-lapack"
 
-EXPORT_FUNCTIONS pkg_postinst pkg_prerm
-
 # @ECLASS-VARIABLE: ALTERNATIVES_DIR
 # @INTERNAL
 # @DESCRIPTION:
@@ -46,18 +44,20 @@ EXPORT_FUNCTIONS pkg_postinst pkg_prerm
 ALTERNATIVES_DIR="/etc/env.d/alternatives"
 
 # @FUNCTION: alternatives_for
-# @USAGE: alternative provider importance source target [source target [...]]
+# @USAGE: <alternative> <provider> <importance> <source> <target> [<source> 
<target> [...]]
 # @DESCRIPTION:
 # Set up alternative provider.
 #
 # EXAMPLE:
 # @CODE
-# alternatives_for cblas atlas 0 \
-#     /usr/$(get_libdir)/pkgconfig/cblas.pc atlas-cblas.pc \
-#     /usr/include/cblas.h atlas/cblas.h
+# alternatives_for sh bash 0 \
+#     /usr/bin/sh bash
 # @CODE
 alternatives_for() {
-       (( $# >= 5 )) && (( ($#-3)%2 == 0)) || die "${FUNCNAME} requires 
exactly 3+N*2 arguments where N>=1"
+       debug-print-function ${FUNCNAME} "${@}"
+
+       (( $# >= 5 )) && (( ($#-3)%2 == 0)) || \
+               die "${FUNCNAME} requires exactly 3+N*2 arguments where N>=1"
        local alternative=${1} provider=${2} importance=${3} index src target 
ret=0
        shift 3
 
@@ -68,7 +68,8 @@ alternatives_for() {
        fi
 
        # Create alternative provider subdirectories under ALTERNATIVES_DIR if 
needed
-       [[ -d "${ED}${ALTERNATIVES_DIR}/${alternative}/${provider}" ]] || dodir 
"${ALTERNATIVES_DIR}/${alternative}/${provider}"
+       [[ -d "${ED}${ALTERNATIVES_DIR}/${alternative}/${provider}" ]] || \
+               dodir "${ALTERNATIVES_DIR}/${alternative}/${provider}"
 
        # Keep track of provided alternatives for use in pkg_{postinst,prerm}.
        # Keep a mapping between importance and provided alternatives
@@ -78,10 +79,11 @@ alternatives_for() {
                index=${#ALTERNATIVES_PROVIDED[@]}
                ALTERNATIVES_PROVIDED+=( "${alternative}:${provider}" )
                ALTERNATIVES_IMPORTANCE[index]=${importance}
-               [[ -n ${importance} ]] && echo "${importance}" > 
"${ED}${ALTERNATIVES_DIR}/${alternative}/${provider}/_importance"
+               [[ -n ${importance} ]] && \
+                       echo "${importance}" > 
"${ED}${ALTERNATIVES_DIR}/${alternative}/${provider}/_importance"
        else
                # Set importance for existing provider
-               for((index=0;index<${#ALTERNATIVES_PROVIDED[@]};index++)); do
+               for ((index=0;index<${#ALTERNATIVES_PROVIDED[@]};index++)); do
                        if [[ ${alternative}:${provider} == 
${ALTERNATIVES_PROVIDED[index]} ]]; then
                                if [[ -n ${ALTERNATIVES_IMPORTANCE[index]} ]]; 
then
                                        if [[ -n ${importance} && 
${ALTERNATIVES_IMPORTANCE[index]} != ${importance} ]]; then
@@ -90,7 +92,8 @@ alternatives_for() {
                                        fi
                                else
                                        
ALTERNATIVES_IMPORTANCE[index]=${importance}
-                                       [[ -n ${importance} ]] && echo 
"${importance}" > 
"${ED}${ALTERNATIVES_DIR}/${alternative}/${provider}/_importance"
+                                       [[ -n ${importance} ]] && \
+                                               echo "${importance}" > 
"${ED}${ALTERNATIVES_DIR}/${alternative}/${provider}/_importance"
                                fi
                        fi
                done
@@ -137,11 +140,14 @@ alternatives_for() {
 }
 
 # @FUNCTION: cleanup_old_alternatives_module
-# @USAGE: alternative
+# @USAGE: <alternative>
 # @DESCRIPTION:
 # Remove old alternatives module.
 cleanup_old_alternatives_module() {
+       debug-print-function ${FUNCNAME} "${@}"
+
        local alt=${1} 
old_module="${EROOT%/}/usr/share/eselect/modules/${alt}.eselect"
+
        if [[ -f "${old_module}" && $(grep 'ALTERNATIVE=' "${old_module}" | cut 
-d '=' -f 2) == "${alt}" ]]; then
                local version="$(grep 'VERSION=' "${old_module}" | grep -o 
'[0-9.]\+')"
                if [[ "${version}" == "0.1" || "${version}" == "20080924" ]]; 
then
@@ -160,8 +166,11 @@ cleanup_old_alternatives_module() {
 #
 # Provided alternatives are set up using alternatives_for().
 alternatives-2_pkg_postinst() {
-       local a alt provider module_version="20090908"
+       debug-print-function ${FUNCNAME} "${@}"
+
+       local a alt provider module_version="20150521"
        local EAUTO="${EROOT%/}/usr/share/eselect/modules/auto"
+
        for a in "${ALTERNATIVES_PROVIDED[@]}"; do
                alt="${a%:*}"
                provider="${a#*:}"
@@ -172,7 +181,7 @@ alternatives-2_pkg_postinst() {
                                install -d "${EAUTO}" || eerror "Could not 
create eselect modules dir"
                        fi
                        einfo "Creating alternatives eselect module for ${alt}"
-                       cat > "${EAUTO}/${alt}.eselect" <<-EOF
+                       cat > "${EAUTO}/${alt}.eselect" <<- EOF
                                # This module was automatically generated by 
alternatives-2.eclass
                                DESCRIPTION="Alternatives for ${alt}"
                                VERSION="${module_version}"
@@ -195,13 +204,16 @@ alternatives-2_pkg_postinst() {
 # @FUNCTION: alternatives-2_pkg_prerm
 # @DESCRIPTION:
 # Ensure a valid provider is set in case the package is unmerged and
-# remove autogenerated eselect modules for all alternatives when last
+# remove autogenerated eselect modules for alternative when last
 # provider is unmerged.
 #
 # Provided alternatives are set up using alternatives_for().
 alternatives-2_pkg_prerm() {
+       debug-print-function ${FUNCNAME} "${@}"
+
        local a alt provider ignore ret
        local EAUTO="${EROOT%/}/usr/share/eselect/modules/auto"
+
        # If we are uninstalling, update alternatives to valid provider
        [[ -n ${REPLACED_BY_VERSION} ]] || ignore="--ignore"
        for a in "${ALTERNATIVES_PROVIDED[@]}"; do
@@ -225,3 +237,5 @@ alternatives-2_pkg_prerm() {
                esac
        done
 }
+
+EXPORT_FUNCTIONS pkg_postinst pkg_prerm

Reply via email to