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

Contents of /eclass/vim-plugin.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.34 - (show annotations) (download)
Sun Jan 27 23:59:35 2013 UTC (14 months, 2 weeks ago) by radhermit
Branch: MAIN
Changes since 1.33: +2 -2 lines
Remove all hidden files in the main tarball dir.

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.33 2013/01/27 11:48:48 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.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 # Remove unwanted files that may exist
41 rm -rf .[^.] .??* Makefile*
42
43 # Install non-vim-help-docs
44 cd "${S}"
45 for f in *; do
46 [[ -f "${f}" ]] || continue
47 if [[ "${f}" = *.html ]]; then
48 dohtml "${f}"
49 else
50 dodoc "${f}"
51 fi
52 rm -f "${f}"
53 done
54
55 # Install remainder of plugin
56 cd "${WORKDIR}"
57 dodir /usr/share/vim
58 mv "${S}" "${ED}"/usr/share/vim/vimfiles
59
60 # Fix remaining bad permissions
61 chmod -R -x+X "${ED}"/usr/share/vim/vimfiles/ || die "chmod failed"
62 }
63
64 vim-plugin_pkg_postinst() {
65 update_vim_helptags # from vim-doc
66 update_vim_afterscripts # see below
67 display_vim_plugin_help # see below
68 }
69
70 vim-plugin_pkg_postrm() {
71 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
72 update_vim_helptags # from vim-doc
73 update_vim_afterscripts # see below
74
75 # Remove empty dirs; this allows
76 # /usr/share/vim to be removed if vim-core is unmerged
77 find "${EPREFIX}/usr/share/vim/vimfiles" -depth -type d -exec rmdir {} \; 2>/dev/null
78 }
79
80 # update_vim_afterscripts: create scripts in
81 # /usr/share/vim/vimfiles/after/* comprised of the snippets in
82 # /usr/share/vim/vimfiles/after/*/*.d
83 update_vim_afterscripts() {
84 has "${EAPI:-0}" 0 1 2 && ! use prefix && EROOT="${ROOT}"
85 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
86 local d f afterdir="${EROOT}"/usr/share/vim/vimfiles/after
87
88 # Nothing to do if the dir isn't there
89 [ -d "${afterdir}" ] || return 0
90
91 einfo "Updating scripts in ${EPREFIX}/usr/share/vim/vimfiles/after"
92 find "${afterdir}" -type d -name \*.vim.d | \
93 while read d; do
94 echo '" Generated by update_vim_afterscripts' > "${d%.d}"
95 find "${d}" -name \*.vim -type f -maxdepth 1 -print0 | \
96 sort -z | xargs -0 cat >> "${d%.d}"
97 done
98
99 einfo "Removing dead scripts in ${EPREFIX}/usr/share/vim/vimfiles/after"
100 find "${afterdir}" -type f -name \*.vim | \
101 while read f; do
102 [[ "$(head -n 1 ${f})" == '" Generated by update_vim_afterscripts' ]] \
103 || continue
104 # This is a generated file, but might be abandoned. Check
105 # if there's no corresponding .d directory, or if the
106 # file's effectively empty
107 if [[ ! -d "${f}.d" || -z "$(grep -v '^"' "${f}")" ]]; then
108 rm -f "${f}"
109 fi
110 done
111 }
112
113 # Display a message with the plugin's help file if one is available. Uses the
114 # VIM_PLUGIN_HELPFILES env var. If multiple help files are available, they
115 # should be separated by spaces. If no help files are available, but the env
116 # var VIM_PLUGIN_HELPTEXT is set, that is displayed instead. Finally, if we
117 # have nothing else, display a link to VIM_PLUGIN_HELPURI. An extra message
118 # regarding enabling filetype plugins is displayed if VIM_PLUGIN_MESSAGES
119 # includes the word "filetype".
120 display_vim_plugin_help() {
121 local h
122
123 if ! has_version ${CATEGORY}/${PN} ; then
124 if [[ -n "${VIM_PLUGIN_HELPFILES}" ]] ; then
125 elog " "
126 elog "This plugin provides documentation via vim's help system. To"
127 elog "view it, use:"
128 for h in ${VIM_PLUGIN_HELPFILES} ; do
129 elog " :help ${h}"
130 done
131 elog " "
132
133 elif [[ -n "${VIM_PLUGIN_HELPTEXT}" ]] ; then
134 elog " "
135 while read h ; do
136 elog "$h"
137 done <<<"${VIM_PLUGIN_HELPTEXT}"
138 elog " "
139
140 elif [[ -n "${VIM_PLUGIN_HELPURI}" ]] ; then
141 elog " "
142 elog "Documentation for this plugin is available online at:"
143 elog " ${VIM_PLUGIN_HELPURI}"
144 elog " "
145 fi
146
147 if has "filetype" "${VIM_PLUGIN_MESSAGES}" ; then
148 elog "This plugin makes use of filetype settings. To enable these,"
149 elog "add lines like:"
150 elog " filetype plugin on"
151 elog " filetype indent on"
152 elog "to your ~/.vimrc file."
153 elog " "
154 fi
155 fi
156 }

  ViewVC Help
Powered by ViewVC 1.1.20