1 |
From: Thomas Bracht Laumann Jespersen <t@×××××××.xyz> |
2 |
|
3 |
* Drop EAPI 0, 1, 2 workarounds |
4 |
* Move EXPORT_FUNCTIONS to end of file |
5 |
* Add required @USAGE on functions |
6 |
* Add _VIM_PLUGIN_ECLASS guard |
7 |
|
8 |
Bug: https://bugs.gentoo.org/830867 |
9 |
Bug: https://bugs.gentoo.org/830866 |
10 |
Signed-off-by: Thomas Bracht Laumann Jespersen <t@×××××××.xyz> |
11 |
Signed-off-by: Anna Vyalkova <cyber+gentoo@×××××.in> |
12 |
--- |
13 |
eclass/vim-plugin.eclass | 35 ++++++++++++++++++++--------------- |
14 |
1 file changed, 20 insertions(+), 15 deletions(-) |
15 |
|
16 |
diff --git a/eclass/vim-plugin.eclass b/eclass/vim-plugin.eclass |
17 |
index 50e727e98f..a457f3a037 100644 |
18 |
--- a/eclass/vim-plugin.eclass |
19 |
+++ b/eclass/vim-plugin.eclass |
20 |
@@ -1,162 +1,167 @@ |
21 |
-# Copyright 1999-2021 Gentoo Authors |
22 |
+# Copyright 1999-2022 Gentoo Authors |
23 |
# Distributed under the terms of the GNU General Public License v2 |
24 |
|
25 |
# @ECLASS: vim-plugin.eclass |
26 |
# @MAINTAINER: |
27 |
# vim@g.o |
28 |
-# @SUPPORTED_EAPIS: 6 7 |
29 |
+# @SUPPORTED_EAPIS: 6 7 8 |
30 |
# @BLURB: used for installing vim plugins |
31 |
# @DESCRIPTION: |
32 |
# This eclass simplifies installation of app-vim plugins into |
33 |
# /usr/share/vim/vimfiles. This is a version-independent directory |
34 |
# which is read automatically by vim. The only exception is |
35 |
# documentation, for which we make a special case via vim-doc.eclass. |
36 |
|
37 |
case ${EAPI} in |
38 |
- 6|7);; |
39 |
- *) die "EAPI ${EAPI:-0} unsupported (too old)";; |
40 |
+ 6|7|8) ;; |
41 |
+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; |
42 |
esac |
43 |
|
44 |
+if [[ ! ${_VIM_PLUGIN_ECLASS} ]]; then |
45 |
+ |
46 |
inherit vim-doc |
47 |
-EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm |
48 |
|
49 |
VIM_PLUGIN_VIM_VERSION="${VIM_PLUGIN_VIM_VERSION:-7.3}" |
50 |
|
51 |
DEPEND="|| ( >=app-editors/vim-${VIM_PLUGIN_VIM_VERSION} |
52 |
>=app-editors/gvim-${VIM_PLUGIN_VIM_VERSION} )" |
53 |
RDEPEND="${DEPEND}" |
54 |
if [[ ${PV} != 9999* ]] ; then |
55 |
SRC_URI="mirror://gentoo/${P}.tar.bz2 |
56 |
https://dev.gentoo.org/~radhermit/vim/${P}.tar.bz2" |
57 |
fi |
58 |
SLOT="0" |
59 |
|
60 |
# @FUNCTION: vim-plugin_src_install |
61 |
+# @USAGE: |
62 |
# @DESCRIPTION: |
63 |
# Overrides the default src_install phase. In order, this function: |
64 |
# * fixes file permission across all files in ${S}. |
65 |
# * installs help and documentation files. |
66 |
# * installs all files in "${ED}"/usr/share/vim/vimfiles. |
67 |
vim-plugin_src_install() { |
68 |
- has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}" |
69 |
- |
70 |
# Install non-vim-help-docs |
71 |
einstalldocs |
72 |
|
73 |
# Install remainder of plugin |
74 |
insinto /usr/share/vim/vimfiles/ |
75 |
local d |
76 |
for d in *; do |
77 |
[[ -d "${d}" ]] || continue |
78 |
doins -r "${d}" |
79 |
done |
80 |
} |
81 |
|
82 |
# @FUNCTION: vim-plugin_pkg_postinst |
83 |
+# @USAGE: |
84 |
# @DESCRIPTION: |
85 |
# Overrides the pkg_postinst phase for this eclass. |
86 |
# The following functions are called: |
87 |
# * update_vim_helptags |
88 |
# * update_vim_afterscripts |
89 |
# * display_vim_plugin_help |
90 |
vim-plugin_pkg_postinst() { |
91 |
- update_vim_helptags # from vim-doc |
92 |
+ update_vim_helptags # from vim-doc |
93 |
update_vim_afterscripts # see below |
94 |
display_vim_plugin_help # see below |
95 |
} |
96 |
|
97 |
# @FUNCTION: vim-plugin_pkg_postrm |
98 |
# @DESCRIPTION: |
99 |
# Overrides the pkg_postrm phase for this eclass. |
100 |
# This function calls the update_vim_helptags and update_vim_afterscripts |
101 |
# functions and eventually removes a bunch of empty directories. |
102 |
vim-plugin_pkg_postrm() { |
103 |
- has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= |
104 |
- update_vim_helptags # from vim-doc |
105 |
+ update_vim_helptags # from vim-doc |
106 |
update_vim_afterscripts # see below |
107 |
|
108 |
# Remove empty dirs; this allows |
109 |
# /usr/share/vim to be removed if vim-core is unmerged |
110 |
find "${EPREFIX}/usr/share/vim/vimfiles" -depth -type d -exec rmdir {} \; 2>/dev/null || \ |
111 |
die "rmdir failed" |
112 |
} |
113 |
|
114 |
# @FUNCTION: update_vim_afterscripts |
115 |
+# @USAGE: |
116 |
# @DESCRIPTION: |
117 |
# Creates scripts in /usr/share/vim/vimfiles/after/* |
118 |
# comprised of the snippets in /usr/share/vim/vimfiles/after/*/*.d |
119 |
update_vim_afterscripts() { |
120 |
- has "${EAPI:-0}" 0 1 2 && ! use prefix && EROOT="${ROOT}" |
121 |
- has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= |
122 |
local d f afterdir="${EROOT}"/usr/share/vim/vimfiles/after |
123 |
|
124 |
# Nothing to do if the dir isn't there |
125 |
- [ -d "${afterdir}" ] || return 0 |
126 |
+ [[ -d "${afterdir}" ]] || return 0 |
127 |
|
128 |
- einfo "Updating scripts in ${EPREFIX}/usr/share/vim/vimfiles/after" |
129 |
+ einfo "Updating scripts in ${afterdir}" |
130 |
find "${afterdir}" -type d -name \*.vim.d | while read d; do |
131 |
echo '" Generated by update_vim_afterscripts' > "${d%.d}" || die |
132 |
find "${d}" -name \*.vim -type f -maxdepth 1 -print0 | sort -z | \ |
133 |
xargs -0 cat >> "${d%.d}" || die "update_vim_afterscripts failed" |
134 |
done |
135 |
|
136 |
- einfo "Removing dead scripts in ${EPREFIX}/usr/share/vim/vimfiles/after" |
137 |
+ einfo "Removing dead scripts in ${afterdir}" |
138 |
find "${afterdir}" -type f -name \*.vim | \ |
139 |
while read f; do |
140 |
[[ "$(head -n 1 ${f})" == '" Generated by update_vim_afterscripts' ]] \ |
141 |
|| continue |
142 |
# This is a generated file, but might be abandoned. Check |
143 |
# if there's no corresponding .d directory, or if the |
144 |
# file's effectively empty |
145 |
if [[ ! -d "${f}.d" || -z "$(grep -v '^"' "${f}")" ]]; then |
146 |
rm "${f}" || die |
147 |
fi |
148 |
done |
149 |
} |
150 |
|
151 |
# @FUNCTION: display_vim_plugin_help |
152 |
+# @USAGE: |
153 |
# @DESCRIPTION: |
154 |
# Displays a message with the plugin's help file if one is available. Uses the |
155 |
# VIM_PLUGIN_HELPFILES env var. If multiple help files are available, they |
156 |
# should be separated by spaces. If no help files are available, but the env |
157 |
# var VIM_PLUGIN_HELPTEXT is set, that is displayed instead. Finally, if we |
158 |
# have nothing else, this functions displays a link to VIM_PLUGIN_HELPURI. An |
159 |
# extra message regarding enabling filetype plugins is displayed if |
160 |
# VIM_PLUGIN_MESSAGES includes the word "filetype". |
161 |
display_vim_plugin_help() { |
162 |
local h |
163 |
|
164 |
if [[ -z ${REPLACING_VERSIONS} ]]; then |
165 |
if [[ -n ${VIM_PLUGIN_HELPFILES} ]]; then |
166 |
elog " " |
167 |
elog "This plugin provides documentation via vim's help system. To" |
168 |
elog "view it, use:" |
169 |
for h in ${VIM_PLUGIN_HELPFILES}; do |
170 |
elog " :help ${h}" |
171 |
done |
172 |
elog " " |
173 |
|
174 |
elif [[ -n ${VIM_PLUGIN_HELPTEXT} ]]; then |
175 |
elog " " |
176 |
while read h ; do |
177 |
elog "$h" |
178 |
done <<<"${VIM_PLUGIN_HELPTEXT}" |
179 |
elog " " |
180 |
|
181 |
elif [[ -n ${VIM_PLUGIN_HELPURI} ]]; then |
182 |
elog " " |
183 |
elog "Documentation for this plugin is available online at:" |
184 |
elog " ${VIM_PLUGIN_HELPURI}" |
185 |
elog " " |
186 |
fi |
187 |
|
188 |
if has filetype ${VIM_PLUGIN_MESSAGES}; then |
189 |
elog "This plugin makes use of filetype settings. To enable these," |
190 |
elog "add lines like:" |
191 |
elog " filetype plugin on" |
192 |
elog " filetype indent on" |
193 |
elog "to your ~/.vimrc file." |
194 |
elog " " |
195 |
fi |
196 |
fi |
197 |
} |
198 |
+ |
199 |
+_VIM_PLUGIN_ECLASS=1 |
200 |
+fi |
201 |
+ |
202 |
+EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm |
203 |
-- |
204 |
2.35.1 |