Gentoo Archives: gentoo-dev

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