eclass/vim-plugin: Sync with gentoo

It's from gentoo commit d2194b951c8a8fbdce77ccafae4356d44c2a29c7.
This commit is contained in:
Krzesimir Nowak 2022-02-25 17:05:24 +01:00
parent c9b5f89903
commit dd467b2fc1

View File

@ -1,9 +1,10 @@
# Copyright 1999-2017 Gentoo Foundation
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: vim-plugin.eclass
# @MAINTAINER:
# vim@gentoo.org
# @SUPPORTED_EAPIS: 6 7
# @BLURB: used for installing vim plugins
# @DESCRIPTION:
# This eclass simplifies installation of app-vim plugins into
@ -11,7 +12,12 @@
# which is read automatically by vim. The only exception is
# documentation, for which we make a special case via vim-doc.eclass.
inherit estack vim-doc
case ${EAPI} in
6|7);;
*) die "EAPI ${EAPI:-0} unsupported (too old)";;
esac
inherit vim-doc
EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
VIM_PLUGIN_VIM_VERSION="${VIM_PLUGIN_VIM_VERSION:-7.3}"
@ -33,47 +39,17 @@ SLOT="0"
# * installs all files in "${ED}"/usr/share/vim/vimfiles.
vim-plugin_src_install() {
has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"
local f
# When globbing, if nothing exists, the shell literally returns the glob
# pattern. So turn on nullglob and extglob options to avoid this.
eshopts_push -s extglob
eshopts_push -s nullglob
ebegin "Cleaning up unwanted files and directories"
# We're looking for dotfiles, dotdirectories and Makefiles here.
local obj
eval "local matches=(@(.[^.]|.??*|Makefile*))"
for obj in "${matches[@]}"; do
rm -rv "${obj}" || die "cannot remove ${obj}"
done
eend $?
# Turn those options back off.
eshopts_pop
eshopts_pop
# Install non-vim-help-docs
cd "${S}" || die "couldn't cd in ${S}"
local f
for f in *; do
[[ -f "${f}" ]] || continue
if [[ "${f}" = *.html ]]; then
dohtml "${f}"
else
dodoc "${f}"
fi
rm "${f}" || die
done
einstalldocs
# Install remainder of plugin
cd "${WORKDIR}" || die "couldn't cd in ${WORKDIR}"
dodir /usr/share/vim
mv "${S}" "${ED}"/usr/share/vim/vimfiles || die \
"couldn't move ${S} to ${ED}/usr/share/vim/vimfiles"
# Set permissions
fperms -R a+rX /usr/share/vim/vimfiles
insinto /usr/share/vim/vimfiles/
local d
for d in *; do
[[ -d "${d}" ]] || continue
doins -r "${d}"
done
}
# @FUNCTION: vim-plugin_pkg_postinst
@ -150,31 +126,31 @@ update_vim_afterscripts() {
display_vim_plugin_help() {
local h
if ! has_version ${CATEGORY}/${PN} ; then
if [[ -n "${VIM_PLUGIN_HELPFILES}" ]] ; then
if [[ -z ${REPLACING_VERSIONS} ]]; then
if [[ -n ${VIM_PLUGIN_HELPFILES} ]]; then
elog " "
elog "This plugin provides documentation via vim's help system. To"
elog "view it, use:"
for h in ${VIM_PLUGIN_HELPFILES} ; do
for h in ${VIM_PLUGIN_HELPFILES}; do
elog " :help ${h}"
done
elog " "
elif [[ -n "${VIM_PLUGIN_HELPTEXT}" ]] ; then
elif [[ -n ${VIM_PLUGIN_HELPTEXT} ]]; then
elog " "
while read h ; do
elog "$h"
done <<<"${VIM_PLUGIN_HELPTEXT}"
elog " "
elif [[ -n "${VIM_PLUGIN_HELPURI}" ]] ; then
elif [[ -n ${VIM_PLUGIN_HELPURI} ]]; then
elog " "
elog "Documentation for this plugin is available online at:"
elog " ${VIM_PLUGIN_HELPURI}"
elog " "
fi
if has "filetype" "${VIM_PLUGIN_MESSAGES}" ; then
if has filetype ${VIM_PLUGIN_MESSAGES}; then
elog "This plugin makes use of filetype settings. To enable these,"
elog "add lines like:"
elog " filetype plugin on"