--- eclass/x-modular.eclass 2005/08/08 02:57:50 1.1 +++ eclass/x-modular.eclass 2005/11/30 09:59:28 1.1.1.1 @@ -1,23 +1,27 @@ # Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/x-modular.eclass,v 1.1 2005/08/08 02:57:50 spyderous Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/x-modular.eclass,v 1.1.1.1 2005/11/30 09:59:28 chriswhite Exp $ # # Author: Donnie Berkholz # # This eclass is designed to reduce code duplication in the modularized X11 # ebuilds. +# +# If the ebuild installs fonts, set FONT="yes" at the top and set FONT_DIRS to +# the subdirectories within /usr/share/fonts to which it installs fonts. -EXPORT_FUNCTIONS src_unpack src_compile src_install +EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst -inherit eutils +inherit eutils libtool # Directory prefix to use for everything -# Change to /usr/X11R6 once it's standard XDIR="/usr" IUSE="" HOMEPAGE="http://xorg.freedesktop.org/" -SRC_URI="http://xorg.freedesktop.org/X11R7.0-RC0/everything/${P}.tar.bz2" +SRC_URI="http://xorg.freedesktop.org/releases/X11R7.0-RC2/everything/${P}.tar.bz2 + http://xorg.freedesktop.org/releases/X11R7.0-RC1/everything/${P}.tar.bz2 + http://xorg.freedesktop.org/releases/X11R7.0-RC0/everything/${P}.tar.bz2" LICENSE="X11" SLOT="0" @@ -31,19 +35,41 @@ >=sys-devel/m4-1.4" fi +# If we're a font package, but not the font.alias one +if [[ "${PN/#font-}" != "${PN}" ]] && [[ "${PN}" != "font-alias" ]]; then + # Activate font code in the rest of the eclass + FONT="yes" + + RDEPEND="${RDEPEND} + media-fonts/encodings" + PDEPEND="${PDEPEND} + media-fonts/font-alias" +fi + +# If we're a driver package +if [[ "${PN/#xf86-video}" != "${PN}" ]] || [[ "${PN/#xf86-input}" != "${PN}" ]]; then + # Don't build static driver modules + DRIVER_OPTIONS="--disable-static" +fi + DEPEND="${DEPEND} - dev-util/pkgconfig - x11-misc/util-macros" + >=dev-util/pkgconfig-0.18 + >=x11-misc/util-macros-0.99.0_p20051007" -RDEPEND="${RDEPEND}" -# Shouldn't be necessary once we're in a standard location +# >=sys-apps/man-1.6b-r2 required to look in [0-8]x/ directories +RDEPEND="${RDEPEND} + !<=x11-base/xorg-x11-6.9 + >=sys-apps/man-1.6b-r2" +# Provides virtual/x11 for temporary use until packages are ported # x11-base/x11-env" -# FIXME: Uncomment once it's in portage -# !x11-base/xorg-x11" x-modular_unpack_source() { unpack ${A} cd ${S} + + # Joshua Baergen - October 23, 2005 + # Fix shared lib issues on MIPS, FBSD, etc etc + elibtoolize } x-modular_patch_source() { @@ -77,7 +103,7 @@ if [ -f "${S}/configure.ac" ] then einfo "Running autoreconf..." - autoreconf -v --install + autoreconf -v --force --install fi fi @@ -89,16 +115,25 @@ x-modular_reconf_source } -x-modular_src_compile() { +x-modular_src_configure() { # If prefix isn't set here, .pc files cause problems if [ -x ./configure ]; then econf --prefix=${XDIR} \ --datadir=${XDIR}/share \ + ${DRIVER_OPTIONS} \ ${CONFIGURE_OPTIONS} fi +} + +x-modular_src_make() { emake || die "emake failed" } +x-modular_src_compile() { + x-modular_src_configure + x-modular_src_make +} + x-modular_src_install() { # Install everything to ${XDIR} make \ @@ -108,4 +143,126 @@ # einstall forces datadir, so we need to re-force it # datadir=${XDIR}/share \ # mandir=${XDIR}/share/man \ + + # Don't install libtool archives for server modules + if [[ -e ${D}/usr/lib/xorg/modules ]]; then + find ${D}/usr/lib/xorg/modules -name '*.la' \ + | xargs rm -f + fi +} + +x-modular_pkg_preinst() { + if [[ -n "${FONT}" ]]; then + discover_font_dirs + fi +} + +x-modular_pkg_postinst() { + if [[ -n "${FONT}" ]]; then + setup_fonts + fi +} + +setup_fonts() { + if [[ ! -n "${FONT_DIRS}" ]]; then + msg="FONT_DIRS empty. Set it to at least one subdir of /usr/share/fonts." + eerror ${msg} + die ${msg} + fi + + create_fonts_scale + create_fonts_dir + fix_font_permissions + create_font_cache +} + +discover_font_dirs() { + pushd ${IMAGE}/usr/share/fonts + FONT_DIRS="$(find . -maxdepth 1 -mindepth 1 -type d)" + FONT_DIRS="$(echo ${FONT_DIRS} | sed -e 's:./::g')" + popd +} + +create_fonts_scale() { + ebegin "Creating fonts.scale files" + local x + for FONT_DIR in ${FONT_DIRS}; do + x=${ROOT}/usr/share/fonts/${FONT_DIR} + [ -z "$(ls ${x}/)" ] && continue + [ "$(ls ${x}/)" = "fonts.cache-1" ] && continue + + # Only generate .scale files if truetype, opentype or type1 + # fonts are present ... + + # First truetype (ttf,ttc) + # NOTE: ttmkfdir does NOT work on type1 fonts (#53753) + # Also, there is no way to regenerate Speedo/CID fonts.scale + # 2 August 2004 + if [ "${x/encodings}" = "${x}" -a \ + -n "$(find ${x} -iname '*.tt[cf]' -print)" ]; then + if [ -x ${ROOT}/usr/bin/ttmkfdir ]; then + LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \ + ${ROOT}/usr/bin/ttmkfdir -x 2 \ + -e ${ROOT}/usr/share/fonts/encodings/encodings.dir \ + -o ${x}/fonts.scale -d ${x} + # ttmkfdir fails on some stuff, so try mkfontscale if it does + local ttmkfdir_return=$? + else + # We didn't use ttmkfdir at all + local ttmkfdir_return=2 + fi + if [ ${ttmkfdir_return} -ne 0 ]; then + LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \ + ${ROOT}/usr/bin/mkfontscale \ + -a /usr/share/fonts/encodings/encodings.dir \ + -- ${x} + fi + # Next type1 and opentype (pfa,pfb,otf,otc) + elif [ "${x/encodings}" = "${x}" -a \ + -n "$(find ${x} -iname '*.[po][ft][abcf]' -print)" ]; then + LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \ + ${ROOT}/usr/bin/mkfontscale \ + -a ${ROOT}/usr/share/fonts/encodings/encodings.dir \ + -- ${x} + fi + done + eend 0 +} + +create_fonts_dir() { + ebegin "Generating fonts.dir files" + for FONT_DIR in ${FONT_DIRS}; do + x=${ROOT}/usr/share/fonts/${FONT_DIR} + [ -z "$(ls ${x}/)" ] && continue + [ "$(ls ${x}/)" = "fonts.cache-1" ] && continue + + if [ "${x/encodings}" = "${x}" ]; then + LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \ + ${ROOT}/usr/bin/mkfontdir \ + -e ${ROOT}/usr/share/fonts/encodings \ + -e ${ROOT}/usr/share/fonts/encodings/large \ + -- ${x} + fi + done + eend 0 +} + +fix_font_permissions() { + ebegin "Fixing permissions" + for FONT_DIR in ${FONT_DIRS}; do + find ${ROOT}/usr/share/fonts/${FONT_DIR} -type f -name 'font.*' \ + -exec chmod 0644 {} \; + done + eend 0 +} + +create_font_cache() { + # danarmak found out that fc-cache should be run AFTER all the above + # stuff, as otherwise the cache is invalid, and has to be run again + # as root anyway + if [ -x ${ROOT}/usr/bin/fc-cache ]; then + ebegin "Creating FC font cache" + HOME="/root" ${ROOT}/usr/bin/fc-cache + eend 0 + fi }