Gentoo Archives: gentoo-dev

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

Attachments

File name MIME type
signature.asc application/pgp-signature