summaryrefslogtreecommitdiff
blob: a5167a9bc7fd522104ac9dd15fdffbcad19a48a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-text/ptex/ptex-3.1.10_p20071203.ebuild,v 1.8 2007/12/29 11:42:43 vapier Exp $

TETEX_PV=3.0_p1

inherit eutils tetex-3 flag-o-matic autotools multilib

SMALL_PV="${TETEX_PV/_p*}"
TETEX_TEXMF_PV="${SMALL_PV}"
TETEX_S="${WORKDIR}/tetex-src-${SMALL_PV}"

DESCRIPTION="TeX distribution teTeX with Japanese patch collection 'ptetex3'"
HOMEPAGE="http://www.nn.iij4u.or.jp/~tutimura/tex/ptetex.html"

#TETEX_SRC="tetex-src-${TETEX_PV}.tar.gz"
TETEX_SRC="tetex-src-${SMALL_PV}.tar.gz"
TETEX_TEXMF="tetex-texmf-${TETEX_TEXMF_PV:-${TETEX_PV}}"
TETEX_TEXMF_SRC="tetex-texmf-${TETEX_TEXMF_PV:-${TETEX_PV}}po.tar.gz"
PTETEX="ptetex3-${PV/*_p}"
PTETEX_CMAP="ptetex-cmap-20051117"

SRC_PATH_TETEX="ftp://cam.ctan.org/tex-archive/systems/unix/teTeX/3.0/distrib"
SRC_URI="${SRC_PATH_TETEX}/${TETEX_SRC}
	${SRC_PATH_TETEX}/${TETEX_TEXMF_SRC}
	http://tutimura.ath.cx/~nob/tex/ptetex/ptetex3/${PTETEX}.tar.gz
	http://tutimura.ath.cx/~nob/tex/ptetex/ptetex-cmap/${PTETEX_CMAP}.tar.gz
	mirror://gentoo/${PN}-3.1.10_p20071122-dviljk-security-fixes.patch.bz2"
#	mirror://gentoo/tetex-${TETEX_PV}-gentoo.tar.gz

KEYWORDS="alpha amd64 arm hppa ia64 ppc ppc64 sh sparc x86"

BUILD_DIR="${WORKDIR}/build/usr"

LICENSE="GPL-2 BSD"
IUSE="X motif lesstif Xaw3d neXt iconv unicode"

DEPEND="!app-text/tetex
	!<app-text/ptetex-3.1.9
	!app-text/dvipdfmx
	!app-text/xdvik
	media-libs/t1lib
	media-libs/gd
	X? (
		>=media-libs/freetype-2.3.4
		|| (
			media-fonts/ja-ipafonts
			media-fonts/ipamonafont
			media-fonts/vlgothic
			media-fonts/sazanami
			media-fonts/kochi-substitute
		)
	)"

S="${WORKDIR}/${PTETEX}"

# Sorry this provides tetex again...
PROVIDE="virtual/tetex"

src_unpack() {
	#tetex-3_src_unpack
	mkdir -p "${WORKDIR}/${TETEX_TEXMF}"
	cd "${WORKDIR}/${TETEX_TEXMF}"
	unpack ${TETEX_TEXMF_SRC}
	cd "${WORKDIR}"
	unpack ${TETEX_SRC}
	cd "${WORKDIR}"
	unpack ${PN}-3.1.10_p20071122-dviljk-security-fixes.patch.bz2
	unpack ${PTETEX}.tar.gz
	unpack ${PTETEX_CMAP}.tar.gz
	echo ">>> Unpacking jis and morisawa fonts ..."
	tar xzf "${WORKDIR}"/${PTETEX}/archive/jis.tar.gz -C "${WORKDIR}" || die
	tar xzf "${WORKDIR}"/${PTETEX}/archive/morisawa.tar.gz -C "${WORKDIR}" || die

	# Gentoo box reserves variable ${P}!!
	cd "${S}"
	epatch "${FILESDIR}"/${P}-gentoo.patch

	cat <<EOF > "${S}"/my_option
SRC_DIR="${WORKDIR}"
TMP_PREFIX="${BUILD_DIR}"
PREFIX=/usr
DATADIR=/usr/share
TEXMFDIST="${WORKDIR}/${TETEX_TEXMF}"
TEXSRC_EXTRACTED="${WORKDIR}"
#make_option vartexfonts=/var/lib/texmf
make_option vartexfonts="${T}/texfonts"
make_option CC="$(tc-getCC)"
make_option CXX="$(tc-getCXX)"
JAPANESE=international
XDVI=echo
PXDVI=echo
PLATEX209=no
conf_option --without-dviljk
conf_option --without-dvipng
conf_option --without-info
conf_option --without-texi2html
conf_option --without-texinfo

conf_option --with-system-zlib
conf_option --with-system-pnglib
conf_option --with-system-gd
conf_option --with-system-ncurses
conf_option --with-system-t1lib
conf_option --enable-shared
EOF

	if use iconv ; then
		echo "conf_option --enable-kanji-iconv" >> "${S}"/my_option
	fi

	if use unicode ; then
		echo "KANJI_CODE=UTF8" >> "${S}"/my_option
	else
		echo "KANJI_CODE=EUC" >> "${S}"/my_option
	fi

	# copied from tetex-3.eclass and modified
	if use X ; then
		if use motif ; then
			append-ldflags $(motif-config --libs)
			export CPPFLAGS="${CPPFLAGS} $(motif-config --cflags)"
			toolkit="motif"
		elif use neXt ; then
			toolkit="neXtaw"
		elif use Xaw3d ; then
			toolkit="xaw3d"
		else
			toolkit="xaw"
		fi
		append-ldflags $(freetype-config --libs)
		echo "export CPPFLAGS=\"${CPPFLAGS} $(freetype-config --cflags)\"" >> "${S}"/my_option
		echo "conf_option --with-xdvi-x-toolkit=${toolkit}" >> "${S}"/my_option
	else
		echo "conf_option --without-x" >> "${S}"/my_option
		echo "conf_option --without-xdvik" >> "${S}"/my_option
		echo "conf_option --without-pxdvik" >> "${S}"/my_option
	fi

	cd "${S}"
	unset TEXMFMAIN TEXMF HOME
	emake -j1 x || die "emake x failed"

	cd "${TETEX_S}"

	epatch "${FILESDIR}/tetex-${SMALL_PV}-kpathsea-pic.patch"

	# bug 85404
	epatch "${FILESDIR}/${PN}-3.1.10_p20071122-epstopdf-wrong-rotation.patch"

	# ptetex included
	#epatch "${FILESDIR}/tetex-${TETEX_PV}-amd64-xdvik-wp.patch"
	epatch "${FILESDIR}/tetex-${TETEX_PV}-mptest.patch"

	#bug 98029
	# no need
	#epatch "${FILESDIR}/${PN}-3.1.10_p20071122-fmtutil-etex.patch"

	#bug 115775
	# ptex included
	#epatch "${FILESDIR}/tetex-${TETEX_PV}-xpdf-vulnerabilities.patch"

	# bug 94860
	epatch "${FILESDIR}/${PN}-3.1.10_p20071122-pdftosrc-install.patch"

	# bug 126918
	epatch "${FILESDIR}/tetex-${TETEX_PV}-create-empty-files.patch"

	# bug 94901
	epatch "${FILESDIR}/tetex-${TETEX_PV}-dvipdfm-timezone.patch"

	# security bug #170861
	# ptetex included
	# epatch "${FILESDIR}/tetex-${TETEX_PV}-CVE-2007-0650.patch"

	# security bug #188172
	# ptetex included
	#epatch "${FILESDIR}/tetex-${TETEX_PV}-xpdf-CVE-2007-3387.patch"

	# security bug #198238
	epatch "${FILESDIR}/tetex-${TETEX_PV}-dvips_bufferoverflow.patch"

	# securty bug #196735
	epatch "${FILESDIR}/xpdf-3.02pl2.patch"

	# Construct a Gentoo site texmf directory
	# that overlays the upstream supplied
	# target not found
	#epatch "${FILESDIR}/tetex-${TETEX_PV}-texmf-site.patch"

	# security bug #198238
	epatch "${WORKDIR}/${PN}-3.1.10_p20071122-dviljk-security-fixes.patch"

	# security bug #198238 and bug #193437
	epatch "${FILESDIR}/tetex-${TETEX_PV}-t1lib-SA26241_buffer_overflow.patch"

	cd "${TETEX_S}/texk/dviljk"
	eautoreconf
}

src_compile() {
	unset TEXMFMAIN TEXMF HOME

	emake -j1 c || die "emake c failed"
	emake -j1 macro || die "emake macro failed"
	emake -j1 otf || die "emake otf failed"
	emake -j1 fonty || die "emake fonty failed"
	emake -j1 babel || die "emake babel failed"

	einfo "Setting ptetex-cmap ..."
	cd "${WORKDIR}/${PTETEX_CMAP}"
	PATH="${BUILD_DIR}/bin:$PATH" ./setup.sh "${BUILD_DIR}"/share/texmf/fonts/cmap
}

src_test() {
	emake -j1 test || die "emake test failed"
}

src_install() {
	#tetex-3_src_install
	einfo "Installing ptetex3 binaries ..."
	dobin "${BUILD_DIR}"/bin/*
	dolib "${BUILD_DIR}"/lib/*

	einfo "Installing /usr/include/* files ..."
	insinto /usr/include
	doins -r "${BUILD_DIR}"/include/*

	einfo "Installing /usr/share/* files ..."
	insinto /usr/share
	#doins -r "${BUILD_DIR}"/share/*
	cp -dr "${BUILD_DIR}"/share/* "${D}"/usr/share

	einfo "Installing document files ..."
	doman "${BUILD_DIR}"/man/*/*
	doinfo "${BUILD_DIR}"/info/*

	einfo "Installing jis and morisawa fonts ..."
	insinto /usr/share/texmf/fonts/tfm
	doins -r "${WORKDIR}"/jis/tfm/*        || die "installing jis/tfm failed"
	doins -r "${WORKDIR}"/morisawa/tfm/*   || die "installing morisawa/tfm failed"

	einfo "Installing texmf files ..."
	find "${WORKDIR}"/${TETEX_TEXMF} -maxdepth 1 -mindepth 1 -type f | xargs rm -f
	insinto /usr/share/texmf
	doins -r "${WORKDIR}"/${TETEX_TEXMF}/*

	einfo "Installing other files ..."
	insinto /usr/share/texmf/fonts/map/dvips/tetex
	doins "${WORKDIR}"/${TETEX_S}/texk/pdvipsk/psfonts_jp.map
	#insinto /var/lib/texmf/web2c
	insinto /usr/share/texmf/web2c
	doins -r "${BUILD_DIR}"/share/texmf-config/web2c/*
	doins -r "${BUILD_DIR}"/share/texmf-var/web2c/*.fmt

	einfo "Removing unnecessary files ..."
	rm -r "${D}"/usr/share/texmf/doc
	#rm -r "${D}"/usr/share/texmf-config
	#rm -r "${D}"/usr/share/texmf-var
	rm -r "${D}"/usr/share/texmf/web2c/texmf.cnf.*
	rm -r "${D}"/usr/share/texmf/web2c/fmtutil.cnf.*
	rm -r "${D}"/usr/info/dir
	find "${D}"/usr/share/texmf | grep "ls-R" | xargs rm -f

	einfo "Installing texmf-update scripte ..."
	dosbin "${FILESDIR}"/texmf-update
	#einfo "Making ls-R files ..."
	#TEXMF="${D}"/usr/share/texmf "${D}"/usr/bin/mktexlsr || die
}

pkg_postinst() {
	tetex-3_pkg_postinst

	elog
	elog "Japanese dvips and xdvi have been renamed to pdvipsk and pxdvik."
	#elog "You also need to emerge app-text/dvipdfmx to convert dvi into PDF."
	elog
}