From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 148F8138CCF for ; Sun, 24 May 2015 08:14:49 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B0B83E0B38; Sun, 24 May 2015 08:14:48 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 4D6FDE0B38 for ; Sun, 24 May 2015 08:14:43 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 50CA6340BE2 for ; Sun, 24 May 2015 08:14:41 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 93F279FF for ; Sun, 24 May 2015 08:14:38 +0000 (UTC) From: "Justin Lecher" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Justin Lecher" Message-ID: <1432454162.21ed8ad45d2230598fb31652ba080e4cbb9daa28.jlec@gentoo> Subject: [gentoo-commits] proj/sci:master commit in: eclass/ X-VCS-Repository: proj/sci X-VCS-Files: eclass/alternatives-2.eclass X-VCS-Directories: eclass/ X-VCS-Committer: jlec X-VCS-Committer-Name: Justin Lecher X-VCS-Revision: 21ed8ad45d2230598fb31652ba080e4cbb9daa28 X-VCS-Branch: master Date: Sun, 24 May 2015 08:14:38 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: e38637f7-87bd-4270-8963-6d02a7965100 X-Archives-Hash: ec99f3c1e8887cae2baaa4073bc78c5e commit: 21ed8ad45d2230598fb31652ba080e4cbb9daa28 Author: Justin Lecher gentoo org> AuthorDate: Sun May 24 07:56:02 2015 +0000 Commit: Justin Lecher gentoo 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 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: [ [...]] # @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: # @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