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

Contents of /eclass/vim-plugin.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.29 - (show annotations) (download)
Fri Aug 3 08:49:22 2012 UTC (2 years ago) by radhermit
Branch: MAIN
Changes since 1.28: +4 -3 lines
Add alternative location for vim plugin tarball archives.

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

  ViewVC Help
Powered by ViewVC 1.1.20