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

Contents of /eclass/x-modular.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.59 - (show annotations) (download)
Tue May 16 06:23:43 2006 UTC (7 years, 11 months ago) by exg
Branch: MAIN
Changes since 1.58: +2 -4 lines
We do not require anymore a specific version of sys-apps/man.

1 # Copyright 1999-2005 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/x-modular.eclass,v 1.58 2006/05/15 03:23:32 spyderous Exp $
4 #
5 # Author: Donnie Berkholz <spyderous@gentoo.org>
6 #
7 # This eclass is designed to reduce code duplication in the modularized X11
8 # ebuilds.
9 #
10 # Using this eclass:
11 #
12 # Inherit it. If you need to run autoreconf for any reason (e.g., your patches
13 # apply to the autotools files rather than configure), set SNAPSHOT="yes". Set
14 # CONFIGURE_OPTIONS to everything you want to pass to the configure script.
15 #
16 # If you have any patches to apply, set PATCHES to their locations and epatch
17 # will apply them. It also handles epatch-style bulk patches, if you know how to
18 # use them and set the correct variables. If you don't, read eutils.eclass.
19 #
20 # If you're creating a font package and the suffix of PN is not equal to the
21 # subdirectory of /usr/share/fonts/ it should install into, set FONT_DIR to that
22 # directory or directories.
23 #
24 # IMPORTANT: Both SNAPSHOT and FONT_DIR must be set _before_ the inherit.
25 #
26 # Pretty much everything else should be automatic.
27
28 EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst pkg_postrm
29
30 inherit eutils libtool toolchain-funcs flag-o-matic autotools
31
32 # Directory prefix to use for everything
33 XDIR="/usr"
34
35 # Set up default patchset version(s) if necessary
36 # x11-driver-patches
37 if [[ -z "${XDPVER}" ]]; then
38 XDPVER="1"
39 fi
40
41 IUSE=""
42 HOMEPAGE="http://xorg.freedesktop.org/"
43
44 # Set up SRC_URI for individual modular releases
45 BASE_INDIVIDUAL_URI="http://xorg.freedesktop.org/releases/individual"
46 if [[ ${CATEGORY} = x11-apps ]] || [[ ${CATEGORY} = x11-wm ]]; then
47 SRC_URI="${SRC_URI}
48 ${BASE_INDIVIDUAL_URI}/app/${P}.tar.bz2"
49 elif [[ ${CATEGORY} = app-doc ]]; then
50 SRC_URI="${SRC_URI}
51 ${BASE_INDIVIDUAL_URI}/doc/${P}.tar.bz2"
52 # x11-misc contains data and util, x11-themes contains data
53 elif [[ ${CATEGORY} = x11-misc ]] || [[ ${CATEGORY} = x11-themes ]]; then
54 SRC_URI="${SRC_URI}
55 ${BASE_INDIVIDUAL_URI}/data/${P}.tar.bz2
56 ${BASE_INDIVIDUAL_URI}/util/${P}.tar.bz2"
57 elif [[ ${CATEGORY} = x11-drivers ]]; then
58 SRC_URI="${SRC_URI}
59 ${BASE_INDIVIDUAL_URI}/driver/${P}.tar.bz2"
60 elif [[ ${CATEGORY} = media-fonts ]]; then
61 SRC_URI="${SRC_URI}
62 ${BASE_INDIVIDUAL_URI}/font/${P}.tar.bz2"
63 elif [[ ${CATEGORY} = x11-libs ]]; then
64 SRC_URI="${SRC_URI}
65 ${BASE_INDIVIDUAL_URI}/lib/${P}.tar.bz2"
66 elif [[ ${CATEGORY} = x11-proto ]]; then
67 SRC_URI="${SRC_URI}
68 ${BASE_INDIVIDUAL_URI}/proto/${P}.tar.bz2"
69 elif [[ ${CATEGORY} = x11-base ]]; then
70 SRC_URI="${SRC_URI}
71 ${BASE_INDIVIDUAL_URI}/xserver/${P}.tar.bz2"
72 fi
73
74 SLOT="0"
75
76 # Set the license for the package. This can be overridden by setting
77 # LICENSE after the inherit.
78 LICENSE=${PN}
79
80 # Set up shared dependencies
81 if [[ -n "${SNAPSHOT}" ]]; then
82 # FIXME: What's the minimal libtool version supporting arbitrary versioning?
83 DEPEND="${DEPEND}
84 >=sys-devel/autoconf-2.57
85 >=sys-devel/automake-1.7
86 >=sys-devel/libtool-1.5
87 >=sys-devel/m4-1.4"
88 fi
89
90 # If we're a font package, but not the font.alias one
91 if [[ "${PN/#font-}" != "${PN}" ]] \
92 && [[ "${CATEGORY}" = "media-fonts" ]] \
93 && [[ "${PN}" != "font-alias" ]] \
94 && [[ "${PN}" != "font-util" ]]; then
95 # Activate font code in the rest of the eclass
96 FONT="yes"
97
98 RDEPEND="${RDEPEND}
99 media-fonts/encodings
100 x11-apps/mkfontscale
101 x11-apps/mkfontdir"
102 PDEPEND="${PDEPEND}
103 media-fonts/font-alias"
104
105 # Starting with 7.0RC3, we can specify the font directory
106 # But oddly, we can't do the same for encodings or font-alias
107
108 # Wrap in `if` so ebuilds can set it too
109 if [[ -z ${FONT_DIR} ]]; then
110 FONT_DIR=${PN##*-}
111
112 fi
113
114 # Fix case of font directories
115 FONT_DIR=${FONT_DIR/ttf/TTF}
116 FONT_DIR=${FONT_DIR/otf/OTF}
117 FONT_DIR=${FONT_DIR/type1/Type1}
118 FONT_DIR=${FONT_DIR/speedo/Speedo}
119
120 # Set up configure option
121 FONT_OPTIONS="--with-fontdir=\"/usr/share/fonts/${FONT_DIR}\""
122
123 if [[ -n "${FONT}" ]]; then
124 if [[ ${PN##*-} = misc ]] || [[ ${PN##*-} = 75dpi ]] || [[ ${PN##*-} = 100dpi ]]; then
125 IUSE="${IUSE} nls"
126 fi
127 fi
128 fi
129
130 # If we're a driver package
131 if [[ "${PN/#xf86-video}" != "${PN}" ]] || [[ "${PN/#xf86-input}" != "${PN}" ]]; then
132 # Enable driver code in the rest of the eclass
133 DRIVER="yes"
134
135 # Add driver patchset to SRC_URI
136 SRC_URI="${SRC_URI}
137 http://dev.gentoo.org/~joshuabaergen/distfiles/x11-driver-patches-${XDPVER}.tar.bz2"
138 fi
139
140 # Debugging -- ignore packages that can't be built with debugging
141 if [[ -z "${FONT}" ]] \
142 || [[ "${PN/app-doc}" != "${PN}" ]] \
143 || [[ "${PN/x11-proto}" != "${PN}" ]] \
144 || [[ "${PN/util-macros}" != "${PN}" ]] \
145 || [[ "${PN/xbitmaps}" != "${PN}" ]] \
146 || [[ "${PN/xkbdata}" != "${PN}" ]] \
147 || [[ "${PN/xorg-cf-files}" != "${PN}" ]] \
148 || [[ "${PN/xcursor}" != "${PN}" ]] \
149 ; then
150 DEBUGGABLE="yes"
151 IUSE="${IUSE} debug"
152 if use debug; then
153 if ! has splitdebug ${FEATURES}; then
154 RESTRICT="${RESTRICT} nostrip"
155 fi
156 fi
157 fi
158
159 DEPEND="${DEPEND}
160 >=dev-util/pkgconfig-0.18"
161
162 if [[ "${PN/util-macros}" = "${PN}" ]]; then
163 DEPEND="${DEPEND}
164 >=x11-misc/util-macros-0.99.2"
165 fi
166
167 RDEPEND="${RDEPEND}
168 !<=x11-base/xorg-x11-6.9"
169 # Provides virtual/x11 for temporary use until packages are ported
170 # x11-base/x11-env"
171
172 x-modular_specs_check() {
173 if [[ ${PN:0:11} = "xorg-server" ]] || [[ -n "${DRIVER}" ]]; then
174 if gcc-specs-now; then
175 msg="${PN} does not work with hardened gcc specs. Switch to vanilla gcc specs to emerge ${PN}."
176 eerror "$msg"
177 die "$msg"
178 fi
179
180 # (#116698) breaks loading
181 filter-ldflags -Wl,-z,now
182 fi
183 }
184
185 x-modular_dri_check() {
186 # (#120057) Enabling DRI in drivers requires that the server was built with
187 # support for it
188 if [[ -n "${DRIVER}" ]]; then
189 if has dri ${IUSE} && use dri; then
190 einfo "Checking for direct rendering capabilities ..."
191 if ! built_with_use x11-base/xorg-server dri; then
192 die "You must build x11-base/xorg-server with USE=dri."
193 fi
194 fi
195 fi
196 }
197
198 x-modular_unpack_source() {
199 unpack ${A}
200 cd ${S}
201
202 if [[ -n ${FONT_OPTIONS} ]]; then
203 einfo "Detected font directory: ${FONT_DIR}"
204 fi
205 }
206
207 x-modular_patch_source() {
208 # Use standardized names and locations with bulk patching
209 # Patch directory is ${WORKDIR}/patch
210 # See epatch() in eutils.eclass for more documentation
211 if [[ -z "${EPATCH_SUFFIX}" ]] ; then
212 EPATCH_SUFFIX="patch"
213 fi
214
215 # If this is a driver package we need to fix man page install location.
216 # Running autoreconf will use the patched util-macros to make the
217 # change for us, so we only need to patch if it is not going to run.
218 if [[ -n "${DRIVER}" ]] && [[ "${SNAPSHOT}" != "yes" ]]; then
219 PATCHES="${PATCHES} ${DISTDIR}/x11-driver-patches-${XDPVER}.tar.bz2"
220 fi
221
222 # For specific list of patches
223 if [[ -n "${PATCHES}" ]] ; then
224 for PATCH in ${PATCHES}
225 do
226 epatch ${PATCH}
227 done
228 # For non-default directory bulk patching
229 elif [[ -n "${PATCH_LOC}" ]] ; then
230 epatch ${PATCH_LOC}
231 # For standard bulk patching
232 elif [[ -d "${EPATCH_SOURCE}" ]] ; then
233 epatch
234 fi
235 }
236
237 x-modular_reconf_source() {
238 # Run autoreconf for CVS snapshots only
239 if [[ "${SNAPSHOT}" = "yes" ]]
240 then
241 # If possible, generate configure if it doesn't exist
242 if [ -f "${S}/configure.ac" ]
243 then
244 eautoreconf
245 fi
246 fi
247
248 # Joshua Baergen - October 23, 2005
249 # Fix shared lib issues on MIPS, FBSD, etc etc
250 elibtoolize
251 }
252
253 x-modular_src_unpack() {
254 x-modular_specs_check
255 x-modular_dri_check
256 x-modular_unpack_source
257 x-modular_patch_source
258 x-modular_reconf_source
259 }
260
261 x-modular_font_configure() {
262 if [[ -n "${FONT}" ]]; then
263 # Might be worth adding an option to configure your desired font
264 # and exclude all others. Also, should this USE be nls or minimal?
265 if ! use nls; then
266 FONT_OPTIONS="${FONT_OPTIONS}
267 --disable-iso8859-2
268 --disable-iso8859-3
269 --disable-iso8859-4
270 --disable-iso8859-5
271 --disable-iso8859-6
272 --disable-iso8859-7
273 --disable-iso8859-8
274 --disable-iso8859-9
275 --disable-iso8859-10
276 --disable-iso8859-11
277 --disable-iso8859-12
278 --disable-iso8859-13
279 --disable-iso8859-14
280 --disable-iso8859-15
281 --disable-iso8859-16
282 --disable-jisx0201
283 --disable-koi8-r"
284 fi
285 fi
286 }
287
288 x-modular_debug_setup() {
289 if [[ -n "${DEBUGGABLE}" ]]; then
290 if use debug; then
291 strip-flags
292 append-flags -g
293 fi
294 fi
295 }
296
297 x-modular_src_configure() {
298 x-modular_font_configure
299 x-modular_debug_setup
300
301 # If prefix isn't set here, .pc files cause problems
302 if [[ -x ./configure ]]; then
303 econf --prefix=${XDIR} \
304 --datadir=${XDIR}/share \
305 ${FONT_OPTIONS} \
306 ${DRIVER_OPTIONS} \
307 ${CONFIGURE_OPTIONS}
308 fi
309 }
310
311 x-modular_src_make() {
312 emake || die "emake failed"
313 }
314
315 x-modular_src_compile() {
316 x-modular_src_configure
317 x-modular_src_make
318 }
319
320 x-modular_src_install() {
321 # Install everything to ${XDIR}
322 make \
323 DESTDIR="${D}" \
324 install
325 # Shouldn't be necessary in XDIR=/usr
326 # einstall forces datadir, so we need to re-force it
327 # datadir=${XDIR}/share \
328 # mandir=${XDIR}/share/man \
329
330 # Make sure docs get compressed
331 prepalldocs
332
333 # Don't install libtool archives for server modules
334 if [[ -e ${D}/usr/lib/xorg/modules ]]; then
335 find ${D}/usr/lib/xorg/modules -name '*.la' \
336 | xargs rm -f
337 fi
338
339 # Don't install overlapping fonts.* files
340 # Generate them instead when possible
341 if [[ -n "${FONT}" ]]; then
342 remove_font_metadata
343 fi
344 }
345
346 x-modular_pkg_preinst() {
347 if [[ -n "${FONT}" ]]; then
348 discover_font_dirs
349 fi
350 }
351
352 x-modular_pkg_postinst() {
353 if [[ -n "${FONT}" ]]; then
354 setup_fonts
355 fi
356 }
357
358 x-modular_pkg_postrm() {
359 if [[ -n "${FONT}" ]]; then
360 cleanup_fonts
361 fi
362 }
363
364 cleanup_fonts() {
365 local ALLOWED_FILES="encodings.dir fonts.cache-1 fonts.dir fonts.scale"
366 for DIR in ${FONT_DIR}; do
367 unset KEEP_FONTDIR
368 REAL_DIR=${ROOT}usr/share/fonts/${DIR}
369
370 ebegin "Checking ${REAL_DIR} for useless files"
371 pushd ${REAL_DIR} &> /dev/null
372 for FILE in *; do
373 unset MATCH
374 for ALLOWED_FILE in ${ALLOWED_FILES}; do
375 if [[ ${FILE} = ${ALLOWED_FILE} ]]; then
376 # If it's allowed, then move on to the next file
377 MATCH="yes"
378 break
379 fi
380 done
381 # If we found a match in allowed files, move on to the next file
382 if [[ -n ${MATCH} ]]; then
383 continue
384 fi
385 # If we get this far, there wasn't a match in the allowed files
386 KEEP_FONTDIR="yes"
387 # We don't need to check more files if we're already keeping it
388 break
389 done
390 popd &> /dev/null
391 # If there are no files worth keeping, then get rid of the dir
392 if [[ -z "${KEEP_FONTDIR}" ]]; then
393 rm -rf ${REAL_DIR}
394 fi
395 eend 0
396 done
397 }
398
399 setup_fonts() {
400 if [[ ! -n "${FONT_DIRS}" ]]; then
401 msg="FONT_DIRS is empty. The ebuild should set it to at least one subdir of /usr/share/fonts."
402 eerror "${msg}"
403 die "${msg}"
404 fi
405
406 create_fonts_scale
407 create_fonts_dir
408 fix_font_permissions
409 create_font_cache
410 }
411
412 remove_font_metadata() {
413 local DIR
414 for DIR in ${FONT_DIR}; do
415 if [[ "${DIR}" != "Speedo" ]] && \
416 [[ "${DIR}" != "CID" ]] ; then
417 # Delete font metadata files
418 # fonts.scale, fonts.dir, fonts.cache-1
419 rm -f ${D}/usr/share/fonts/${DIR}/fonts.{scale,dir,cache-1}
420 fi
421 done
422 }
423
424 discover_font_dirs() {
425 pushd ${IMAGE}/usr/share/fonts
426 FONT_DIRS="$(find . -maxdepth 1 -mindepth 1 -type d)"
427 FONT_DIRS="$(echo ${FONT_DIRS} | sed -e 's:./::g')"
428 popd
429 }
430
431 create_fonts_scale() {
432 ebegin "Creating fonts.scale files"
433 local x
434 for FONT_DIR in ${FONT_DIRS}; do
435 x=${ROOT}/usr/share/fonts/${FONT_DIR}
436 [[ -z "$(ls ${x}/)" ]] && continue
437 [[ "$(ls ${x}/)" = "fonts.cache-1" ]] && continue
438
439 # Only generate .scale files if truetype, opentype or type1
440 # fonts are present ...
441
442 # First truetype (ttf,ttc)
443 # NOTE: ttmkfdir does NOT work on type1 fonts (#53753)
444 # Also, there is no way to regenerate Speedo/CID fonts.scale
445 # <spyderous@gentoo.org> 2 August 2004
446 if [[ "${x/encodings}" = "${x}" ]] \
447 && [[ -n "$(find ${x} -iname '*.tt[cf]' -print)" ]]; then
448 if [[ -x ${ROOT}/usr/bin/ttmkfdir ]]; then
449 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
450 ${ROOT}/usr/bin/ttmkfdir -x 2 \
451 -e ${ROOT}/usr/share/fonts/encodings/encodings.dir \
452 -o ${x}/fonts.scale -d ${x}
453 # ttmkfdir fails on some stuff, so try mkfontscale if it does
454 local ttmkfdir_return=$?
455 else
456 # We didn't use ttmkfdir at all
457 local ttmkfdir_return=2
458 fi
459 if [[ ${ttmkfdir_return} -ne 0 ]]; then
460 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
461 ${ROOT}/usr/bin/mkfontscale \
462 -a /usr/share/fonts/encodings/encodings.dir \
463 -- ${x}
464 fi
465 # Next type1 and opentype (pfa,pfb,otf,otc)
466 elif [[ "${x/encodings}" = "${x}" ]] \
467 && [[ -n "$(find ${x} -iname '*.[po][ft][abcf]' -print)" ]]; then
468 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
469 ${ROOT}/usr/bin/mkfontscale \
470 -a ${ROOT}/usr/share/fonts/encodings/encodings.dir \
471 -- ${x}
472 fi
473 done
474 eend 0
475 }
476
477 create_fonts_dir() {
478 ebegin "Generating fonts.dir files"
479 for FONT_DIR in ${FONT_DIRS}; do
480 x=${ROOT}/usr/share/fonts/${FONT_DIR}
481 [[ -z "$(ls ${x}/)" ]] && continue
482 [[ "$(ls ${x}/)" = "fonts.cache-1" ]] && continue
483
484 if [[ "${x/encodings}" = "${x}" ]]; then
485 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
486 ${ROOT}/usr/bin/mkfontdir \
487 -e ${ROOT}/usr/share/fonts/encodings \
488 -e ${ROOT}/usr/share/fonts/encodings/large \
489 -- ${x}
490 fi
491 done
492 eend 0
493 }
494
495 fix_font_permissions() {
496 ebegin "Fixing permissions"
497 for FONT_DIR in ${FONT_DIRS}; do
498 find ${ROOT}/usr/share/fonts/${FONT_DIR} -type f -name 'font.*' \
499 -exec chmod 0644 {} \;
500 done
501 eend 0
502 }
503
504 create_font_cache() {
505 # danarmak found out that fc-cache should be run AFTER all the above
506 # stuff, as otherwise the cache is invalid, and has to be run again
507 # as root anyway
508 if [[ -x ${ROOT}/usr/bin/fc-cache ]]; then
509 ebegin "Creating FC font cache"
510 HOME="/root" ${ROOT}/usr/bin/fc-cache
511 eend 0
512 fi
513 }

  ViewVC Help
Powered by ViewVC 1.1.20