| 1 |
aballier |
1.4 |
# Copyright 1999-2008 Gentoo Foundation
|
| 2 |
aballier |
1.1 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
aballier |
1.9 |
# $Header: /var/cvsroot/gentoo-x86/eclass/texlive-common.eclass,v 1.8 2008/10/14 06:42:44 aballier Exp $
|
| 4 |
aballier |
1.1 |
|
| 5 |
aballier |
1.4 |
# @ECLASS: texlive-common.eclass
|
| 6 |
|
|
# @MAINTAINER:
|
| 7 |
|
|
# tex@gentoo.org
|
| 8 |
aballier |
1.1 |
#
|
| 9 |
|
|
# Original Author: Alexis Ballier <aballier@gentoo.org>
|
| 10 |
aballier |
1.4 |
# @BLURB: Provide various functions used by both texlive-core and texlive modules
|
| 11 |
|
|
# @DESCRIPTION:
|
| 12 |
aballier |
1.1 |
# Purpose: Provide various functions used by both texlive-core and texlive
|
| 13 |
|
|
# modules.
|
| 14 |
aballier |
1.4 |
#
|
| 15 |
aballier |
1.1 |
# Note that this eclass *must* not assume the presence of any standard tex tool
|
| 16 |
|
|
|
| 17 |
|
|
|
| 18 |
|
|
TEXMF_PATH=/usr/share/texmf
|
| 19 |
|
|
TEXMF_DIST_PATH=/usr/share/texmf-dist
|
| 20 |
aballier |
1.3 |
TEXMF_VAR_PATH=/var/lib/texmf
|
| 21 |
aballier |
1.1 |
|
| 22 |
aballier |
1.4 |
# @FUNCTION: texlive-common_handle_config_files
|
| 23 |
|
|
# @DESCRIPTION:
|
| 24 |
aballier |
1.1 |
# Has to be called in src_install after having installed the files in ${D}
|
| 25 |
|
|
# This function will move the relevant files to /etc/texmf and symling them
|
| 26 |
|
|
# from their original location. This is to allow easy update of texlive's
|
| 27 |
|
|
# configuration
|
| 28 |
|
|
|
| 29 |
|
|
texlive-common_handle_config_files() {
|
| 30 |
|
|
# Handle config files properly
|
| 31 |
aballier |
1.5 |
[ -d "${D}${TEXMF_PATH}" ] || return
|
| 32 |
aballier |
1.1 |
cd "${D}${TEXMF_PATH}"
|
| 33 |
|
|
for f in $(find . -name '*.cnf' -o -name '*.cfg' -type f | sed -e "s:\./::g") ; do
|
| 34 |
|
|
if [ "${f#*config}" != "${f}" ] ; then
|
| 35 |
|
|
continue
|
| 36 |
|
|
fi
|
| 37 |
|
|
dodir /etc/texmf/$(dirname ${f}).d
|
| 38 |
|
|
mv "${D}/${TEXMF_PATH}/${f}" "${D}/etc/texmf/$(dirname ${f}).d" || die "mv ${f} failed."
|
| 39 |
|
|
dosym /etc/texmf/$(dirname ${f}).d/$(basename ${f}) ${TEXMF_PATH}/${f}
|
| 40 |
|
|
done
|
| 41 |
|
|
}
|
| 42 |
|
|
|
| 43 |
aballier |
1.4 |
# @FUNCTION: texlive-common_is_file_present_in_texmf
|
| 44 |
|
|
# @DESCRIPTION:
|
| 45 |
aballier |
1.1 |
# Return if a file is present in the texmf tree
|
| 46 |
|
|
# Call it from the directory containing texmf and texmf-dist
|
| 47 |
|
|
|
| 48 |
|
|
texlive-common_is_file_present_in_texmf() {
|
| 49 |
|
|
local mark="${T}/$1.found"
|
| 50 |
|
|
find texmf -name $1 -exec touch "${mark}" \;
|
| 51 |
|
|
find texmf-dist -name $1 -exec touch "${mark}" \;
|
| 52 |
|
|
[ -f "${mark}" ]
|
| 53 |
|
|
}
|
| 54 |
aballier |
1.2 |
|
| 55 |
aballier |
1.4 |
# @FUNCTION: texlive-common_do_symlinks
|
| 56 |
|
|
# @USAGE: < src > < dest >
|
| 57 |
|
|
# @DESCRIPTION:
|
| 58 |
aballier |
1.2 |
# Mimic the install_link function of texlinks
|
| 59 |
aballier |
1.4 |
#
|
| 60 |
aballier |
1.2 |
# Should have the same behavior as the one in /usr/bin/texlinks
|
| 61 |
|
|
# except that it is under the control of the package manager
|
| 62 |
|
|
# Note that $1 corresponds to $src and $2 to $dest in this function
|
| 63 |
|
|
# ( Arguments are switched because texlinks main function sends them switched )
|
| 64 |
|
|
# This function should not be called from an ebuild, prefer etexlinks that will
|
| 65 |
|
|
# also do the fmtutil file parsing.
|
| 66 |
|
|
|
| 67 |
|
|
texlive-common_do_symlinks() {
|
| 68 |
|
|
while [ $# != 0 ]; do
|
| 69 |
|
|
case $1 in
|
| 70 |
|
|
cont-??|metafun|mptopdf)
|
| 71 |
aballier |
1.8 |
einfo "Symlink $1 skipped (special case)"
|
| 72 |
aballier |
1.2 |
;;
|
| 73 |
aballier |
1.6 |
mf)
|
| 74 |
aballier |
1.8 |
einfo "Symlink $1 -> $2 skipped (texlive-core takes care of it)"
|
| 75 |
aballier |
1.6 |
;;
|
| 76 |
aballier |
1.2 |
*)
|
| 77 |
|
|
if [ $1 = $2 ];
|
| 78 |
|
|
then
|
| 79 |
aballier |
1.8 |
einfo "Symlink $1 -> $2 skipped"
|
| 80 |
aballier |
1.2 |
elif [ -e "${D}/usr/bin/$1" ];
|
| 81 |
|
|
then
|
| 82 |
aballier |
1.8 |
einfo "Symlink $1 skipped (file exists)"
|
| 83 |
aballier |
1.2 |
else
|
| 84 |
aballier |
1.8 |
einfo "Making symlink from $1 to $2"
|
| 85 |
aballier |
1.2 |
dosym $2 /usr/bin/$1
|
| 86 |
|
|
fi
|
| 87 |
|
|
;;
|
| 88 |
|
|
esac
|
| 89 |
|
|
shift; shift;
|
| 90 |
|
|
done
|
| 91 |
|
|
}
|
| 92 |
|
|
|
| 93 |
aballier |
1.4 |
# @FUNCTION: etexlinks
|
| 94 |
|
|
# @USAGE: < file >
|
| 95 |
|
|
# @DESCRIPTION:
|
| 96 |
aballier |
1.2 |
# Mimic texlinks on a fmtutil format file
|
| 97 |
aballier |
1.4 |
#
|
| 98 |
aballier |
1.2 |
# $1 has to be a fmtutil format file like fmtutil.cnf
|
| 99 |
|
|
# etexlinks foo will install the symlinks that texlinks --cnffile foo would have
|
| 100 |
|
|
# created. We cannot use texlinks with portage as it is not DESTDIR aware.
|
| 101 |
|
|
# (It would not fail but will not create the symlinks if the target is not in
|
| 102 |
|
|
# the same dir as the source)
|
| 103 |
|
|
# Also, as this eclass must not depend on a tex distribution to be installed we
|
| 104 |
|
|
# cannot use texlinks from here.
|
| 105 |
|
|
|
| 106 |
|
|
etexlinks() {
|
| 107 |
|
|
# Install symlinks from formats to engines
|
| 108 |
|
|
texlive-common_do_symlinks $(sed '/^[ ]*#/d; /^[ ]*$/d' "$1" | awk '{print $1, $2}')
|
| 109 |
|
|
}
|
| 110 |
|
|
|
| 111 |
aballier |
1.7 |
# @FUNCTION: dobin_texmf_scripts
|
| 112 |
|
|
# @USAGE: < file1 file2 ... >
|
| 113 |
|
|
# @DESCRIPTION:
|
| 114 |
aballier |
1.9 |
# Symlinks a script from the texmf tree to /usr/bin. Requires permissions to be
|
| 115 |
|
|
# correctly set for the file that it will point to.
|
| 116 |
aballier |
1.7 |
|
| 117 |
|
|
dobin_texmf_scripts() {
|
| 118 |
|
|
while [ $# -gt 0 ] ; do
|
| 119 |
|
|
local trg=$(basename ${1} | sed 's,\.[^/]*$,,' | tr '[:upper:]' '[:lower:]')
|
| 120 |
aballier |
1.9 |
einfo "Installing ${1} as ${trg} bin wrapper"
|
| 121 |
|
|
dosym ../share/${1} /usr/bin/${trg} || die "failed to install ${1} as $trg"
|
| 122 |
aballier |
1.7 |
shift
|
| 123 |
|
|
done
|
| 124 |
|
|
}
|