| 1 | # Author Matthew Turk <m-turk@nwu.edu> |
1 | # Copyright 1999-2008 Gentoo Foundation |
| 2 | # An ebuild calling this class can cd to the appropriate |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # directory and call latex-package_src_doinstall all, or leave |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/latex-package.eclass,v 1.34 2008/07/19 09:22:54 tove Exp $ |
| 4 | # the src_install function as-is if the system is single-directory. |
4 | |
|
|
5 | # @ECLASS: latex-package.eclass |
|
|
6 | # @MAINTAINER: |
|
|
7 | # TeX team <tex@gentoo.org> |
|
|
8 | # |
|
|
9 | # Author Matthew Turk <satai@gentoo.org> |
|
|
10 | # Martin Ehmsen <ehmsen@gentoo.org> |
|
|
11 | # @BLURB: An eclass for easy installation of LaTeX packages |
|
|
12 | # @DESCRIPTION: |
|
|
13 | # This eClass is designed to be easy to use and implement. The vast majority of |
|
|
14 | # LaTeX packages will only need to define SRC_URI (and sometimes S) for a |
|
|
15 | # successful installation. If fonts need to be installed, then the variable |
|
|
16 | # SUPPLIER must also be defined. |
|
|
17 | # |
|
|
18 | # However, those packages that contain subdirectories must process each |
|
|
19 | # subdirectory individually. For example, a package that contains directories |
|
|
20 | # DIR1 and DIR2 must call latex-package_src_compile() and |
|
|
21 | # latex-package_src_install() in each directory, as shown here: |
|
|
22 | # |
|
|
23 | # src_compile() { |
|
|
24 | # cd ${S} |
|
|
25 | # cd DIR1 |
|
|
26 | # latex-package_src_compile |
|
|
27 | # cd .. |
|
|
28 | # cd DIR2 |
|
|
29 | # latex-package_src_compile |
|
|
30 | # } |
|
|
31 | # |
|
|
32 | # src_install() { |
|
|
33 | # cd ${S} |
|
|
34 | # cd DIR1 |
|
|
35 | # latex-package_src_install |
|
|
36 | # cd .. |
|
|
37 | # cd DIR2 |
|
|
38 | # latex-package_src_install |
|
|
39 | # } |
|
|
40 | # |
|
|
41 | # The eClass automatically takes care of rehashing TeX's cache (ls-lR) after |
|
|
42 | # installation and after removal, as well as creating final documentation from |
|
|
43 | # TeX files that come with the source. Note that we break TeX layout standards |
|
|
44 | # by placing documentation in /usr/share/doc/${PN} |
|
|
45 | # |
|
|
46 | # For examples of basic installations, check out dev-tex/aastex and |
|
|
47 | # dev-tex/leaflet . |
|
|
48 | # |
|
|
49 | # NOTE: The CTAN "directory grab" function creates files with different MD5 |
|
|
50 | # signatures EVERY TIME. For this reason, if you are grabbing from the CTAN, |
|
|
51 | # you must either grab each file individually, or find a place to mirror an |
|
|
52 | # archive of them. (iBiblio) |
|
|
53 | # |
|
|
54 | # It inherits base. |
| 5 | |
55 | |
| 6 | inherit base |
56 | inherit base |
| 7 | INHERITED="$INHERITED $ECLASS" |
|
|
| 8 | |
57 | |
| 9 | newdepend ">=app-text/tetex-1.0.7" |
58 | DEPEND="virtual/latex-base |
| 10 | ECLASS=latex-package |
59 | >=sys-apps/texinfo-4.2-r5" |
| 11 | HOMEPAGE="http://www.tug.org/" |
60 | HOMEPAGE="http://www.tug.org/" |
| 12 | SRC_URI="ftp://tug.ctan.org/macros/latex/" |
61 | SRC_URI="ftp://tug.ctan.org/macros/latex/" |
| 13 | S=${WORKDIR}/${P} |
62 | S=${WORKDIR}/${P} |
| 14 | TEXMF="/usr/share/texmf" |
63 | TEXMF="/usr/share/texmf" |
|
|
64 | |
|
|
65 | # @ECLASS-VARIABLE: SUPPLIER |
|
|
66 | # @DESCRIPTION: |
| 15 | 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" |
| 16 | |
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 |
| 17 | latex-package_src_doinstall() { |
92 | latex-package_src_doinstall() { |
| 18 | debug-print function $FUNCNAME $* |
93 | debug-print function $FUNCNAME $* |
| 19 | # This actually follows the directions for a "single-user" system |
94 | # This actually follows the directions for a "single-user" system |
| 20 | # at http://www.ctan.org/installationadvice/ modified for gentoo. |
95 | # at http://www.ctan.org/installationadvice/ modified for gentoo. |
| 21 | [ -z "$1" ] && latex-package_src_install all |
96 | [ -z "$1" ] && latex-package_src_install all |
| 22 | |
97 | |
| 23 | while [ "$1" ]; do |
98 | while [ "$1" ]; do |
| 24 | case $1 in |
99 | case $1 in |
| 25 | "sh") |
100 | "sh") |
| 26 | for i in `find . -maxdepth 1 -name "*.${1}"` |
101 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
| 27 | do |
102 | do |
| 28 | dobin $i |
103 | dobin $i || die "dobin $i failed" |
| 29 | done |
104 | done |
| 30 | ;; |
105 | ;; |
| 31 | "sty" | "cls" | "fd") |
106 | "sty" | "cls" | "fd" | "clo" | "def" | "cfg") |
| 32 | for i in `find . -maxdepth 1 -name "*.${1}"` |
107 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
| 33 | do |
108 | do |
| 34 | insinto ${TEXMF}/tex/latex/${PN} |
109 | insinto ${TEXMF}/tex/latex/${PN} |
| 35 | doins $i |
110 | doins $i || die "doins $i failed" |
| 36 | done |
111 | done |
| 37 | ;; |
112 | ;; |
| 38 | "dvi" | "ps" | "pdf" | "tex") |
113 | "dvi" | "ps" | "pdf") |
| 39 | for i in `find . -maxdepth 1 -name "*.${1}"` |
114 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
| 40 | do |
115 | do |
| 41 | insinto ${TEXMF}/doc/latex/${PN} |
116 | insinto /usr/share/doc/${P} |
| 42 | doins $i |
117 | doins $i || die "doins $i failed" |
| 43 | done |
118 | #dodoc -u $i |
| 44 | ;; |
119 | done |
| 45 | "tfm" | "vf" | "afm" | "pfb") |
120 | ;; |
|
|
121 | "tex" | "dtx") |
| 46 | for i in `find . -maxdepth 1 -name "*.${1}"` |
122 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
| 47 | do |
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 |
| 48 | insinto ${TEXMF}/fonts/${1}/${SUPPLIER}/${PN} |
131 | insinto ${TEXMF}/fonts/${1}/${SUPPLIER}/${PN} |
| 49 | doins $i |
132 | doins $i || die "doins $i failed" |
| 50 | done |
133 | done |
| 51 | ;; |
134 | ;; |
| 52 | "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") |
| 53 | for i in `find . -maxdepth 1 -name "*.ttf"` |
143 | for i in `find . -maxdepth 1 -type f -name "*.ttf"` |
| 54 | do |
144 | do |
| 55 | insinto ${TEXMF}/fonts/truetype/${SUPPLIER}/${PN} |
145 | insinto ${TEXMF}/fonts/truetype/${SUPPLIER}/${PN} |
| 56 | doins $i |
146 | doins $i || die "doins $i failed" |
| 57 | done |
147 | done |
| 58 | ;; |
148 | ;; |
| 59 | "styles") |
149 | "bst") |
| 60 | latex-package_src_doinstall sty cls fd |
150 | for i in `find . -maxdepth 1 -type f -name "*.bst"` |
| 61 | ;; |
151 | do |
| 62 | "doc") |
152 | insinto ${TEXMF}/bibtex/bst/${PN} |
| 63 | latex-package_src_doinstall dvi ps pdf tex |
153 | doins $i || die "doins $i failed" |
| 64 | ;; |
154 | done |
| 65 | "fonts") |
155 | ;; |
|
|
156 | "styles") |
|
|
157 | latex-package_src_doinstall sty cls fd clo def cfg bst |
|
|
158 | ;; |
|
|
159 | "doc") |
|
|
160 | latex-package_src_doinstall tex dtx dvi ps pdf |
|
|
161 | ;; |
|
|
162 | "fonts") |
| 66 | latex-package_src_doinstall tfm vg afm pfb ttf |
163 | latex-package_src_doinstall tfm vf afm pfb ttf |
| 67 | ;; |
164 | ;; |
| 68 | "bin") |
165 | "bin") |
| 69 | latex-package_src_doinstall sh |
166 | latex-package_src_doinstall sh |
| 70 | ;; |
167 | ;; |
| 71 | "all") |
168 | "all") |
| 72 | latex-package_src_doinstall styles doc fonts bin |
169 | latex-package_src_doinstall styles fonts bin doc |
| 73 | ;; |
170 | ;; |
| 74 | esac |
171 | esac |
| 75 | shift |
172 | shift |
| 76 | done |
173 | done |
| 77 | } |
174 | } |
| 78 | |
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 |
| 79 | latex-package_src_compile() { |
180 | latex-package_src_compile() { |
| 80 | debug-print function $FUNCNAME $* |
181 | debug-print function $FUNCNAME $* |
| 81 | cd ${S} |
|
|
| 82 | for i in `find \`pwd\` -maxdepth 1 -name "*.ins"` |
182 | for i in `find \`pwd\` -maxdepth 1 -type f -name "*.ins"` |
| 83 | do |
183 | do |
| 84 | echo "Extracting from $i" |
184 | einfo "Extracting from $i" |
| 85 | latex --interaction=batchmode $i > /dev/null |
185 | latex --interaction=batchmode $i &> /dev/null |
| 86 | done |
186 | done |
| 87 | for i in `find \`pwd\` -maxdepth 1 -name "*.dtx"` |
|
|
| 88 | do |
|
|
| 89 | echo "Extracting from $i" |
|
|
| 90 | latex --interaction=batchmode $i > /dev/null |
|
|
| 91 | done |
|
|
| 92 | } |
187 | } |
| 93 | |
188 | |
|
|
189 | # @FUNCTION: latex-package_src_install |
|
|
190 | # @DESCRIPTION: |
|
|
191 | # Installs the package |
| 94 | latex-package_src_install() { |
192 | latex-package_src_install() { |
| 95 | debug-print function $FUNCNAME $* |
193 | debug-print function $FUNCNAME $* |
| 96 | cd ${S} |
|
|
| 97 | latex-package_src_doinstall all |
194 | latex-package_src_doinstall all |
|
|
195 | if [ -n "${DOCS}" ] ; then |
|
|
196 | dodoc ${DOCS} |
|
|
197 | fi |
| 98 | } |
198 | } |
| 99 | |
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 |
| 100 | latex-package_pkg_postinst() { |
204 | latex-package_pkg_postinst() { |
| 101 | debug-print function $FUNCNAME $* |
205 | debug-print function $FUNCNAME $* |
| 102 | latex-package_rehash |
206 | latex-package_rehash |
| 103 | if [ ! -e ${TEXMF}/doc/latex/${PN} ] ; then return ; fi |
|
|
| 104 | cd ${TEXMF}/doc/latex/${PN} |
|
|
| 105 | latex-package_make_documentation |
|
|
| 106 | } |
207 | } |
| 107 | |
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 |
| 108 | latex-package_pkg_postrm() { |
213 | latex-package_pkg_postrm() { |
| 109 | debug-print function $FUNCNAME $* |
214 | debug-print function $FUNCNAME $* |
| 110 | # This may be a bit harsh, so perhaps it should be overridden. |
|
|
| 111 | latex-package_rehash |
215 | latex-package_rehash |
| 112 | if [ ! -e ${TEXMF}/doc/latex/${PN} ] ; then return ; fi |
|
|
| 113 | echo "Removing stale documentation: ${TEXMF}/doc/latex/${PN}" |
|
|
| 114 | rm -rf ${TEXMF}/doc/latex/${PN} |
|
|
| 115 | } |
216 | } |
| 116 | |
217 | |
|
|
218 | # @FUNCTION: latex-package_rehash |
|
|
219 | # @DESCRIPTION: |
|
|
220 | # Rehashes the kpathsea database, according to the current TeX installation |
| 117 | latex-package_rehash() { |
221 | latex-package_rehash() { |
| 118 | debug-print function $FUNCNAME $* |
222 | debug-print function $FUNCNAME $* |
|
|
223 | if latex-package_has_tetex_3 ; then |
|
|
224 | texmf-update |
|
|
225 | else |
| 119 | texconfig rehash |
226 | texconfig rehash |
| 120 | } |
227 | fi |
| 121 | |
|
|
| 122 | latex-package_make_documentation() { |
|
|
| 123 | debug-print function $FUNCNAME $* |
|
|
| 124 | # This has to come after the installation of all our files. |
|
|
| 125 | # All errors will be discarded. |
|
|
| 126 | for i in `find \`pwd\` -maxdepth 1 -name "*.tex"` |
|
|
| 127 | do |
|
|
| 128 | # Note - we rerun twice to get references properly. |
|
|
| 129 | echo "Making Documentation: $i" |
|
|
| 130 | latex --interaction=batchmode $i > /dev/null |
|
|
| 131 | done |
|
|
| 132 | echo "Completed." |
|
|
| 133 | } |
228 | } |
| 134 | |
229 | |
| 135 | EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_postrm |
230 | EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_postrm |