1 |
Signed-off-by: Michał Górny <mgorny@g.o> |
2 |
--- |
3 |
eclass/bash-completion-r1.eclass | 13 +++++++++---- |
4 |
1 file changed, 9 insertions(+), 4 deletions(-) |
5 |
|
6 |
diff --git a/eclass/bash-completion-r1.eclass b/eclass/bash-completion-r1.eclass |
7 |
index 80f2d5fcd32a..58c1debf334e 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: 0 1 2 3 4 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} ]]; 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 |
+ [5-8]) ;; |
46 |
+ *) die "EAPI ${EAPI} unsupported." |
47 |
esac |
48 |
|
49 |
# @FUNCTION: _bash-completion-r1_get_bashdir |
50 |
# @INTERNAL |
51 |
# @DESCRIPTION: |
52 |
# First argument is name of the string in bash-completion.pc |
53 |
# Second argument is the fallback directory if the string is not found |
54 |
# @EXAMPLE: |
55 |
# _bash-completion-r1_get_bashdir completionsdir /usr/share/bash-completion |
56 |
_bash-completion-r1_get_bashdir() { |
57 |
debug-print-function ${FUNCNAME} "${@}" |
58 |
|
59 |
if $(tc-getPKG_CONFIG) --exists bash-completion &>/dev/null; then |
60 |
local path |
61 |
path=$($(tc-getPKG_CONFIG) --variable="${1}" bash-completion) || die |
62 |
# we need to return unprefixed, so strip from what pkg-config returns |
63 |
# to us, bug #477692 |
64 |
echo "${path#${EPREFIX}}" |
65 |
else |
66 |
echo "${2}" |
67 |
fi |
68 |
} |
69 |
|
70 |
# @FUNCTION: _bash-completion-r1_get_bashcompdir |
71 |
# @INTERNAL |
72 |
# @DESCRIPTION: |
73 |
# Get unprefixed bash-completion completions directory. |
74 |
_bash-completion-r1_get_bashcompdir() { |
75 |
debug-print-function ${FUNCNAME} "${@}" |
76 |
|
77 |
_bash-completion-r1_get_bashdir completionsdir /usr/share/bash-completion/completions |
78 |
} |
79 |
|
80 |
# @FUNCTION: _bash-completion-r1_get_helpersdir |
81 |
# @INTERNAL |
82 |
# @DESCRIPTION: |
83 |
# Get unprefixed bash-completion helpers directory. |
84 |
_bash-completion-r1_get_bashhelpersdir() { |
85 |
debug-print-function ${FUNCNAME} "${@}" |
86 |
|
87 |
_bash-completion-r1_get_bashdir helpersdir /usr/share/bash-completion/helpers |
88 |
} |
89 |
|
90 |
# @FUNCTION: get_bashcompdir |
91 |
# @DESCRIPTION: |
92 |
# Get the bash-completion completions directory. |
93 |
get_bashcompdir() { |
94 |
debug-print-function ${FUNCNAME} "${@}" |
95 |
|
96 |
echo "${EPREFIX}$(_bash-completion-r1_get_bashcompdir)" |
97 |
} |
98 |
|
99 |
# @FUNCTION: get_bashhelpersdir |
100 |
# @INTERNAL |
101 |
# @DESCRIPTION: |
102 |
# Get the bash-completion helpers directory. |
103 |
get_bashhelpersdir() { |
104 |
debug-print-function ${FUNCNAME} "${@}" |
105 |
|
106 |
echo "${EPREFIX}$(_bash-completion-r1_get_bashhelpersdir)" |
107 |
} |
108 |
|
109 |
# @FUNCTION: dobashcomp |
110 |
# @USAGE: <file> [...] |
111 |
# @DESCRIPTION: |
112 |
# Install bash-completion files passed as args. Has EAPI-dependent failure |
113 |
# behavior (like doins). |
114 |
dobashcomp() { |
115 |
debug-print-function ${FUNCNAME} "${@}" |
116 |
|
117 |
( |
118 |
insopts -m 0644 |
119 |
insinto "$(_bash-completion-r1_get_bashcompdir)" |
120 |
doins "${@}" |
121 |
) |
122 |
} |
123 |
|
124 |
# @FUNCTION: newbashcomp |
125 |
# @USAGE: <file> <newname> |
126 |
# @DESCRIPTION: |
127 |
# Install bash-completion file under a new name. Has EAPI-dependent failure |
128 |
# behavior (like newins). |
129 |
newbashcomp() { |
130 |
debug-print-function ${FUNCNAME} "${@}" |
131 |
|
132 |
( |
133 |
insopts -m 0644 |
134 |
insinto "$(_bash-completion-r1_get_bashcompdir)" |
135 |
newins "${@}" |
136 |
) |
137 |
} |
138 |
|
139 |
# @FUNCTION: bashcomp_alias |
140 |
# @USAGE: <basename> <alias>... |
141 |
# @DESCRIPTION: |
142 |
# Alias <basename> completion to one or more commands (<alias>es). |
143 |
bashcomp_alias() { |
144 |
debug-print-function ${FUNCNAME} "${@}" |
145 |
|
146 |
[[ ${#} -lt 2 ]] && die "Usage: ${FUNCNAME} <basename> <alias>..." |
147 |
local base=${1} f |
148 |
shift |
149 |
|
150 |
for f; do |
151 |
dosym "${base}" "$(_bash-completion-r1_get_bashcompdir)/${f}" \ |
152 |
|| return |
153 |
done |
154 |
} |
155 |
+ |
156 |
+_BASH_COMPLETION_R1=1 |
157 |
+fi |
158 |
-- |
159 |
2.32.0 |