/[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.4 Revision 1.37
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.37 2008/08/30 13:49:28 aballier 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
6inherit base 56inherit base
7ECLASS=latex-package
8INHERITED="$INHERITED $ECLASS"
9 57
10newdepend ">=app-text/tetex-1.0.7" 58RDEPEND="virtual/latex-base"
11 59DEPEND="${RDEPEND}
60 >=sys-apps/texinfo-4.2-r5"
12HOMEPAGE="http://www.tug.org/" 61HOMEPAGE="http://www.tug.org/"
13SRC_URI="ftp://tug.ctan.org/macros/latex/" 62SRC_URI="ftp://tug.ctan.org/macros/latex/"
14S=${WORKDIR}/${P} 63S=${WORKDIR}/${P}
15TEXMF="/usr/share/texmf" 64TEXMF="/usr/share/texmf"
65
66# @ECLASS-VARIABLE: SUPPLIER
67# @DESCRIPTION:
16SUPPLIER="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"
17 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
18latex-package_src_doinstall() { 93latex-package_src_doinstall() {
19 debug-print function $FUNCNAME $* 94 debug-print function $FUNCNAME $*
20 # This actually follows the directions for a "single-user" system 95 # This actually follows the directions for a "single-user" system
21 # at http://www.ctan.org/installationadvice/ modified for gentoo. 96 # at http://www.ctan.org/installationadvice/ modified for gentoo.
22 [ -z "$1" ] && latex-package_src_install all 97 [ -z "$1" ] && latex-package_src_install all
23 98
24 while [ "$1" ]; do 99 while [ "$1" ]; do
25 case $1 in 100 case $1 in
26 "sh") 101 "sh")
27 for i in `find . -maxdepth 1 -name "*.${1}"` 102 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
28 do 103 do
29 dobin $i 104 dobin $i || die "dobin $i failed"
30 done 105 done
31 ;; 106 ;;
32 "sty" | "cls" | "fd") 107 "sty" | "cls" | "fd" | "clo" | "def" | "cfg")
33 for i in `find . -maxdepth 1 -name "*.${1}"` 108 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
34 do 109 do
35 insinto ${TEXMF}/tex/latex/${PN} 110 insinto ${TEXMF}/tex/latex/${PN}
36 doins $i 111 doins $i || die "doins $i failed"
37 done 112 done
38 ;; 113 ;;
39 "dvi" | "ps" | "pdf" | "tex") 114 "dvi" | "ps" | "pdf")
40 for i in `find . -maxdepth 1 -name "*.${1}"` 115 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
41 do 116 do
42 insinto ${TEXMF}/doc/latex/${PN} 117 insinto /usr/share/doc/${PF}
43 doins $i 118 doins $i || die "doins $i failed"
44 done 119 dosym /usr/share/doc/${PF}/$(basename ${i}) ${TEXMF}/doc/latex/${PN}/${i}
45 ;; 120 #dodoc -u $i
46 "tfm" | "vf" | "afm" | "pfb") 121 done
122 ;;
123 "tex" | "dtx")
47 for i in `find . -maxdepth 1 -name "*.${1}"` 124 for i in `find . -maxdepth 1 -type f -name "*.${1}"`
48 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
49 insinto ${TEXMF}/fonts/${1}/${SUPPLIER}/${PN} 133 insinto ${TEXMF}/fonts/${1}/${SUPPLIER}/${PN}
50 doins $i 134 doins $i || die "doins $i failed"
51 done 135 done
52 ;; 136 ;;
53 "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")
54 for i in `find . -maxdepth 1 -name "*.ttf"` 145 for i in `find . -maxdepth 1 -type f -name "*.ttf"`
55 do 146 do
56 insinto ${TEXMF}/fonts/truetype/${SUPPLIER}/${PN} 147 insinto ${TEXMF}/fonts/truetype/${SUPPLIER}/${PN}
57 doins $i 148 doins $i || die "doins $i failed"
58 done 149 done
59 ;; 150 ;;
60 "styles") 151 "bst")
61 latex-package_src_doinstall sty cls fd 152 for i in `find . -maxdepth 1 -type f -name "*.bst"`
62 ;; 153 do
63 "doc") 154 insinto ${TEXMF}/bibtex/bst/${PN}
64 latex-package_src_doinstall dvi ps pdf tex 155 doins $i || die "doins $i failed"
65 ;; 156 done
66 "fonts") 157 ;;
158 "styles")
159 latex-package_src_doinstall sty cls fd clo def cfg bst
160 ;;
161 "doc")
162 latex-package_src_doinstall tex dtx dvi ps pdf
163 ;;
164 "fonts")
67 latex-package_src_doinstall tfm vg afm pfb ttf 165 latex-package_src_doinstall tfm vf afm pfb ttf
68 ;; 166 ;;
69 "bin") 167 "bin")
70 latex-package_src_doinstall sh 168 latex-package_src_doinstall sh
71 ;; 169 ;;
72 "all") 170 "all")
73 latex-package_src_doinstall styles doc fonts bin 171 latex-package_src_doinstall styles fonts bin doc
74 ;; 172 ;;
75 esac 173 esac
76 shift 174 shift
77 done 175 done
78} 176}
79 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
80latex-package_src_compile() { 182latex-package_src_compile() {
81 debug-print function $FUNCNAME $* 183 debug-print function $FUNCNAME $*
82 cd ${S}
83 for i in `find \`pwd\` -maxdepth 1 -name "*.ins"` 184 for i in `find \`pwd\` -maxdepth 1 -type f -name "*.ins"`
84 do 185 do
85 echo "Extracting from $i" 186 einfo "Extracting from $i"
86 latex --interaction=batchmode $i > /dev/null 187 latex --interaction=batchmode $i &> /dev/null
87 done 188 done
88 for i in `find \`pwd\` -maxdepth 1 -name "*.dtx"`
89 do
90 echo "Extracting from $i"
91 latex --interaction=batchmode $i > /dev/null
92 done
93} 189}
94 190
191# @FUNCTION: latex-package_src_install
192# @DESCRIPTION:
193# Installs the package
95latex-package_src_install() { 194latex-package_src_install() {
96 debug-print function $FUNCNAME $* 195 debug-print function $FUNCNAME $*
97 cd ${S}
98 latex-package_src_doinstall all 196 latex-package_src_doinstall all
197 if [ -n "${DOCS}" ] ; then
198 dodoc ${DOCS}
199 fi
99} 200}
100 201
202# @FUNCTION: latex-pacakge_pkg_postinst
203# @DESCRIPTION:
204# Calls latex-package_rehash to ensure the TeX installation is consistent with
205# the kpathsea database
101latex-package_pkg_postinst() { 206latex-package_pkg_postinst() {
102 debug-print function $FUNCNAME $* 207 debug-print function $FUNCNAME $*
103 latex-package_rehash 208 latex-package_rehash
104 if [ ! -e ${TEXMF}/doc/latex/${PN} ] ; then return ; fi
105 cd ${TEXMF}/doc/latex/${PN}
106 latex-package_make_documentation
107} 209}
108 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
109latex-package_pkg_postrm() { 215latex-package_pkg_postrm() {
110 debug-print function $FUNCNAME $* 216 debug-print function $FUNCNAME $*
111 # This may be a bit harsh, so perhaps it should be overridden.
112 latex-package_rehash 217 latex-package_rehash
113 if [ ! -e ${TEXMF}/doc/latex/${PN} ] ; then return ; fi
114 echo "Removing stale documentation: ${TEXMF}/doc/latex/${PN}"
115 rm -rf ${TEXMF}/doc/latex/${PN}
116} 218}
117 219
220# @FUNCTION: latex-package_rehash
221# @DESCRIPTION:
222# Rehashes the kpathsea database, according to the current TeX installation
118latex-package_rehash() { 223latex-package_rehash() {
119 debug-print function $FUNCNAME $* 224 debug-print function $FUNCNAME $*
225 if latex-package_has_tetex_3 ; then
226 texmf-update
227 else
120 texconfig rehash 228 texconfig rehash
121} 229 fi
122
123latex-package_make_documentation() {
124 debug-print function $FUNCNAME $*
125 # This has to come after the installation of all our files.
126 # All errors will be discarded.
127 for i in `find \`pwd\` -maxdepth 1 -name "*.tex"`
128 do
129 # Note - we rerun twice to get references properly.
130 echo "Making Documentation: $i"
131 latex --interaction=batchmode $i > /dev/null
132 done
133 echo "Completed."
134} 230}
135 231
136EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_postrm 232EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_postrm

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.37

  ViewVC Help
Powered by ViewVC 1.1.20