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

Contents of /eclass/texlive-common.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.21 - (show annotations) (download)
Tue Mar 18 16:52:10 2014 UTC (6 months ago) by ottxor
Branch: MAIN
CVS Tags: HEAD
Changes since 1.20: +19 -12 lines
added prefix support (bug #485608)

1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/texlive-common.eclass,v 1.20 2013/06/26 15:54:48 aballier Exp $
4
5 # @ECLASS: texlive-common.eclass
6 # @MAINTAINER:
7 # tex@gentoo.org
8 # @AUTHOR:
9 # Original Author: Alexis Ballier <aballier@gentoo.org>
10 # @BLURB: Provide various functions used by both texlive-core and texlive modules
11 # @DESCRIPTION:
12 # Purpose: Provide various functions used by both texlive-core and texlive
13 # modules.
14 #
15 # Note that this eclass *must* not assume the presence of any standard tex tool
16
17 case "${EAPI:-0}" in
18 0|1|2)
19 die "EAPI='${EAPI}' is not supported anymore"
20 ;;
21 *)
22 ;;
23 esac
24
25 TEXMF_PATH=/usr/share/texmf
26 TEXMF_DIST_PATH=/usr/share/texmf-dist
27 TEXMF_VAR_PATH=/var/lib/texmf
28
29 # @FUNCTION: texlive-common_handle_config_files
30 # @DESCRIPTION:
31 # Has to be called in src_install after having installed the files in ${D}
32 # This function will move the relevant files to /etc/texmf and symling them
33 # from their original location. This is to allow easy update of texlive's
34 # configuration
35
36 texlive-common_handle_config_files() {
37 # Handle config files properly
38 [ -d "${ED}${TEXMF_PATH}" ] || return
39 cd "${ED}${TEXMF_PATH}"
40 for f in $(find . -name '*.cnf' -type f -o -name '*.cfg' -type f | sed -e "s:\./::g") ; do
41 if [ "${f#*config}" != "${f}" -o "${f#doc}" != "${f}" ] ; then
42 continue
43 fi
44 dodir /etc/texmf/$(dirname ${f}).d
45 einfo "Moving (and symlinking) ${EPREFIX}${TEXMF_PATH}/${f} to ${EPREFIX}/etc/texmf/$(dirname ${f}).d"
46 mv "${ED}/${TEXMF_PATH}/${f}" "${ED}/etc/texmf/$(dirname ${f}).d" || die "mv ${f} failed."
47 dosym /etc/texmf/$(dirname ${f}).d/$(basename ${f}) ${TEXMF_PATH}/${f}
48 done
49 }
50
51 # @FUNCTION: texlive-common_is_file_present_in_texmf
52 # @DESCRIPTION:
53 # Return if a file is present in the texmf tree
54 # Call it from the directory containing texmf and texmf-dist
55
56 texlive-common_is_file_present_in_texmf() {
57 local mark="${T}/$1.found"
58 [ -d texmf ] && find texmf -name $1 -exec touch "${mark}" \;
59 [ -d texmf-dist ] && find texmf-dist -name $1 -exec touch "${mark}" \;
60 [ -f "${mark}" ]
61 }
62
63 # @FUNCTION: texlive-common_do_symlinks
64 # @USAGE: < src > < dest >
65 # @DESCRIPTION:
66 # Mimic the install_link function of texlinks
67 #
68 # Should have the same behavior as the one in /usr/bin/texlinks
69 # except that it is under the control of the package manager
70 # Note that $1 corresponds to $src and $2 to $dest in this function
71 # ( Arguments are switched because texlinks main function sends them switched )
72 # This function should not be called from an ebuild, prefer etexlinks that will
73 # also do the fmtutil file parsing.
74
75 texlive-common_do_symlinks() {
76 while [ $# != 0 ]; do
77 case $1 in
78 cont-??|metafun|mptopdf)
79 einfo "Symlink $1 skipped (special case)"
80 ;;
81 mf)
82 einfo "Symlink $1 -> $2 skipped (texlive-core takes care of it)"
83 ;;
84 *)
85 if [ $1 = $2 ];
86 then
87 einfo "Symlink $1 -> $2 skipped"
88 elif [ -e "${ED}/usr/bin/$1" ];
89 then
90 einfo "Symlink $1 skipped (file exists)"
91 else
92 einfo "Making symlink from $1 to $2"
93 dosym $2 /usr/bin/$1
94 fi
95 ;;
96 esac
97 shift; shift;
98 done
99 }
100
101 # @FUNCTION: etexlinks
102 # @USAGE: < file >
103 # @DESCRIPTION:
104 # Mimic texlinks on a fmtutil format file
105 #
106 # $1 has to be a fmtutil format file like fmtutil.cnf
107 # etexlinks foo will install the symlinks that texlinks --cnffile foo would have
108 # created. We cannot use texlinks with portage as it is not DESTDIR aware.
109 # (It would not fail but will not create the symlinks if the target is not in
110 # the same dir as the source)
111 # Also, as this eclass must not depend on a tex distribution to be installed we
112 # cannot use texlinks from here.
113
114 etexlinks() {
115 # Install symlinks from formats to engines
116 texlive-common_do_symlinks $(sed '/^[ ]*#/d; /^[ ]*$/d' "$1" | awk '{print $1, $2}')
117 }
118
119 # @FUNCTION: dobin_texmf_scripts
120 # @USAGE: < file1 file2 ... >
121 # @DESCRIPTION:
122 # Symlinks a script from the texmf tree to /usr/bin. Requires permissions to be
123 # correctly set for the file that it will point to.
124
125 dobin_texmf_scripts() {
126 while [ $# -gt 0 ] ; do
127 local trg=$(basename ${1} | sed 's,\.[^/]*$,,' | tr '[:upper:]' '[:lower:]')
128 einfo "Installing ${1} as ${trg} bin wrapper"
129 [ -x "${ED}/usr/share/${1}" ] || die "Trying to install a non existing or non executable symlink to /usr/bin: ${1}"
130 dosym ../share/${1} /usr/bin/${trg} || die "failed to install ${1} as $trg"
131 shift
132 done
133 }
134
135 # @FUNCTION: etexmf-update
136 # @USAGE: In ebuilds' pkg_postinst and pkg_postrm phases
137 # @DESCRIPTION:
138 # Runs texmf-update if it is available and prints a warning otherwise. This
139 # function helps in factorizing some code.
140
141 etexmf-update() {
142 if has_version 'app-text/texlive-core' ; then
143 if [ "$ROOT" = "/" ] && [ -x "${EPREFIX}"/usr/sbin/texmf-update ] ; then
144 "${EPREFIX}"/usr/sbin/texmf-update
145 else
146 ewarn "Cannot run texmf-update for some reason."
147 ewarn "Your texmf tree might be inconsistent with your configuration"
148 ewarn "Please try to figure what has happened"
149 fi
150 fi
151 }
152
153 # @FUNCTION: efmtutil-sys
154 # @USAGE: In ebuilds' pkg_postinst to force a rebuild of TeX formats.
155 # @DESCRIPTION:
156 # Runs fmtutil-sys if it is available and prints a warning otherwise. This
157 # function helps in factorizing some code.
158
159 efmtutil-sys() {
160 if has_version 'app-text/texlive-core' ; then
161 if [ "$ROOT" = "/" ] && [ -x "${EPREFIX}"/usr/bin/fmtutil-sys ] ; then
162 einfo "Rebuilding formats"
163 "${EPREFIX}"/usr/bin/fmtutil-sys --all &> /dev/null
164 else
165 ewarn "Cannot run fmtutil-sys for some reason."
166 ewarn "Your formats might be inconsistent with your installed ${PN} version"
167 ewarn "Please try to figure what has happened"
168 fi
169 fi
170 }

  ViewVC Help
Powered by ViewVC 1.1.20