1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: latex-package.eclass
6 # TeX team <tex@gentoo.org>
8 # Matthew Turk <satai@gentoo.org>
9 # 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.
56 RDEPEND="virtual/latex-base"
58 >=sys-apps/texinfo-4.2-r5"
62 *) die "${EAPI} is not supported" ;;
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 # @FUNCTION: latex-package_src_doinstall
84 # [module] can be one or more of: sh, sty, cls, fd, clo, def, cfg, dvi, ps, pdf,
85 # tex, dtx, tfm, vf, afm, pfb, ttf, bst, styles, doc, fonts, bin, or all.
86 # If [module] is not given, all is assumed.
87 # It installs the files found in the current directory to the standard locations
88 # for a TeX installation
89 latex-package_src_doinstall() {
90 debug-print function $FUNCNAME $*
92 # Avoid generating font cache outside of the sandbox
93 export VARTEXFONTS="${T}/fonts"
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}
114 "dvi" | "ps" | "pdf")
115 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
117 insinto /usr/share/doc/${PF}
119 dosym /usr/share/doc/${PF}/$(basename ${i}) ${TEXMF}/doc/latex/${PN}/${i}
120 # prevent compression of symlink target
121 docompress -x /usr/share/doc/${PF}/$(basename ${i})
127 if ! in_iuse doc || use doc ; then
128 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
130 [[-n ${LATEX_PACKAGE_SKIP} ]] && has ${i##*/} ${LATEX_PACKAGE_SKIP} && continue
131 einfo "Making documentation: ${i}"
132 if pdflatex ${LATEX_DOC_ARGUMENTS} --halt-on-error --interaction=nonstopmode $i ; then
133 pdflatex ${LATEX_DOC_ARGUMENTS} --halt-on-error --interaction=nonstopmode $i || die
135 einfo "pdflatex failed, trying texi2dvi"
136 texi2dvi -q -c --language=latex ${i} || die
141 "tfm" | "vf" | "afm")
142 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
144 insinto ${TEXMF}/fonts/${1}/${SUPPLIER}/${PN}
149 for i in `find . -maxdepth 1 -type f -name "*.pfb"`
151 insinto ${TEXMF}/fonts/type1/${SUPPLIER}/${PN}
155 for i in `find . -maxdepth 1 -type f -name "*.ttf"`
157 insinto ${TEXMF}/fonts/truetype/${SUPPLIER}/${PN}
162 for i in `find . -maxdepth 1 -type f -name "*.bst"`
164 insinto ${TEXMF}/bibtex/bst/${PN}
169 latex-package_src_doinstall sty cls fd clo def cfg bst
172 latex-package_src_doinstall tex dtx dvi ps pdf
175 latex-package_src_doinstall tfm vf afm pfb ttf
178 latex-package_src_doinstall sh
181 latex-package_src_doinstall styles fonts bin doc
188 # @FUNCTION: latex-package_src_compile
190 # Calls latex for each *.ins in the current directory in order to generate the
191 # relevant files that will be installed
192 latex-package_src_compile() {
193 debug-print function $FUNCNAME $*
194 for i in `find \`pwd\` -maxdepth 1 -type f -name "*.ins"`
196 einfo "Extracting from ${i}"
197 latex --halt-on-error --interaction=nonstopmode ${i} || die
201 # @FUNCTION: latex-package_src_install
203 # Installs the package
204 latex-package_src_install() {
205 debug-print function $FUNCNAME $*
206 latex-package_src_doinstall all
207 if [[ -n ${DOCS} ]] ; then
212 # @FUNCTION: latex-package_pkg_postinst
214 # Calls latex-package_rehash to ensure the TeX installation is consistent with
215 # the kpathsea database
216 latex-package_pkg_postinst() {
217 debug-print function $FUNCNAME $*
221 # @FUNCTION: latex-package_pkg_postrm
223 # Calls latex-package_rehash to ensure the TeX installation is consistent with
224 # the kpathsea database
225 latex-package_pkg_postrm() {
226 debug-print function $FUNCNAME $*
230 # @FUNCTION: latex-package_rehash
232 # Rehashes the kpathsea database, according to the current TeX installation
233 latex-package_rehash() {
234 debug-print function $FUNCNAME $*
238 EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_postrm