Gentoo Archives: gentoo-dev

From: Anna Vyalkova <cyber+gentoo@×××××.in>
To: gentoo-dev@l.g.o
Cc: vim@g.o
Subject: [gentoo-dev] [PATCH v4 4/9] vim-plugin.eclass: EAPI 8: add src_prepare
Date: Thu, 07 Apr 2022 12:03:19
Message-Id: 20220407120116.12893-5-cyber+gentoo@sysrq.in
In Reply to: [gentoo-dev] [PATCH v4 0/9] Vim eclasses by Anna Vyalkova
1 Signed-off-by: Anna Vyalkova <cyber+gentoo@×××××.in>
2 ---
3 eclass/vim-plugin.eclass | 39 ++++++++++++++++++++++++++++++++++++---
4 1 file changed, 36 insertions(+), 3 deletions(-)
5
6 diff --git a/eclass/vim-plugin.eclass b/eclass/vim-plugin.eclass
7 index 8a6a02f2d2..722f906c65 100644
8 --- a/eclass/vim-plugin.eclass
9 +++ b/eclass/vim-plugin.eclass
10 @@ -13,7 +13,8 @@
11 # documentation, for which we make a special case via vim-doc.eclass.
12
13 case ${EAPI} in
14 - 6|7|8);;
15 + 6|7) ;;
16 + 8) _DEFINE_VIM_PLUGIN_SRC_PREPARE=true ;;
17 *) die "${ECLASS}: EAPI ${EAPI:-0} unsupported (too old)";;
18 esac
19
20 @@ -21,6 +22,17 @@ if [[ ! ${_VIM_PLUGIN_ECLASS} ]]; then
21
22 inherit vim-doc
23
24 +fi
25 +
26 +EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
27 +
28 +# src_prepare is only exported in EAPI >= 8
29 +case ${EAPI:-0} in
30 + 6|7) ;;
31 + 8) EXPORT_FUNCTIONS src_prepare ;;
32 +esac
33 +
34 +if [[ ! ${_VIM_PLUGIN_ECLASS} ]]; then
35 VIM_PLUGIN_VIM_VERSION="${VIM_PLUGIN_VIM_VERSION:-7.3}"
36
37 DEPEND="|| ( >=app-editors/vim-${VIM_PLUGIN_VIM_VERSION}
38 @@ -32,6 +44,29 @@ if [[ ${PV} != 9999* ]] ; then
39 fi
40 SLOT="0"
41
42 +if ${_DEFINE_VIM_PLUGIN_SRC_PREPARE}; then
43 +# @FUNCTION: vim-plugin_src_prepare
44 +# @USAGE:
45 +# @DESCRIPTION:
46 +# Moves "after/syntax" plugins to directories to avoid file collisions with
47 +# other packages.
48 +# Note that this function is only defined and exported in EAPIs >= 8.
49 +vim-plugin_src_prepare() {
50 + default_src_prepare
51 +
52 + # return if there's nothing to do
53 + [[ -d after/syntax ]] || return
54 +
55 + pushd after/syntax >/dev/null || die
56 + for file in *.vim; do
57 + [[ -f "${file}" ]] || continue
58 + mkdir "${file%.vim}" || die
59 + mv "${file}" "${file%.vim}/${PN}.vim" || die
60 + done
61 + popd >/dev/null || die
62 +}
63 +fi
64 +
65 # @ECLASS_VARIABLE: _VIM_PLUGIN_ALLOWED_DIRS
66 # @INTERNAL
67 # @DESCRIPTION:
68 @@ -189,5 +224,3 @@ display_vim_plugin_help() {
69
70 _VIM_PLUGIN_ECLASS=1
71 fi
72 -
73 -EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
74 --
75 2.35.1