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