/[gentoo-x86]/eclass/latex-package.eclass
Gentoo

Diff of /eclass/latex-package.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.5 Revision 1.38
1# Author Matthew Turk <m-turk@nwu.edu> 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.38 2009/01/11 21:46:39 ulm Exp $
4
5# @ECLASS: latex-package.eclass
6# @MAINTAINER:
7# TeX team <tex@gentoo.org>
2# 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:
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
44inherit base 56inherit base
45INHERITED="$INHERITED $ECLASS"
46 57
47newdepend ">=app-text/tetex-1.0.7" 58RDEPEND="virtual/latex-base"
48ECLASS=latex-package 59DEPEND="${RDEPEND}
60 >=sys-apps/texinfo-4.2-r5"
49HOMEPAGE="http://www.tug.org/" 61HOMEPAGE="http://www.tug.org/"
50SRC_URI="ftp://tug.ctan.org/macros/latex/" 62SRC_URI="ftp://tug.ctan.org/macros/latex/"
51S=${WORKDIR}/${P} 63S=${WORKDIR}/${P}
52TEXMF="/usr/share/texmf" 64TEXMF="/usr/share/texmf"
65
66# @ECLASS-VARIABLE: SUPPLIER
67# @DESCRIPTION:
53SUPPLIER="misc" # This refers to the font supplier; it should be overridden 68# This refers to the font supplier; it should be overridden (see eclass
69# DESCRIPTION above)
70SUPPLIER="misc"
54 71
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
74# @DESCRIPTION:
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
77latex-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
79 true
80 else
81 false
82 fi
83}
84
85# @FUNCTION: latex-package_src_doinstall
86# @USAGE: [ module ]
87# @DESCRIPTION:
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
55latex-package_src_doinstall() { 93latex-package_src_doinstall() {
56 debug-print function $FUNCNAME $* 94 debug-print function $FUNCNAME $*
57 # This actually follows the directions for a "single-user" system 95 # This actually follows the directions for a "single-user" system
58 # at http://www.ctan.org/installationadvice/ modified for gentoo. 96 # at http://www.ctan.org/installationadvice/ modified for gentoo.
59 [ -z "$1" ] && latex-package_src_install all 97 [ -z "$1" ] && latex-package_src_install all
60 98
61 while [ "$1" ]; do 99 while [ "$1" ]; do
62 case $1 in 100 case $1 in
63 "sh") 101 "sh")
64 for i in `find . -maxdepth 1 -type f -name "*.${1}"` 102 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
65 do 103 do
66 dobin $i 104 dobin $i || die "dobin $i failed"
67 done 105 done
68 ;; 106 ;;
69 "sty" | "cls" | "fd" | "clo" | "def") 107 "sty" | "cls" | "fd" | "clo" | "def" | "cfg")
70 for i in `find . -maxdepth 1 -type f -name "*.${1}"` 108 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
71 do 109 do
72 insinto ${TEXMF}/tex/latex/${PN} 110 insinto ${TEXMF}/tex/latex/${PN}
73 doins $i 111 doins $i || die "doins $i failed"
74 done 112 done
75 ;; 113 ;;
76 "dvi" | "ps" | "pdf" | "tex" | "dtx") 114 "dvi" | "ps" | "pdf")
77 for i in `find . -maxdepth 1 -type f -name "*.${1}"` 115 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
78 do 116 do
79 dodoc $i 117 insinto /usr/share/doc/${PF}
80 done 118 doins $i || die "doins $i failed"
81 ;; 119 dosym /usr/share/doc/${PF}/$(basename ${i}) ${TEXMF}/doc/latex/${PN}/${i}
82 "tfm" | "vf" | "afm" | "pfb") 120 #dodoc -u $i
121 done
122 ;;
123 "tex" | "dtx")
83 for i in `find . -maxdepth 1 -type f -name "*.${1}"` 124 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
84 do 125 do
126 einfo "Making documentation: $i"
127 texi2dvi -q -c --language=latex $i &> /dev/null
128 done
129 ;;
130 "tfm" | "vf" | "afm")
131 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
132 do
85 insinto ${TEXMF}/fonts/${1}/${SUPPLIER}/${PN} 133 insinto ${TEXMF}/fonts/${1}/${SUPPLIER}/${PN}
86 doins $i 134 doins $i || die "doins $i failed"
87 done 135 done
88 ;; 136 ;;
89 "ttf") 137 "pfb")
138 for i in `find . -maxdepth 1 -type f -name "*.pfb"`
139 do
140 insinto ${TEXMF}/fonts/type1/${SUPPLIER}/${PN}
141 doins $i || die "doins $i failed"
142 done
143 ;;
144 "ttf")
90 for i in `find . -maxdepth 1 -type f -name "*.ttf"` 145 for i in `find . -maxdepth 1 -type f -name "*.ttf"`
91 do 146 do
92 insinto ${TEXMF}/fonts/truetype/${SUPPLIER}/${PN} 147 insinto ${TEXMF}/fonts/truetype/${SUPPLIER}/${PN}
93 doins $i 148 doins $i || die "doins $i failed"
94 done 149 done
95 ;; 150 ;;
96 "styles") 151 "bst")
152 for i in `find . -maxdepth 1 -type f -name "*.bst"`
153 do
154 insinto ${TEXMF}/bibtex/bst/${PN}
155 doins $i || die "doins $i failed"
156 done
157 ;;
158 "styles")
97 latex-package_src_doinstall sty cls fd clo def 159 latex-package_src_doinstall sty cls fd clo def cfg bst
98 ;; 160 ;;
99 "doc") 161 "doc")
100 latex-package_src_doinstall dvi ps pdf tex dtx 162 latex-package_src_doinstall tex dtx dvi ps pdf
101 ;; 163 ;;
102 "fonts") 164 "fonts")
103 latex-package_src_doinstall tfm vg afm pfb ttf 165 latex-package_src_doinstall tfm vf afm pfb ttf
104 ;; 166 ;;
105 "bin") 167 "bin")
106 latex-package_src_doinstall sh 168 latex-package_src_doinstall sh
107 ;; 169 ;;
108 "all") 170 "all")
109 latex-package_src_doinstall styles doc fonts bin 171 latex-package_src_doinstall styles fonts bin doc
110 ;; 172 ;;
111 esac 173 esac
112 shift 174 shift
113 done 175 done
114} 176}
115 177
178# @FUNCTION: latex-package_src_compile
179# @DESCRIPTION:
180# Calls latex for each *.ins in the current directory in order to generate the
181# relevant files that will be installed
116latex-package_src_compile() { 182latex-package_src_compile() {
117 debug-print function $FUNCNAME $* 183 debug-print function $FUNCNAME $*
118 cd ${S}
119 for i in `find \`pwd\` -maxdepth 1 -type f -name "*.ins"` 184 for i in `find \`pwd\` -maxdepth 1 -type f -name "*.ins"`
120 do 185 do
121 echo "Extracting from $i" 186 einfo "Extracting from $i"
122 latex --interaction=batchmode $i > /dev/null 187 latex --interaction=batchmode $i &> /dev/null
123 done 188 done
124} 189}
125 190
191# @FUNCTION: latex-package_src_install
192# @DESCRIPTION:
193# Installs the package
126latex-package_src_install() { 194latex-package_src_install() {
127 debug-print function $FUNCNAME $* 195 debug-print function $FUNCNAME $*
128 cd ${S}
129 latex-package_src_doinstall all 196 latex-package_src_doinstall all
197 if [ -n "${DOCS}" ] ; then
198 dodoc ${DOCS}
199 fi
130} 200}
131 201
202# @FUNCTION: latex-package_pkg_postinst
203# @DESCRIPTION:
204# Calls latex-package_rehash to ensure the TeX installation is consistent with
205# the kpathsea database
132latex-package_pkg_postinst() { 206latex-package_pkg_postinst() {
133 debug-print function $FUNCNAME $* 207 debug-print function $FUNCNAME $*
134 latex-package_rehash 208 latex-package_rehash
135 if [ ! -e /usr/doc/latex/${PN} ] ; then return ; fi
136 cd /usr/share/doc/${PN}
137 latex-package_make_documentation
138} 209}
139 210
211# @FUNCTION: latex-package_pkg_postrm
212# @DESCRIPTION:
213# Calls latex-package_rehash to ensure the TeX installation is consistent with
214# the kpathsea database
140latex-package_pkg_postrm() { 215latex-package_pkg_postrm() {
141 debug-print function $FUNCNAME $* 216 debug-print function $FUNCNAME $*
142 latex-package_rehash 217 latex-package_rehash
143} 218}
144 219
220# @FUNCTION: latex-package_rehash
221# @DESCRIPTION:
222# Rehashes the kpathsea database, according to the current TeX installation
145latex-package_rehash() { 223latex-package_rehash() {
146 debug-print function $FUNCNAME $* 224 debug-print function $FUNCNAME $*
225 if latex-package_has_tetex_3 ; then
226 texmf-update
227 else
147 texconfig rehash 228 texconfig rehash
148} 229 fi
149
150latex-package_make_documentation() {
151 debug-print function $FUNCNAME $*
152 for i in `find \`pwd\` -maxdepth 1 -type f -name "*.[dt]tex"`
153 do
154 echo "Making Documentation: $i"
155 latex --interaction=batchmode $i > /dev/null
156 # And we don't want any leftovers...
157 for ext in aux toc log
158 do
159 rm ${i}.${ext}
160 done
161 done
162 echo "Completed."
163} 230}
164 231
165EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_postrm 232EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_postrm

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.38

  ViewVC Help
Powered by ViewVC 1.1.20