/[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.2
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.2 2005/08/11 06:19:16 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
107# Shouldn't be necessary in XDIR=/usr 110# Shouldn't be necessary in XDIR=/usr
108# einstall forces datadir, so we need to re-force it 111# einstall forces datadir, so we need to re-force it
109# datadir=${XDIR}/share \ 112# datadir=${XDIR}/share \
110# mandir=${XDIR}/share/man \ 113# mandir=${XDIR}/share/man \
111} 114}
115
116x-modular_pkg_postinst() {
117 if [[ -n "${FONT}" ]]; then
118 setup_fonts
119 fi
120}
121
122setup_fonts() {
123 if [[ ! -n "${FONT_DIRS}" ]]; then
124 msg="FONT_DIRS empty. Set it to at least one subdir of /usr/share/fonts."
125 eerror ${msg}
126 die ${msg}
127 fi
128
129 create_fonts_scale
130 create_fonts_dir
131 fix_font_permissions
132 create_font_cache
133}
134
135create_fonts_scale() {
136 ebegin "Creating fonts.scale files"
137 local x
138 for FONT_DIR in ${FONT_DIRS}; do
139 x=${ROOT}/usr/share/fonts/${FONT_DIR}
140 [ -z "$(ls ${x}/)" ] && continue
141 [ "$(ls ${x}/)" = "fonts.cache-1" ] && continue
142
143 # Only generate .scale files if truetype, opentype or type1
144 # fonts are present ...
145
146 # First truetype (ttf,ttc)
147 # NOTE: ttmkfdir does NOT work on type1 fonts (#53753)
148 # Also, there is no way to regenerate Speedo/CID fonts.scale
149 # <spyderous@gentoo.org> 2 August 2004
150 if [ "${x/encodings}" = "${x}" -a \
151 -n "$(find ${x} -iname '*.tt[cf]' -print)" ]; then
152 if [ -x ${ROOT}/usr/bin/ttmkfdir ]; then
153 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
154 ${ROOT}/usr/bin/ttmkfdir -x 2 \
155 -e ${ROOT}/usr/share/fonts/encodings/encodings.dir \
156 -o ${x}/fonts.scale -d ${x}
157 # ttmkfdir fails on some stuff, so try mkfontscale if it does
158 local ttmkfdir_return=$?
159 else
160 # We didn't use ttmkfdir at all
161 local ttmkfdir_return=2
162 fi
163 if [ ${ttmkfdir_return} -ne 0 ]; then
164 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
165 ${ROOT}/usr/bin/mkfontscale \
166 -a /usr/share/fonts/encodings/encodings.dir \
167 -- ${x}
168 fi
169 # Next type1 and opentype (pfa,pfb,otf,otc)
170 elif [ "${x/encodings}" = "${x}" -a \
171 -n "$(find ${x} -iname '*.[po][ft][abcf]' -print)" ]; then
172 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
173 ${ROOT}/usr/bin/mkfontscale \
174 -a ${ROOT}/usr/share/fonts/encodings/encodings.dir \
175 -- ${x}
176 fi
177 done
178 eend 0
179}
180
181create_fonts_dir() {
182 ebegin "Generating fonts.dir files"
183 for FONT_DIR in ${FONT_DIRS}; do
184 x=${ROOT}/usr/share/fonts/${FONT_DIR}
185 [ -z "$(ls ${x}/)" ] && continue
186 [ "$(ls ${x}/)" = "fonts.cache-1" ] && continue
187
188 if [ "${x/encodings}" = "${x}" ]; then
189 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
190 ${ROOT}/usr/bin/mkfontdir \
191 -e ${ROOT}/usr/share/fonts/encodings \
192 -e ${ROOT}/usr/share/fonts/encodings/large \
193 -- ${x}
194 fi
195 done
196 eend 0
197}
198
199fix_font_permissions() {
200 ebegin "Fixing permissions"
201 for FONT_DIR in ${FONT_DIRS}; do
202 find ${ROOT}/usr/share/fonts/${FONT_DIR} -type f -name 'font.*' \
203 -exec chmod 0644 {} \;
204 done
205 eend 0
206}
207
208create_font_cache() {
209 # danarmak found out that fc-cache should be run AFTER all the above
210 # stuff, as otherwise the cache is invalid, and has to be run again
211 # as root anyway
212 if [ -x ${ROOT}/usr/bin/fc-cache ]; then
213 ebegin "Creating FC font cache"
214 HOME="/root" ${ROOT}/usr/bin/fc-cache
215 eend 0
216 fi
217}

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

  ViewVC Help
Powered by ViewVC 1.1.20