/[gentoo-x86]/eclass/texlive-common.eclass
Gentoo

Diff of /eclass/texlive-common.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.20