/[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.5
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.5 2005/08/15 00:33:31 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_preinst 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
16XDIR="/usr" 18XDIR="/usr"
17 19
18IUSE="" 20IUSE=""
19HOMEPAGE="http://xorg.freedesktop.org/" 21HOMEPAGE="http://xorg.freedesktop.org/"
20SRC_URI="http://xorg.freedesktop.org/X11R7.0-RC0/everything/${P}.tar.bz2" 22SRC_URI="http://xorg.freedesktop.org/X11R7.0-RC0/everything/${P}.tar.bz2"
27 DEPEND="${DEPEND} 29 DEPEND="${DEPEND}
28 >=sys-devel/autoconf-2.57 30 >=sys-devel/autoconf-2.57
29 >=sys-devel/automake-1.7 31 >=sys-devel/automake-1.7
30 >=sys-devel/libtool-1.5 32 >=sys-devel/libtool-1.5
31 >=sys-devel/m4-1.4" 33 >=sys-devel/m4-1.4"
34fi
35
36# If we're a font package, but not the font.alias one
37if [[ "${PN/#font}" != "${PN}" ]] && [[ "${PN}" != "font-alias" ]]; then
38 # Activate font code in the rest of the eclass
39 FONT="yes"
40
41 RDEPEND="${RDEPEND}
42 media-fonts/encodings"
43 PDEPEND="${PDEPEND}
44 media-fonts/font-alias"
32fi 45fi
33 46
34DEPEND="${DEPEND} 47DEPEND="${DEPEND}
35 dev-util/pkgconfig 48 dev-util/pkgconfig
36 x11-misc/util-macros" 49 x11-misc/util-macros"
107# Shouldn't be necessary in XDIR=/usr 120# Shouldn't be necessary in XDIR=/usr
108# einstall forces datadir, so we need to re-force it 121# einstall forces datadir, so we need to re-force it
109# datadir=${XDIR}/share \ 122# datadir=${XDIR}/share \
110# mandir=${XDIR}/share/man \ 123# mandir=${XDIR}/share/man \
111} 124}
125
126x-modular_pkg_preinst() {
127 if [[ -n "${FONT}" ]]; then
128 discover_font_dirs
129 fi
130}
131
132x-modular_pkg_postinst() {
133 if [[ -n "${FONT}" ]]; then
134 setup_fonts
135 fi
136}
137
138setup_fonts() {
139 if [[ ! -n "${FONT_DIRS}" ]]; then
140 msg="FONT_DIRS empty. Set it to at least one subdir of /usr/share/fonts."
141 eerror ${msg}
142 die ${msg}
143 fi
144
145 create_fonts_scale
146 create_fonts_dir
147 fix_font_permissions
148 create_font_cache
149}
150
151discover_font_dirs() {
152 pushd ${IMAGE}/usr/share/fonts
153 FONT_DIRS="$(find . -maxdepth 1 -mindepth 1 -type d)"
154 FONT_DIRS="$(echo ${FONT_DIRS} | sed -e 's:./::g')"
155 popd
156}
157
158create_fonts_scale() {
159 ebegin "Creating fonts.scale files"
160 local x
161 for FONT_DIR in ${FONT_DIRS}; do
162 x=${ROOT}/usr/share/fonts/${FONT_DIR}
163 [ -z "$(ls ${x}/)" ] && continue
164 [ "$(ls ${x}/)" = "fonts.cache-1" ] && continue
165
166 # Only generate .scale files if truetype, opentype or type1
167 # fonts are present ...
168
169 # First truetype (ttf,ttc)
170 # NOTE: ttmkfdir does NOT work on type1 fonts (#53753)
171 # Also, there is no way to regenerate Speedo/CID fonts.scale
172 # <spyderous@gentoo.org> 2 August 2004
173 if [ "${x/encodings}" = "${x}" -a \
174 -n "$(find ${x} -iname '*.tt[cf]' -print)" ]; then
175 if [ -x ${ROOT}/usr/bin/ttmkfdir ]; then
176 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
177 ${ROOT}/usr/bin/ttmkfdir -x 2 \
178 -e ${ROOT}/usr/share/fonts/encodings/encodings.dir \
179 -o ${x}/fonts.scale -d ${x}
180 # ttmkfdir fails on some stuff, so try mkfontscale if it does
181 local ttmkfdir_return=$?
182 else
183 # We didn't use ttmkfdir at all
184 local ttmkfdir_return=2
185 fi
186 if [ ${ttmkfdir_return} -ne 0 ]; then
187 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
188 ${ROOT}/usr/bin/mkfontscale \
189 -a /usr/share/fonts/encodings/encodings.dir \
190 -- ${x}
191 fi
192 # Next type1 and opentype (pfa,pfb,otf,otc)
193 elif [ "${x/encodings}" = "${x}" -a \
194 -n "$(find ${x} -iname '*.[po][ft][abcf]' -print)" ]; then
195 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
196 ${ROOT}/usr/bin/mkfontscale \
197 -a ${ROOT}/usr/share/fonts/encodings/encodings.dir \
198 -- ${x}
199 fi
200 done
201 eend 0
202}
203
204create_fonts_dir() {
205 ebegin "Generating fonts.dir files"
206 for FONT_DIR in ${FONT_DIRS}; do
207 x=${ROOT}/usr/share/fonts/${FONT_DIR}
208 [ -z "$(ls ${x}/)" ] && continue
209 [ "$(ls ${x}/)" = "fonts.cache-1" ] && continue
210
211 if [ "${x/encodings}" = "${x}" ]; then
212 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
213 ${ROOT}/usr/bin/mkfontdir \
214 -e ${ROOT}/usr/share/fonts/encodings \
215 -e ${ROOT}/usr/share/fonts/encodings/large \
216 -- ${x}
217 fi
218 done
219 eend 0
220}
221
222fix_font_permissions() {
223 ebegin "Fixing permissions"
224 for FONT_DIR in ${FONT_DIRS}; do
225 find ${ROOT}/usr/share/fonts/${FONT_DIR} -type f -name 'font.*' \
226 -exec chmod 0644 {} \;
227 done
228 eend 0
229}
230
231create_font_cache() {
232 # danarmak found out that fc-cache should be run AFTER all the above
233 # stuff, as otherwise the cache is invalid, and has to be run again
234 # as root anyway
235 if [ -x ${ROOT}/usr/bin/fc-cache ]; then
236 ebegin "Creating FC font cache"
237 HOME="/root" ${ROOT}/usr/bin/fc-cache
238 eend 0
239 fi
240}

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

  ViewVC Help
Powered by ViewVC 1.1.20