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