net-irc/limnoria: use HTTPS for GitHub and HOMEPAGE
[gentoo.git] / eclass / vim-spell.eclass
1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 #
5 # Original Author: Ciaran McCreesh <ciaranm@gentoo.org>
6 # Maintainers:     Vim Herd <vim@gentoo.org>
7 # Purpose:         Simplify installing spell files for vim7
8 #
9
10 # How to make a vim spell file package using prebuilt spell lists
11 # from upstream (${CODE} is the language's two letter code):
12 #
13 # * Get the ${CODE}.*.spl, ${CODE}.*.sug (if your language has them) and
14 #   README_${CODE}.txt files. Currently they're at
15 #   ftp://ftp.vim.org/pub/vim/unstable/runtime/spell/ (except for English,
16 #   which should be taken from CVS instead).
17 #
18 # * Stick them in vim-spell-${CODE}-$(date --iso | tr -d - ).tar.bz2 . Make sure
19 #   that they're in the appropriately named subdirectory to avoid having to mess
20 #   with S=.
21 #
22 # * Upload the tarball to the Gentoo mirrors.
23 #
24 # * (for now) Add your spell file to package.mask next to the other vim7
25 #   things. The vim herd will handle unmasking your spell packages when vim7
26 #   comes out of package.mask.
27 #
28 # * Create the app-vim/vim-spell-${CODE} package. You should base your ebuild
29 #   upon app-vim/vim-spell-en. You will need to change VIM_SPELL_LANGUAGE,
30 #   KEYWORDS and LICENSE. Check the license carefully! The README will tell
31 #   you what it is.
32 #
33 # * Don't forget metadata.xml. You should list vim as the herd, and yourself
34 #   as the maintainer (there is no need to join the vim herd just for spell
35 #   files):
36 #
37 #     <?xml version="1.0" encoding="UTF-8"?>
38 #     <!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
39 #     <pkgmetadata>
40 #       <herd>vim</herd>
41 #       <maintainer>
42 #               <email>your-name@gentoo.org</email>
43 #       </maintainer>
44 #       <longdescription lang="en">
45 #               Vim spell files for French (fr). Supported character sets are
46 #               UTF-8 and latin1.
47 #       </longdescription>
48 #     </pkgmetadata>
49 #
50 # * Send an email to vim@gentoo.org to let us know.
51 #
52 # Don't forget to update your package as necessary.
53 #
54 # If there isn't an upstream-provided pregenerated spell file for your language
55 # yet, read :help spell.txt from inside vim7 for instructions on how to create
56 # spell files. It's best to let upstream know if you've generated spell files
57 # for another language rather than keeping them Gentoo-specific.
58
59 inherit eutils
60
61 EXPORT_FUNCTIONS src_install pkg_postinst
62
63 IUSE=""
64 DEPEND="|| ( >=app-editors/vim-7_alpha
65         >=app-editors/gvim-7_alpha )"
66 RDEPEND="${DEPEND}"
67 SRC_URI="mirror://gentoo/${P}.tar.bz2"
68 SLOT="0"
69
70 if [[ -z "${VIM_SPELL_CODE}" ]] ; then
71         VIM_SPELL_CODE="${PN/vim-spell-/}"
72 fi
73
74 DESCRIPTION="vim spell files: ${VIM_SPELL_LANGUAGE} (${VIM_SPELL_CODE})"
75
76 if [[ -z "${HOMEPAGE}" ]] ; then
77         HOMEPAGE="http://www.vim.org/"
78 fi
79
80 vim-spell_src_install() {
81         target="/usr/share/vim/vimfiles/spell/"
82         dodir "${target}"
83         insinto "${target}"
84
85         had_spell_file=
86         for f in *.spl ; do
87                 if [[ -f "${f}" ]]; then
88                         doins "${f}"
89                         had_spell_file="yes"
90                 fi
91         done
92
93         for f in *.sug ; do
94                 if [[ -f "${f}" ]]; then
95                         doins "${f}"
96                 fi
97         done
98
99         for f in README* ; do
100                 dodoc "${f}"
101         done
102
103         [[ -z "${had_spell_file}" ]] && die "Didn't install any spell files?"
104 }
105
106 vim-spell_pkg_postinst() {
107         has "${EAPI:-0}" 0 1 2 && ! use prefix && EROOT="${ROOT}"
108         target="/usr/share/vim/vimfiles/spell/"
109         echo
110         elog "To enable ${VIM_SPELL_LANGUAGE} spell checking, use"
111         elog "    :setlocal spell spelllang=${VIM_SPELL_CODE}"
112         echo
113         elog "The following (Vim internal, not file) encodings are supported for"
114         elog "this language:"
115         for f in "${EROOT}/${target}/${VIM_SPELL_CODE}".*.spl ; do
116                 enc="${f##*/${VIM_SPELL_CODE}.}"
117                 enc="${enc%.spl}"
118                 [[ -z "${enc}" ]] && continue
119                 elog "    ${enc}"
120         done
121         echo
122         elog "For further documentation, use:"
123         elog "    :help spell"
124         echo
125 }