1 |
Signed-off-by: Michał Górny <mgorny@g.o> |
2 |
--- |
3 |
eclass/bash-completion-r1.eclass | 15 ++++++++++----- |
4 |
1 file changed, 10 insertions(+), 5 deletions(-) |
5 |
|
6 |
diff --git a/eclass/bash-completion-r1.eclass b/eclass/bash-completion-r1.eclass |
7 |
index 80f2d5fcd32a..a9bac0ffae42 100644 |
8 |
--- a/eclass/bash-completion-r1.eclass |
9 |
+++ b/eclass/bash-completion-r1.eclass |
10 |
@@ -1,138 +1,143 @@ |
11 |
# Copyright 1999-2021 Gentoo Authors |
12 |
# Distributed under the terms of the GNU General Public License v2 |
13 |
|
14 |
# @ECLASS: bash-completion-r1.eclass |
15 |
# @MAINTAINER: |
16 |
# mgorny@g.o |
17 |
-# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 7 |
18 |
+# @SUPPORTED_EAPIS: 5 6 7 8 |
19 |
# @BLURB: A few quick functions to install bash-completion files |
20 |
# @EXAMPLE: |
21 |
# |
22 |
# @CODE |
23 |
-# EAPI=5 |
24 |
+# EAPI=8 |
25 |
# |
26 |
# src_configure() { |
27 |
# econf \ |
28 |
# --with-bash-completion-dir="$(get_bashcompdir)" |
29 |
# } |
30 |
# |
31 |
# src_install() { |
32 |
# default |
33 |
# |
34 |
# newbashcomp contrib/${PN}.bash-completion ${PN} |
35 |
# } |
36 |
# @CODE |
37 |
|
38 |
+if [[ ! ${_BASH_COMPLETION_R1_ECLASS} ]]; then |
39 |
+ |
40 |
inherit toolchain-funcs |
41 |
|
42 |
-case ${EAPI:-0} in |
43 |
- 0|1|2|3|4|5|6|7) ;; |
44 |
- *) die "EAPI ${EAPI} unsupported (yet)." |
45 |
+case ${EAPI} in |
46 |
+ 5|6|7|8) ;; |
47 |
+ *) die "${ECLASS}: EAPI ${EAPI} unsupported." |
48 |
esac |
49 |
|
50 |
# @FUNCTION: _bash-completion-r1_get_bashdir |
51 |
# @INTERNAL |
52 |
# @DESCRIPTION: |
53 |
# First argument is name of the string in bash-completion.pc |
54 |
# Second argument is the fallback directory if the string is not found |
55 |
# @EXAMPLE: |
56 |
# _bash-completion-r1_get_bashdir completionsdir /usr/share/bash-completion |
57 |
_bash-completion-r1_get_bashdir() { |
58 |
debug-print-function ${FUNCNAME} "${@}" |
59 |
|
60 |
if $(tc-getPKG_CONFIG) --exists bash-completion &>/dev/null; then |
61 |
local path |
62 |
path=$($(tc-getPKG_CONFIG) --variable="${1}" bash-completion) || die |
63 |
# we need to return unprefixed, so strip from what pkg-config returns |
64 |
# to us, bug #477692 |
65 |
echo "${path#${EPREFIX}}" |
66 |
else |
67 |
echo "${2}" |
68 |
fi |
69 |
} |
70 |
|
71 |
# @FUNCTION: _bash-completion-r1_get_bashcompdir |
72 |
# @INTERNAL |
73 |
# @DESCRIPTION: |
74 |
# Get unprefixed bash-completion completions directory. |
75 |
_bash-completion-r1_get_bashcompdir() { |
76 |
debug-print-function ${FUNCNAME} "${@}" |
77 |
|
78 |
_bash-completion-r1_get_bashdir completionsdir /usr/share/bash-completion/completions |
79 |
} |
80 |
|
81 |
# @FUNCTION: _bash-completion-r1_get_helpersdir |
82 |
# @INTERNAL |
83 |
# @DESCRIPTION: |
84 |
# Get unprefixed bash-completion helpers directory. |
85 |
_bash-completion-r1_get_bashhelpersdir() { |
86 |
debug-print-function ${FUNCNAME} "${@}" |
87 |
|
88 |
_bash-completion-r1_get_bashdir helpersdir /usr/share/bash-completion/helpers |
89 |
} |
90 |
|
91 |
# @FUNCTION: get_bashcompdir |
92 |
# @DESCRIPTION: |
93 |
# Get the bash-completion completions directory. |
94 |
get_bashcompdir() { |
95 |
debug-print-function ${FUNCNAME} "${@}" |
96 |
|
97 |
echo "${EPREFIX}$(_bash-completion-r1_get_bashcompdir)" |
98 |
} |
99 |
|
100 |
# @FUNCTION: get_bashhelpersdir |
101 |
# @INTERNAL |
102 |
# @DESCRIPTION: |
103 |
# Get the bash-completion helpers directory. |
104 |
get_bashhelpersdir() { |
105 |
debug-print-function ${FUNCNAME} "${@}" |
106 |
|
107 |
echo "${EPREFIX}$(_bash-completion-r1_get_bashhelpersdir)" |
108 |
} |
109 |
|
110 |
# @FUNCTION: dobashcomp |
111 |
# @USAGE: <file> [...] |
112 |
# @DESCRIPTION: |
113 |
# Install bash-completion files passed as args. Has EAPI-dependent failure |
114 |
# behavior (like doins). |
115 |
dobashcomp() { |
116 |
debug-print-function ${FUNCNAME} "${@}" |
117 |
|
118 |
( |
119 |
insopts -m 0644 |
120 |
insinto "$(_bash-completion-r1_get_bashcompdir)" |
121 |
doins "${@}" |
122 |
) |
123 |
} |
124 |
|
125 |
# @FUNCTION: newbashcomp |
126 |
# @USAGE: <file> <newname> |
127 |
# @DESCRIPTION: |
128 |
# Install bash-completion file under a new name. Has EAPI-dependent failure |
129 |
# behavior (like newins). |
130 |
newbashcomp() { |
131 |
debug-print-function ${FUNCNAME} "${@}" |
132 |
|
133 |
( |
134 |
insopts -m 0644 |
135 |
insinto "$(_bash-completion-r1_get_bashcompdir)" |
136 |
newins "${@}" |
137 |
) |
138 |
} |
139 |
|
140 |
# @FUNCTION: bashcomp_alias |
141 |
# @USAGE: <basename> <alias>... |
142 |
# @DESCRIPTION: |
143 |
# Alias <basename> completion to one or more commands (<alias>es). |
144 |
bashcomp_alias() { |
145 |
debug-print-function ${FUNCNAME} "${@}" |
146 |
|
147 |
[[ ${#} -lt 2 ]] && die "Usage: ${FUNCNAME} <basename> <alias>..." |
148 |
local base=${1} f |
149 |
shift |
150 |
|
151 |
for f; do |
152 |
dosym "${base}" "$(_bash-completion-r1_get_bashcompdir)/${f}" \ |
153 |
|| return |
154 |
done |
155 |
} |
156 |
+ |
157 |
+_BASH_COMPLETION_R1_ECLASS=1 |
158 |
+fi |
159 |
-- |
160 |
2.32.0 |