net-fs/openafs-kernel: remove vulnerable versions
[gentoo.git] / eclass / myspell-r2.eclass
1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 # @ECLASS: aspell-dict.eclass
6 # @MAINTAINER:
7 # maintainer-needed@gentoo.org
8 # @AUTHOR:
9 # Tomáš Chvátal <scarabeus@gentoo.org>
10 # @BLURB: An eclass to ease the construction of ebuilds for myspell dicts
11 # @DESCRIPTION:
12
13 EXPORT_FUNCTIONS src_unpack src_install
14
15 # @ECLASS-VARIABLE: MYSPELL_DICT
16 # @DEFAULT_UNSET
17 # @DESCRIPTION:
18 # Array variable containing list of all dictionary files.
19 # MYSPELL_DICT=( "file.dic" "dir/file2.aff" )
20
21 # @ECLASS-VARIABLE: MYSPELL_HYPH
22 # @DESCRIPTION:
23 # Array variable containing list of all hyphenation files.
24 # MYSPELL_HYPH=( "file.dic" "dir/file2.dic" )
25
26 # @ECLASS-VARIABLE: MYSPELL_THES
27 # @DESCRIPTION:
28 # Array variable containing list of all thesarus files.
29 # MYSPELL_HYPH=( "file.dat" "dir/file2.idx" )
30
31 # Basically no extra deps needed.
32 # Unzip is required for .oxt libreoffice extensions
33 # which are just fancy zip files.
34 DEPEND="app-arch/unzip"
35 RDEPEND=""
36
37 # by default this stuff does not have any folder in the pack
38 S="${WORKDIR}"
39
40 # @FUNCTION: myspell-r2_src_unpack
41 # @DESCRIPTION:
42 # Unpack all variants of weird stuff.
43 # In our case .oxt packs.
44 myspell-r2_src_unpack() {
45         debug-print-function ${FUNCNAME} "$@"
46
47         local f
48         for f in ${A}; do
49                 case ${f} in
50                         *.oxt)
51                                 echo ">>> Unpacking "${DISTDIR}/${f}" to ${PWD}"
52                                 unzip -qoj ${DISTDIR}/${f}
53                                 assert "failed unpacking ${DISTDIR}/${f}"
54                                 ;;
55                         *) unpack ${f} ;;
56                 esac
57         done
58 }
59
60 # @FUNCTION: myspell-r2_src_install
61 # @DESCRIPTION:
62 # Install the dictionaries to the right places.
63 myspell-r2_src_install() {
64         debug-print-function ${FUNCNAME} "$@"
65
66         local x target
67         
68         # Following the debian directory layout here.
69         # DICT: /usr/share/hunspell
70         # THES: /usr/share/mythes
71         # HYPH: /usr/share/hyphen
72         # We just need to copy the required files to proper places.
73
74         # TODO: backcompat dosym remove when all dictionaries and libreoffice
75         #       ebuilds in tree use only the new paths
76
77         # Very old installs have hunspell to be symlink to myspell.
78         # This results in fcked up install/symlink stuff.
79         if [[ -L "${EPREFIX}/usr/share/hunspell" ]] ; then
80                 eerror "\"${EPREFIX}/usr/share/hunspell\" is a symlink."
81                 eerror "Please remove it so it is created properly as folder"
82                 die "\"${EPREFIX}/usr/share/hunspell\" is a symlink."
83         fi
84
85         insinto /usr/share/hunspell
86         for x in "${MYSPELL_DICT[@]}"; do
87                 target="${x##*/}"
88                 newins "${x}" "${target}" || die
89                 dosym /usr/share/hunspell/"${target}" /usr/share/myspell/"${target}" || die
90         done
91
92         insinto /usr/share/mythes
93         for x in "${MYSPELL_THES[@]}"; do
94                 target="${x##*/}"
95                 newins "${x}" "${target}" || die
96                 dosym /usr/share/mythes/"${target}" /usr/share/myspell/"${target}" || die
97         done
98
99         insinto /usr/share/hyphen
100         for x in "${MYSPELL_HYPH[@]}"; do
101                 target="${x##*/}"
102                 newins "${x}" "${target}" || die
103                 dosym /usr/share/hyphen/"${target}" /usr/share/myspell/"${target}" || die
104         done
105
106         # Remove licenses as they suffix them with .txt too
107         rm -rf COPYING*
108         rm -rf LICENSE*
109         rm -rf LICENCE*
110         rm -rf license*
111         rm -rf licence*
112         # Readme and so on
113         for x in *.txt README*; do
114                 if [[ -f ${x} ]]; then
115                         dodoc ${x} || die
116                 fi
117         done
118 }