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

Contents of /eclass/texlive-common.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.17 - (hide annotations) (download)
Fri Mar 30 13:50:39 2012 UTC (2 years, 5 months ago) by aballier
Branch: MAIN
Changes since 1.16: +2 -4 lines
installing broken links has been non fatal only for texlive prior to 2010, which are now gone, remove the code for these versions and make it always fatal

1 vapier 1.15 # Copyright 1999-2011 Gentoo Foundation
2 aballier 1.1 # Distributed under the terms of the GNU General Public License v2
3 aballier 1.17 # $Header: /var/cvsroot/gentoo-x86/eclass/texlive-common.eclass,v 1.16 2011/08/29 01:28:10 vapier 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    
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 aballier 1.12 for f in $(find . -name '*.cnf' -type f -o -name '*.cfg' -type f | sed -e "s:\./::g") ; do
34 aballier 1.11 if [ "${f#*config}" != "${f}" -o "${f#doc}" != "${f}" ] ; then
35 aballier 1.1 continue
36     fi
37     dodir /etc/texmf/$(dirname ${f}).d
38 aballier 1.10 einfo "Moving (and symlinking) ${TEXMF_PATH}/${f} to /etc/texmf/$(dirname ${f}).d"
39 aballier 1.1 mv "${D}/${TEXMF_PATH}/${f}" "${D}/etc/texmf/$(dirname ${f}).d" || die "mv ${f} failed."
40     dosym /etc/texmf/$(dirname ${f}).d/$(basename ${f}) ${TEXMF_PATH}/${f}
41     done
42     }
43    
44 aballier 1.4 # @FUNCTION: texlive-common_is_file_present_in_texmf
45     # @DESCRIPTION:
46 aballier 1.1 # Return if a file is present in the texmf tree
47     # Call it from the directory containing texmf and texmf-dist
48    
49     texlive-common_is_file_present_in_texmf() {
50     local mark="${T}/$1.found"
51     find texmf -name $1 -exec touch "${mark}" \;
52     find texmf-dist -name $1 -exec touch "${mark}" \;
53     [ -f "${mark}" ]
54     }
55 aballier 1.2
56 aballier 1.4 # @FUNCTION: texlive-common_do_symlinks
57     # @USAGE: < src > < dest >
58     # @DESCRIPTION:
59 aballier 1.2 # Mimic the install_link function of texlinks
60 aballier 1.4 #
61 aballier 1.2 # 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    
68     texlive-common_do_symlinks() {
69     while [ $# != 0 ]; do
70     case $1 in
71     cont-??|metafun|mptopdf)
72 aballier 1.8 einfo "Symlink $1 skipped (special case)"
73 aballier 1.2 ;;
74 aballier 1.6 mf)
75 aballier 1.8 einfo "Symlink $1 -> $2 skipped (texlive-core takes care of it)"
76 aballier 1.6 ;;
77 aballier 1.2 *)
78     if [ $1 = $2 ];
79     then
80 aballier 1.8 einfo "Symlink $1 -> $2 skipped"
81 aballier 1.2 elif [ -e "${D}/usr/bin/$1" ];
82     then
83 aballier 1.8 einfo "Symlink $1 skipped (file exists)"
84 aballier 1.2 else
85 aballier 1.8 einfo "Making symlink from $1 to $2"
86 aballier 1.2 dosym $2 /usr/bin/$1
87     fi
88     ;;
89     esac
90     shift; shift;
91     done
92     }
93    
94 aballier 1.4 # @FUNCTION: etexlinks
95 vapier 1.16 # @USAGE: < file >
96 aballier 1.4 # @DESCRIPTION:
97 aballier 1.2 # Mimic texlinks on a fmtutil format file
98 aballier 1.4 #
99 aballier 1.2 # $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    
107     etexlinks() {
108     # Install symlinks from formats to engines
109     texlive-common_do_symlinks $(sed '/^[ ]*#/d; /^[ ]*$/d' "$1" | awk '{print $1, $2}')
110     }
111    
112 aballier 1.7 # @FUNCTION: dobin_texmf_scripts
113 vapier 1.16 # @USAGE: < file1 file2 ... >
114 aballier 1.7 # @DESCRIPTION:
115 aballier 1.9 # Symlinks a script from the texmf tree to /usr/bin. Requires permissions to be
116 vapier 1.16 # correctly set for the file that it will point to.
117 aballier 1.7
118     dobin_texmf_scripts() {
119     while [ $# -gt 0 ] ; do
120     local trg=$(basename ${1} | sed 's,\.[^/]*$,,' | tr '[:upper:]' '[:lower:]')
121 aballier 1.9 einfo "Installing ${1} as ${trg} bin wrapper"
122 aballier 1.17 [ -x "${D}/usr/share/${1}" ] || die "Trying to install a non existing or non executable symlink to /usr/bin: ${1}"
123 aballier 1.9 dosym ../share/${1} /usr/bin/${trg} || die "failed to install ${1} as $trg"
124 aballier 1.7 shift
125     done
126     }
127 aballier 1.14
128     # @FUNCTION: etexmf-update
129     # @USAGE: In ebuilds' pkg_postinst and pkg_postrm phases
130     # @DESCRIPTION:
131     # Runs texmf-update if it is available and prints a warning otherwise. This
132     # function helps in factorizing some code.
133    
134     etexmf-update() {
135     if [ "$ROOT" = "/" ] && [ -x /usr/sbin/texmf-update ] ; then
136     /usr/sbin/texmf-update
137     else
138     ewarn "Cannot run texmf-update for some reason."
139     ewarn "Your texmf tree might be inconsistent with your configuration"
140     ewarn "Please try to figure what has happened"
141     fi
142     }

  ViewVC Help
Powered by ViewVC 1.1.20