|
|
1 | # Copyright 1999-2008 Gentoo Foundation |
|
|
2 | # Distributed under the terms of the GNU General Public License v2 |
|
|
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/latex-package.eclass,v 1.32 2008/02/17 19:01:31 aballier Exp $ |
|
|
4 | |
|
|
5 | # @ECLASS: latex-package.eclass |
|
|
6 | # @MAINTAINER: |
|
|
7 | # text-markup team <text-markup@gentoo.org> |
|
|
8 | # |
| 1 | # Author Matthew Turk <satai@gentoo.org> |
9 | # Author Matthew Turk <satai@gentoo.org> |
| 2 | # |
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 | DEPEND="virtual/latex-base |
| 48 | >=sys-apps/texinfo-4.2-r5" |
59 | >=sys-apps/texinfo-4.2-r5" |
| 49 | ECLASS=latex-package |
|
|
| 50 | HOMEPAGE="http://www.tug.org/" |
60 | HOMEPAGE="http://www.tug.org/" |
| 51 | SRC_URI="ftp://tug.ctan.org/macros/latex/" |
61 | SRC_URI="ftp://tug.ctan.org/macros/latex/" |
| 52 | S=${WORKDIR}/${P} |
62 | S=${WORKDIR}/${P} |
| 53 | TEXMF="/usr/share/texmf" |
63 | TEXMF="/usr/share/texmf" |
|
|
64 | |
|
|
65 | # @ECLASS-VARIABLE: SUPPLIER |
|
|
66 | # @DESCRIPTION: |
| 54 | SUPPLIER="misc" # This refers to the font supplier; it should be overridden |
67 | # This refers to the font supplier; it should be overridden (see eclass |
|
|
68 | # DESCRIPTION above) |
|
|
69 | SUPPLIER="misc" |
| 55 | |
70 | |
|
|
71 | # @FUNCTION: latex-package_has_tetex3 |
|
|
72 | # @RETURN: true if at least one of (>=tetex-3 or >=ptex-3.1.8 or >=texlive-core-2007) is installed, else false |
|
|
73 | # @DESCRIPTION: |
|
|
74 | # It is often used to know if the current TeX installation supports gentoo's |
|
|
75 | # texmf-update or if the package has to do it the old way |
|
|
76 | latex-package_has_tetex_3() { |
|
|
77 | if has_version '>=app-text/tetex-3' || has_version '>=app-text/ptex-3.1.8' || has_version '>=app-text/texlive-core-2007' ; then |
|
|
78 | true |
|
|
79 | else |
|
|
80 | false |
|
|
81 | fi |
|
|
82 | } |
|
|
83 | |
|
|
84 | # @FUNCTION: latex-package_src_doinstall |
|
|
85 | # @USAGE: [ module ] |
|
|
86 | # @DESCRIPTION: |
|
|
87 | # [module] can be one or more of: sh, sty, cls, fd, clo, def, cfg, dvi, ps, pdf, |
|
|
88 | # tex, dtx, tfm, vf, afm, pfb, ttf, bst, styles, doc, fonts, bin, or all. |
|
|
89 | # If [module] is not given, all is assumed. |
|
|
90 | # It installs the files found in the current directory to the standard locations |
|
|
91 | # for a TeX installation |
| 56 | latex-package_src_doinstall() { |
92 | latex-package_src_doinstall() { |
| 57 | debug-print function $FUNCNAME $* |
93 | debug-print function $FUNCNAME $* |
| 58 | # This actually follows the directions for a "single-user" system |
94 | # This actually follows the directions for a "single-user" system |
| 59 | # at http://www.ctan.org/installationadvice/ modified for gentoo. |
95 | # at http://www.ctan.org/installationadvice/ modified for gentoo. |
| 60 | [ -z "$1" ] && latex-package_src_install all |
96 | [ -z "$1" ] && latex-package_src_install all |
| 61 | |
97 | |
| 62 | while [ "$1" ]; do |
98 | while [ "$1" ]; do |
| 63 | case $1 in |
99 | case $1 in |
| 64 | "sh") |
100 | "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 | insinto /usr/share/doc/${P} |
|
|
| 81 | doins $i |
|
|
| 82 | #dodoc -u $i |
|
|
| 83 | done |
|
|
| 84 | ;; |
|
|
| 85 | "tex" | "dtx") |
|
|
| 86 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
101 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
| 87 | do |
102 | do |
| 88 | echo "Making documentation: $i" |
103 | dobin $i || die "dobin $i failed" |
| 89 | texi2dvi -q -c --language=latex $i |
104 | done |
| 90 | done |
105 | ;; |
| 91 | ;; |
106 | "sty" | "cls" | "fd" | "clo" | "def" | "cfg") |
| 92 | "tfm" | "vf" | "afm" | "pfb") |
|
|
| 93 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
107 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
| 94 | do |
108 | do |
|
|
109 | insinto ${TEXMF}/tex/latex/${PN} |
|
|
110 | doins $i || die "doins $i failed" |
|
|
111 | done |
|
|
112 | ;; |
|
|
113 | "dvi" | "ps" | "pdf") |
|
|
114 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
|
|
115 | do |
|
|
116 | insinto /usr/share/doc/${P} |
|
|
117 | doins $i || "doins $i failed" |
|
|
118 | #dodoc -u $i |
|
|
119 | done |
|
|
120 | ;; |
|
|
121 | "tex" | "dtx") |
|
|
122 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
|
|
123 | do |
|
|
124 | einfo "Making documentation: $i" |
|
|
125 | texi2dvi -q -c --language=latex $i &> /dev/null |
|
|
126 | done |
|
|
127 | ;; |
|
|
128 | "tfm" | "vf" | "afm") |
|
|
129 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
|
|
130 | do |
| 95 | insinto ${TEXMF}/fonts/${1}/${SUPPLIER}/${PN} |
131 | insinto ${TEXMF}/fonts/${1}/${SUPPLIER}/${PN} |
| 96 | doins $i |
132 | doins $i || die "doins $i failed" |
| 97 | done |
133 | done |
| 98 | ;; |
134 | ;; |
| 99 | "ttf") |
135 | "pfb") |
|
|
136 | for i in `find . -maxdepth 1 -type f -name "*.pfb"` |
|
|
137 | do |
|
|
138 | insinto ${TEXMF}/fonts/type1/${SUPPLIER}/${PN} |
|
|
139 | doins $i || die "doins $i failed" |
|
|
140 | done |
|
|
141 | ;; |
|
|
142 | "ttf") |
| 100 | for i in `find . -maxdepth 1 -type f -name "*.ttf"` |
143 | for i in `find . -maxdepth 1 -type f -name "*.ttf"` |
| 101 | do |
144 | do |
| 102 | insinto ${TEXMF}/fonts/truetype/${SUPPLIER}/${PN} |
145 | insinto ${TEXMF}/fonts/truetype/${SUPPLIER}/${PN} |
| 103 | doins $i |
146 | doins $i || die "doins $i failed" |
| 104 | done |
147 | done |
| 105 | ;; |
148 | ;; |
| 106 | "styles") |
149 | "bst") |
|
|
150 | for i in `find . -maxdepth 1 -type f -name "*.bst"` |
|
|
151 | do |
|
|
152 | insinto ${TEXMF}/bibtex/bst/${PN} |
|
|
153 | doins $i || die "doins $i failed" |
|
|
154 | done |
|
|
155 | ;; |
|
|
156 | "styles") |
| 107 | latex-package_src_doinstall sty cls fd clo def |
157 | latex-package_src_doinstall sty cls fd clo def cfg bst |
| 108 | ;; |
158 | ;; |
| 109 | "doc") |
159 | "doc") |
| 110 | latex-package_src_doinstall tex dtx dvi ps pdf |
160 | latex-package_src_doinstall tex dtx dvi ps pdf |
| 111 | ;; |
161 | ;; |
| 112 | "fonts") |
162 | "fonts") |
| 113 | latex-package_src_doinstall tfm vg afm pfb ttf |
163 | latex-package_src_doinstall tfm vf afm pfb ttf |
| 114 | ;; |
164 | ;; |
| 115 | "bin") |
165 | "bin") |
| 116 | latex-package_src_doinstall sh |
166 | latex-package_src_doinstall sh |
| 117 | ;; |
167 | ;; |
| 118 | "all") |
168 | "all") |
| 119 | latex-package_src_doinstall styles fonts bin doc |
169 | latex-package_src_doinstall styles fonts bin doc |
| 120 | ;; |
170 | ;; |
| 121 | esac |
171 | esac |
| 122 | shift |
172 | shift |
| 123 | done |
173 | done |
| 124 | } |
174 | } |
| 125 | |
175 | |
|
|
176 | # @FUNCTION: latex-package_src_compile |
|
|
177 | # @DESCRIPTION: |
|
|
178 | # Calls latex for each *.ins in the current directory in order to generate the |
|
|
179 | # relevant files that will be installed |
| 126 | latex-package_src_compile() { |
180 | latex-package_src_compile() { |
| 127 | debug-print function $FUNCNAME $* |
181 | debug-print function $FUNCNAME $* |
| 128 | cd ${S} |
|
|
| 129 | for i in `find \`pwd\` -maxdepth 1 -type f -name "*.ins"` |
182 | for i in `find \`pwd\` -maxdepth 1 -type f -name "*.ins"` |
| 130 | do |
183 | do |
| 131 | echo "Extracting from $i" |
184 | einfo "Extracting from $i" |
| 132 | latex --interaction=batchmode $i > /dev/null |
185 | latex --interaction=batchmode $i &> /dev/null |
| 133 | done |
186 | done |
| 134 | } |
187 | } |
| 135 | |
188 | |
|
|
189 | # @FUNCTION: latex-package_src_install |
|
|
190 | # @DESCRIPTION: |
|
|
191 | # Installs the package |
| 136 | latex-package_src_install() { |
192 | latex-package_src_install() { |
| 137 | debug-print function $FUNCNAME $* |
193 | debug-print function $FUNCNAME $* |
| 138 | cd ${S} |
|
|
| 139 | latex-package_src_doinstall all |
194 | latex-package_src_doinstall all |
|
|
195 | if [ -n "${DOCS}" ] ; then |
|
|
196 | dodoc ${DOCS} |
|
|
197 | fi |
| 140 | } |
198 | } |
| 141 | |
199 | |
|
|
200 | # @FUNCTION: latex-pacakge_pkg_postinst |
|
|
201 | # @DESCRIPTION: |
|
|
202 | # Calls latex-package_rehash to ensure the TeX installation is consistent with |
|
|
203 | # the kpathsea database |
| 142 | latex-package_pkg_postinst() { |
204 | latex-package_pkg_postinst() { |
| 143 | debug-print function $FUNCNAME $* |
205 | debug-print function $FUNCNAME $* |
| 144 | latex-package_rehash |
206 | latex-package_rehash |
| 145 | } |
207 | } |
| 146 | |
208 | |
|
|
209 | # @FUNCTION: latex-package_pkg_postrm |
|
|
210 | # @DESCRIPTION: |
|
|
211 | # Calls latex-package_rehash to ensure the TeX installation is consistent with |
|
|
212 | # the kpathsea database |
| 147 | latex-package_pkg_postrm() { |
213 | latex-package_pkg_postrm() { |
| 148 | debug-print function $FUNCNAME $* |
214 | debug-print function $FUNCNAME $* |
| 149 | latex-package_rehash |
215 | latex-package_rehash |
| 150 | } |
216 | } |
| 151 | |
217 | |
|
|
218 | # @FUNCTION: latex-package_rehash |
|
|
219 | # @DESCRIPTION: |
|
|
220 | # Rehashes the kpathsea database, according to the current TeX installation |
| 152 | latex-package_rehash() { |
221 | latex-package_rehash() { |
| 153 | debug-print function $FUNCNAME $* |
222 | debug-print function $FUNCNAME $* |
|
|
223 | if latex-package_has_tetex_3 ; then |
|
|
224 | texmf-update |
|
|
225 | else |
| 154 | texconfig rehash |
226 | texconfig rehash |
|
|
227 | fi |
| 155 | } |
228 | } |
| 156 | |
229 | |
| 157 | EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_postrm |
230 | EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_postrm |