1 |
This also includes the following cleanups: |
2 |
- Drop support for undocumented banned EAPIs. |
3 |
- Properly document functions for manpage generation. |
4 |
- Make syntax errors fatal. |
5 |
- Support cross-compiling. |
6 |
- Allow db_findver to accept zero arguments for consistency. |
7 |
- Use modern Gentoo bash conventions. |
8 |
|
9 |
Signed-off-by: David Michael <fedora.dm0@×××××.com> |
10 |
--- |
11 |
eclass/db-use.eclass | 159 ++++++++++++++++--------------------------- |
12 |
1 file changed, 58 insertions(+), 101 deletions(-) |
13 |
|
14 |
diff --git a/eclass/db-use.eclass b/eclass/db-use.eclass |
15 |
index d23b08d1999..1df07a8a7ac 100644 |
16 |
--- a/eclass/db-use.eclass |
17 |
+++ b/eclass/db-use.eclass |
18 |
@@ -1,129 +1,86 @@ |
19 |
# Copyright 1999-2021 Gentoo Authors |
20 |
# Distributed under the terms of the GNU General Public License v2 |
21 |
-# This is a common location for functions that aid the use of sys-libs/db |
22 |
-# |
23 |
|
24 |
# @ECLASS: db-use.eclass |
25 |
# @MAINTAINER: |
26 |
# maintainer-needed@g.o |
27 |
# @AUTHOR: |
28 |
# Paul de Vrieze <pauldv@g.o> |
29 |
-# @SUPPORTED_EAPIS: 5 6 7 |
30 |
-# @BLURB: This is a common location for functions that aid the use of sys-libs/db |
31 |
+# @SUPPORTED_EAPIS: 5 6 7 8 |
32 |
+# @BLURB: functions that aid the use of sys-libs/db |
33 |
# @DESCRIPTION: |
34 |
-# This eclass is designed to provide helpful functions for depending on |
35 |
-# sys-libs/db. |
36 |
+# This eclass provides helpful functions for depending on sys-libs/db. |
37 |
|
38 |
-# multilib is used for get_libname in all EAPI |
39 |
-case "${EAPI:-0}" in |
40 |
- 0|1|2|3|4|5|6) inherit eapi7-ver multilib ;; |
41 |
- *) inherit multilib ;; |
42 |
+case ${EAPI} in |
43 |
+ 5|6|7|8) ;; |
44 |
+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; |
45 |
esac |
46 |
|
47 |
-#Convert a version to a db slot |
48 |
+# multilib is used for get_libname |
49 |
+[[ ${EAPI} == [56] ]] && inherit eapi7-ver |
50 |
+inherit multilib |
51 |
+ |
52 |
+# @FUNCTION: db_ver_to_slot |
53 |
+# @USAGE: <version> |
54 |
+# @DESCRIPTION: |
55 |
+# Convert a version to a db slot. |
56 |
db_ver_to_slot() { |
57 |
- if [ $# -ne 1 ]; then |
58 |
- eerror "Function db_ver_to_slot needs one argument" >&2 |
59 |
- eerror "args given:" >&2 |
60 |
- for f in $@ |
61 |
- do |
62 |
- eerror " - \"$@\"" >&2 |
63 |
- done |
64 |
- return 1 |
65 |
- fi |
66 |
+ [[ $# -eq 1 ]] || die "${FUNCNAME} needs one argument" |
67 |
+ |
68 |
# 5.0.x uses 5.0 as slot value, so this replacement will break it; |
69 |
# older sys-libs/db might have been using this but it's no longer |
70 |
# the case, so make it work for latest rather than older stuff. |
71 |
- # echo -n "${1/.0/}" |
72 |
- echo -n "$1" |
73 |
+ echo "$1" |
74 |
} |
75 |
|
76 |
-#Find the version that correspond to the given atom |
77 |
+# @FUNCTION: db_findver |
78 |
+# @USAGE: [atom] |
79 |
+# @DESCRIPTION: |
80 |
+# Output the best version that corresponds to the given atom. If no atom is |
81 |
+# given, sys-libs/db is used by default. |
82 |
db_findver() { |
83 |
- has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= |
84 |
- if [ $# -ne 1 ]; then |
85 |
- eerror "Function db_findver needs one argument" >&2 |
86 |
- eerror "args given:" >&2 |
87 |
- for f in $@ |
88 |
- do |
89 |
- eerror " - \"$@\"" >&2 |
90 |
- done |
91 |
- return 1 |
92 |
- fi |
93 |
+ [[ $# -le 1 ]] || die "${FUNCNAME} needs zero or one arguments" |
94 |
|
95 |
- PKG="$(best_version $1)" |
96 |
- VER="$(ver_cut 1-2 "${PKG/*db-/}")" |
97 |
- if [ -d "${EPREFIX}"/usr/include/db$(db_ver_to_slot "$VER") ]; then |
98 |
- #einfo "Found db version ${VER}" >&2 |
99 |
- echo -n "$VER" |
100 |
- return 0 |
101 |
- else |
102 |
- return 1 |
103 |
- fi |
104 |
+ local pkg=$(best_version "${1:-sys-libs/db}") |
105 |
+ local ver=$(ver_cut 1-2 "${pkg#*db-}") |
106 |
+ [[ -d ${ESYSROOT:-${EPREFIX}}/usr/include/db$(db_ver_to_slot "${ver}") ]] || return 1 |
107 |
+ echo "${ver}" |
108 |
} |
109 |
|
110 |
-# Get the include dir for berkeley db. |
111 |
-# This function has two modes. Without any arguments it will give the best |
112 |
-# version available. With arguments that form the versions of db packages |
113 |
-# to test for, it will aim to find the library corresponding to it. |
114 |
- |
115 |
+# @FUNCTION: db_includedir |
116 |
+# @USAGE: [version]... |
117 |
+# @DESCRIPTION: |
118 |
+# Output the include directory for berkeley db. Without any arguments, it will |
119 |
+# give the best version available. With a list of versions, it will output the |
120 |
+# include directory of the first version found. |
121 |
db_includedir() { |
122 |
- has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= |
123 |
- if [ $# -eq 0 ]; then |
124 |
- VER="$(db_findver sys-libs/db)" || return 1 |
125 |
- VER="$(db_ver_to_slot "$VER")" |
126 |
- echo "include version ${VER}" >&2 |
127 |
- if [ -d "${EPREFIX}/usr/include/db${VER}" ]; then |
128 |
- echo -n "${EPREFIX}/usr/include/db${VER}" |
129 |
- return 0 |
130 |
- else |
131 |
- eerror "sys-libs/db package requested, but headers not found" >&2 |
132 |
- return 1 |
133 |
- fi |
134 |
- else |
135 |
- #arguments given |
136 |
- for x in $@ |
137 |
- do |
138 |
- if VER=$(db_findver "=sys-libs/db-${x}*") && |
139 |
- [ -d "${EPREFIX}/usr/include/db$(db_ver_to_slot $VER)" ]; then |
140 |
- echo -n "${EPREFIX}/usr/include/db$(db_ver_to_slot $VER)" |
141 |
- return 0 |
142 |
- fi |
143 |
- done |
144 |
- eerror "No suitable db version found" |
145 |
- return 1 |
146 |
- fi |
147 |
+ local ver |
148 |
+ for ver in "${@:-}"; do |
149 |
+ ver=$(db_findver ${ver:+"=sys-libs/db-${ver}*"}) && |
150 |
+ ver=$(db_ver_to_slot "${ver}") && |
151 |
+ [[ -d ${ESYSROOT:-${EPREFIX}}/usr/include/db${ver} ]] && |
152 |
+ echo "${ESYSROOT:-${EPREFIX}}/usr/include/db${ver}" && |
153 |
+ return |
154 |
+ done |
155 |
+ eerror "No suitable db version found" |
156 |
+ return 1 |
157 |
} |
158 |
|
159 |
|
160 |
-# Get the library name for berkeley db. Something like "db-4.2" will be the |
161 |
-# outcome. This function has two modes. Without any arguments it will give |
162 |
-# the best version available. With arguments that form the versions of db |
163 |
-# packages to test for, it will aim to find the library corresponding to it. |
164 |
- |
165 |
+# @FUNCTION: db_libname |
166 |
+# @USAGE: [version]... |
167 |
+# @DESCRIPTION: |
168 |
+# Output the library name for berkeley db of the form "db-4.2". Without any |
169 |
+# arguments, it will give the best version available. With a list of versions, |
170 |
+# it will output the library name of the first version found. |
171 |
db_libname() { |
172 |
- has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= |
173 |
- if [ $# -eq 0 ]; then |
174 |
- VER="$(db_findver sys-libs/db)" || return 1 |
175 |
- if [ -e "${EPREFIX}/usr/$(get_libdir)/libdb-${VER}$(get_libname)" ]; then |
176 |
- echo -n "db-${VER}" |
177 |
- return 0 |
178 |
- else |
179 |
- eerror "sys-libs/db package requested, but library not found" >&2 |
180 |
- return 1 |
181 |
- fi |
182 |
- else |
183 |
- #arguments given |
184 |
- for x in $@ |
185 |
- do |
186 |
- if VER=$(db_findver "=sys-libs/db-${x}*"); then |
187 |
- if [ -e "${EPREFIX}/usr/$(get_libdir)/libdb-${VER}$(get_libname)" ]; then |
188 |
- echo -n "db-${VER}" |
189 |
- return 0 |
190 |
- fi |
191 |
- fi |
192 |
- done |
193 |
- eerror "No suitable db version found" >&2 |
194 |
- return 1 |
195 |
- fi |
196 |
+ local ver |
197 |
+ for ver in "${@:-}"; do |
198 |
+ ver=$(db_findver ${ver:+"=sys-libs/db-${ver}*"}) && |
199 |
+ [[ -e ${ESYSROOT:-${EPREFIX}}/usr/$(get_libdir)/libdb-${ver}$(get_libname) ]] && |
200 |
+ echo "db-${ver}" && |
201 |
+ return |
202 |
+ done |
203 |
+ eerror "No suitable db version found" |
204 |
+ return 1 |
205 |
} |
206 |
-- |
207 |
2.31.1 |