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

Contents of /eclass/texlive-common.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.21 - (hide 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 ottxor 1.21 # Copyright 1999-2014 Gentoo Foundation
2 aballier 1.1 # Distributed under the terms of the GNU General Public License v2
3 ottxor 1.21 # $Header: /var/cvsroot/gentoo-x86/eclass/texlive-common.eclass,v 1.20 2013/06/26 15:54:48 aballier Exp $
4 aballier 1.1
5 aballier 1.4 # @ECLASS: texlive-common.eclass
6     # @MAINTAINER:
7     # tex@gentoo.org
8 vapier 1.15 # @AUTHOR:
9 aballier 1.1 # 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 ottxor 1.21 case "${EAPI:-0}" in
18     0|1|2)
19     die "EAPI='${EAPI}' is not supported anymore"
20     ;;
21     *)
22     ;;
23     esac
24 aballier 1.1
25     TEXMF_PATH=/usr/share/texmf
26     TEXMF_DIST_PATH=/usr/share/texmf-dist
27 aballier 1.3 TEXMF_VAR_PATH=/var/lib/texmf
28 aballier 1.1
29 aballier 1.4 # @FUNCTION: texlive-common_handle_config_files
30     # @DESCRIPTION:
31 aballier 1.1 # 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 ottxor 1.21 [ -d "${ED}${TEXMF_PATH}" ] || return
39     cd "${ED}${TEXMF_PATH}"
40 aballier 1.12 for f in $(find . -name '*.cnf' -type f -o -name '*.cfg' -type f | sed -e "s:\./::g") ; do
41 aballier 1.11 if [ "${f#*config}" != "${f}" -o "${f#doc}" != "${f}" ] ; then
42 aballier 1.1 continue
43     fi
44     dodir /etc/texmf/$(dirname ${f}).d
45 ottxor 1.21 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 aballier 1.1 dosym /etc/texmf/$(dirname ${f}).d/$(basename ${f}) ${TEXMF_PATH}/${f}
48     done
49     }
50    
51 aballier 1.4 # @FUNCTION: texlive-common_is_file_present_in_texmf
52     # @DESCRIPTION:
53 aballier 1.1 # 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 aballier 1.20 [ -d texmf ] && find texmf -name $1 -exec touch "${mark}" \;
59     [ -d texmf-dist ] && find texmf-dist -name $1 -exec touch "${mark}" \;
60 aballier 1.1 [ -f "${mark}" ]
61     }
62 aballier 1.2
63 aballier 1.4 # @FUNCTION: texlive-common_do_symlinks
64     # @USAGE: < src > < dest >
65     # @DESCRIPTION:
66 aballier 1.2 # Mimic the install_link function of texlinks
67 aballier 1.4 #
68 aballier 1.2 # 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 aballier 1.8 einfo "Symlink $1 skipped (special case)"
80 aballier 1.2 ;;
81 aballier 1.6 mf)
82 aballier 1.8 einfo "Symlink $1 -> $2 skipped (texlive-core takes care of it)"
83 aballier 1.6 ;;
84 aballier 1.2 *)
85     if [ $1 = $2 ];
86     then
87 aballier 1.8 einfo "Symlink $1 -> $2 skipped"
88 ottxor 1.21 elif [ -e "${ED}/usr/bin/$1" ];
89 aballier 1.2 then
90 aballier 1.8 einfo "Symlink $1 skipped (file exists)"
91 aballier 1.2 else
92 aballier 1.8 einfo "Making symlink from $1 to $2"
93 aballier 1.2 dosym $2 /usr/bin/$1
94     fi
95     ;;
96     esac
97     shift; shift;
98     done
99     }
100    
101 aballier 1.4 # @FUNCTION: etexlinks
102 vapier 1.16 # @USAGE: < file >
103 aballier 1.4 # @DESCRIPTION:
104 aballier 1.2 # Mimic texlinks on a fmtutil format file
105 aballier 1.4 #
106 aballier 1.2 # $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 aballier 1.7 # @FUNCTION: dobin_texmf_scripts
120 vapier 1.16 # @USAGE: < file1 file2 ... >
121 aballier 1.7 # @DESCRIPTION:
122 aballier 1.9 # Symlinks a script from the texmf tree to /usr/bin. Requires permissions to be
123 vapier 1.16 # correctly set for the file that it will point to.
124 aballier 1.7
125     dobin_texmf_scripts() {
126     while [ $# -gt 0 ] ; do
127     local trg=$(basename ${1} | sed 's,\.[^/]*$,,' | tr '[:upper:]' '[:lower:]')
128 aballier 1.9 einfo "Installing ${1} as ${trg} bin wrapper"
129 ottxor 1.21 [ -x "${ED}/usr/share/${1}" ] || die "Trying to install a non existing or non executable symlink to /usr/bin: ${1}"
130 aballier 1.9 dosym ../share/${1} /usr/bin/${trg} || die "failed to install ${1} as $trg"
131 aballier 1.7 shift
132     done
133     }
134 aballier 1.14
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 aballier 1.18 if has_version 'app-text/texlive-core' ; then
143 ottxor 1.21 if [ "$ROOT" = "/" ] && [ -x "${EPREFIX}"/usr/sbin/texmf-update ] ; then
144     "${EPREFIX}"/usr/sbin/texmf-update
145 aballier 1.18 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 aballier 1.14 fi
151     }
152 aballier 1.19
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 ottxor 1.21 if [ "$ROOT" = "/" ] && [ -x "${EPREFIX}"/usr/bin/fmtutil-sys ] ; then
162 aballier 1.19 einfo "Rebuilding formats"
163 ottxor 1.21 "${EPREFIX}"/usr/bin/fmtutil-sys --all &> /dev/null
164 aballier 1.19 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