| 1 | # Copyright 1999-2004 Gentoo Foundation |
1 | # Copyright 1999-2008 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/latex-package.eclass,v 1.24 2005/07/06 20:20:03 agriffis Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/latex-package.eclass,v 1.37 2008/08/30 13:49:28 aballier Exp $ |
| 4 | # |
4 | |
|
|
5 | # @ECLASS: latex-package.eclass |
|
|
6 | # @MAINTAINER: |
|
|
7 | # TeX team <tex@gentoo.org> |
|
|
8 | # |
| 5 | # Author Matthew Turk <satai@gentoo.org> |
9 | # Author Matthew Turk <satai@gentoo.org> |
| 6 | # |
10 | # Martin Ehmsen <ehmsen@gentoo.org> |
|
|
11 | # @BLURB: An eclass for easy installation of LaTeX packages |
|
|
12 | # @DESCRIPTION: |
| 7 | # This eClass is designed to be easy to use and implement. The vast majority of |
13 | # This eClass is designed to be easy to use and implement. The vast majority of |
| 8 | # LaTeX packages will only need to define SRC_URI (and sometimes S) for a |
14 | # LaTeX packages will only need to define SRC_URI (and sometimes S) for a |
| 9 | # successful installation. If fonts need to be installed, then the variable |
15 | # successful installation. If fonts need to be installed, then the variable |
| 10 | # SUPPLIER must also be defined. |
16 | # SUPPLIER must also be defined. |
| 11 | # |
17 | # |
| … | |
… | |
| 32 | # latex-package_src_install |
38 | # latex-package_src_install |
| 33 | # } |
39 | # } |
| 34 | # |
40 | # |
| 35 | # The eClass automatically takes care of rehashing TeX's cache (ls-lR) after |
41 | # The eClass automatically takes care of rehashing TeX's cache (ls-lR) after |
| 36 | # installation and after removal, as well as creating final documentation from |
42 | # installation and after removal, as well as creating final documentation from |
| 37 | # TeX files that come with the source. Note that we break TeX layout standards |
43 | # TeX files that come with the source. Note that we break TeX layout standards |
| 38 | # by placing documentation in /usr/share/doc/${PN} |
44 | # by placing documentation in /usr/share/doc/${PN} |
| 39 | # |
45 | # |
| 40 | # For examples of basic installations, check out dev-tex/aastex and |
46 | # For examples of basic installations, check out dev-tex/aastex and |
| 41 | # dev-tex/leaflet . |
47 | # dev-tex/leaflet . |
| 42 | # |
48 | # |
| 43 | # NOTE: The CTAN "directory grab" function creates files with different MD5 |
49 | # NOTE: The CTAN "directory grab" function creates files with different MD5 |
| 44 | # signatures EVERY TIME. For this reason, if you are grabbing from the CTAN, |
50 | # signatures EVERY TIME. For this reason, if you are grabbing from the CTAN, |
| 45 | # you must either grab each file individually, or find a place to mirror an |
51 | # you must either grab each file individually, or find a place to mirror an |
| 46 | # archive of them. (iBiblio) |
52 | # archive of them. (iBiblio) |
|
|
53 | # |
|
|
54 | # It inherits base. |
| 47 | |
55 | |
| 48 | inherit base |
56 | inherit base |
| 49 | |
57 | |
| 50 | DEPEND="virtual/tetex |
58 | RDEPEND="virtual/latex-base" |
|
|
59 | DEPEND="${RDEPEND} |
| 51 | >=sys-apps/texinfo-4.2-r5" |
60 | >=sys-apps/texinfo-4.2-r5" |
| 52 | HOMEPAGE="http://www.tug.org/" |
61 | HOMEPAGE="http://www.tug.org/" |
| 53 | SRC_URI="ftp://tug.ctan.org/macros/latex/" |
62 | SRC_URI="ftp://tug.ctan.org/macros/latex/" |
| 54 | S=${WORKDIR}/${P} |
63 | S=${WORKDIR}/${P} |
| 55 | TEXMF="/usr/share/texmf" |
64 | TEXMF="/usr/share/texmf" |
|
|
65 | |
|
|
66 | # @ECLASS-VARIABLE: SUPPLIER |
|
|
67 | # @DESCRIPTION: |
| 56 | SUPPLIER="misc" # This refers to the font supplier; it should be overridden |
68 | # This refers to the font supplier; it should be overridden (see eclass |
|
|
69 | # DESCRIPTION above) |
|
|
70 | SUPPLIER="misc" |
| 57 | |
71 | |
|
|
72 | # @FUNCTION: latex-package_has_tetex3 |
|
|
73 | # @RETURN: true if at least one of (>=tetex-3 or >=ptex-3.1.8 or >=texlive-core-2007) is installed, else false |
|
|
74 | # @DESCRIPTION: |
|
|
75 | # It is often used to know if the current TeX installation supports gentoo's |
|
|
76 | # texmf-update or if the package has to do it the old way |
| 58 | latex-package_has_tetex_3() { |
77 | latex-package_has_tetex_3() { |
| 59 | if has_version '>=app-text/tetex-3' || has_version '>=app-text/ptex-3.1.8' ; then |
78 | if has_version '>=app-text/tetex-3' || has_version '>=app-text/ptex-3.1.8' || has_version '>=app-text/texlive-core-2007' ; then |
| 60 | true |
79 | true |
| 61 | else |
80 | else |
| 62 | false |
81 | false |
| 63 | fi |
82 | fi |
| 64 | } |
83 | } |
| 65 | |
84 | |
|
|
85 | # @FUNCTION: latex-package_src_doinstall |
|
|
86 | # @USAGE: [ module ] |
|
|
87 | # @DESCRIPTION: |
|
|
88 | # [module] can be one or more of: sh, sty, cls, fd, clo, def, cfg, dvi, ps, pdf, |
|
|
89 | # tex, dtx, tfm, vf, afm, pfb, ttf, bst, styles, doc, fonts, bin, or all. |
|
|
90 | # If [module] is not given, all is assumed. |
|
|
91 | # It installs the files found in the current directory to the standard locations |
|
|
92 | # for a TeX installation |
| 66 | latex-package_src_doinstall() { |
93 | latex-package_src_doinstall() { |
| 67 | debug-print function $FUNCNAME $* |
94 | debug-print function $FUNCNAME $* |
| 68 | # This actually follows the directions for a "single-user" system |
95 | # This actually follows the directions for a "single-user" system |
| 69 | # at http://www.ctan.org/installationadvice/ modified for gentoo. |
96 | # at http://www.ctan.org/installationadvice/ modified for gentoo. |
| 70 | [ -z "$1" ] && latex-package_src_install all |
97 | [ -z "$1" ] && latex-package_src_install all |
| … | |
… | |
| 85 | done |
112 | done |
| 86 | ;; |
113 | ;; |
| 87 | "dvi" | "ps" | "pdf") |
114 | "dvi" | "ps" | "pdf") |
| 88 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
115 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
| 89 | do |
116 | do |
| 90 | insinto /usr/share/doc/${P} |
117 | insinto /usr/share/doc/${PF} |
| 91 | doins $i || "doins $i failed" |
118 | doins $i || die "doins $i failed" |
|
|
119 | dosym /usr/share/doc/${PF}/$(basename ${i}) ${TEXMF}/doc/latex/${PN}/${i} |
| 92 | #dodoc -u $i |
120 | #dodoc -u $i |
| 93 | done |
121 | done |
| 94 | ;; |
122 | ;; |
| 95 | "tex" | "dtx") |
123 | "tex" | "dtx") |
| 96 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
124 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
| 97 | do |
125 | do |
| 98 | einfo "Making documentation: $i" |
126 | einfo "Making documentation: $i" |
| 99 | texi2dvi -q -c --language=latex $i &> /dev/null |
127 | texi2dvi -q -c --language=latex $i &> /dev/null |
| 100 | done |
128 | done |
| 101 | ;; |
129 | ;; |
| 102 | "tfm" | "vf" | "afm" | "pfb") |
130 | "tfm" | "vf" | "afm") |
| 103 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
131 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
| 104 | do |
132 | do |
| 105 | insinto ${TEXMF}/fonts/${1}/${SUPPLIER}/${PN} |
133 | insinto ${TEXMF}/fonts/${1}/${SUPPLIER}/${PN} |
|
|
134 | doins $i || die "doins $i failed" |
|
|
135 | done |
|
|
136 | ;; |
|
|
137 | "pfb") |
|
|
138 | for i in `find . -maxdepth 1 -type f -name "*.pfb"` |
|
|
139 | do |
|
|
140 | insinto ${TEXMF}/fonts/type1/${SUPPLIER}/${PN} |
| 106 | doins $i || die "doins $i failed" |
141 | doins $i || die "doins $i failed" |
| 107 | done |
142 | done |
| 108 | ;; |
143 | ;; |
| 109 | "ttf") |
144 | "ttf") |
| 110 | for i in `find . -maxdepth 1 -type f -name "*.ttf"` |
145 | for i in `find . -maxdepth 1 -type f -name "*.ttf"` |
| … | |
… | |
| 138 | esac |
173 | esac |
| 139 | shift |
174 | shift |
| 140 | done |
175 | done |
| 141 | } |
176 | } |
| 142 | |
177 | |
|
|
178 | # @FUNCTION: latex-package_src_compile |
|
|
179 | # @DESCRIPTION: |
|
|
180 | # Calls latex for each *.ins in the current directory in order to generate the |
|
|
181 | # relevant files that will be installed |
| 143 | latex-package_src_compile() { |
182 | latex-package_src_compile() { |
| 144 | debug-print function $FUNCNAME $* |
183 | debug-print function $FUNCNAME $* |
| 145 | for i in `find \`pwd\` -maxdepth 1 -type f -name "*.ins"` |
184 | for i in `find \`pwd\` -maxdepth 1 -type f -name "*.ins"` |
| 146 | do |
185 | do |
| 147 | einfo "Extracting from $i" |
186 | einfo "Extracting from $i" |
| 148 | latex --interaction=batchmode $i &> /dev/null |
187 | latex --interaction=batchmode $i &> /dev/null |
| 149 | done |
188 | done |
| 150 | } |
189 | } |
| 151 | |
190 | |
|
|
191 | # @FUNCTION: latex-package_src_install |
|
|
192 | # @DESCRIPTION: |
|
|
193 | # Installs the package |
| 152 | latex-package_src_install() { |
194 | latex-package_src_install() { |
| 153 | debug-print function $FUNCNAME $* |
195 | debug-print function $FUNCNAME $* |
| 154 | latex-package_src_doinstall all |
196 | latex-package_src_doinstall all |
| 155 | if [ -n "${DOCS}" ] ; then |
197 | if [ -n "${DOCS}" ] ; then |
| 156 | dodoc ${DOCS} |
198 | dodoc ${DOCS} |
| 157 | fi |
199 | fi |
| 158 | } |
200 | } |
| 159 | |
201 | |
|
|
202 | # @FUNCTION: latex-pacakge_pkg_postinst |
|
|
203 | # @DESCRIPTION: |
|
|
204 | # Calls latex-package_rehash to ensure the TeX installation is consistent with |
|
|
205 | # the kpathsea database |
| 160 | latex-package_pkg_postinst() { |
206 | latex-package_pkg_postinst() { |
| 161 | debug-print function $FUNCNAME $* |
207 | debug-print function $FUNCNAME $* |
| 162 | latex-package_rehash |
208 | latex-package_rehash |
| 163 | } |
209 | } |
| 164 | |
210 | |
|
|
211 | # @FUNCTION: latex-package_pkg_postrm |
|
|
212 | # @DESCRIPTION: |
|
|
213 | # Calls latex-package_rehash to ensure the TeX installation is consistent with |
|
|
214 | # the kpathsea database |
| 165 | latex-package_pkg_postrm() { |
215 | latex-package_pkg_postrm() { |
| 166 | debug-print function $FUNCNAME $* |
216 | debug-print function $FUNCNAME $* |
| 167 | latex-package_rehash |
217 | latex-package_rehash |
| 168 | } |
218 | } |
| 169 | |
219 | |
|
|
220 | # @FUNCTION: latex-package_rehash |
|
|
221 | # @DESCRIPTION: |
|
|
222 | # Rehashes the kpathsea database, according to the current TeX installation |
| 170 | latex-package_rehash() { |
223 | latex-package_rehash() { |
| 171 | debug-print function $FUNCNAME $* |
224 | debug-print function $FUNCNAME $* |
| 172 | if latex-package_has_tetex_3 ; then |
225 | if latex-package_has_tetex_3 ; then |
| 173 | texmf-update |
226 | texmf-update |
| 174 | else |
227 | else |
| 175 | texconfig rehash |
228 | texconfig rehash |
| 176 | fi |
229 | fi |
| 177 | } |
230 | } |
| 178 | |
231 | |
| 179 | EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_postrm has_tetex_3 |
232 | EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_postrm |