dev-cpp/pangomm: stable 2.42.1 for hppa, bug #717144
[gentoo.git] / eclass / vim-spell.eclass
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: vim-spell.eclass
5 # @MAINTAINER:
6 # Vim Maintainers <vim@gentoo.org>
7 # @AUTHOR:
8 # Ciaran McCreesh <ciaranm@gentoo.org>
9 # @BLURB: Eclass for managing Vim spell files.
10 # @DESCRIPTION:
11 # How to make a vim spell file package using prebuilt spell lists
12 # from upstream (${CODE} is the language's two letter code):
13 #
14 # * Get the ${CODE}.*.spl, ${CODE}.*.sug (if your language has them) and
15 #   README_${CODE}.txt files. Currently they're at
16 #   ftp://ftp.vim.org/pub/vim/unstable/runtime/spell/ (except for English,
17 #   which should be taken from CVS instead).
18 #
19 # * Stick them in vim-spell-${CODE}-$(date --iso | tr -d - ).tar.bz2 . Make sure
20 #   that they're in the appropriately named subdirectory to avoid having to mess
21 #   with S=.
22 #
23 # * Upload the tarball to the Gentoo mirrors.
24 #
25 # * Add your spell file to package.mask next to the other vim things. Vim
26 #   Project members will handle unmasking your spell packages when vim comes out
27 #   of package.mask.
28 #
29 # * Create the app-vim/vim-spell-${CODE} package. You should base your ebuild
30 #   upon app-vim/vim-spell-en. You will need to change VIM_SPELL_LANGUAGE,
31 #   KEYWORDS and LICENSE. Check the license carefully! The README will tell
32 #   you what it is.
33 #
34 # * Don't forget metadata.xml. You should list the Vim project and yourself
35 #   as maintainers. There is no need to join the Vim project just for spell
36 #   files. Here's an example of a metadata.xml file:
37 #
38 #     <?xml version="1.0" encoding="UTF-8"?>
39 #     <!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
40 #     <pkgmetadata>
41 #        <maintainer type="person">
42 #                <email>your@email.tld</email>
43 #                <name>Your Name</name>
44 #        </maintainer>
45 #        <maintainer type="project">
46 #                <email>vim@gentoo.org</email>
47 #                <name>Vim Maintainers</name>
48 #        </maintainer>
49 #
50 #       <longdescription lang="en">
51 #               Vim spell files for French (fr). Supported character sets are
52 #               UTF-8 and latin1.
53 #       </longdescription>
54 #     </pkgmetadata>
55 #
56 # * Send an email to vim@gentoo.org to let us know.
57 #
58 # Don't forget to update your package as necessary.
59 #
60 # If there isn't an upstream-provided pregenerated spell file for your language
61 # yet, read :help spell.txt from inside vim for instructions on how to create
62 # spell files. It's best to let upstream know if you've generated spell files
63 # for another language rather than keeping them Gentoo-specific.
64
65 inherit eutils
66
67 EXPORT_FUNCTIONS src_install pkg_postinst
68
69 SRC_URI="mirror://gentoo/${P}.tar.bz2"
70 SLOT="0"
71
72 # @ECLASS-VARIABLE: VIM_SPELL_LANGUAGE
73 # @DESCRIPTION:
74 # This variable defines the language for the spell package being
75 # installed.
76 # The default value is "English".
77 : ${VIM_SPELL_LANGUAGE:="English"}
78
79 # @ECLASS-VARIABLE: VIM_SPELL_LOCALE
80 # @INTERNAL
81 # @DESCRIPTION:
82 # This variable defines the locale for the current ebuild.
83 # The default value is ${PN} stripped of the "vim-spell-" string.
84 : ${VIM_SPELL_LOCALE:="${PN/vim-spell-/}"}
85
86 # @ECLASS-VARIABLE: VIM_SPELL_DIRECTORY
87 # @INTERNAL
88 # @DESCRIPTION:
89 # This variable defines the path to Vim spell files.
90 : ${VIM_SPELL_DIRECTORY:="${EPREFIX}/usr/share/vim/vimfiles/spell/"}
91
92 # @ECLASS-VARIABLE: DESCRIPTION
93 # @DESCRIPTION:
94 # This variable defines the DESCRIPTION for Vim spell ebuilds.
95 : ${DESCRIPTION:="vim spell files: ${VIM_SPELL_LANGUAGE} (${VIM_SPELL_LOCALE})"}
96
97 # @ECLASS-VARIABLE: HOMEPAGE
98 # @DESCRIPTION:
99 # This variable defines the HOMEPAGE for Vim spell ebuilds.
100 : ${HOMEPAGE:="https://www.vim.org"}
101
102 # @FUNCTION: vim-spell_src_install
103 # @DESCRIPTION:
104 # This function installs Vim spell files.
105 vim-spell_src_install() {
106         dodir "${VIM_SPELL_DIRECTORY}"
107         insinto "${VIM_SPELL_DIRECTORY}"
108
109         local had_spell_file=
110         local f
111         for f in *.spl; do
112                 if [[ -f "${f}" ]]; then
113                         doins "${f}"
114                         had_spell_file="yes"
115                 fi
116         done
117
118         for f in *.sug; do
119                 if [[ -f "${f}" ]]; then
120                         doins "${f}"
121                 fi
122         done
123
124         for f in README*; do
125                 dodoc "${f}"
126         done
127
128         [[ -z "${had_spell_file}" ]] && die "Didn't install any spell files?"
129 }
130
131 # @FUNCTION: vim-spell_pkg_postinst
132 # @DESCRIPTION:
133 # This function displays installed Vim spell files.
134 vim-spell_pkg_postinst() {
135         has "${EAPI:-0}" 0 1 2 && ! use prefix && EROOT="${ROOT}"
136         echo
137         elog "To enable ${VIM_SPELL_LANGUAGE} spell checking, use"
138         elog "    :setlocal spell spelllang=${VIM_SPELL_LOCALE}"
139         echo
140         elog "The following (Vim internal, not file) encodings are supported for"
141         elog "this language:"
142         local f enc
143         for f in "${EROOT}${VIM_SPELL_DIRECTORY}/${VIM_SPELL_LOCALE}".*.spl; do
144                 enc="${f##*/${VIM_SPELL_LOCALE}.}"
145                 enc="${enc%.spl}"
146                 [[ -z "${enc}" ]] && continue
147                 elog "    ${enc}"
148         done
149         echo
150         elog "For further documentation, use:"
151         elog "    :help spell"
152         echo
153 }