| 1 |
# Copyright 1999-2004 Gentoo Foundation |
| 2 |
# Distributed under the terms of the GNU General Public License v2 |
| 3 |
# $Header: /var/cvsroot/gentoo-x86/eclass/texlive-module.eclass,v 1.2 2007/10/17 14:34:09 aballier Exp $ |
| 4 |
|
| 5 |
# |
| 6 |
# Original Author: Alexis Ballier <aballier@gentoo.org> |
| 7 |
# Purpose: Provide generic install functions so that modular texlive's texmf ebuilds will |
| 8 |
# only have to inherit this eclass. |
| 9 |
# Ebuilds have to provide TEXLIVE_MODULE_CONTENTS variable that contains the list |
| 10 |
# of packages that it will install. |
| 11 |
# TEXLIVE_MODULE_CONTENTS will be expanded to SRC_URI : |
| 12 |
# foo -> texlive-module-foo-${PV}.zip |
| 13 |
# What is assumed is that it unpacks texmf and texmf-dist directories to |
| 14 |
# ${WORKDIR}. |
| 15 |
# |
| 16 |
|
| 17 |
inherit texlive-common |
| 18 |
|
| 19 |
HOMEPAGE="http://www.tug.org/texlive/" |
| 20 |
|
| 21 |
for i in ${TEXLIVE_MODULE_CONTENTS}; do |
| 22 |
SRC_URI="${SRC_URI} mirror://gentoo/texlive-module-${i}-${PV}.zip" |
| 23 |
done |
| 24 |
|
| 25 |
COMMON_DEPEND=">=app-text/texlive-core-${PV} |
| 26 |
${TEXLIVE_MODULES_DEPS}" |
| 27 |
|
| 28 |
DEPEND="${COMMON_DEPEND} |
| 29 |
app-arch/unzip" |
| 30 |
|
| 31 |
RDEPEND="${COMMON_DEPEND}" |
| 32 |
|
| 33 |
IUSE="doc" |
| 34 |
|
| 35 |
S="${WORKDIR}" |
| 36 |
|
| 37 |
# src_compile, exported function: |
| 38 |
# Will look for format.foo.cnf and build foo format files using fmtutil |
| 39 |
# (provided by texlive-core). The compiled format files will be sent to |
| 40 |
# texmf-var/web2c, like fmtutil defaults to but with some trick to stay in the |
| 41 |
# sandbox |
| 42 |
# The next step is to generate config files that are to be installed in |
| 43 |
# /etc/texmf; texmf-update script will take care of merging the different config |
| 44 |
# files for different packages in a single one used by the whole tex installation. |
| 45 |
|
| 46 |
texlive-module_src_compile() { |
| 47 |
# Build format files |
| 48 |
for i in texmf/fmtutil/format*.cnf; do |
| 49 |
if [ -f "${i}" ]; then |
| 50 |
einfo "Building format ${i}" |
| 51 |
TEXMFHOME="${S}/texmf:${S}/texmf-dist"\ |
| 52 |
fmtutil --cnffile "${i}" --fmtdir "${S}/texmf-var/web2c" --all\ |
| 53 |
|| die "failed to build format ${i}" |
| 54 |
fi |
| 55 |
done |
| 56 |
|
| 57 |
# Generate config files |
| 58 |
for i in "${S}"/texmf/lists/*; |
| 59 |
do |
| 60 |
grep '^!' "${i}" | tr ' ' '=' |sort|uniq >> "${T}/jobs" |
| 61 |
done |
| 62 |
|
| 63 |
for j in $(<"${T}/jobs"); |
| 64 |
do |
| 65 |
command=$(echo ${j} | sed 's/.\(.*\)=.*/\1/') |
| 66 |
parameter=$(echo ${j} | sed 's/.*=\(.*\)/\1/') |
| 67 |
case "${command}" in |
| 68 |
addMap) |
| 69 |
echo "Map ${parameter}" >> "${S}/${PN}.cfg";; |
| 70 |
addMixedMap) |
| 71 |
echo "MixedMap ${parameter}" >> "${S}/${PN}.cfg";; |
| 72 |
addDvipsMap) |
| 73 |
echo "p +${parameter}" >> "${S}/${PN}-config.ps";; |
| 74 |
addDvipdfmMap) |
| 75 |
echo "f ${parameter}" >> "${S}/${PN}-config";; |
| 76 |
esac |
| 77 |
done |
| 78 |
} |
| 79 |
|
| 80 |
# src_install, exported function: |
| 81 |
# Install texmf and config files to the system |
| 82 |
|
| 83 |
texlive-module_src_install() { |
| 84 |
for i in texmf/fmtutil/format*.cnf; do |
| 85 |
[ -f "${i}" ] && etexlinks "${i}" |
| 86 |
done |
| 87 |
|
| 88 |
insinto /usr/share |
| 89 |
[ -d texmf ] && doins -r texmf |
| 90 |
[ -d texmf-dist ] && doins -r texmf-dist |
| 91 |
use doc && [ -d texmf-doc ] && doins -r texmf-doc |
| 92 |
|
| 93 |
TEXMFSYSVAR="$(kpsewhich -var-value=TEXMFSYSVAR)" |
| 94 |
insinto "${TEXMFSYSVAR}" |
| 95 |
[ -d texmf-var ] && doins -r texmf-var/* |
| 96 |
|
| 97 |
insinto /etc/texmf/updmap.d |
| 98 |
[ -f "${S}/${PN}.cfg" ] && doins "${S}/${PN}.cfg" |
| 99 |
insinto /etc/texmf/dvips/config |
| 100 |
[ -f "${S}/${PN}-config.ps" ] && doins "${S}/${PN}-config.ps" |
| 101 |
insinto /etc/texmf/dvipdfm/config |
| 102 |
[ -f "${S}/${PN}-config" ] && doins "${S}/${PN}-config" |
| 103 |
|
| 104 |
texlive-common_handle_config_files |
| 105 |
} |
| 106 |
|
| 107 |
# pkg_postinst and pkg_postrm, exported functions: |
| 108 |
# run texmf-update to ensure the tex installation is consistent with the |
| 109 |
# installed texmf trees. |
| 110 |
|
| 111 |
texlive-module_pkg_postinst() { |
| 112 |
if [ "$ROOT" = "/" ] ; then |
| 113 |
/usr/sbin/texmf-update |
| 114 |
fi |
| 115 |
} |
| 116 |
|
| 117 |
texlive-module_pkg_postrm() { |
| 118 |
if [ "$ROOT" = "/" ] ; then |
| 119 |
/usr/sbin/texmf-update |
| 120 |
fi |
| 121 |
} |
| 122 |
|
| 123 |
EXPORT_FUNCTIONS src_compile src_install pkg_postinst pkg_postrm |