1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: latex-package.eclass
7 # TeX team <tex@gentoo.org>
9 # Matthew Turk <satai@gentoo.org>
10 # Martin Ehmsen <ehmsen@gentoo.org>
11 # @BLURB: An eclass for easy installation of LaTeX packages
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.
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:
26 # latex-package_src_compile
29 # latex-package_src_compile
35 # latex-package_src_install
38 # latex-package_src_install
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}
46 # For examples of basic installations, check out dev-tex/aastex and
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)
58 RDEPEND="virtual/latex-base"
60 >=sys-apps/texinfo-4.2-r5"
61 HOMEPAGE="http://www.tug.org/"
62 SRC_URI="ftp://tug.ctan.org/macros/latex/"
64 TEXMF="/usr/share/texmf-site"
66 # @ECLASS-VARIABLE: SUPPLIER
68 # This refers to the font supplier; it should be overridden (see eclass
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
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
85 # @FUNCTION: latex-package_src_doinstall
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
93 latex-package_src_doinstall() {
94 debug-print function $FUNCNAME $*
95 # This actually follows the directions for a "single-user" system
96 # at http://www.ctan.org/installationadvice/ modified for gentoo.
97 [ -z "$1" ] && latex-package_src_install all
102 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
104 dobin $i || die "dobin $i failed"
107 "sty" | "cls" | "fd" | "clo" | "def" | "cfg")
108 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
110 insinto ${TEXMF}/tex/latex/${PN}
111 doins $i || die "doins $i failed"
114 "dvi" | "ps" | "pdf")
115 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
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}
123 # prevent compression of symlink target
124 docompress -x /usr/share/doc/${PF}/$(basename ${i})
130 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
132 einfo "Making documentation: $i"
133 texi2dvi -q -c --language=latex $i &> /dev/null
136 "tfm" | "vf" | "afm")
137 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
139 insinto ${TEXMF}/fonts/${1}/${SUPPLIER}/${PN}
140 doins $i || die "doins $i failed"
144 for i in `find . -maxdepth 1 -type f -name "*.pfb"`
146 insinto ${TEXMF}/fonts/type1/${SUPPLIER}/${PN}
147 doins $i || die "doins $i failed"
151 for i in `find . -maxdepth 1 -type f -name "*.ttf"`
153 insinto ${TEXMF}/fonts/truetype/${SUPPLIER}/${PN}
154 doins $i || die "doins $i failed"
158 for i in `find . -maxdepth 1 -type f -name "*.bst"`
160 insinto ${TEXMF}/bibtex/bst/${PN}
161 doins $i || die "doins $i failed"
165 latex-package_src_doinstall sty cls fd clo def cfg bst
168 latex-package_src_doinstall tex dtx dvi ps pdf
171 latex-package_src_doinstall tfm vf afm pfb ttf
174 latex-package_src_doinstall sh
177 latex-package_src_doinstall styles fonts bin doc
184 # @FUNCTION: latex-package_src_compile
186 # Calls latex for each *.ins in the current directory in order to generate the
187 # relevant files that will be installed
188 latex-package_src_compile() {
189 debug-print function $FUNCNAME $*
190 for i in `find \`pwd\` -maxdepth 1 -type f -name "*.ins"`
192 einfo "Extracting from $i"
193 latex --interaction=batchmode $i &> /dev/null
197 # @FUNCTION: latex-package_src_install
199 # Installs the package
200 latex-package_src_install() {
201 debug-print function $FUNCNAME $*
202 latex-package_src_doinstall all
203 if [ -n "${DOCS}" ] ; then
208 # @FUNCTION: latex-package_pkg_postinst
210 # Calls latex-package_rehash to ensure the TeX installation is consistent with
211 # the kpathsea database
212 latex-package_pkg_postinst() {
213 debug-print function $FUNCNAME $*
217 # @FUNCTION: latex-package_pkg_postrm
219 # Calls latex-package_rehash to ensure the TeX installation is consistent with
220 # the kpathsea database
221 latex-package_pkg_postrm() {
222 debug-print function $FUNCNAME $*
226 # @FUNCTION: latex-package_rehash
228 # Rehashes the kpathsea database, according to the current TeX installation
229 latex-package_rehash() {
230 debug-print function $FUNCNAME $*
231 if latex-package_has_tetex_3 ; then
238 EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_postrm