Gentoo Archives: gentoo-dev

From: David Seifert <soap@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: Re: [gentoo-dev] [PATCH v4] bash-completion-r1.eclass: Add EAPI 8 support
Date: Fri, 16 Jul 2021 22:14:45
Message-Id: 54df73e2c3c5ecc249b5dae62a841406beb31088.camel@gentoo.org
In Reply to: [gentoo-dev] [PATCH v4] bash-completion-r1.eclass: Add EAPI 8 support by "Michał Górny"
1 On Fri, 2021-07-16 at 20:36 +0200, Michał Górny wrote:
2 > Signed-off-by: Michał Górny <mgorny@g.o>
3 > ---
4 >  eclass/bash-completion-r1.eclass | 15 ++++++++++-----
5 >  1 file changed, 10 insertions(+), 5 deletions(-)
6 >
7 > diff --git a/eclass/bash-completion-r1.eclass b/eclass/bash-
8 > completion-r1.eclass
9 > index 80f2d5fcd32a..a9bac0ffae42 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: 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_ECLASS} ]]; then
41 > +
42
43 _BASH_COMPLETION_R1_ECLASS needs to be defined here, as ulm mentioned
44 earlier.
45
46 >  inherit toolchain-funcs
47 >  
48 > -case ${EAPI:-0} in
49 > -       0|1|2|3|4|5|6|7) ;;
50 > -       *) die "EAPI ${EAPI} unsupported (yet)."
51 > +case ${EAPI} in
52 > +       5|6|7|8) ;;
53 > +       *) die "${ECLASS}: EAPI ${EAPI} unsupported."
54 >  esac
55 >  
56 >  # @FUNCTION: _bash-completion-r1_get_bashdir
57 >  # @INTERNAL
58 >  # @DESCRIPTION:
59 >  # First argument is name of the string in bash-completion.pc
60 >  # Second argument is the fallback directory if the string is not
61 > found
62 >  # @EXAMPLE:
63 >  # _bash-completion-r1_get_bashdir completionsdir /usr/share/bash-
64 > completion
65 >  _bash-completion-r1_get_bashdir() {
66 >         debug-print-function ${FUNCNAME} "${@}"
67 >  
68 >         if $(tc-getPKG_CONFIG) --exists bash-completion &>/dev/null;
69 > then
70 >                 local path
71 >                 path=$($(tc-getPKG_CONFIG) --variable="${1}" bash-
72 > completion) || die
73 >                 # we need to return unprefixed, so strip from what
74 > pkg-config returns
75 >                 # to us, bug #477692
76 >                 echo "${path#${EPREFIX}}"
77 >         else
78 >                 echo "${2}"
79 >         fi
80 >  }
81 >  
82 >  # @FUNCTION: _bash-completion-r1_get_bashcompdir
83 >  # @INTERNAL
84 >  # @DESCRIPTION:
85 >  # Get unprefixed bash-completion completions directory.
86 >  _bash-completion-r1_get_bashcompdir() {
87 >         debug-print-function ${FUNCNAME} "${@}"
88 >  
89 >         _bash-completion-r1_get_bashdir completionsdir
90 > /usr/share/bash-completion/completions
91 >  }
92 >  
93 >  # @FUNCTION: _bash-completion-r1_get_helpersdir
94 >  # @INTERNAL
95 >  # @DESCRIPTION:
96 >  # Get unprefixed bash-completion helpers directory.
97 >  _bash-completion-r1_get_bashhelpersdir() {
98 >         debug-print-function ${FUNCNAME} "${@}"
99 >  
100 >         _bash-completion-r1_get_bashdir helpersdir /usr/share/bash-
101 > completion/helpers
102 >  }
103 >  
104 >  # @FUNCTION: get_bashcompdir
105 >  # @DESCRIPTION:
106 >  # Get the bash-completion completions directory.
107 >  get_bashcompdir() {
108 >         debug-print-function ${FUNCNAME} "${@}"
109 >  
110 >         echo "${EPREFIX}$(_bash-completion-r1_get_bashcompdir)"
111 >  }
112 >  
113 >  # @FUNCTION: get_bashhelpersdir
114 >  # @INTERNAL
115 >  # @DESCRIPTION:
116 >  # Get the bash-completion helpers directory.
117 >  get_bashhelpersdir() {
118 >         debug-print-function ${FUNCNAME} "${@}"
119 >  
120 >         echo "${EPREFIX}$(_bash-completion-r1_get_bashhelpersdir)"
121 >  }
122 >  
123 >  # @FUNCTION: dobashcomp
124 >  # @USAGE: <file> [...]
125 >  # @DESCRIPTION:
126 >  # Install bash-completion files passed as args. Has EAPI-dependent
127 > failure
128 >  # behavior (like doins).
129 >  dobashcomp() {
130 >         debug-print-function ${FUNCNAME} "${@}"
131 >  
132 >         (
133 >                 insopts -m 0644
134 >                 insinto "$(_bash-completion-r1_get_bashcompdir)"
135 >                 doins "${@}"
136 >         )
137 >  }
138 >  
139 >  # @FUNCTION: newbashcomp
140 >  # @USAGE: <file> <newname>
141 >  # @DESCRIPTION:
142 >  # Install bash-completion file under a new name. Has EAPI-dependent
143 > failure
144 >  # behavior (like newins).
145 >  newbashcomp() {
146 >         debug-print-function ${FUNCNAME} "${@}"
147 >  
148 >         (
149 >                 insopts -m 0644
150 >                 insinto "$(_bash-completion-r1_get_bashcompdir)"
151 >                 newins "${@}"
152 >         )
153 >  }
154 >  
155 >  # @FUNCTION: bashcomp_alias
156 >  # @USAGE: <basename> <alias>...
157 >  # @DESCRIPTION:
158 >  # Alias <basename> completion to one or more commands (<alias>es).
159 >  bashcomp_alias() {
160 >         debug-print-function ${FUNCNAME} "${@}"
161 >  
162 >         [[ ${#} -lt 2 ]] && die "Usage: ${FUNCNAME} <basename>
163 > <alias>..."
164 >         local base=${1} f
165 >         shift
166 >  
167 >         for f; do
168 >                 dosym "${base}" "$(_bash-completion-
169 > r1_get_bashcompdir)/${f}" \
170 >                         || return
171 >         done
172 >  }
173 > +
174 > +_BASH_COMPLETION_R1_ECLASS=1
175 > +fi