Gentoo Archives: gentoo-science

From: Reinis Danne <rei4dan@×××××.com>
To: gentoo-science@l.g.o
Subject: [gentoo-science] [PATCH 08/10] alternatives-2.eclass: Add documentation comments
Date: Mon, 20 Jan 2014 17:54:47
Message-Id: 1390240392-12173-9-git-send-email-rei4dan@gmail.com
In Reply to: [gentoo-science] [PATCH 00/10] alternatives-2.eclass updates by Reinis Danne
1 ---
2 eclass/alternatives-2.eclass | 41 +++++++++++++++++++++++++++++++++++++----
3 1 file changed, 37 insertions(+), 4 deletions(-)
4
5 diff --git a/eclass/alternatives-2.eclass b/eclass/alternatives-2.eclass
6 index 5128e11..e15edfa 100644
7 --- a/eclass/alternatives-2.eclass
8 +++ b/eclass/alternatives-2.eclass
9 @@ -7,6 +7,12 @@
10 # Copyright 2008, 2009 Mike Kelly
11 # Copyright 2009 David Leverton
12
13 +# @ECLASS: alternatives-2
14 +# @MAINTAINER:
15 +# Gentoo Science Project <sci@g.o>
16 +# @BLURB: Manage alternative implementations.
17 +# @DESCRIPTION:
18 +#
19 # If your package provides pkg_postinst or pkg_prerm phases, you need to be
20 # sure you explicitly run alternatives-2_pkg_{postinst,prerm} where appropriate.
21
22 @@ -21,8 +27,6 @@ case "${EAPI:-0}" in
23 ;;
24 esac
25
26 -ALTERNATIVES_DIR="/etc/env.d/alternatives"
27 -
28 DEPEND=">=app-admin/eselect-1.4-r100"
29 RDEPEND="${DEPEND}
30 !app-admin/eselect-blas
31 @@ -31,9 +35,24 @@ RDEPEND="${DEPEND}
32
33 EXPORT_FUNCTIONS pkg_postinst pkg_prerm
34
35 -# alternatives_for alternative provider importance source target [ source target [...]]
36 -alternatives_for() {
37 +# @ECLASS-VARIABLE: ALTERNATIVES_DIR
38 +# @INTERNAL
39 +# @DESCRIPTION:
40 +# Alternatives directory with symlinks managed by eselect.
41 +ALTERNATIVES_DIR="/etc/env.d/alternatives"
42
43 +# @FUNCTION: alternatives_for
44 +# @USAGE: alternative provider importance source target [source target [...]]
45 +# @DESCRIPTION:
46 +# Set up alternative provider.
47 +#
48 +# EXAMPLE:
49 +# @CODE
50 +# alternatives_for cblas atlas 0 \
51 +# /usr/$(get_libdir)/pkgconfig/cblas.pc atlas-cblas.pc \
52 +# /usr/include/cblas.h atlas/cblas.h
53 +# @CODE
54 +alternatives_for() {
55 (( $# >= 5 )) && (( ($#-3)%2 == 0)) || die "${FUNCNAME} requires exactly 3+N*2 arguments where N>=1"
56 local alternative=${1} provider=${2} importance=${3} index src target ret=0
57 shift 3
58 @@ -106,6 +125,10 @@ alternatives_for() {
59 [[ ${ret} -eq 0 ]] || die "Errors detected for ${provider}, provided for ${alternative}"
60 }
61
62 +# @FUNCTION: cleanup_old_alternatives_module
63 +# @USAGE: alternative
64 +# @DESCRIPTION:
65 +# Remove old alternatives module.
66 cleanup_old_alternatives_module() {
67 local alt=${1} old_module="${EROOT%/}/usr/share/eselect/modules/${alt}.eselect"
68 if [[ -f "${old_module}" && "$(source "${old_module}" &>/dev/null; echo "${ALTERNATIVE}")" == "${alt}" ]]; then
69 @@ -117,6 +140,11 @@ cleanup_old_alternatives_module() {
70 fi
71 }
72
73 +# @FUNCTION: alternatives-2_pkg_postinst
74 +# @DESCRIPTION:
75 +# Create eselect modules for all provided alternatives.
76 +#
77 +# Provided alternatives are set up using alternatives_for().
78 alternatives-2_pkg_postinst() {
79 local a alt provider module_version="20090908"
80 local EAUTO="${EROOT%/}/usr/share/eselect/modules/auto"
81 @@ -149,6 +177,11 @@ alternatives-2_pkg_postinst() {
82 done
83 }
84
85 +# @FUNCTION: alternatives-2_pkg_prerm
86 +# @DESCRIPTION:
87 +# Remove autogenerated eselect modules for all alternatives.
88 +#
89 +# Provided alternatives are set up using alternatives_for().
90 alternatives-2_pkg_prerm() {
91 local a alt provider ignore
92 local EAUTO="${EROOT%/}/usr/share/eselect/modules/auto"
93 --
94 1.8.5.3