1 # Copyright 1999-2016 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)
54 # It inherits base and eutils in EAPI 5 and earlier.
57 0|1|2|3|4|5) inherit base eutils ;;
59 *) die "Unknown EAPI ${EAPI} for ${ECLASS}" ;;
62 RDEPEND="virtual/latex-base"
64 >=sys-apps/texinfo-4.2-r5"
65 HOMEPAGE="http://www.tug.org/"
66 TEXMF="/usr/share/texmf-site"
68 # @ECLASS-VARIABLE: SUPPLIER
70 # This refers to the font supplier; it should be overridden (see eclass
74 # @ECLASS-VARIABLE: LATEX_DOC_ARGUMENTS
76 # When compiling documentation (.tex/.dtx), this variable will be passed
77 # to pdflatex as additional argument (e.g. -shell-escape). This variable
78 # must be set after inherit, as it gets automatically cleared otherwise.
79 LATEX_DOC_ARGUMENTS=""
81 # Kept for backwards compatibility
82 latex-package_has_tetex_3() {
84 0|1|2|3|4|5) return 0 ;;
85 *) die "${FUNCNAME} no longer supported in EAPI ${EAPI}" ;;
89 # @FUNCTION: latex-package_src_doinstall
92 # [module] can be one or more of: sh, sty, cls, fd, clo, def, cfg, dvi, ps, pdf,
93 # tex, dtx, tfm, vf, afm, pfb, ttf, bst, styles, doc, fonts, bin, or all.
94 # If [module] is not given, all is assumed.
95 # It installs the files found in the current directory to the standard locations
96 # for a TeX installation
97 latex-package_src_doinstall() {
98 debug-print function $FUNCNAME $*
100 # Avoid generating font cache outside of the sandbox
101 export VARTEXFONTS="${T}/fonts"
103 # This actually follows the directions for a "single-user" system
104 # at http://www.ctan.org/installationadvice/ modified for gentoo.
105 [ -z "$1" ] && latex-package_src_install all
110 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
112 dobin $i || die "dobin $i failed"
115 "sty" | "cls" | "fd" | "clo" | "def" | "cfg")
116 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
118 insinto ${TEXMF}/tex/latex/${PN}
119 doins $i || die "doins $i failed"
122 "dvi" | "ps" | "pdf")
123 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
125 insinto /usr/share/doc/${PF}
126 doins $i || die "doins $i failed"
127 dosym /usr/share/doc/${PF}/$(basename ${i}) ${TEXMF}/doc/latex/${PN}/${i}
131 # prevent compression of symlink target
132 docompress -x /usr/share/doc/${PF}/$(basename ${i})
138 if ! in_iuse doc || use doc ; then
139 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
141 einfo "Making documentation: $i"
142 if pdflatex ${LATEX_DOC_ARGUMENTS} --interaction=batchmode $i &> /dev/null ; then
143 pdflatex ${LATEX_DOC_ARGUMENTS} --interaction=batchmode $i &> /dev/null || die
145 einfo "pdflatex failed, trying texi2dvi"
146 texi2dvi -q -c --language=latex $i &> /dev/null || die
151 "tfm" | "vf" | "afm")
152 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
154 insinto ${TEXMF}/fonts/${1}/${SUPPLIER}/${PN}
155 doins $i || die "doins $i failed"
159 for i in `find . -maxdepth 1 -type f -name "*.pfb"`
161 insinto ${TEXMF}/fonts/type1/${SUPPLIER}/${PN}
162 doins $i || die "doins $i failed"
166 for i in `find . -maxdepth 1 -type f -name "*.ttf"`
168 insinto ${TEXMF}/fonts/truetype/${SUPPLIER}/${PN}
169 doins $i || die "doins $i failed"
173 for i in `find . -maxdepth 1 -type f -name "*.bst"`
175 insinto ${TEXMF}/bibtex/bst/${PN}
176 doins $i || die "doins $i failed"
180 latex-package_src_doinstall sty cls fd clo def cfg bst
183 latex-package_src_doinstall tex dtx dvi ps pdf
186 latex-package_src_doinstall tfm vf afm pfb ttf
189 latex-package_src_doinstall sh
192 latex-package_src_doinstall styles fonts bin doc
199 # @FUNCTION: latex-package_src_compile
201 # Calls latex for each *.ins in the current directory in order to generate the
202 # relevant files that will be installed
203 latex-package_src_compile() {
204 debug-print function $FUNCNAME $*
205 for i in `find \`pwd\` -maxdepth 1 -type f -name "*.ins"`
207 einfo "Extracting from $i"
208 latex --interaction=batchmode $i &> /dev/null || die
212 # @FUNCTION: latex-package_src_install
214 # Installs the package
215 latex-package_src_install() {
216 debug-print function $FUNCNAME $*
217 latex-package_src_doinstall all
218 if [ -n "${DOCS}" ] ; then
223 # @FUNCTION: latex-package_pkg_postinst
225 # Calls latex-package_rehash to ensure the TeX installation is consistent with
226 # the kpathsea database
227 latex-package_pkg_postinst() {
228 debug-print function $FUNCNAME $*
232 # @FUNCTION: latex-package_pkg_postrm
234 # Calls latex-package_rehash to ensure the TeX installation is consistent with
235 # the kpathsea database
236 latex-package_pkg_postrm() {
237 debug-print function $FUNCNAME $*
241 # @FUNCTION: latex-package_rehash
243 # Rehashes the kpathsea database, according to the current TeX installation
244 latex-package_rehash() {
245 debug-print function $FUNCNAME $*
249 EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_postrm