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