/[gentoo-x86]/eclass/vim-plugin.eclass
Gentoo

Contents of /eclass/vim-plugin.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.37 - (show annotations) (download)
Mon Jun 17 07:57:30 2013 UTC (15 months ago) by radhermit
Branch: MAIN
CVS Tags: HEAD
Changes since 1.36: +2 -2 lines
Update default VIM_PLUGIN_VIM_VERSION to 7.3.

1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/vim-plugin.eclass,v 1.36 2013/06/01 09:28:16 radhermit Exp $
4 #
5 # This eclass simplifies installation of app-vim plugins into
6 # /usr/share/vim/vimfiles. This is a version-independent directory
7 # which is read automatically by vim. The only exception is
8 # documentation, for which we make a special case via vim-doc.eclass
9
10 inherit vim-doc
11 EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
12
13 VIM_PLUGIN_VIM_VERSION="${VIM_PLUGIN_VIM_VERSION:-7.3}"
14
15 DEPEND="|| ( >=app-editors/vim-${VIM_PLUGIN_VIM_VERSION}
16 >=app-editors/gvim-${VIM_PLUGIN_VIM_VERSION} )"
17 RDEPEND="${DEPEND}"
18 if [[ ${PV} != 9999* ]] ; then
19 SRC_URI="mirror://gentoo/${P}.tar.bz2
20 http://dev.gentoo.org/~radhermit/vim/${P}.tar.bz2"
21 fi
22 SLOT="0"
23
24 vim-plugin_src_install() {
25 has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"
26 local f
27
28 if use !prefix && [[ ${EUID} -eq 0 ]] ; then
29 ebegin "Fixing file permissions"
30 # Make sure perms are good
31 chmod -R a+rX "${S}" || die "chmod failed"
32 find "${S}" -user 'portage' -exec chown root '{}' \; || die "chown failed"
33 if use userland_BSD || [[ ${CHOST} == *-darwin* ]] ; then
34 find "${S}" -group 'portage' -exec chgrp wheel '{}' \; || die "chgrp failed"
35 else
36 find "${S}" -group 'portage' -exec chgrp root '{}' \; || die "chgrp failed"
37 fi
38 eend $?
39 fi
40
41 # Remove unwanted files that may exist
42 rm -rf .[^.] .??* Makefile*
43
44 # Install non-vim-help-docs
45 cd "${S}"
46 for f in *; do
47 [[ -f "${f}" ]] || continue
48 if [[ "${f}" = *.html ]]; then
49 dohtml "${f}"
50 else
51 dodoc "${f}"
52 fi
53 rm -f "${f}"
54 done
55
56 # Install remainder of plugin
57 cd "${WORKDIR}"
58 dodir /usr/share/vim
59 mv "${S}" "${ED}"/usr/share/vim/vimfiles
60
61 # Fix remaining bad permissions
62 chmod -R -x+X "${ED}"/usr/share/vim/vimfiles/ || die "chmod failed"
63 }
64
65 vim-plugin_pkg_postinst() {
66 update_vim_helptags # from vim-doc
67 update_vim_afterscripts # see below
68 display_vim_plugin_help # see below
69 }
70
71 vim-plugin_pkg_postrm() {
72 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
73 update_vim_helptags # from vim-doc
74 update_vim_afterscripts # see below
75
76 # Remove empty dirs; this allows
77 # /usr/share/vim to be removed if vim-core is unmerged
78 find "${EPREFIX}/usr/share/vim/vimfiles" -depth -type d -exec rmdir {} \; 2>/dev/null
79 }
80
81 # update_vim_afterscripts: create scripts in
82 # /usr/share/vim/vimfiles/after/* comprised of the snippets in
83 # /usr/share/vim/vimfiles/after/*/*.d
84 update_vim_afterscripts() {
85 has "${EAPI:-0}" 0 1 2 && ! use prefix && EROOT="${ROOT}"
86 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
87 local d f afterdir="${EROOT}"/usr/share/vim/vimfiles/after
88
89 # Nothing to do if the dir isn't there
90 [ -d "${afterdir}" ] || return 0
91
92 einfo "Updating scripts in ${EPREFIX}/usr/share/vim/vimfiles/after"
93 find "${afterdir}" -type d -name \*.vim.d | \
94 while read d; do
95 echo '" Generated by update_vim_afterscripts' > "${d%.d}"
96 find "${d}" -name \*.vim -type f -maxdepth 1 -print0 | \
97 sort -z | xargs -0 cat >> "${d%.d}"
98 done
99
100 einfo "Removing dead scripts in ${EPREFIX}/usr/share/vim/vimfiles/after"
101 find "${afterdir}" -type f -name \*.vim | \
102 while read f; do
103 [[ "$(head -n 1 ${f})" == '" Generated by update_vim_afterscripts' ]] \
104 || continue
105 # This is a generated file, but might be abandoned. Check
106 # if there's no corresponding .d directory, or if the
107 # file's effectively empty
108 if [[ ! -d "${f}.d" || -z "$(grep -v '^"' "${f}")" ]]; then
109 rm -f "${f}"
110 fi
111 done
112 }
113
114 # Display a message with the plugin's help file if one is available. Uses the
115 # VIM_PLUGIN_HELPFILES env var. If multiple help files are available, they
116 # should be separated by spaces. If no help files are available, but the env
117 # var VIM_PLUGIN_HELPTEXT is set, that is displayed instead. Finally, if we
118 # have nothing else, display a link to VIM_PLUGIN_HELPURI. An extra message
119 # regarding enabling filetype plugins is displayed if VIM_PLUGIN_MESSAGES
120 # includes the word "filetype".
121 display_vim_plugin_help() {
122 local h
123
124 if ! has_version ${CATEGORY}/${PN} ; then
125 if [[ -n "${VIM_PLUGIN_HELPFILES}" ]] ; then
126 elog " "
127 elog "This plugin provides documentation via vim's help system. To"
128 elog "view it, use:"
129 for h in ${VIM_PLUGIN_HELPFILES} ; do
130 elog " :help ${h}"
131 done
132 elog " "
133
134 elif [[ -n "${VIM_PLUGIN_HELPTEXT}" ]] ; then
135 elog " "
136 while read h ; do
137 elog "$h"
138 done <<<"${VIM_PLUGIN_HELPTEXT}"
139 elog " "
140
141 elif [[ -n "${VIM_PLUGIN_HELPURI}" ]] ; then
142 elog " "
143 elog "Documentation for this plugin is available online at:"
144 elog " ${VIM_PLUGIN_HELPURI}"
145 elog " "
146 fi
147
148 if has "filetype" "${VIM_PLUGIN_MESSAGES}" ; then
149 elog "This plugin makes use of filetype settings. To enable these,"
150 elog "add lines like:"
151 elog " filetype plugin on"
152 elog " filetype indent on"
153 elog "to your ~/.vimrc file."
154 elog " "
155 fi
156 fi
157 }

  ViewVC Help
Powered by ViewVC 1.1.20