/[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.107 Revision 1.119
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.107 2009/03/03 16:28:32 remi Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/x-modular.eclass,v 1.119 2010/07/04 20:42:22 dirtyepic Exp $
4# 4#
5# @ECLASS: x-modular.eclass 5# @ECLASS: x-modular.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Donnie Berkholz <dberkholz@gentoo.org>, x11@gentoo.org 7# Donnie Berkholz <dberkholz@gentoo.org>, x11@gentoo.org
8# @BLURB: Reduces code duplication in the modularized X11 ebuilds. 8# @BLURB: Reduces code duplication in the modularized X11 ebuilds.
15# All you need to do in a basic ebuild is inherit this eclass and set 15# All you need to do in a basic ebuild is inherit this eclass and set
16# DESCRIPTION, KEYWORDS and RDEPEND/DEPEND. If your package is hosted 16# DESCRIPTION, KEYWORDS and RDEPEND/DEPEND. If your package is hosted
17# with the other X packages, you don't need to set SRC_URI. Pretty much 17# with the other X packages, you don't need to set SRC_URI. Pretty much
18# everything else should be automatic. 18# everything else should be automatic.
19 19
20if [[ ${PV} = 9999* ]]; then
21 GIT_ECLASS="git"
22 SNAPSHOT="yes"
23 SRC_URI=""
24fi
25
26# If we're a font package, but not the font.alias one
27FONT_ECLASS=""
28if [[ "${PN/#font-}" != "${PN}" ]] \
29 && [[ "${CATEGORY}" = "media-fonts" ]] \
30 && [[ "${PN}" != "font-alias" ]] \
31 && [[ "${PN}" != "font-util" ]]; then
32 # Activate font code in the rest of the eclass
33 FONT="yes"
34
35 # Whether to inherit the font eclass
36 FONT_ECLASS="font"
37fi
38
39inherit eutils libtool multilib toolchain-funcs flag-o-matic autotools \
40 ${FONT_ECLASS} ${GIT_ECLASS}
41
42EXPORTED_FUNCTIONS="src_unpack src_compile src_install pkg_preinst pkg_postinst pkg_postrm"
43
44case "${EAPI:-0}" in
45 0|1)
46 ;;
47 2)
48 EXPORTED_FUNCTIONS="${EXPORTED_FUNCTIONS} src_prepare src_configure"
49 ;;
50 *)
51 die "Unknown EAPI ${EAPI}"
52 ;;
53esac
54
55# exports must be ALWAYS after inherit
56EXPORT_FUNCTIONS ${EXPORTED_FUNCTIONS}
57
20# @ECLASS-VARIABLE: XDIR 58# @ECLASS-VARIABLE: XDIR
21# @DESCRIPTION: 59# @DESCRIPTION:
22# Directory prefix to use for everything. If you want to install to a 60# Directory prefix to use for everything. If you want to install to a
23# non-default prefix (e.g., /opt/xorg), change XDIR. This has not been 61# non-default prefix (e.g., /opt/xorg), change XDIR. This has not been
24# recently tested. You may need to uncomment the setting of datadir and 62# recently tested. You may need to uncomment the setting of datadir and
27XDIR="/usr" 65XDIR="/usr"
28 66
29IUSE="" 67IUSE=""
30HOMEPAGE="http://xorg.freedesktop.org/" 68HOMEPAGE="http://xorg.freedesktop.org/"
31 69
32if [[ -z ${SNAPSHOT} ]]; then
33# @ECLASS-VARIABLE: SNAPSHOT 70# @ECLASS-VARIABLE: SNAPSHOT
34# @DESCRIPTION: 71# @DESCRIPTION:
35# If set to 'yes' and configure.ac exists, eautoreconf will run. Set 72# If set to 'yes' and configure.ac exists, eautoreconf will run. Set
36# before inheriting this eclass. 73# before inheriting this eclass.
37 SNAPSHOT="no" 74: ${SNAPSHOT:=no}
38fi
39
40if [[ ${PV} = 9999* ]]; then
41 GIT_ECLASS="git"
42 SNAPSHOT="yes"
43 SRC_URI=""
44fi
45 75
46# Set up SRC_URI for individual modular releases 76# Set up SRC_URI for individual modular releases
47BASE_INDIVIDUAL_URI="http://xorg.freedesktop.org/releases/individual" 77BASE_INDIVIDUAL_URI="http://xorg.freedesktop.org/releases/individual"
48# @ECLASS-VARIABLE: MODULE 78# @ECLASS-VARIABLE: MODULE
49# @DESCRIPTION: 79# @DESCRIPTION:
50# The subdirectory to download source from. Possible settings are app, 80# The subdirectory to download source from. Possible settings are app,
51# doc, data, util, driver, font, lib, proto, xserver. Set above the 81# doc, data, util, driver, font, lib, proto, xserver. Set above the
52# inherit to override the default autoconfigured module. 82# inherit to override the default autoconfigured module.
53if [[ -z ${MODULE} ]]; then 83if [[ -z ${MODULE} ]]; then
54 MODULE=""
55 case ${CATEGORY} in 84 case ${CATEGORY} in
56 app-doc) MODULE="doc" ;; 85 app-doc) MODULE="doc" ;;
57 media-fonts) MODULE="font" ;; 86 media-fonts) MODULE="font" ;;
58 x11-apps|x11-wm) MODULE="app" ;; 87 x11-apps|x11-wm) MODULE="app" ;;
59 x11-misc|x11-themes) MODULE="util" ;; 88 x11-misc|x11-themes) MODULE="util" ;;
71fi 100fi
72 101
73SLOT="0" 102SLOT="0"
74 103
75# Set the license for the package. This can be overridden by setting 104# Set the license for the package. This can be overridden by setting
76# LICENSE after the inherit. 105# LICENSE after the inherit. Nearly all FreeDesktop-hosted X packages
77LICENSE=${PN} 106# are under the MIT license. (This is what Red Hat does in their rpms)
107LICENSE="MIT"
78 108
79# Set up shared dependencies 109# Set up shared dependencies
80if [[ -n "${SNAPSHOT}" ]]; then 110if [[ -n "${SNAPSHOT}" ]]; then
81# FIXME: What's the minimal libtool version supporting arbitrary versioning? 111# FIXME: What's the minimal libtool version supporting arbitrary versioning?
82 DEPEND="${DEPEND} 112 DEPEND="${DEPEND}
84 >=sys-devel/m4-1.4" 114 >=sys-devel/m4-1.4"
85 WANT_AUTOCONF="latest" 115 WANT_AUTOCONF="latest"
86 WANT_AUTOMAKE="latest" 116 WANT_AUTOMAKE="latest"
87fi 117fi
88 118
89# If we're a font package, but not the font.alias one 119if [[ -n "${FONT}" ]]; then
90FONT_ECLASS=""
91if [[ "${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 # Whether to inherit the font eclass
99 FONT_ECLASS="font"
100
101 RDEPEND="${RDEPEND} 120 RDEPEND="${RDEPEND}
102 media-fonts/encodings 121 media-fonts/encodings
103 x11-apps/mkfontscale 122 x11-apps/mkfontscale
104 x11-apps/mkfontdir" 123 x11-apps/mkfontdir"
105 PDEPEND="${PDEPEND} 124 PDEPEND="${PDEPEND}
106 media-fonts/font-alias" 125 media-fonts/font-alias"
107 126
108 # Starting with 7.0RC3, we can specify the font directory 127 # Starting with 7.0RC3, we can specify the font directory
109 # But oddly, we can't do the same for encodings or font-alias 128 # But oddly, we can't do the same for encodings or font-alias
110 129
111 # Wrap in `if` so ebuilds can set it too
112 if [[ -z ${FONT_DIR} ]]; then
113# @ECLASS-VARIABLE: FONT_DIR 130# @ECLASS-VARIABLE: FONT_DIR
114# @DESCRIPTION: 131# @DESCRIPTION:
115# If you're creating a font package and the suffix of PN is not equal to 132# If you're creating a font package and the suffix of PN is not equal to
116# the subdirectory of /usr/share/fonts/ it should install into, set 133# the subdirectory of /usr/share/fonts/ it should install into, set
117# FONT_DIR to that directory or directories. Set before inheriting this 134# FONT_DIR to that directory or directories. Set before inheriting this
118# eclass. 135# eclass.
119 FONT_DIR=${PN##*-} 136 : ${FONT_DIR:=${PN##*-}}
120
121 fi
122 137
123 # Fix case of font directories 138 # Fix case of font directories
124 FONT_DIR=${FONT_DIR/ttf/TTF} 139 FONT_DIR=${FONT_DIR/ttf/TTF}
125 FONT_DIR=${FONT_DIR/otf/OTF} 140 FONT_DIR=${FONT_DIR/otf/OTF}
126 FONT_DIR=${FONT_DIR/type1/Type1} 141 FONT_DIR=${FONT_DIR/type1/Type1}
127 FONT_DIR=${FONT_DIR/speedo/Speedo} 142 FONT_DIR=${FONT_DIR/speedo/Speedo}
128 143
129 # Set up configure option 144 # Set up configure options, wrapped so ebuilds can override if need be
145 if [[ -z ${FONT_OPTIONS} ]]; then
130 FONT_OPTIONS="--with-fontdir=\"/usr/share/fonts/${FONT_DIR}\"" 146 FONT_OPTIONS="--with-fontdir=\"/usr/share/fonts/${FONT_DIR}\""
147 fi
131 148
132 if [[ -n "${FONT}" ]]; then 149 if [[ -n "${FONT}" ]]; then
133 if [[ ${PN##*-} = misc ]] || [[ ${PN##*-} = 75dpi ]] || [[ ${PN##*-} = 100dpi ]] || [[ ${PN##*-} = cyrillic ]]; then 150 if [[ ${PN##*-} = misc ]] || [[ ${PN##*-} = 75dpi ]] || [[ ${PN##*-} = 100dpi ]] || [[ ${PN##*-} = cyrillic ]]; then
134 IUSE="${IUSE} nls" 151 IUSE="${IUSE} nls"
135 fi 152 fi
159DEPEND="${DEPEND} 176DEPEND="${DEPEND}
160 >=dev-util/pkgconfig-0.18" 177 >=dev-util/pkgconfig-0.18"
161 178
162if [[ "${PN/util-macros}" = "${PN}" ]]; then 179if [[ "${PN/util-macros}" = "${PN}" ]]; then
163 DEPEND="${DEPEND} 180 DEPEND="${DEPEND}
164 >=x11-misc/util-macros-0.99.2 181 >=x11-misc/util-macros-1.3.0
165 >=sys-devel/binutils-2.16.1-r3" 182 sys-devel/binutils"
166fi 183fi
167 184
168RDEPEND="${RDEPEND} 185RDEPEND="${RDEPEND}
169 !<=x11-base/xorg-x11-6.9" 186 !<=x11-base/xorg-x11-6.9"
170# Provides virtual/x11 for temporary use until packages are ported 187# Provides virtual/x11 for temporary use until packages are ported
171# x11-base/x11-env" 188# x11-base/x11-env"
172
173inherit eutils libtool multilib toolchain-funcs flag-o-matic autotools \
174 ${FONT_ECLASS} ${GIT_ECLASS}
175 189
176# @FUNCTION: x-modular_specs_check 190# @FUNCTION: x-modular_specs_check
177# @USAGE: 191# @USAGE:
178# @DESCRIPTION: 192# @DESCRIPTION:
179# Make any necessary changes related to gcc specs (generally hardened) 193# Make any necessary changes related to gcc specs (generally hardened)
295 # Joshua Baergen - October 23, 2005 309 # Joshua Baergen - October 23, 2005
296 # Fix shared lib issues on MIPS, FBSD, etc etc 310 # Fix shared lib issues on MIPS, FBSD, etc etc
297 elibtoolize 311 elibtoolize
298} 312}
299 313
314# @FUNCTION: x-modular_src_prepare
315# @USAGE:
316# @DESCRIPTION:
317# Prepare a package after unpacking, performing all X-related tasks.
318x-modular_src_prepare() {
319 [[ -n ${GIT_ECLASS} ]] && has src_prepare ${EXPORTED_FUNCTIONS} \
320 && git_src_prepare
321 x-modular_patch_source
322 x-modular_reconf_source
323}
324
300# @FUNCTION: x-modular_src_unpack 325# @FUNCTION: x-modular_src_unpack
301# @USAGE: 326# @USAGE:
302# @DESCRIPTION: 327# @DESCRIPTION:
303# Unpack a package, performing all X-related tasks. 328# Unpack a package, performing all X-related tasks.
304x-modular_src_unpack() { 329x-modular_src_unpack() {
305 x-modular_specs_check 330 x-modular_specs_check
306 x-modular_server_supports_drivers_check 331 x-modular_server_supports_drivers_check
307 x-modular_dri_check 332 x-modular_dri_check
308 x-modular_unpack_source 333 x-modular_unpack_source
309 x-modular_patch_source 334 has src_prepare ${EXPORTED_FUNCTIONS} || x-modular_src_prepare
310 x-modular_reconf_source
311} 335}
312 336
313# @FUNCTION: x-modular_font_configure 337# @FUNCTION: x-modular_font_configure
314# @USAGE: 338# @USAGE:
315# @DESCRIPTION: 339# @DESCRIPTION:
316# If a font package, perform any necessary configuration steps 340# If a font package, perform any necessary configuration steps
317x-modular_font_configure() { 341x-modular_font_configure() {
318 if [[ -n "${FONT}" ]]; then 342 if [[ -n "${FONT}" ]]; then
319 # Might be worth adding an option to configure your desired font 343 # Might be worth adding an option to configure your desired font
320 # and exclude all others. Also, should this USE be nls or minimal? 344 # and exclude all others. Also, should this USE be nls or minimal?
321 if ! use nls; then 345 if has nls ${IUSE//+} && ! use nls; then
322 FONT_OPTIONS="${FONT_OPTIONS} 346 FONT_OPTIONS="${FONT_OPTIONS}
323 --disable-iso8859-2 347 --disable-iso8859-2
324 --disable-iso8859-3 348 --disable-iso8859-3
325 --disable-iso8859-4 349 --disable-iso8859-4
326 --disable-iso8859-5 350 --disable-iso8859-5
362 x-modular_font_configure 386 x-modular_font_configure
363 x-modular_debug_setup 387 x-modular_debug_setup
364 388
365# @VARIABLE: CONFIGURE_OPTIONS 389# @VARIABLE: CONFIGURE_OPTIONS
366# @DESCRIPTION: 390# @DESCRIPTION:
367# Any options to pass to configure 391# Any extra options to pass to configure
368[[ -n ${CONFIGURE_OPTIONS} ]]
369 392
370 # If prefix isn't set here, .pc files cause problems 393 # If prefix isn't set here, .pc files cause problems
371 if [[ -x ${ECONF_SOURCE:-.}/configure ]]; then 394 if [[ -x ${ECONF_SOURCE:-.}/configure ]]; then
372 econf --prefix=${XDIR} \ 395 econf --prefix=${XDIR} \
373 --datadir=${XDIR}/share \ 396 --datadir=${XDIR}/share \
383# Run make. 406# Run make.
384x-modular_src_make() { 407x-modular_src_make() {
385 emake || die "emake failed" 408 emake || die "emake failed"
386} 409}
387 410
388# @FUNCTION: x-modular_src_configure 411# @FUNCTION: x-modular_src_compile
389# @USAGE: 412# @USAGE:
390# @DESCRIPTION: 413# @DESCRIPTION:
391# Compile a package, performing all X-related tasks. 414# Compile a package, performing all X-related tasks.
392x-modular_src_compile() { 415x-modular_src_compile() {
393 x-modular_src_configure 416 has src_configure ${EXPORTED_FUNCTIONS} || x-modular_src_configure
394 x-modular_src_make 417 x-modular_src_make
395} 418}
396 419
397# @FUNCTION: x-modular_src_install 420# @FUNCTION: x-modular_src_install
398# @USAGE: 421# @USAGE:
407 DESTDIR="${D}" \ 430 DESTDIR="${D}" \
408 install \ 431 install \
409 || die 432 || die
410 else 433 else
411 make \ 434 make \
435 docdir=/usr/share/doc/${PF} \
412 DESTDIR="${D}" \ 436 DESTDIR="${D}" \
413 install \ 437 install \
414 || die 438 || die
415 fi 439 fi
416# Shouldn't be necessary in XDIR=/usr 440# Shouldn't be necessary in XDIR=/usr
427 if [[ -e ${S}/ChangeLog ]]; then 451 if [[ -e ${S}/ChangeLog ]]; then
428 dodoc "${S}"/ChangeLog 452 dodoc "${S}"/ChangeLog
429 fi 453 fi
430# @VARIABLE: DOCS 454# @VARIABLE: DOCS
431# @DESCRIPTION: 455# @DESCRIPTION:
432# Any documentation to install 456# Any documentation to install via dodoc
433 [[ -n ${DOCS} ]] && dodoc ${DOCS} 457 [[ -n ${DOCS} ]] && dodoc ${DOCS}
434 458
435 # Don't install libtool archives for server modules 459 # Don't install libtool archives for server modules
436 if [[ -e ${D}/usr/$(get_libdir)/xorg/modules ]]; then 460 if [[ -e ${D}/usr/$(get_libdir)/xorg/modules ]]; then
437 find "${D}"/usr/$(get_libdir)/xorg/modules -name '*.la' \ 461 find "${D}"/usr/$(get_libdir)/xorg/modules -name '*.la' \
472# @DESCRIPTION: 496# @DESCRIPTION:
473# Run X-specific post-removal tasks on the live filesystem. The only 497# Run X-specific post-removal tasks on the live filesystem. The only
474# task right now is some cleanup for font packages. 498# task right now is some cleanup for font packages.
475x-modular_pkg_postrm() { 499x-modular_pkg_postrm() {
476 if [[ -n "${FONT}" ]]; then 500 if [[ -n "${FONT}" ]]; then
477 cleanup_fonts
478 font_pkg_postrm 501 font_pkg_postrm
479 fi 502 fi
480}
481
482# @FUNCTION: cleanup_fonts
483# @USAGE:
484# @DESCRIPTION:
485# Get rid of font directories that only contain generated files
486cleanup_fonts() {
487 local ALLOWED_FILES="encodings.dir fonts.cache-1 fonts.dir fonts.scale"
488 for DIR in ${FONT_DIR}; do
489 unset KEEP_FONTDIR
490 REAL_DIR=${ROOT}usr/share/fonts/${DIR}
491
492 ebegin "Checking ${REAL_DIR} for useless files"
493 pushd ${REAL_DIR} &> /dev/null
494 for FILE in *; do
495 unset MATCH
496 for ALLOWED_FILE in ${ALLOWED_FILES}; do
497 if [[ ${FILE} = ${ALLOWED_FILE} ]]; then
498 # If it's allowed, then move on to the next file
499 MATCH="yes"
500 break
501 fi
502 done
503 # If we found a match in allowed files, move on to the next file
504 if [[ -n ${MATCH} ]]; then
505 continue
506 fi
507 # If we get this far, there wasn't a match in the allowed files
508 KEEP_FONTDIR="yes"
509 # We don't need to check more files if we're already keeping it
510 break
511 done
512 popd &> /dev/null
513 # If there are no files worth keeping, then get rid of the dir
514 if [[ -z "${KEEP_FONTDIR}" ]]; then
515 rm -rf ${REAL_DIR}
516 fi
517 eend 0
518 done
519} 503}
520 504
521# @FUNCTION: setup_fonts 505# @FUNCTION: setup_fonts
522# @USAGE: 506# @USAGE:
523# @DESCRIPTION: 507# @DESCRIPTION:
529 die "${msg}" 513 die "${msg}"
530 fi 514 fi
531 515
532 create_fonts_scale 516 create_fonts_scale
533 create_fonts_dir 517 create_fonts_dir
534 fix_font_permissions
535 create_font_cache 518 create_font_cache
536} 519}
537 520
538# @FUNCTION: remove_font_metadata 521# @FUNCTION: remove_font_metadata
539# @USAGE: 522# @USAGE:
622 fi 605 fi
623 done 606 done
624 eend 0 607 eend 0
625} 608}
626 609
627# @FUNCTION: fix_font_permissions
628# @USAGE:
629# @DESCRIPTION:
630# Font files should have 644 permissions. Ensure this is the case.
631fix_font_permissions() {
632 ebegin "Fixing permissions"
633 for DIR in ${FONT_DIR}; do
634 find "${ROOT}"/usr/share/fonts/${DIR} -type f -name 'font.*' \
635 -exec chmod 0644 {} \;
636 done
637 eend 0
638}
639
640# @FUNCTION: create_font_cache 610# @FUNCTION: create_font_cache
641# @USAGE: 611# @USAGE:
642# @DESCRIPTION: 612# @DESCRIPTION:
643# Create fonts.cache-1 files, used by the new client-side fonts 613# Create fonts.cache-1 files, used by the new client-side fonts
644# subsystem. 614# subsystem.
645create_font_cache() { 615create_font_cache() {
646 font_pkg_postinst 616 font_pkg_postinst
647} 617}
648
649EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst pkg_postrm

Legend:
Removed from v.1.107  
changed lines
  Added in v.1.119

  ViewVC Help
Powered by ViewVC 1.1.20