1 | # Author Matthew Turk <m-turk@nwu.edu> |
1 | # Copyright 1999-2004 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.27 2006/02/28 11:09:25 nattfodd Exp $ |
4 | # the src_install function as-is if the system is single-directory. |
4 | # |
|
|
5 | # Author Matthew Turk <satai@gentoo.org> |
|
|
6 | # |
|
|
7 | # This eClass is designed to be easy to use and implement. The vast majority of |
|
|
8 | # LaTeX packages will only need to define SRC_URI (and sometimes S) for a |
|
|
9 | # successful installation. If fonts need to be installed, then the variable |
|
|
10 | # SUPPLIER must also be defined. |
|
|
11 | # |
|
|
12 | # However, those packages that contain subdirectories must process each |
|
|
13 | # subdirectory individually. For example, a package that contains directories |
|
|
14 | # DIR1 and DIR2 must call latex-package_src_compile() and |
|
|
15 | # latex-package_src_install() in each directory, as shown here: |
|
|
16 | # |
|
|
17 | # src_compile() { |
|
|
18 | # cd ${S} |
|
|
19 | # cd DIR1 |
|
|
20 | # latex-package_src_compile |
|
|
21 | # cd .. |
|
|
22 | # cd DIR2 |
|
|
23 | # latex-package_src_compile |
|
|
24 | # } |
|
|
25 | # |
|
|
26 | # src_install() { |
|
|
27 | # cd ${S} |
|
|
28 | # cd DIR1 |
|
|
29 | # latex-package_src_install |
|
|
30 | # cd .. |
|
|
31 | # cd DIR2 |
|
|
32 | # latex-package_src_install |
|
|
33 | # } |
|
|
34 | # |
|
|
35 | # The eClass automatically takes care of rehashing TeX's cache (ls-lR) after |
|
|
36 | # installation and after removal, as well as creating final documentation from |
|
|
37 | # TeX files that come with the source. Note that we break TeX layout standards |
|
|
38 | # by placing documentation in /usr/share/doc/${PN} |
|
|
39 | # |
|
|
40 | # For examples of basic installations, check out dev-tex/aastex and |
|
|
41 | # dev-tex/leaflet . |
|
|
42 | # |
|
|
43 | # NOTE: The CTAN "directory grab" function creates files with different MD5 |
|
|
44 | # signatures EVERY TIME. For this reason, if you are grabbing from the CTAN, |
|
|
45 | # you must either grab each file individually, or find a place to mirror an |
|
|
46 | # archive of them. (iBiblio) |
5 | |
47 | |
6 | inherit base |
48 | inherit base |
7 | |
49 | |
8 | newdepend ">=app-text/tetex-1.0.7" |
50 | DEPEND="virtual/tetex |
9 | ECLASS=latex-package |
51 | >=sys-apps/texinfo-4.2-r5" |
10 | HOMEPAGE="http://www.tug.org/" |
52 | HOMEPAGE="http://www.tug.org/" |
11 | SRC_URI="ftp://tug.ctan.org/macros/latex/" |
53 | SRC_URI="ftp://tug.ctan.org/macros/latex/" |
12 | S=${WORKDIR}/${P} |
54 | S=${WORKDIR}/${P} |
13 | TEXMF="/usr/share/texmf" |
55 | TEXMF="/usr/share/texmf" |
14 | SUPPLIER="misc" # This refers to the font supplier; it should be overridden |
56 | SUPPLIER="misc" # This refers to the font supplier; it should be overridden |
15 | |
57 | |
|
|
58 | latex-package_has_tetex_3() { |
|
|
59 | if has_version '>=app-text/tetex-3' || has_version '>=app-text/ptex-3.1.8' ; then |
|
|
60 | true |
|
|
61 | else |
|
|
62 | false |
|
|
63 | fi |
|
|
64 | } |
|
|
65 | |
16 | latex-package_src_doinstall() { |
66 | latex-package_src_doinstall() { |
17 | debug-print function $FUNCNAME $* |
67 | debug-print function $FUNCNAME $* |
18 | # This actually follows the directions for a "single-user" system |
68 | # This actually follows the directions for a "single-user" system |
19 | # at http://www.ctan.org/installationadvice/ modified for gentoo. |
69 | # at http://www.ctan.org/installationadvice/ modified for gentoo. |
20 | [ -z "$1" ] && latex-package_src_install all |
70 | [ -z "$1" ] && latex-package_src_install all |
21 | |
71 | |
22 | while [ "$1" ]; do |
72 | while [ "$1" ]; do |
23 | case $1 in |
73 | case $1 in |
24 | "sh") |
74 | "sh") |
25 | for i in `find . -maxdepth 1 -name "*.${1}"` |
75 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
26 | do |
76 | do |
27 | dobin $i |
77 | dobin $i || die "dobin $i failed" |
28 | done |
78 | done |
29 | ;; |
79 | ;; |
30 | "sty" | "cls" | "fd") |
80 | "sty" | "cls" | "fd" | "clo" | "def" | "cfg") |
31 | for i in `find . -maxdepth 1 -name "*.${1}"` |
81 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
32 | do |
82 | do |
33 | insinto ${TEXMF}/tex/latex/${PN} |
83 | insinto ${TEXMF}/tex/latex/${PN} |
34 | doins $i |
84 | doins $i || die "doins $i failed" |
35 | done |
85 | done |
36 | ;; |
86 | ;; |
37 | "dvi" | "ps" | "pdf" | "tex") |
87 | "dvi" | "ps" | "pdf") |
38 | for i in `find . -maxdepth 1 -name "*.${1}"` |
88 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
39 | do |
89 | do |
40 | insinto ${TEXMF}/doc/latex/${PN} |
90 | insinto /usr/share/doc/${P} |
41 | doins $i |
91 | doins $i || "doins $i failed" |
42 | done |
92 | #dodoc -u $i |
43 | ;; |
93 | done |
44 | "tfm" | "vf" | "afm" | "pfb") |
94 | ;; |
|
|
95 | "tex" | "dtx") |
45 | for i in `find . -maxdepth 1 -name "*.${1}"` |
96 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
46 | do |
97 | do |
|
|
98 | einfo "Making documentation: $i" |
|
|
99 | texi2dvi -q -c --language=latex $i &> /dev/null |
|
|
100 | done |
|
|
101 | ;; |
|
|
102 | "tfm" | "vf" | "afm") |
|
|
103 | for i in `find . -maxdepth 1 -type f -name "*.${1}"` |
|
|
104 | do |
47 | insinto ${TEXMF}/fonts/${1}/${SUPPLIER}/${PN} |
105 | insinto ${TEXMF}/fonts/${1}/${SUPPLIER}/${PN} |
48 | doins $i |
106 | doins $i || die "doins $i failed" |
49 | done |
107 | done |
50 | ;; |
108 | ;; |
51 | "ttf") |
109 | "pfb") |
|
|
110 | for i in `find . -maxdepth 1 -type f -name "*.pfb"` |
|
|
111 | do |
|
|
112 | insinto ${TEXMF}/fonts/type1/${SUPPLIER}/${PN} |
|
|
113 | doins $i || die "doins $i failed" |
|
|
114 | done |
|
|
115 | ;; |
|
|
116 | "ttf") |
52 | for i in `find . -maxdepth 1 -name "*.ttf"` |
117 | for i in `find . -maxdepth 1 -type f -name "*.ttf"` |
53 | do |
118 | do |
54 | insinto ${TEXMF}/fonts/truetype/${SUPPLIER}/${PN} |
119 | insinto ${TEXMF}/fonts/truetype/${SUPPLIER}/${PN} |
55 | doins $i |
120 | doins $i || die "doins $i failed" |
56 | done |
121 | done |
57 | ;; |
122 | ;; |
58 | "styles") |
123 | "bst") |
59 | latex-package_src_doinstall sty cls fd |
124 | for i in `find . -maxdepth 1 -type f -name "*.bst"` |
60 | ;; |
125 | do |
61 | "doc") |
126 | insinto ${TEXMF}/bibtex/bst/${PN} |
62 | latex-package_src_doinstall dvi ps pdf tex |
127 | doins $i || die "doins $i failed" |
63 | ;; |
128 | done |
64 | "fonts") |
129 | ;; |
|
|
130 | "styles") |
|
|
131 | latex-package_src_doinstall sty cls fd clo def cfg bst |
|
|
132 | ;; |
|
|
133 | "doc") |
|
|
134 | latex-package_src_doinstall tex dtx dvi ps pdf |
|
|
135 | ;; |
|
|
136 | "fonts") |
65 | latex-package_src_doinstall tfm vg afm pfb ttf |
137 | latex-package_src_doinstall tfm vf afm pfb ttf |
66 | ;; |
138 | ;; |
67 | "bin") |
139 | "bin") |
68 | latex-package_src_doinstall sh |
140 | latex-package_src_doinstall sh |
69 | ;; |
141 | ;; |
70 | "all") |
142 | "all") |
71 | latex-package_src_doinstall styles doc fonts bin |
143 | latex-package_src_doinstall styles fonts bin doc |
72 | ;; |
144 | ;; |
73 | esac |
145 | esac |
74 | shift |
146 | shift |
75 | done |
147 | done |
76 | } |
148 | } |
77 | |
149 | |
78 | latex-package_src_compile() { |
150 | latex-package_src_compile() { |
79 | debug-print function $FUNCNAME $* |
151 | debug-print function $FUNCNAME $* |
80 | cd ${S} |
|
|
81 | for i in `find \`pwd\` -maxdepth 1 -name "*.ins"` |
152 | for i in `find \`pwd\` -maxdepth 1 -type f -name "*.ins"` |
82 | do |
153 | do |
83 | echo "Extracting from $i" |
154 | einfo "Extracting from $i" |
84 | latex --interaction=batchmode $i > /dev/null |
155 | latex --interaction=batchmode $i &> /dev/null |
85 | done |
156 | done |
86 | for i in `find \`pwd\` -maxdepth 1 -name "*.dtx"` |
|
|
87 | do |
|
|
88 | echo "Extracting from $i" |
|
|
89 | latex --interaction=batchmode $i > /dev/null |
|
|
90 | done |
|
|
91 | } |
157 | } |
92 | |
158 | |
93 | latex-package_src_install() { |
159 | latex-package_src_install() { |
94 | debug-print function $FUNCNAME $* |
160 | debug-print function $FUNCNAME $* |
95 | cd ${S} |
|
|
96 | latex-package_src_doinstall all |
161 | latex-package_src_doinstall all |
|
|
162 | if [ -n "${DOCS}" ] ; then |
|
|
163 | dodoc ${DOCS} |
|
|
164 | fi |
97 | } |
165 | } |
98 | |
166 | |
99 | latex-package_pkg_postinst() { |
167 | latex-package_pkg_postinst() { |
100 | debug-print function $FUNCNAME $* |
168 | debug-print function $FUNCNAME $* |
101 | latex-package_rehash |
169 | latex-package_rehash |
102 | if [ ! -e ${TEXMF}/doc/latex/${PN} ] ; then return ; fi |
|
|
103 | cd ${TEXMF}/doc/latex/${PN} |
|
|
104 | latex-package_make_documentation |
|
|
105 | } |
170 | } |
106 | |
171 | |
107 | latex-package_pkg_postrm() { |
172 | latex-package_pkg_postrm() { |
108 | debug-print function $FUNCNAME $* |
173 | debug-print function $FUNCNAME $* |
109 | # This may be a bit harsh, so perhaps it should be overridden. |
|
|
110 | latex-package_rehash |
174 | latex-package_rehash |
111 | if [ ! -e ${TEXMF}/doc/latex/${PN} ] ; then return ; fi |
|
|
112 | echo "Removing stale documentation: ${TEXMF}/doc/latex/${PN}" |
|
|
113 | rm -rf ${TEXMF}/doc/latex/${PN} |
|
|
114 | } |
175 | } |
115 | |
176 | |
116 | latex-package_rehash() { |
177 | latex-package_rehash() { |
117 | debug-print function $FUNCNAME $* |
178 | debug-print function $FUNCNAME $* |
|
|
179 | if latex-package_has_tetex_3 ; then |
|
|
180 | texmf-update |
|
|
181 | else |
118 | texconfig rehash |
182 | texconfig rehash |
119 | } |
183 | fi |
120 | |
|
|
121 | latex-package_make_documentation() { |
|
|
122 | debug-print function $FUNCNAME $* |
|
|
123 | # This has to come after the installation of all our files. |
|
|
124 | # All errors will be discarded. |
|
|
125 | for i in `find \`pwd\` -maxdepth 1 -name "*.tex"` |
|
|
126 | do |
|
|
127 | # Note - we rerun twice to get references properly. |
|
|
128 | echo "Making Documentation: $i" |
|
|
129 | latex --interaction=batchmode $i > /dev/null |
|
|
130 | done |
|
|
131 | echo "Completed." |
|
|
132 | } |
184 | } |
133 | |
185 | |
134 | EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_postrm |
186 | EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_postrm |