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 76C85138247 for ; Wed, 22 Jan 2014 10:09:52 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8BFA8E10AD; Wed, 22 Jan 2014 10:09:41 +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 84D00E10AD for ; Wed, 22 Jan 2014 10:09:40 +0000 (UTC) Received: from spoonbill.gentoo.org (spoonbill.gentoo.org [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D374033FAFD for ; Wed, 22 Jan 2014 10:09:38 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id 99D50187BB for ; Wed, 22 Jan 2014 10:09:36 +0000 (UTC) From: "Reinis Danne" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Reinis Danne" Message-ID: <1390334121.ff8b1ad72e5f30ec5b3f084b87c672f2a7b81c6f.rei4dan@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: rei4dan X-VCS-Committer-Name: Reinis Danne X-VCS-Revision: ff8b1ad72e5f30ec5b3f084b87c672f2a7b81c6f X-VCS-Branch: master Date: Wed, 22 Jan 2014 10:09:36 +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: c3d2a1f8-0c46-4353-b8fa-873db85d231e X-Archives-Hash: 9fdc212080f725090022953aabd66c4a commit: ff8b1ad72e5f30ec5b3f084b87c672f2a7b81c6f Author: Reinis Danne gmail com> AuthorDate: Mon Jan 20 16:35:24 2014 +0000 Commit: Reinis Danne gmail com> CommitDate: Tue Jan 21 19:55:21 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/sci.git;a=commit;h=ff8b1ad7 alternatives-2.eclass: Add documentation comments --- eclass/alternatives-2.eclass | 50 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/eclass/alternatives-2.eclass b/eclass/alternatives-2.eclass index f83c479..bc60108 100644 --- a/eclass/alternatives-2.eclass +++ b/eclass/alternatives-2.eclass @@ -7,6 +7,16 @@ # Copyright 2008, 2009 Mike Kelly # Copyright 2009 David Leverton +# @ECLASS: alternatives-2 +# @MAINTAINER: +# Gentoo Science Project +# @BLURB: Manage alternative implementations. +# @DESCRIPTION: +# Autogenerate eselect modules for alternatives and ensure that valid provider +# is set. +# +# Remove eselect modules when last provider is unmerged. +# # If your package provides pkg_postinst or pkg_prerm phases, you need to be # sure you explicitly run alternatives-2_pkg_{postinst,prerm} where appropriate. @@ -21,8 +31,6 @@ case "${EAPI:-0}" in ;; esac -ALTERNATIVES_DIR="/etc/env.d/alternatives" - DEPEND=">=app-admin/eselect-1.4-r100" RDEPEND="${DEPEND} !app-admin/eselect-blas @@ -31,9 +39,24 @@ RDEPEND="${DEPEND} EXPORT_FUNCTIONS pkg_postinst pkg_prerm -# alternatives_for alternative provider importance source target [ source target [...]] -alternatives_for() { +# @ECLASS-VARIABLE: ALTERNATIVES_DIR +# @INTERNAL +# @DESCRIPTION: +# Alternatives directory with symlinks managed by eselect. +ALTERNATIVES_DIR="/etc/env.d/alternatives" +# @FUNCTION: alternatives_for +# @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 +# @CODE +alternatives_for() { (( $# >= 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 @@ -106,6 +129,10 @@ alternatives_for() { [[ ${ret} -eq 0 ]] || die "Errors detected for ${provider}, provided for ${alternative}" } +# @FUNCTION: cleanup_old_alternatives_module +# @USAGE: alternative +# @DESCRIPTION: +# Remove old alternatives module. cleanup_old_alternatives_module() { local alt=${1} old_module="${EROOT%/}/usr/share/eselect/modules/${alt}.eselect" if [[ -f "${old_module}" && "$(source "${old_module}" &>/dev/null; echo "${ALTERNATIVE}")" == "${alt}" ]]; then @@ -117,6 +144,14 @@ cleanup_old_alternatives_module() { fi } +# @FUNCTION: alternatives-2_pkg_postinst +# @DESCRIPTION: +# Create eselect modules for all provided alternatives if necessary and ensure +# that valid provider is set. +# +# Also remove old eselect modules for provided alternatives. +# +# Provided alternatives are set up using alternatives_for(). alternatives-2_pkg_postinst() { local a alt provider module_version="20090908" local EAUTO="${EROOT%/}/usr/share/eselect/modules/auto" @@ -149,6 +184,13 @@ alternatives-2_pkg_postinst() { done } +# @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 +# provider is unmerged. +# +# Provided alternatives are set up using alternatives_for(). alternatives-2_pkg_prerm() { local a alt provider ignore local EAUTO="${EROOT%/}/usr/share/eselect/modules/auto"