| 1 | # Author Matthew Turk <m-turk@nwu.edu> |
1 | # Copyright 1999-2011 Gentoo Foundation |
| 2 | # |
2 | # Distributed under the terms of the GNU General Public License v2 |
|
|
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/latex-package.eclass,v 1.39 2011/08/22 04:46:32 vapier Exp $ |
|
|
4 | |
|
|
5 | # @ECLASS: latex-package.eclass |
|
|
6 | # @MAINTAINER: |
|
|
7 | # TeX team <tex@gentoo.org> |
|
|
8 | # @AUTHOR: |
|
|
9 | # Matthew Turk <satai@gentoo.org> |
|
|
10 | # Martin Ehmsen <ehmsen@gentoo.org> |
|
|
11 | # @BLURB: An eclass for easy installation of LaTeX packages |
|
|
12 | # @DESCRIPTION: |
| 3 | # 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 |
| 4 | # 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 |
| 5 | # successful installation. If fonts need to be installed, then the variable |
15 | # successful installation. If fonts need to be installed, then the variable |
| 6 | # SUPPLIER must also be defined. |
16 | # SUPPLIER must also be defined. |
| 7 | # |
17 | # |
| … | |
… | |
| 28 | # latex-package_src_install |
38 | # latex-package_src_install |
| 29 | # } |
39 | # } |
| 30 | # |
40 | # |
| 31 | # 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 |
| 32 | # installation and after removal, as well as creating final documentation from |
42 | # installation and after removal, as well as creating final documentation from |
| 33 | # 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 |
| 34 | # by placing documentation in /usr/share/doc/${PN} |
44 | # by placing documentation in /usr/share/doc/${PN} |
| 35 | # |
45 | # |
| 36 | # For examples of basic installations, check out app-text/latex-aastex and |
46 | # For examples of basic installations, check out dev-tex/aastex and |
| 37 | # app-text/latex-leaflet. |
47 | # dev-tex/leaflet . |
| 38 | # |
48 | # |
| 39 | # NOTE: The CTAN "directory grab" function creates files with different MD5 |
49 | # NOTE: The CTAN "directory grab" function creates files with different MD5 |
| 40 | # 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, |
| 41 | # 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 |
| 42 | # archive of them. (iBiblio) |
52 | # archive of them. (iBiblio) |
|
|
53 | # |
|
|
54 | # It inherits base. |
| 43 | |
55 | |
| 44 | inherit base |
56 | inherit base |
| 45 | INHERITED="$INHERITED $ECLASS" |
|
|
| 46 | |
57 | |
| 47 | newdepend ">=app-text/tetex-1.0.7 |
58 | RDEPEND="virtual/latex-base" |
|
|
59 | DEPEND="${RDEPEND} |
| 48 | >=sys-apps/texinfo-4.2-r5" |
60 | >=sys-apps/texinfo-4.2-r5" |
| 49 | ECLASS=latex-package |
|
|
| 50 | HOMEPAGE="http://www.tug.org/" |
61 | HOMEPAGE="http://www.tug.org/" |
| 51 | SRC_URI="ftp://tug.ctan.org/macros/latex/" |
62 | SRC_URI="ftp://tug.ctan.org/macros/latex/" |
| 52 | S=${WORKDIR}/${P} |
63 | S=${WORKDIR}/${P} |
| 53 | TEXMF="/usr/share/texmf" |
64 | TEXMF="/usr/share/texmf" |
|
|
65 | |
|
|
66 | # @ECLASS-VARIABLE: SUPPLIER |
|
|
67 | # @DESCRIPTION: |
| 54 | 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" |
| 55 | |
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 |
|
|
77 | latex-package_has_tetex_3() { |
|
|
78 | if has_version '>=app-text/tetex-3' || has_version '>=app-text/ptex-3.1.8' || has_version '>=app-text/texlive-core-2007' ; then |
|
|
79 | true |
|
|
80 | else |
|
|
81 | false |
|
|
82 | fi |
|
|
83 | } |
|
|
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 |
| 56 | latex-package_src_doinstall() { |
93 | latex-package_src_doinstall() { |
| 57 | debug-print function $FUNCNAME $* |
94 | debug-print function $FUNCNAME $* |
| 58 | # This actually follows the directions for a "single-user" system |
95 | # This actually follows the directions for a "single-user" system |
| 59 | # at http://www.ctan.org/installationadvice/ modified for gentoo. |
96 | # at http://www.ctan.org/installationadvice/ modified for gentoo. |
| 60 | [ -z "$1" ] && latex-package_src_install all |
97 | [ -z "$1" ] && latex-package_src_install all |
| 61 | |
98 | |
| 62 | while [ "$1" ]; do |
99 | while [ "$1" ]; do |
| 63 | case $1 in |
100 | case $1 in |
| 64 | "sh") |
101 | "sh") |
| 65 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
|
|
| 66 | do |
|
|
| 67 | dobin $i |
|
|
| 68 | done |
|
|
| 69 | ;; |
|
|
| 70 | "sty" | "cls" | "fd" | "clo" | "def") |
|
|
| 71 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
|
|
| 72 | do |
|
|
| 73 | insinto ${TEXMF}/tex/latex/${PN} |
|
|
| 74 | doins $i |
|
|
| 75 | done |
|
|
| 76 | ;; |
|
|
| 77 | "dvi" | "ps" | "pdf") |
|
|
| 78 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
|
|
| 79 | do |
|
|
| 80 | dodoc $i |
|
|
| 81 | done |
|
|
| 82 | ;; |
|
|
| 83 | "tex" | "dtx") |
|
|
| 84 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
102 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
| 85 | do |
103 | do |
|
|
104 | dobin $i || die "dobin $i failed" |
|
|
105 | done |
|
|
106 | ;; |
|
|
107 | "sty" | "cls" | "fd" | "clo" | "def" | "cfg") |
|
|
108 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
|
|
109 | do |
|
|
110 | insinto ${TEXMF}/tex/latex/${PN} |
|
|
111 | doins $i || die "doins $i failed" |
|
|
112 | done |
|
|
113 | ;; |
|
|
114 | "dvi" | "ps" | "pdf") |
|
|
115 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
|
|
116 | do |
|
|
117 | insinto /usr/share/doc/${PF} |
|
|
118 | doins $i || die "doins $i failed" |
|
|
119 | dosym /usr/share/doc/${PF}/$(basename ${i}) ${TEXMF}/doc/latex/${PN}/${i} |
|
|
120 | #dodoc -u $i |
|
|
121 | done |
|
|
122 | ;; |
|
|
123 | "tex" | "dtx") |
|
|
124 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
|
|
125 | do |
|
|
126 | einfo "Making documentation: $i" |
| 86 | texi2dvi -q -c --language=latex $i |
127 | texi2dvi -q -c --language=latex $i &> /dev/null |
|
|
128 | done |
|
|
129 | ;; |
|
|
130 | "tfm" | "vf" | "afm") |
|
|
131 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
|
|
132 | do |
|
|
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} |
|
|
141 | doins $i || die "doins $i failed" |
|
|
142 | done |
|
|
143 | ;; |
|
|
144 | "ttf") |
|
|
145 | for i in `find . -maxdepth 1 -type f -name "*.ttf"` |
|
|
146 | do |
|
|
147 | insinto ${TEXMF}/fonts/truetype/${SUPPLIER}/${PN} |
|
|
148 | doins $i || die "doins $i failed" |
|
|
149 | done |
|
|
150 | ;; |
|
|
151 | "bst") |
|
|
152 | for i in `find . -maxdepth 1 -type f -name "*.bst"` |
|
|
153 | do |
|
|
154 | insinto ${TEXMF}/bibtex/bst/${PN} |
|
|
155 | doins $i || die "doins $i failed" |
|
|
156 | done |
|
|
157 | ;; |
|
|
158 | "styles") |
|
|
159 | latex-package_src_doinstall sty cls fd clo def cfg bst |
|
|
160 | ;; |
|
|
161 | "doc") |
|
|
162 | latex-package_src_doinstall tex dtx dvi ps pdf |
|
|
163 | ;; |
|
|
164 | "fonts") |
|
|
165 | latex-package_src_doinstall tfm vf afm pfb ttf |
|
|
166 | ;; |
|
|
167 | "bin") |
|
|
168 | latex-package_src_doinstall sh |
|
|
169 | ;; |
|
|
170 | "all") |
|
|
171 | latex-package_src_doinstall styles fonts bin doc |
|
|
172 | ;; |
|
|
173 | esac |
|
|
174 | shift |
| 87 | done |
175 | done |
| 88 | ;; |
|
|
| 89 | "tfm" | "vf" | "afm" | "pfb") |
|
|
| 90 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
|
|
| 91 | do |
|
|
| 92 | insinto ${TEXMF}/fonts/${1}/${SUPPLIER}/${PN} |
|
|
| 93 | doins $i |
|
|
| 94 | done |
|
|
| 95 | ;; |
|
|
| 96 | "ttf") |
|
|
| 97 | for i in `find . -maxdepth 1 -type f -name "*.ttf"` |
|
|
| 98 | do |
|
|
| 99 | insinto ${TEXMF}/fonts/truetype/${SUPPLIER}/${PN} |
|
|
| 100 | doins $i |
|
|
| 101 | done |
|
|
| 102 | ;; |
|
|
| 103 | "styles") |
|
|
| 104 | latex-package_src_doinstall sty cls fd clo def |
|
|
| 105 | ;; |
|
|
| 106 | "doc") |
|
|
| 107 | latex-package_src_doinstall tex dtx dvi ps pdf |
|
|
| 108 | ;; |
|
|
| 109 | "fonts") |
|
|
| 110 | latex-package_src_doinstall tfm vg afm pfb ttf |
|
|
| 111 | ;; |
|
|
| 112 | "bin") |
|
|
| 113 | latex-package_src_doinstall sh |
|
|
| 114 | ;; |
|
|
| 115 | "all") |
|
|
| 116 | latex-package_src_doinstall styles doc fonts bin |
|
|
| 117 | ;; |
|
|
| 118 | esac |
|
|
| 119 | shift |
|
|
| 120 | done |
|
|
| 121 | } |
176 | } |
| 122 | |
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 |
| 123 | latex-package_src_compile() { |
182 | latex-package_src_compile() { |
| 124 | debug-print function $FUNCNAME $* |
183 | debug-print function $FUNCNAME $* |
| 125 | cd ${S} |
|
|
| 126 | for i in `find \`pwd\` -maxdepth 1 -type f -name "*.ins"` |
184 | for i in `find \`pwd\` -maxdepth 1 -type f -name "*.ins"` |
| 127 | do |
185 | do |
| 128 | echo "Extracting from $i" |
186 | einfo "Extracting from $i" |
| 129 | latex --interaction=batchmode $i > /dev/null |
187 | latex --interaction=batchmode $i &> /dev/null |
| 130 | done |
188 | done |
| 131 | } |
189 | } |
| 132 | |
190 | |
|
|
191 | # @FUNCTION: latex-package_src_install |
|
|
192 | # @DESCRIPTION: |
|
|
193 | # Installs the package |
| 133 | latex-package_src_install() { |
194 | latex-package_src_install() { |
| 134 | debug-print function $FUNCNAME $* |
195 | debug-print function $FUNCNAME $* |
| 135 | cd ${S} |
|
|
| 136 | latex-package_src_doinstall all |
196 | latex-package_src_doinstall all |
|
|
197 | if [ -n "${DOCS}" ] ; then |
|
|
198 | dodoc ${DOCS} |
|
|
199 | fi |
| 137 | } |
200 | } |
| 138 | |
201 | |
|
|
202 | # @FUNCTION: latex-package_pkg_postinst |
|
|
203 | # @DESCRIPTION: |
|
|
204 | # Calls latex-package_rehash to ensure the TeX installation is consistent with |
|
|
205 | # the kpathsea database |
| 139 | latex-package_pkg_postinst() { |
206 | latex-package_pkg_postinst() { |
| 140 | debug-print function $FUNCNAME $* |
207 | debug-print function $FUNCNAME $* |
| 141 | latex-package_rehash |
208 | latex-package_rehash |
| 142 | } |
209 | } |
| 143 | |
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 |
| 144 | latex-package_pkg_postrm() { |
215 | latex-package_pkg_postrm() { |
| 145 | debug-print function $FUNCNAME $* |
216 | debug-print function $FUNCNAME $* |
| 146 | latex-package_rehash |
217 | latex-package_rehash |
| 147 | } |
218 | } |
| 148 | |
219 | |
|
|
220 | # @FUNCTION: latex-package_rehash |
|
|
221 | # @DESCRIPTION: |
|
|
222 | # Rehashes the kpathsea database, according to the current TeX installation |
| 149 | latex-package_rehash() { |
223 | latex-package_rehash() { |
| 150 | debug-print function $FUNCNAME $* |
224 | debug-print function $FUNCNAME $* |
|
|
225 | if latex-package_has_tetex_3 ; then |
|
|
226 | texmf-update |
|
|
227 | else |
| 151 | texconfig rehash |
228 | texconfig rehash |
|
|
229 | fi |
| 152 | } |
230 | } |
| 153 | |
231 | |
| 154 | EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_postrm |
232 | EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_postrm |