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

Contents of /eclass/x-modular.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.30 - (hide annotations) (download)
Sat Dec 10 21:49:07 2005 UTC (8 years, 10 months ago) by spyderous
Branch: MAIN
Changes since 1.29: +4 -1 lines
(#115085) Add mkfontdir and mkfontscale to DEPEND for fonts.

1 spyderous 1.1 # Copyright 1999-2005 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 spyderous 1.30 # $Header: /var/cvsroot/gentoo-x86/eclass/x-modular.eclass,v 1.29 2005/12/09 23:32:27 joshuabaergen Exp $
4 spyderous 1.1 #
5     # Author: Donnie Berkholz <spyderous@gentoo.org>
6     #
7     # This eclass is designed to reduce code duplication in the modularized X11
8     # ebuilds.
9 spyderous 1.2 #
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.
12 spyderous 1.1
13 spyderous 1.25 EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst pkg_postrm
14 spyderous 1.1
15 joshuabaergen 1.26 inherit eutils libtool toolchain-funcs
16 spyderous 1.1
17     # Directory prefix to use for everything
18     XDIR="/usr"
19    
20 joshuabaergen 1.29 # Set up default patchset version(s) if necessary
21     # x11-driver-patches
22     if [[ -z "${XDPVER}" ]]; then
23     XDPVER="1"
24     fi
25    
26 spyderous 1.1 IUSE=""
27     HOMEPAGE="http://xorg.freedesktop.org/"
28 joshuabaergen 1.23 SRC_URI="http://xorg.freedesktop.org/releases/X11R7.0-RC3/everything/${P}.tar.bz2
29     http://xorg.freedesktop.org/releases/X11R7.0-RC2/everything/${P}.tar.bz2
30 spyderous 1.20 http://xorg.freedesktop.org/releases/X11R7.0-RC1/everything/${P}.tar.bz2
31 spyderous 1.14 http://xorg.freedesktop.org/releases/X11R7.0-RC0/everything/${P}.tar.bz2"
32 spyderous 1.1 LICENSE="X11"
33     SLOT="0"
34    
35     # Set up shared dependencies
36 spyderous 1.28 if [[ -n "${SNAPSHOT}" ]]; then
37 spyderous 1.1 # FIXME: What's the minimal libtool version supporting arbitrary versioning?
38     DEPEND="${DEPEND}
39     >=sys-devel/autoconf-2.57
40     >=sys-devel/automake-1.7
41     >=sys-devel/libtool-1.5
42     >=sys-devel/m4-1.4"
43     fi
44    
45 spyderous 1.3 # If we're a font package, but not the font.alias one
46 spyderous 1.25 if [[ "${PN/#font-}" != "${PN}" ]] \
47     && [[ "${PN}" != "font-alias" ]] \
48     && [[ "${PN}" != "font-util" ]]; then
49 spyderous 1.4 # Activate font code in the rest of the eclass
50     FONT="yes"
51    
52 spyderous 1.3 RDEPEND="${RDEPEND}
53     media-fonts/encodings"
54 spyderous 1.30 DEPEND="${DEPEND}
55     x11-apps/mkfontscale
56     x11-apps/mkfontdir"
57 spyderous 1.3 PDEPEND="${PDEPEND}
58     media-fonts/font-alias"
59 spyderous 1.25
60     # Starting with 7.0RC3, we can specify the font directory
61     # But oddly, we can't do the same for encodings or font-alias
62    
63     # Wrap in `if` so ebuilds can set it too
64     if [[ -z ${FONT_DIR} ]]; then
65     FONT_DIR=${PN##*-}
66    
67     fi
68    
69     # Fix case of font directories
70     FONT_DIR=${FONT_DIR/ttf/TTF}
71     FONT_DIR=${FONT_DIR/otf/OTF}
72     FONT_DIR=${FONT_DIR/type1/Type1}
73     FONT_DIR=${FONT_DIR/speedo/Speedo}
74    
75     # Set up configure option
76     FONT_OPTIONS="--with-fontdir=\"/usr/share/fonts/${FONT_DIR}\""
77    
78     if [[ -n "${FONT}" ]]; then
79     if [[ ${PN##*-} = misc ]] || [[ ${PN##*-} = 75dpi ]] || [[ ${PN##*-} = 100dpi ]]; then
80     IUSE="${IUSE} nls"
81     fi
82     fi
83 spyderous 1.3 fi
84    
85 spyderous 1.7 # If we're a driver package
86 spyderous 1.12 if [[ "${PN/#xf86-video}" != "${PN}" ]] || [[ "${PN/#xf86-input}" != "${PN}" ]]; then
87 spyderous 1.7 # Don't build static driver modules
88     DRIVER_OPTIONS="--disable-static"
89 joshuabaergen 1.29
90     # Enable driver code in the rest of the eclass
91     DRIVER="yes"
92    
93     # Add driver patchset to SRC_URI
94     SRC_URI="${SRC_URI}
95     http://dev.gentoo.org/~joshuabaergen/distfiles/x11-driver-patches-${XDPVER}.tar.bz2"
96 spyderous 1.7 fi
97    
98 spyderous 1.1 DEPEND="${DEPEND}
99 spyderous 1.11 >=dev-util/pkgconfig-0.18
100 spyderous 1.24 >=x11-misc/util-macros-0.99.2"
101 spyderous 1.1
102 spyderous 1.21 # >=sys-apps/man-1.6b-r2 required to look in [0-8]x/ directories
103 spyderous 1.13 RDEPEND="${RDEPEND}
104 joshuabaergen 1.22 !<=x11-base/xorg-x11-6.9
105 spyderous 1.21 >=sys-apps/man-1.6b-r2"
106 spyderous 1.13 # Provides virtual/x11 for temporary use until packages are ported
107 spyderous 1.1 # x11-base/x11-env"
108    
109     x-modular_unpack_source() {
110     unpack ${A}
111     cd ${S}
112 joshuabaergen 1.16
113 spyderous 1.25 if [[ -n ${FONT_OPTIONS} ]]; then
114     einfo "Detected font directory: ${FONT_DIR}"
115     fi
116 spyderous 1.1 }
117    
118     x-modular_patch_source() {
119     # Use standardized names and locations with bulk patching
120     # Patch directory is ${WORKDIR}/patch
121     # See epatch() in eutils.eclass for more documentation
122 spyderous 1.28 if [[ -z "${EPATCH_SUFFIX}" ]] ; then
123 spyderous 1.1 EPATCH_SUFFIX="patch"
124     fi
125    
126 joshuabaergen 1.29 # If this is a driver package we need to fix man page install location.
127     # Running autoreconf will use the patched util-macros to make the
128     # change for us, so we only need to patch if it is not going to run.
129     if [[ -n "${DRIVER}" ]] && [[ "${SNAPSHOT}" != "yes" ]]; then
130     PATCHES="${PATCHES} ${DISTDIR}/x11-driver-patches-${XDPVER}.tar.bz2"
131     fi
132    
133 spyderous 1.1 # For specific list of patches
134 spyderous 1.28 if [[ -n "${PATCHES}" ]] ; then
135 spyderous 1.1 for PATCH in ${PATCHES}
136     do
137     epatch ${PATCH}
138     done
139     # For non-default directory bulk patching
140 spyderous 1.28 elif [[ -n "${PATCH_LOC}" ]] ; then
141 spyderous 1.1 epatch ${PATCH_LOC}
142     # For standard bulk patching
143 spyderous 1.28 elif [[ -d "${EPATCH_SOURCE}" ]] ; then
144 spyderous 1.1 epatch
145     fi
146     }
147    
148     x-modular_reconf_source() {
149     # Run autoreconf for CVS snapshots only
150 spyderous 1.28 if [[ "${SNAPSHOT}" = "yes" ]]
151 spyderous 1.1 then
152     # If possible, generate configure if it doesn't exist
153     if [ -f "${S}/configure.ac" ]
154     then
155     einfo "Running autoreconf..."
156 cardoe 1.8 autoreconf -v --force --install
157 spyderous 1.1 fi
158     fi
159    
160     }
161    
162     x-modular_src_unpack() {
163 joshuabaergen 1.29 if [[ ${PN:0:11} = "xorg-server" ]] || [[ -n "${DRIVER}" ]]; then
164     if gcc-specs-now; then
165 joshuabaergen 1.26 msg="Do not emerge ${PN} without vanilla gcc!"
166     eerror "$msg"
167     die "$msg"
168     fi
169 joshuabaergen 1.29 fi
170 joshuabaergen 1.26
171 spyderous 1.1 x-modular_unpack_source
172     x-modular_patch_source
173     x-modular_reconf_source
174 spyderous 1.27
175     # Joshua Baergen - October 23, 2005
176     # Fix shared lib issues on MIPS, FBSD, etc etc
177     elibtoolize
178 spyderous 1.1 }
179    
180 spyderous 1.25 x-modular_font_configure() {
181     if [[ -n "${FONT}" ]]; then
182     # Might be worth adding an option to configure your desired font
183     # and exclude all others. Also, should this USE be nls or minimal?
184     if ! use nls; then
185     FONT_OPTIONS="${FONT_OPTIONS}
186     --disable-iso8859-2
187     --disable-iso8859-3
188     --disable-iso8859-4
189     --disable-iso8859-5
190     --disable-iso8859-6
191     --disable-iso8859-7
192     --disable-iso8859-8
193     --disable-iso8859-9
194     --disable-iso8859-10
195     --disable-iso8859-11
196     --disable-iso8859-12
197     --disable-iso8859-13
198     --disable-iso8859-14
199     --disable-iso8859-15
200     --disable-iso8859-16
201     --disable-jisx0201
202     --disable-koi8-r"
203     fi
204     fi
205     }
206    
207 spyderous 1.6 x-modular_src_configure() {
208 spyderous 1.25 x-modular_font_configure
209    
210 spyderous 1.1 # If prefix isn't set here, .pc files cause problems
211 spyderous 1.28 if [[ -x ./configure ]]; then
212 spyderous 1.1 econf --prefix=${XDIR} \
213     --datadir=${XDIR}/share \
214 spyderous 1.25 ${FONT_OPTIONS} \
215 spyderous 1.7 ${DRIVER_OPTIONS} \
216 spyderous 1.1 ${CONFIGURE_OPTIONS}
217     fi
218 spyderous 1.6 }
219    
220     x-modular_src_make() {
221 spyderous 1.1 emake || die "emake failed"
222     }
223    
224 spyderous 1.6 x-modular_src_compile() {
225     x-modular_src_configure
226     x-modular_src_make
227     }
228    
229 spyderous 1.1 x-modular_src_install() {
230     # Install everything to ${XDIR}
231     make \
232     DESTDIR="${D}" \
233     install
234     # Shouldn't be necessary in XDIR=/usr
235     # einstall forces datadir, so we need to re-force it
236     # datadir=${XDIR}/share \
237     # mandir=${XDIR}/share/man \
238 spyderous 1.7
239     # Don't install libtool archives for server modules
240     if [[ -e ${D}/usr/lib/xorg/modules ]]; then
241     find ${D}/usr/lib/xorg/modules -name '*.la' \
242     | xargs rm -f
243     fi
244 spyderous 1.1 }
245 spyderous 1.2
246 spyderous 1.4 x-modular_pkg_preinst() {
247     if [[ -n "${FONT}" ]]; then
248     discover_font_dirs
249     fi
250     }
251    
252 spyderous 1.2 x-modular_pkg_postinst() {
253     if [[ -n "${FONT}" ]]; then
254     setup_fonts
255     fi
256     }
257    
258 spyderous 1.25 x-modular_pkg_postrm() {
259     if [[ -n "${FONT}" ]]; then
260     cleanup_fonts
261     fi
262     }
263    
264     cleanup_fonts() {
265     local ALLOWED_FILES="encodings.dir fonts.cache-1 fonts.dir fonts.scale"
266     for DIR in ${FONT_DIR}; do
267     unset KEEP_FONTDIR
268     REAL_DIR=${ROOT}usr/share/fonts/${DIR}
269    
270     ebegin "Checking ${REAL_DIR} for useless files"
271     pushd ${REAL_DIR} &> /dev/null
272     for FILE in *; do
273     unset MATCH
274     for ALLOWED_FILE in ${ALLOWED_FILES}; do
275     if [[ ${FILE} = ${ALLOWED_FILE} ]]; then
276     # If it's allowed, then move on to the next file
277     MATCH="yes"
278     break
279     fi
280     done
281     # If we found a match in allowed files, move on to the next file
282     if [[ -n ${MATCH} ]]; then
283     continue
284     fi
285     # If we get this far, there wasn't a match in the allowed files
286     KEEP_FONTDIR="yes"
287     # We don't need to check more files if we're already keeping it
288     break
289     done
290     popd &> /dev/null
291     # If there are no files worth keeping, then get rid of the dir
292     if [[ -z "${KEEP_FONTDIR}" ]]; then
293     rm -rf ${REAL_DIR}
294     fi
295     eend 0
296     done
297     }
298    
299 spyderous 1.2 setup_fonts() {
300     if [[ ! -n "${FONT_DIRS}" ]]; then
301 spyderous 1.25 msg="FONT_DIRS is empty. The ebuild should set it to at least one subdir of /usr/share/fonts."
302     eerror "${msg}"
303     die "${msg}"
304 spyderous 1.2 fi
305    
306     create_fonts_scale
307     create_fonts_dir
308     fix_font_permissions
309     create_font_cache
310     }
311    
312 spyderous 1.4 discover_font_dirs() {
313     pushd ${IMAGE}/usr/share/fonts
314     FONT_DIRS="$(find . -maxdepth 1 -mindepth 1 -type d)"
315     FONT_DIRS="$(echo ${FONT_DIRS} | sed -e 's:./::g')"
316     popd
317     }
318    
319 spyderous 1.2 create_fonts_scale() {
320     ebegin "Creating fonts.scale files"
321     local x
322     for FONT_DIR in ${FONT_DIRS}; do
323     x=${ROOT}/usr/share/fonts/${FONT_DIR}
324 spyderous 1.28 [[ -z "$(ls ${x}/)" ]] && continue
325     [[ "$(ls ${x}/)" = "fonts.cache-1" ]] && continue
326 spyderous 1.2
327     # Only generate .scale files if truetype, opentype or type1
328     # fonts are present ...
329    
330     # First truetype (ttf,ttc)
331     # NOTE: ttmkfdir does NOT work on type1 fonts (#53753)
332     # Also, there is no way to regenerate Speedo/CID fonts.scale
333     # <spyderous@gentoo.org> 2 August 2004
334 spyderous 1.28 if [[ "${x/encodings}" = "${x}" ]] \
335     && [[ -n "$(find ${x} -iname '*.tt[cf]' -print)" ]]; then
336     if [[ -x ${ROOT}/usr/bin/ttmkfdir ]]; then
337 spyderous 1.2 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
338     ${ROOT}/usr/bin/ttmkfdir -x 2 \
339     -e ${ROOT}/usr/share/fonts/encodings/encodings.dir \
340     -o ${x}/fonts.scale -d ${x}
341     # ttmkfdir fails on some stuff, so try mkfontscale if it does
342     local ttmkfdir_return=$?
343     else
344     # We didn't use ttmkfdir at all
345     local ttmkfdir_return=2
346     fi
347 spyderous 1.28 if [[ ${ttmkfdir_return} -ne 0 ]]; then
348 spyderous 1.2 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
349     ${ROOT}/usr/bin/mkfontscale \
350     -a /usr/share/fonts/encodings/encodings.dir \
351     -- ${x}
352     fi
353     # Next type1 and opentype (pfa,pfb,otf,otc)
354 spyderous 1.28 elif [[ "${x/encodings}" = "${x}" ]] \
355     && [[ -n "$(find ${x} -iname '*.[po][ft][abcf]' -print)" ]]; then
356 spyderous 1.2 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
357     ${ROOT}/usr/bin/mkfontscale \
358     -a ${ROOT}/usr/share/fonts/encodings/encodings.dir \
359     -- ${x}
360     fi
361     done
362     eend 0
363     }
364    
365     create_fonts_dir() {
366     ebegin "Generating fonts.dir files"
367     for FONT_DIR in ${FONT_DIRS}; do
368     x=${ROOT}/usr/share/fonts/${FONT_DIR}
369 spyderous 1.28 [[ -z "$(ls ${x}/)" ]] && continue
370     [[ "$(ls ${x}/)" = "fonts.cache-1" ]] && continue
371 spyderous 1.2
372 spyderous 1.28 if [[ "${x/encodings}" = "${x}" ]]; then
373 spyderous 1.2 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
374     ${ROOT}/usr/bin/mkfontdir \
375     -e ${ROOT}/usr/share/fonts/encodings \
376     -e ${ROOT}/usr/share/fonts/encodings/large \
377     -- ${x}
378     fi
379     done
380     eend 0
381     }
382    
383     fix_font_permissions() {
384     ebegin "Fixing permissions"
385     for FONT_DIR in ${FONT_DIRS}; do
386     find ${ROOT}/usr/share/fonts/${FONT_DIR} -type f -name 'font.*' \
387     -exec chmod 0644 {} \;
388     done
389     eend 0
390     }
391    
392     create_font_cache() {
393     # danarmak found out that fc-cache should be run AFTER all the above
394     # stuff, as otherwise the cache is invalid, and has to be run again
395     # as root anyway
396 spyderous 1.28 if [[ -x ${ROOT}/usr/bin/fc-cache ]]; then
397 spyderous 1.2 ebegin "Creating FC font cache"
398     HOME="/root" ${ROOT}/usr/bin/fc-cache
399     eend 0
400     fi
401     }

  ViewVC Help
Powered by ViewVC 1.1.20