Gentoo Archives: gentoo-commits

From: Reinis Danne <rei4dan@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/sci:master commit in: eclass/
Date: Wed, 22 Jan 2014 10:09:52
Message-Id: 1390334121.ff8b1ad72e5f30ec5b3f084b87c672f2a7b81c6f.rei4dan@gentoo
1 commit: ff8b1ad72e5f30ec5b3f084b87c672f2a7b81c6f
2 Author: Reinis Danne <rei4dan <AT> gmail <DOT> com>
3 AuthorDate: Mon Jan 20 16:35:24 2014 +0000
4 Commit: Reinis Danne <rei4dan <AT> gmail <DOT> com>
5 CommitDate: Tue Jan 21 19:55:21 2014 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/sci.git;a=commit;h=ff8b1ad7
7
8 alternatives-2.eclass: Add documentation comments
9
10 ---
11 eclass/alternatives-2.eclass | 50 ++++++++++++++++++++++++++++++++++++++++----
12 1 file changed, 46 insertions(+), 4 deletions(-)
13
14 diff --git a/eclass/alternatives-2.eclass b/eclass/alternatives-2.eclass
15 index f83c479..bc60108 100644
16 --- a/eclass/alternatives-2.eclass
17 +++ b/eclass/alternatives-2.eclass
18 @@ -7,6 +7,16 @@
19 # Copyright 2008, 2009 Mike Kelly
20 # Copyright 2009 David Leverton
21
22 +# @ECLASS: alternatives-2
23 +# @MAINTAINER:
24 +# Gentoo Science Project <sci@g.o>
25 +# @BLURB: Manage alternative implementations.
26 +# @DESCRIPTION:
27 +# Autogenerate eselect modules for alternatives and ensure that valid provider
28 +# is set.
29 +#
30 +# Remove eselect modules when last provider is unmerged.
31 +#
32 # If your package provides pkg_postinst or pkg_prerm phases, you need to be
33 # sure you explicitly run alternatives-2_pkg_{postinst,prerm} where appropriate.
34
35 @@ -21,8 +31,6 @@ case "${EAPI:-0}" in
36 ;;
37 esac
38
39 -ALTERNATIVES_DIR="/etc/env.d/alternatives"
40 -
41 DEPEND=">=app-admin/eselect-1.4-r100"
42 RDEPEND="${DEPEND}
43 !app-admin/eselect-blas
44 @@ -31,9 +39,24 @@ RDEPEND="${DEPEND}
45
46 EXPORT_FUNCTIONS pkg_postinst pkg_prerm
47
48 -# alternatives_for alternative provider importance source target [ source target [...]]
49 -alternatives_for() {
50 +# @ECLASS-VARIABLE: ALTERNATIVES_DIR
51 +# @INTERNAL
52 +# @DESCRIPTION:
53 +# Alternatives directory with symlinks managed by eselect.
54 +ALTERNATIVES_DIR="/etc/env.d/alternatives"
55
56 +# @FUNCTION: alternatives_for
57 +# @USAGE: alternative provider importance source target [source target [...]]
58 +# @DESCRIPTION:
59 +# Set up alternative provider.
60 +#
61 +# EXAMPLE:
62 +# @CODE
63 +# alternatives_for cblas atlas 0 \
64 +# /usr/$(get_libdir)/pkgconfig/cblas.pc atlas-cblas.pc \
65 +# /usr/include/cblas.h atlas/cblas.h
66 +# @CODE
67 +alternatives_for() {
68 (( $# >= 5 )) && (( ($#-3)%2 == 0)) || die "${FUNCNAME} requires exactly 3+N*2 arguments where N>=1"
69 local alternative=${1} provider=${2} importance=${3} index src target ret=0
70 shift 3
71 @@ -106,6 +129,10 @@ alternatives_for() {
72 [[ ${ret} -eq 0 ]] || die "Errors detected for ${provider}, provided for ${alternative}"
73 }
74
75 +# @FUNCTION: cleanup_old_alternatives_module
76 +# @USAGE: alternative
77 +# @DESCRIPTION:
78 +# Remove old alternatives module.
79 cleanup_old_alternatives_module() {
80 local alt=${1} old_module="${EROOT%/}/usr/share/eselect/modules/${alt}.eselect"
81 if [[ -f "${old_module}" && "$(source "${old_module}" &>/dev/null; echo "${ALTERNATIVE}")" == "${alt}" ]]; then
82 @@ -117,6 +144,14 @@ cleanup_old_alternatives_module() {
83 fi
84 }
85
86 +# @FUNCTION: alternatives-2_pkg_postinst
87 +# @DESCRIPTION:
88 +# Create eselect modules for all provided alternatives if necessary and ensure
89 +# that valid provider is set.
90 +#
91 +# Also remove old eselect modules for provided alternatives.
92 +#
93 +# Provided alternatives are set up using alternatives_for().
94 alternatives-2_pkg_postinst() {
95 local a alt provider module_version="20090908"
96 local EAUTO="${EROOT%/}/usr/share/eselect/modules/auto"
97 @@ -149,6 +184,13 @@ alternatives-2_pkg_postinst() {
98 done
99 }
100
101 +# @FUNCTION: alternatives-2_pkg_prerm
102 +# @DESCRIPTION:
103 +# Ensure a valid provider is set in case the package is unmerged and
104 +# remove autogenerated eselect modules for all alternatives when last
105 +# provider is unmerged.
106 +#
107 +# Provided alternatives are set up using alternatives_for().
108 alternatives-2_pkg_prerm() {
109 local a alt provider ignore
110 local EAUTO="${EROOT%/}/usr/share/eselect/modules/auto"