commit:     72d55e0f005d399231b34eaed9dd279c4ccf1378
Author:     Anna Vyalkova <cyber+gentoo <AT> sysrq <DOT> in>
AuthorDate: Wed Apr  6 11:34:18 2022 +0000
Commit:     Patrice Clement <monsieurp <AT> gentoo <DOT> org>
CommitDate: Mon May 30 12:57:02 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=72d55e0f

vim-plugin.eclass: EAPI 8: add src_prepare

Signed-off-by: Anna Vyalkova <cyber+gentoo <AT> sysrq.in>
Signed-off-by: Patrice Clement <monsieurp <AT> gentoo.org>

 eclass/vim-plugin.eclass | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/eclass/vim-plugin.eclass b/eclass/vim-plugin.eclass
index 0c323e0d09e7..9d300ad4826b 100644
--- a/eclass/vim-plugin.eclass
+++ b/eclass/vim-plugin.eclass
@@ -13,7 +13,8 @@
 # documentation, for which we make a special case via vim-doc.eclass.
 
 case ${EAPI} in
-       6|7|8) ;;
+       6|7) ;;
+       8) _DEFINE_VIM_PLUGIN_SRC_PREPARE=true ;;
        *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
 esac
 
@@ -32,6 +33,29 @@ if [[ ${PV} != 9999* ]] ; then
 fi
 SLOT="0"
 
+if [[ ${_DEFINE_VIM_PLUGIN_SRC_PREPARE} ]]; then
+# @FUNCTION: vim-plugin_src_prepare
+# @USAGE:
+# @DESCRIPTION:
+# Moves "after/syntax" plugins to directories to avoid file collisions with
+# other packages.
+# Note that this function is only defined and exported in EAPIs >= 8.
+vim-plugin_src_prepare() {
+       default_src_prepare
+
+       # return if there's nothing to do
+       [[ -d after/syntax ]] || return
+
+       pushd after/syntax >/dev/null || die
+       for file in *.vim; do
+               [[ -f "${file}" ]] || continue
+               mkdir "${file%.vim}" || die
+               mv "${file}" "${file%.vim}/${PN}.vim" || die
+       done
+       popd >/dev/null || die
+}
+fi
+
 # @ECLASS_VARIABLE: _VIM_PLUGIN_ALLOWED_DIRS
 # @INTERNAL
 # @DESCRIPTION:
@@ -190,3 +214,9 @@ _VIM_PLUGIN_ECLASS=1
 fi
 
 EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
+
+# src_prepare is only exported in EAPI >= 8
+case ${EAPI} in
+       6|7) ;;
+       *) EXPORT_FUNCTIONS src_prepare ;;
+esac

Reply via email to