/[gentoo-x86]/eclass/x-modular.eclass
Gentoo

Diff of /eclass/x-modular.eclass

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

Revision 1.1 Revision 1.3
1# Copyright 1999-2005 Gentoo Foundation 1# Copyright 1999-2005 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/x-modular.eclass,v 1.1 2005/08/08 02:57:50 spyderous Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/x-modular.eclass,v 1.3 2005/08/14 23:04:02 spyderous Exp $
4# 4#
5# Author: Donnie Berkholz <spyderous@gentoo.org> 5# Author: Donnie Berkholz <spyderous@gentoo.org>
6# 6#
7# This eclass is designed to reduce code duplication in the modularized X11 7# This eclass is designed to reduce code duplication in the modularized X11
8# ebuilds. 8# ebuilds.
9#
10# If the ebuild installs fonts, set FONT="yes" at the top and set FONT_DIRS to
11# the subdirectories within /usr/share/fonts to which it installs fonts.
9 12
10EXPORT_FUNCTIONS src_unpack src_compile src_install 13EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_postinst
11 14
12inherit eutils 15inherit eutils
13 16
14# Directory prefix to use for everything 17# Directory prefix to use for everything
15# Change to /usr/X11R6 once it's standard 18# Change to /usr/X11R6 once it's standard
27 DEPEND="${DEPEND} 30 DEPEND="${DEPEND}
28 >=sys-devel/autoconf-2.57 31 >=sys-devel/autoconf-2.57
29 >=sys-devel/automake-1.7 32 >=sys-devel/automake-1.7
30 >=sys-devel/libtool-1.5 33 >=sys-devel/libtool-1.5
31 >=sys-devel/m4-1.4" 34 >=sys-devel/m4-1.4"
35fi
36
37# If we're a font package, but not the font.alias one
38if [[ "${PN/#font}" != "${PN}" ]] && [[ "${PN}" != "font-alias" ]]; then
39 RDEPEND="${RDEPEND}
40 media-fonts/encodings"
41 PDEPEND="${PDEPEND}
42 media-fonts/font-alias"
32fi 43fi
33 44
34DEPEND="${DEPEND} 45DEPEND="${DEPEND}
35 dev-util/pkgconfig 46 dev-util/pkgconfig
36 x11-misc/util-macros" 47 x11-misc/util-macros"
107# Shouldn't be necessary in XDIR=/usr 118# Shouldn't be necessary in XDIR=/usr
108# einstall forces datadir, so we need to re-force it 119# einstall forces datadir, so we need to re-force it
109# datadir=${XDIR}/share \ 120# datadir=${XDIR}/share \
110# mandir=${XDIR}/share/man \ 121# mandir=${XDIR}/share/man \
111} 122}
123
124x-modular_pkg_postinst() {
125 if [[ -n "${FONT}" ]]; then
126 setup_fonts
127 fi
128}
129
130setup_fonts() {
131 if [[ ! -n "${FONT_DIRS}" ]]; then
132 msg="FONT_DIRS empty. Set it to at least one subdir of /usr/share/fonts."
133 eerror ${msg}
134 die ${msg}
135 fi
136
137 create_fonts_scale
138 create_fonts_dir
139 fix_font_permissions
140 create_font_cache
141}
142
143create_fonts_scale() {
144 ebegin "Creating fonts.scale files"
145 local x
146 for FONT_DIR in ${FONT_DIRS}; do
147 x=${ROOT}/usr/share/fonts/${FONT_DIR}
148 [ -z "$(ls ${x}/)" ] && continue
149 [ "$(ls ${x}/)" = "fonts.cache-1" ] && continue
150
151 # Only generate .scale files if truetype, opentype or type1
152 # fonts are present ...
153
154 # First truetype (ttf,ttc)
155 # NOTE: ttmkfdir does NOT work on type1 fonts (#53753)
156 # Also, there is no way to regenerate Speedo/CID fonts.scale
157 # <spyderous@gentoo.org> 2 August 2004
158 if [ "${x/encodings}" = "${x}" -a \
159 -n "$(find ${x} -iname '*.tt[cf]' -print)" ]; then
160 if [ -x ${ROOT}/usr/bin/ttmkfdir ]; then
161 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
162 ${ROOT}/usr/bin/ttmkfdir -x 2 \
163 -e ${ROOT}/usr/share/fonts/encodings/encodings.dir \
164 -o ${x}/fonts.scale -d ${x}
165 # ttmkfdir fails on some stuff, so try mkfontscale if it does
166 local ttmkfdir_return=$?
167 else
168 # We didn't use ttmkfdir at all
169 local ttmkfdir_return=2
170 fi
171 if [ ${ttmkfdir_return} -ne 0 ]; then
172 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
173 ${ROOT}/usr/bin/mkfontscale \
174 -a /usr/share/fonts/encodings/encodings.dir \
175 -- ${x}
176 fi
177 # Next type1 and opentype (pfa,pfb,otf,otc)
178 elif [ "${x/encodings}" = "${x}" -a \
179 -n "$(find ${x} -iname '*.[po][ft][abcf]' -print)" ]; then
180 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
181 ${ROOT}/usr/bin/mkfontscale \
182 -a ${ROOT}/usr/share/fonts/encodings/encodings.dir \
183 -- ${x}
184 fi
185 done
186 eend 0
187}
188
189create_fonts_dir() {
190 ebegin "Generating fonts.dir files"
191 for FONT_DIR in ${FONT_DIRS}; do
192 x=${ROOT}/usr/share/fonts/${FONT_DIR}
193 [ -z "$(ls ${x}/)" ] && continue
194 [ "$(ls ${x}/)" = "fonts.cache-1" ] && continue
195
196 if [ "${x/encodings}" = "${x}" ]; then
197 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
198 ${ROOT}/usr/bin/mkfontdir \
199 -e ${ROOT}/usr/share/fonts/encodings \
200 -e ${ROOT}/usr/share/fonts/encodings/large \
201 -- ${x}
202 fi
203 done
204 eend 0
205}
206
207fix_font_permissions() {
208 ebegin "Fixing permissions"
209 for FONT_DIR in ${FONT_DIRS}; do
210 find ${ROOT}/usr/share/fonts/${FONT_DIR} -type f -name 'font.*' \
211 -exec chmod 0644 {} \;
212 done
213 eend 0
214}
215
216create_font_cache() {
217 # danarmak found out that fc-cache should be run AFTER all the above
218 # stuff, as otherwise the cache is invalid, and has to be run again
219 # as root anyway
220 if [ -x ${ROOT}/usr/bin/fc-cache ]; then
221 ebegin "Creating FC font cache"
222 HOME="/root" ${ROOT}/usr/bin/fc-cache
223 eend 0
224 fi
225}

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

  ViewVC Help
Powered by ViewVC 1.1.20