Gentoo Archives: gentoo-commits

From: James Le Cuirot <chewi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-eselect/eselect-blas/, app-eselect/eselect-blas/files/
Date: Sat, 18 Mar 2023 21:45:52
Message-Id: 1679175876.f3f7e9cacb8eb71c76c8cab08359e35756530612.chewi@gentoo
1 commit: f3f7e9cacb8eb71c76c8cab08359e35756530612
2 Author: James Le Cuirot <chewi <AT> gentoo <DOT> org>
3 AuthorDate: Mon Feb 27 23:34:56 2023 +0000
4 Commit: James Le Cuirot <chewi <AT> gentoo <DOT> org>
5 CommitDate: Sat Mar 18 21:44:36 2023 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f3f7e9ca
7
8 app-eselect/eselect-blas: Bump to fix ROOT handling and apply quoting
9
10 The module assumed that ROOT should be present in LDPATH variable of the
11 generated config files. This makes no sense because ROOT is not applicable at
12 runtime.
13
14 Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>
15
16 app-eselect/eselect-blas/eselect-blas-0.3.ebuild | 28 ++++
17 app-eselect/eselect-blas/files/blas.eselect-0.3 | 168 +++++++++++++++++++++++
18 2 files changed, 196 insertions(+)
19
20 diff --git a/app-eselect/eselect-blas/eselect-blas-0.3.ebuild b/app-eselect/eselect-blas/eselect-blas-0.3.ebuild
21 new file mode 100644
22 index 000000000000..2dfac934a3c7
23 --- /dev/null
24 +++ b/app-eselect/eselect-blas/eselect-blas-0.3.ebuild
25 @@ -0,0 +1,28 @@
26 +# Copyright 1999-2022 Gentoo Authors
27 +# Distributed under the terms of the GNU General Public License v2
28 +
29 +EAPI=7
30 +
31 +DESCRIPTION="BLAS/CBLAS module for eselect"
32 +HOMEPAGE="https://wiki.gentoo.org/wiki/No_homepage"
33 +SRC_URI=""
34 +
35 +LICENSE="GPL-2"
36 +SLOT="0"
37 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
38 +IUSE=""
39 +
40 +# Need skel.bash lib
41 +RDEPEND=( ">=app-admin/eselect-1.0.5"
42 + "!app-eselect/eselect-cblas" )
43 +DEPEND="${RDEPEND}"
44 +
45 +S="${WORKDIR}"
46 +
47 +src_install() {
48 + local MODULEDIR="/usr/share/eselect/modules"
49 + local MODULE="blas"
50 + insinto ${MODULEDIR}
51 + newins "${FILESDIR}"/${MODULE}.eselect-${PVR} ${MODULE}.eselect
52 + doman "${FILESDIR}"/blas.eselect.5
53 +}
54
55 diff --git a/app-eselect/eselect-blas/files/blas.eselect-0.3 b/app-eselect/eselect-blas/files/blas.eselect-0.3
56 new file mode 100644
57 index 000000000000..8941f720054f
58 --- /dev/null
59 +++ b/app-eselect/eselect-blas/files/blas.eselect-0.3
60 @@ -0,0 +1,168 @@
61 +# -*-eselect-*- vim: ft=eselect
62 +# Copyright 2019-2023 Gentoo Authors
63 +# Distributed under the terms of the GNU GPL version 2 or later
64 +
65 +inherit config tests multilib skel
66 +
67 +MODULE="BLAS/CBLAS"
68 +IFACE="blas"
69 +DESCRIPTION="Manage installed alternatives of $MODULE shared objects"
70 +MAINTAINER="lumin@××××××.org"
71 +VERSION="0.3"
72 +
73 +### helper utility to find all available BLAS/CBLAS implementations
74 +find_targets_in() {
75 + [[ $# -eq 1 ]] || die -q "in which libdir?"
76 +
77 + local cand
78 + for cand in "${EROOT}/etc/env.d/blas/$1"/*; do
79 + [[ "config" = $(basename ${cand}) ]] && continue
80 + [[ -r ${cand} ]] && basename ${cand}
81 + done
82 +}
83 +
84 +### helper utility to validate a BLAS/CBLAS library directory
85 +validate_blaslibdir() {
86 + [[ -d $1 ]] || return 2 # dir doesn't exist
87 + [[ -r "${1}/libblas.so.3" ]] && [[ -r "${1}/libblas.so" ]] \
88 + && [[ -r "${1}/libcblas.so.3" ]] && [[ -r "${1}/libcblas.so" ]] \
89 + || return 1
90 +}
91 +
92 +### show action
93 +do_show() {
94 + # do_show -- show both lib64 and lib32 selection
95 + # do_show libxx -- show libxx selection
96 + local libdir cur libdirs=( $(list_libdirs) )
97 +
98 + # if manually specified libdirs
99 + if [[ ! $# -eq 0 ]]; then
100 + for libdir in $@; do
101 + has $libdir ${libdirs[@]} || die -q "invalid libdir '$libdir'!"
102 + done
103 + libdirs=( $@ )
104 + fi
105 +
106 + for libdir in ${libdirs[@]}; do
107 + [[ ! -d ${EROOT}/usr/$libdir ]] && continue
108 + [[ ! -r ${EROOT}/etc/env.d/blas/${libdir}/config ]] && continue
109 + cur=$(load_config "${EROOT}"/etc/env.d/blas/${libdir}/config CURRENT)
110 + echo ${libdir}: $cur
111 + done
112 +}
113 +
114 +### list action
115 +do_list() {
116 + local i cur targets
117 + local libdir libdirs=( $(list_libdirs) )
118 +
119 + # if manually specified libdirs
120 + if [[ ! $# -eq 0 ]]; then
121 + for libdir in $@; do
122 + has $libdir ${libdirs[@]} || die -q "invalid libdir '$libdir'!"
123 + done
124 + libdirs=( $@ )
125 + fi
126 +
127 + for libdir in ${libdirs[@]}; do
128 + [[ ! -d ${EROOT}/usr/$libdir ]] || [[ -L ${EROOT}/usr/$libdir ]] && continue
129 + targets=( $(find_targets_in $libdir) )
130 + cur=$(load_config "${EROOT}"/etc/env.d/blas/${libdir}/config CURRENT)
131 +
132 + write_list_start "Available BLAS/CBLAS ($libdir) candidates:"
133 + for (( i = 0; i < ${#targets[@]}; i++ )); do
134 + [[ ${targets[i]} = $cur ]] \
135 + && targets[i]=$(highlight_marker "${targets[i]}")
136 + done
137 + write_numbered_list -m "(none found)" "${targets[@]}"
138 + done
139 +}
140 +
141 +### validate action
142 +describe_validate() {
143 + echo "validate candidates and remove invalid ones"
144 +}
145 +
146 +do_validate() {
147 + local i ldpath targets target candidate
148 + local libdir libdirs=( $(list_libdirs) )
149 + for libdir in ${libdirs[@]}; do
150 + [[ ! -d ${EROOT}/usr/$libdir ]] || [[ -L ${EROOT}/usr/$libdir ]] && continue
151 + targets=( $(find_targets_in $libdir) )
152 + for target in ${targets[@]}; do
153 + candidate=${EROOT}/etc/env.d/blas/${libdir}/${target}
154 + ldpath=$(load_config "$candidate" LDPATH)
155 + if ! validate_blaslibdir "${ROOT}/$ldpath"; then
156 + echo "Removing invalid BLAS/CBLAS candidate ($candidate) ..."
157 + rm -v "$candidate"
158 + fi
159 + done
160 + done
161 +}
162 +
163 +### set action
164 +
165 +describe_set() {
166 + echo "Activate one of the installed $MODULE implementations"
167 +}
168 +
169 +describe_set_parameters() {
170 + echo "[<libdir>] <implementation>"
171 +}
172 +
173 +describe_set_options() {
174 + echo "libdir: lib64 or lib32. Will use the native one when omitted."
175 + echo "implementation : implementation name or number (from 'list' action)"
176 +}
177 +
178 +do_set() {
179 + local libdirs=( $(list_libdirs) )
180 + local targets libdir ldconf libpath impl
181 +
182 + # check argument existence
183 + [[ $# -eq 1 ]] || [[ $# -eq 2 ]] || \
184 + die -q "Please specify [<libdir>] <impl> to activate!"
185 + # read argumenets
186 + if [[ $# -eq 2 ]]; then libdir="$1"; else libdir="$(get_libdir)"; fi
187 + if [[ $# -eq 2 ]]; then impl="$2"; else impl="$1"; fi
188 + # validate arguments
189 + has "$libdir" "${libdirs[@]}" || die -q "Invalid libdir ($libdir) !"
190 + targets=( $(find_targets_in $libdir) )
191 + if ! has "$impl" "${targets[@]}"; then
192 + if [[ ${impl} -gt 0 ]] && [[ ${impl} -le ${#targets[@]} ]]; then
193 + impl=${targets[(${impl} - 1)]}
194 + else
195 + die -q "Invalid impl ($impl) !"
196 + fi
197 + fi
198 + # store the configuration to env.d
199 + store_config "${EROOT}"/etc/env.d/blas/${libdir}/config CURRENT "${impl}"
200 + # generate ld.so.conf file
201 + ldconf="${EROOT}/etc/ld.so.conf.d/81-blas-${libdir}.conf"
202 + libpath=$(load_config ${EROOT}/etc/env.d/blas/${libdir}/${impl} LDPATH)
203 + truncate -s0 "$ldconf"
204 + echo "# Auto-generated by eselect::blas. DON'T EDIT." >> "$ldconf"
205 + echo "$libpath" >> "$ldconf"
206 +
207 + # refresh cache. env-update will call ldconfig (see
208 + # portage::env_update.py) so we don't need to call it explicitly.
209 + env-update
210 +}
211 +
212 +### add action
213 +describe_add_parameters() {
214 + echo "<libdir> <dir> <impl>"
215 +}
216 +
217 +describe_add_options() {
218 + echo "libdir : library directory where $MODULE implementation is installed (lib, lib64, etc.)"
219 + echo "dir : directory containing lib{,c}blas.so{.3}"
220 + echo "impl : name of the $MODULE implementation"
221 +}
222 +
223 +do_add() {
224 + [[ $# -eq 3 ]] \
225 + || die -q "Please specify <libdir> <dir> <impl> to activate!"
226 + validate_blaslibdir "${ROOT}/$2" || die -q "invalid blas libdir!"
227 + store_config "${EROOT}/etc/env.d/blas/$1/$3" LDPATH "$2"
228 +}