mirror of
https://github.com/flatcar/scripts.git
synced 2025-10-01 02:22:11 +02:00
eclass/vim-{doc,plugins}: Sync with Gentoo upstream to support EAPI8
Signed-off-by: Sayan Chowdhury <schowdhury@microsoft.com>
This commit is contained in:
parent
5dfc04cef3
commit
a000a47cff
@ -1,10 +1,10 @@
|
|||||||
# Copyright 1999-2021 Gentoo Authors
|
# Copyright 1999-2022 Gentoo Authors
|
||||||
# Distributed under the terms of the GNU General Public License v2
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
|
|
||||||
# @ECLASS: vim-doc.eclass
|
# @ECLASS: vim-doc.eclass
|
||||||
# @MAINTAINER:
|
# @MAINTAINER:
|
||||||
# vim@gentoo.org
|
# vim@gentoo.org
|
||||||
# @SUPPORTED_EAPIS: 6 7
|
# @SUPPORTED_EAPIS: 6 7 8
|
||||||
# @BLURB: Eclass for vim{,-plugin}.eclass to update documentation tags.
|
# @BLURB: Eclass for vim{,-plugin}.eclass to update documentation tags.
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# This eclass is used by vim.eclass and vim-plugin.eclass to update
|
# This eclass is used by vim.eclass and vim-plugin.eclass to update
|
||||||
@ -16,26 +16,31 @@
|
|||||||
# DEPEND in vim-plugin or by whatever version of vim is being
|
# DEPEND in vim-plugin or by whatever version of vim is being
|
||||||
# installed by the eclass.
|
# installed by the eclass.
|
||||||
|
|
||||||
case ${EAPI:-0} in
|
case ${EAPI} in
|
||||||
[67]) ;;
|
6|7|8) ;;
|
||||||
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
|
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ -z ${_VIM_DOC_ECLASS} ]] ; then
|
if [[ ! ${_VIM_DOC_ECLASS} ]] ; then
|
||||||
_VIM_DOC_ECLASS=1
|
|
||||||
|
|
||||||
|
# @FUNCTION: update_vim_helptags
|
||||||
|
# @USAGE:
|
||||||
|
# @DESCRIPTION:
|
||||||
|
# Update the documentation tags in the versioned Vim directory.
|
||||||
update_vim_helptags() {
|
update_vim_helptags() {
|
||||||
local vimfiles vim d s
|
debug-print-function ${FUNCNAME} "${@}"
|
||||||
|
|
||||||
|
local vimfiles helpfile files vim d
|
||||||
|
|
||||||
# This is where vim plugins are installed
|
# This is where vim plugins are installed
|
||||||
vimfiles="${EROOT}"/usr/share/vim/vimfiles
|
vimfiles="${EROOT}"/usr/share/vim/vimfiles
|
||||||
|
|
||||||
if [[ $PN != vim-core ]]; then
|
if [[ ${PN} != vim-core ]]; then
|
||||||
# Find a suitable vim binary for updating tags :helptags
|
# Find a suitable vim binary for updating tags :helptags
|
||||||
vim=$(type -P vim 2>/dev/null)
|
vim=$(type -P vim 2>/dev/null)
|
||||||
[[ -z "$vim" ]] && vim=$(type -P gvim 2>/dev/null)
|
[[ -z "${vim}" ]] && vim=$(type -P gvim 2>/dev/null)
|
||||||
[[ -z "$vim" ]] && vim=$(type -P kvim 2>/dev/null)
|
[[ -z "${vim}" ]] && vim=$(type -P kvim 2>/dev/null)
|
||||||
if [[ -z "$vim" ]]; then
|
if [[ -z "${vim}" ]]; then
|
||||||
ewarn "No suitable vim binary to rebuild documentation tags"
|
ewarn "No suitable vim binary to rebuild documentation tags"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -43,44 +48,57 @@ update_vim_helptags() {
|
|||||||
# Make vim not try to connect to X. See :help gui-x11-start
|
# Make vim not try to connect to X. See :help gui-x11-start
|
||||||
# in vim for how this evil trickery works.
|
# in vim for how this evil trickery works.
|
||||||
if [[ -n "${vim}" ]] ; then
|
if [[ -n "${vim}" ]] ; then
|
||||||
ln -s "${vim}" "${T}/tagvim"
|
ln -s "${vim}" "${T}/tagvim" || die
|
||||||
vim="${T}/tagvim"
|
vim="${T}/tagvim"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install the documentation symlinks into the versioned vim
|
# Install the documentation symlinks into the versioned vim
|
||||||
# directory and run :helptags
|
# directory and run :helptags
|
||||||
for d in "${EROOT%/}"/usr/share/vim/vim[0-9]*; do
|
for d in "${EROOT%/}"/usr/share/vim/vim[0-9]*; do
|
||||||
[[ -d "$d/doc" ]] || continue # catch a failed glob
|
[[ -d "${d}/doc" ]] || continue # catch a failed glob
|
||||||
|
|
||||||
# Remove links, and possibly remove stale dirs
|
# Remove links
|
||||||
find $d/doc -name \*.txt -type l | while read s; do
|
readarray -d '' files < <(find "${d}"/doc -name "*.txt" -type l -print0 || die "cannot traverse ${d}/doc" )
|
||||||
[[ $(readlink "$s") = $vimfiles/* ]] && rm -f "$s"
|
for helpfile in "${files[@]}"; do
|
||||||
|
if [[ $(readlink -f "${helpfile}") == "${vimfiles}"/* ]]; then
|
||||||
|
rm "${helpfile}" || die
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
if [[ -f "$d/doc/tags" && $(find "$d" | wc -l | tr -d ' ') = 3 ]]; then
|
|
||||||
|
# Remove stale dirs, if possible
|
||||||
|
readarray -d '' files < <(find "${d}" -print0 || die "cannot traverse ${d}")
|
||||||
|
if [[ -f "${d}/doc/tags" && ${#files[@]} -eq 3 ]]; then
|
||||||
# /usr/share/vim/vim61
|
# /usr/share/vim/vim61
|
||||||
# /usr/share/vim/vim61/doc
|
# /usr/share/vim/vim61/doc
|
||||||
# /usr/share/vim/vim61/doc/tags
|
# /usr/share/vim/vim61/doc/tags
|
||||||
einfo "Removing $d"
|
einfo "Removing ${d}"
|
||||||
rm -r "$d"
|
rm -r "${d}" || die
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Re-create / install new links
|
# Re-create / install new links
|
||||||
if [[ -d $vimfiles/doc ]]; then
|
if [[ -d "${vimfiles}"/doc ]]; then
|
||||||
ln -s $vimfiles/doc/*.txt $d/doc 2>/dev/null
|
for helpfile in "${vimfiles}"/doc/*.txt; do
|
||||||
|
if [[ ! -e "${d}/doc/$(basename "${helpfile}")" ]]; then
|
||||||
|
ln -s "${helpfile}" "${d}/doc" || die
|
||||||
|
fi
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update tags; need a vim binary for this
|
# Update tags; need a vim binary for this
|
||||||
if [[ -n "$vim" ]]; then
|
if [[ -n "${vim}" ]]; then
|
||||||
einfo "Updating documentation tags in $d"
|
einfo "Updating documentation tags in ${d}"
|
||||||
DISPLAY= $vim -u NONE -U NONE -T xterm -X -n -f \
|
DISPLAY= "${vim}" -u NONE -U NONE -T xterm -X -n -f \
|
||||||
'+set nobackup nomore' \
|
'+set nobackup nomore' \
|
||||||
"+helptags $d/doc" \
|
"+helptags ${d}/doc" \
|
||||||
'+qa!' </dev/null &>/dev/null
|
'+qa!' </dev/null &>/dev/null || die
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
[[ -n "${vim}" && -f "${vim}" ]] && rm "${vim}"
|
if [[ -n "${vim}" && -f "${vim}" ]]; then
|
||||||
|
rm "${vim}" || die
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_VIM_DOC_ECLASS=1
|
||||||
fi
|
fi
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
# Copyright 1999-2021 Gentoo Authors
|
# Copyright 1999-2022 Gentoo Authors
|
||||||
# Distributed under the terms of the GNU General Public License v2
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
|
|
||||||
# @ECLASS: vim-plugin.eclass
|
# @ECLASS: vim-plugin.eclass
|
||||||
# @MAINTAINER:
|
# @MAINTAINER:
|
||||||
# vim@gentoo.org
|
# vim@gentoo.org
|
||||||
# @SUPPORTED_EAPIS: 6 7
|
# @SUPPORTED_EAPIS: 6 7 8
|
||||||
# @BLURB: used for installing vim plugins
|
# @BLURB: used for installing vim plugins
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# This eclass simplifies installation of app-vim plugins into
|
# This eclass simplifies installation of app-vim plugins into
|
||||||
@ -13,14 +13,19 @@
|
|||||||
# documentation, for which we make a special case via vim-doc.eclass.
|
# documentation, for which we make a special case via vim-doc.eclass.
|
||||||
|
|
||||||
case ${EAPI} in
|
case ${EAPI} in
|
||||||
6|7);;
|
6|7) ;;
|
||||||
*) die "EAPI ${EAPI:-0} unsupported (too old)";;
|
8) _DEFINE_VIM_PLUGIN_SRC_PREPARE=true ;;
|
||||||
|
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
inherit vim-doc
|
if [[ ! ${_VIM_PLUGIN_ECLASS} ]]; then
|
||||||
EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
|
|
||||||
|
|
||||||
VIM_PLUGIN_VIM_VERSION="${VIM_PLUGIN_VIM_VERSION:-7.3}"
|
inherit vim-doc
|
||||||
|
|
||||||
|
# @ECLASS_VARIABLE: VIM_PLUGIN_VIM_VERSION
|
||||||
|
# @DESCRIPTION:
|
||||||
|
# Minimum Vim version the plugin supports.
|
||||||
|
: ${VIM_PLUGIN_VIM_VERSION:=7.3}
|
||||||
|
|
||||||
DEPEND="|| ( >=app-editors/vim-${VIM_PLUGIN_VIM_VERSION}
|
DEPEND="|| ( >=app-editors/vim-${VIM_PLUGIN_VIM_VERSION}
|
||||||
>=app-editors/gvim-${VIM_PLUGIN_VIM_VERSION} )"
|
>=app-editors/gvim-${VIM_PLUGIN_VIM_VERSION} )"
|
||||||
@ -31,14 +36,59 @@ if [[ ${PV} != 9999* ]] ; then
|
|||||||
fi
|
fi
|
||||||
SLOT="0"
|
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() {
|
||||||
|
debug-print-function ${FUNCNAME} "${@}"
|
||||||
|
|
||||||
|
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:
|
||||||
|
# Vanilla Vim dirs.
|
||||||
|
# See /usr/share/vim/vim* for reference.
|
||||||
|
_VIM_PLUGIN_ALLOWED_DIRS=(
|
||||||
|
after autoload colors compiler doc ftdetect ftplugin indent keymap
|
||||||
|
macros plugin spell syntax
|
||||||
|
)
|
||||||
|
|
||||||
# @FUNCTION: vim-plugin_src_install
|
# @FUNCTION: vim-plugin_src_install
|
||||||
|
# @USAGE: [<dir>...]
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Overrides the default src_install phase. In order, this function:
|
# Overrides the default src_install phase. In order, this function:
|
||||||
# * fixes file permission across all files in ${S}.
|
#
|
||||||
# * installs help and documentation files.
|
# * installs help and documentation files.
|
||||||
# * installs all files in "${ED}"/usr/share/vim/vimfiles.
|
#
|
||||||
|
# * installs all files recognized by default Vim installation and directories
|
||||||
|
# passed to this function as arguments in "${ED}"/usr/share/vim/vimfiles.
|
||||||
|
#
|
||||||
|
# Example use:
|
||||||
|
# @CODE
|
||||||
|
# src_install() {
|
||||||
|
# vim-plugin_src_install syntax_checkers
|
||||||
|
# }
|
||||||
|
# @CODE
|
||||||
vim-plugin_src_install() {
|
vim-plugin_src_install() {
|
||||||
has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"
|
debug-print-function ${FUNCNAME} "${@}"
|
||||||
|
|
||||||
# Install non-vim-help-docs
|
# Install non-vim-help-docs
|
||||||
einstalldocs
|
einstalldocs
|
||||||
@ -46,20 +96,34 @@ vim-plugin_src_install() {
|
|||||||
# Install remainder of plugin
|
# Install remainder of plugin
|
||||||
insinto /usr/share/vim/vimfiles/
|
insinto /usr/share/vim/vimfiles/
|
||||||
local d
|
local d
|
||||||
|
case ${EAPI:-0} in
|
||||||
|
6|7)
|
||||||
for d in *; do
|
for d in *; do
|
||||||
[[ -d "${d}" ]] || continue
|
[[ -d "${d}" ]] || continue
|
||||||
doins -r "${d}"
|
doins -r "${d}"
|
||||||
done
|
done ;;
|
||||||
|
*)
|
||||||
|
for d in "${_VIM_PLUGIN_ALLOWED_DIRS[@]}" "${@}"; do
|
||||||
|
[[ -d "${d}" ]] || continue
|
||||||
|
doins -r "${d}"
|
||||||
|
done ;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# @FUNCTION: vim-plugin_pkg_postinst
|
# @FUNCTION: vim-plugin_pkg_postinst
|
||||||
|
# @USAGE:
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Overrides the pkg_postinst phase for this eclass.
|
# Overrides the pkg_postinst phase for this eclass.
|
||||||
# The following functions are called:
|
# The following functions are called:
|
||||||
|
#
|
||||||
# * update_vim_helptags
|
# * update_vim_helptags
|
||||||
|
#
|
||||||
# * update_vim_afterscripts
|
# * update_vim_afterscripts
|
||||||
|
#
|
||||||
# * display_vim_plugin_help
|
# * display_vim_plugin_help
|
||||||
vim-plugin_pkg_postinst() {
|
vim-plugin_pkg_postinst() {
|
||||||
|
debug-print-function ${FUNCNAME} "${@}"
|
||||||
|
|
||||||
update_vim_helptags # from vim-doc
|
update_vim_helptags # from vim-doc
|
||||||
update_vim_afterscripts # see below
|
update_vim_afterscripts # see below
|
||||||
display_vim_plugin_help # see below
|
display_vim_plugin_help # see below
|
||||||
@ -71,7 +135,8 @@ vim-plugin_pkg_postinst() {
|
|||||||
# This function calls the update_vim_helptags and update_vim_afterscripts
|
# This function calls the update_vim_helptags and update_vim_afterscripts
|
||||||
# functions and eventually removes a bunch of empty directories.
|
# functions and eventually removes a bunch of empty directories.
|
||||||
vim-plugin_pkg_postrm() {
|
vim-plugin_pkg_postrm() {
|
||||||
has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
|
debug-print-function ${FUNCNAME} "${@}"
|
||||||
|
|
||||||
update_vim_helptags # from vim-doc
|
update_vim_helptags # from vim-doc
|
||||||
update_vim_afterscripts # see below
|
update_vim_afterscripts # see below
|
||||||
|
|
||||||
@ -82,25 +147,26 @@ vim-plugin_pkg_postrm() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# @FUNCTION: update_vim_afterscripts
|
# @FUNCTION: update_vim_afterscripts
|
||||||
|
# @USAGE:
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Creates scripts in /usr/share/vim/vimfiles/after/*
|
# Creates scripts in /usr/share/vim/vimfiles/after/*
|
||||||
# comprised of the snippets in /usr/share/vim/vimfiles/after/*/*.d
|
# comprised of the snippets in /usr/share/vim/vimfiles/after/*/*.d
|
||||||
update_vim_afterscripts() {
|
update_vim_afterscripts() {
|
||||||
has "${EAPI:-0}" 0 1 2 && ! use prefix && EROOT="${ROOT}"
|
debug-print-function ${FUNCNAME} "${@}"
|
||||||
has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
|
|
||||||
local d f afterdir="${EROOT}"/usr/share/vim/vimfiles/after
|
local d f afterdir="${EROOT}"/usr/share/vim/vimfiles/after
|
||||||
|
|
||||||
# Nothing to do if the dir isn't there
|
# Nothing to do if the dir isn't there
|
||||||
[ -d "${afterdir}" ] || return 0
|
[[ -d "${afterdir}" ]] || return 0
|
||||||
|
|
||||||
einfo "Updating scripts in ${EPREFIX}/usr/share/vim/vimfiles/after"
|
einfo "Updating scripts in ${afterdir}"
|
||||||
find "${afterdir}" -type d -name \*.vim.d | while read d; do
|
find "${afterdir}" -type d -name \*.vim.d | while read d; do
|
||||||
echo '" Generated by update_vim_afterscripts' > "${d%.d}" || die
|
echo '" Generated by update_vim_afterscripts' > "${d%.d}" || die
|
||||||
find "${d}" -name \*.vim -type f -maxdepth 1 -print0 | sort -z | \
|
find "${d}" -name \*.vim -type f -maxdepth 1 -print0 | sort -z | \
|
||||||
xargs -0 cat >> "${d%.d}" || die "update_vim_afterscripts failed"
|
xargs -0 cat >> "${d%.d}" || die "update_vim_afterscripts failed"
|
||||||
done
|
done
|
||||||
|
|
||||||
einfo "Removing dead scripts in ${EPREFIX}/usr/share/vim/vimfiles/after"
|
einfo "Removing dead scripts in ${afterdir}"
|
||||||
find "${afterdir}" -type f -name \*.vim | \
|
find "${afterdir}" -type f -name \*.vim | \
|
||||||
while read f; do
|
while read f; do
|
||||||
[[ "$(head -n 1 ${f})" == '" Generated by update_vim_afterscripts' ]] \
|
[[ "$(head -n 1 ${f})" == '" Generated by update_vim_afterscripts' ]] \
|
||||||
@ -115,6 +181,7 @@ update_vim_afterscripts() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# @FUNCTION: display_vim_plugin_help
|
# @FUNCTION: display_vim_plugin_help
|
||||||
|
# @USAGE:
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Displays a message with the plugin's help file if one is available. Uses the
|
# Displays a message with the plugin's help file if one is available. Uses the
|
||||||
# VIM_PLUGIN_HELPFILES env var. If multiple help files are available, they
|
# VIM_PLUGIN_HELPFILES env var. If multiple help files are available, they
|
||||||
@ -124,6 +191,8 @@ update_vim_afterscripts() {
|
|||||||
# extra message regarding enabling filetype plugins is displayed if
|
# extra message regarding enabling filetype plugins is displayed if
|
||||||
# VIM_PLUGIN_MESSAGES includes the word "filetype".
|
# VIM_PLUGIN_MESSAGES includes the word "filetype".
|
||||||
display_vim_plugin_help() {
|
display_vim_plugin_help() {
|
||||||
|
debug-print-function ${FUNCNAME} "${@}"
|
||||||
|
|
||||||
local h
|
local h
|
||||||
|
|
||||||
if [[ -z ${REPLACING_VERSIONS} ]]; then
|
if [[ -z ${REPLACING_VERSIONS} ]]; then
|
||||||
@ -160,3 +229,14 @@ display_vim_plugin_help() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user