| 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.4 2005/08/14 23:45:52 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 |
# 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 |
|
| 13 |
EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst
|
| 14 |
|
| 15 |
inherit eutils
|
| 16 |
|
| 17 |
# Directory prefix to use for everything
|
| 18 |
XDIR="/usr"
|
| 19 |
|
| 20 |
IUSE=""
|
| 21 |
HOMEPAGE="http://xorg.freedesktop.org/"
|
| 22 |
SRC_URI="http://xorg.freedesktop.org/X11R7.0-RC0/everything/${P}.tar.bz2"
|
| 23 |
LICENSE="X11"
|
| 24 |
SLOT="0"
|
| 25 |
|
| 26 |
# Set up shared dependencies
|
| 27 |
if [ -n "${SNAPSHOT}" ]; then
|
| 28 |
# FIXME: What's the minimal libtool version supporting arbitrary versioning?
|
| 29 |
DEPEND="${DEPEND}
|
| 30 |
>=sys-devel/autoconf-2.57
|
| 31 |
>=sys-devel/automake-1.7
|
| 32 |
>=sys-devel/libtool-1.5
|
| 33 |
>=sys-devel/m4-1.4"
|
| 34 |
fi
|
| 35 |
|
| 36 |
# If we're a font package, but not the font.alias one
|
| 37 |
if [[ "${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"
|
| 45 |
fi
|
| 46 |
|
| 47 |
DEPEND="${DEPEND}
|
| 48 |
dev-util/pkgconfig
|
| 49 |
x11-misc/util-macros"
|
| 50 |
|
| 51 |
RDEPEND="${RDEPEND}"
|
| 52 |
# Shouldn't be necessary once we're in a standard location
|
| 53 |
# x11-base/x11-env"
|
| 54 |
# FIXME: Uncomment once it's in portage
|
| 55 |
# !x11-base/xorg-x11"
|
| 56 |
|
| 57 |
x-modular_unpack_source() {
|
| 58 |
unpack ${A}
|
| 59 |
cd ${S}
|
| 60 |
}
|
| 61 |
|
| 62 |
x-modular_patch_source() {
|
| 63 |
# Use standardized names and locations with bulk patching
|
| 64 |
# Patch directory is ${WORKDIR}/patch
|
| 65 |
# See epatch() in eutils.eclass for more documentation
|
| 66 |
if [ -z "${EPATCH_SUFFIX}" ] ; then
|
| 67 |
EPATCH_SUFFIX="patch"
|
| 68 |
fi
|
| 69 |
|
| 70 |
# For specific list of patches
|
| 71 |
if [ -n "${PATCHES}" ] ; then
|
| 72 |
for PATCH in ${PATCHES}
|
| 73 |
do
|
| 74 |
epatch ${PATCH}
|
| 75 |
done
|
| 76 |
# For non-default directory bulk patching
|
| 77 |
elif [ -n "${PATCH_LOC}" ] ; then
|
| 78 |
epatch ${PATCH_LOC}
|
| 79 |
# For standard bulk patching
|
| 80 |
elif [ -d "${EPATCH_SOURCE}" ] ; then
|
| 81 |
epatch
|
| 82 |
fi
|
| 83 |
}
|
| 84 |
|
| 85 |
x-modular_reconf_source() {
|
| 86 |
# Run autoreconf for CVS snapshots only
|
| 87 |
if [ "${SNAPSHOT}" = "yes" ]
|
| 88 |
then
|
| 89 |
# If possible, generate configure if it doesn't exist
|
| 90 |
if [ -f "${S}/configure.ac" ]
|
| 91 |
then
|
| 92 |
einfo "Running autoreconf..."
|
| 93 |
autoreconf -v --install
|
| 94 |
fi
|
| 95 |
fi
|
| 96 |
|
| 97 |
}
|
| 98 |
|
| 99 |
x-modular_src_unpack() {
|
| 100 |
x-modular_unpack_source
|
| 101 |
x-modular_patch_source
|
| 102 |
x-modular_reconf_source
|
| 103 |
}
|
| 104 |
|
| 105 |
x-modular_src_compile() {
|
| 106 |
# If prefix isn't set here, .pc files cause problems
|
| 107 |
if [ -x ./configure ]; then
|
| 108 |
econf --prefix=${XDIR} \
|
| 109 |
--datadir=${XDIR}/share \
|
| 110 |
${CONFIGURE_OPTIONS}
|
| 111 |
fi
|
| 112 |
emake || die "emake failed"
|
| 113 |
}
|
| 114 |
|
| 115 |
x-modular_src_install() {
|
| 116 |
# Install everything to ${XDIR}
|
| 117 |
make \
|
| 118 |
DESTDIR="${D}" \
|
| 119 |
install
|
| 120 |
# Shouldn't be necessary in XDIR=/usr
|
| 121 |
# einstall forces datadir, so we need to re-force it
|
| 122 |
# datadir=${XDIR}/share \
|
| 123 |
# mandir=${XDIR}/share/man \
|
| 124 |
}
|
| 125 |
|
| 126 |
x-modular_pkg_preinst() {
|
| 127 |
if [[ -n "${FONT}" ]]; then
|
| 128 |
discover_font_dirs
|
| 129 |
fi
|
| 130 |
}
|
| 131 |
|
| 132 |
x-modular_pkg_postinst() {
|
| 133 |
if [[ -n "${FONT}" ]]; then
|
| 134 |
setup_fonts
|
| 135 |
fi
|
| 136 |
}
|
| 137 |
|
| 138 |
setup_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 |
|
| 151 |
discover_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 |
|
| 158 |
create_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 |
|
| 204 |
create_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 |
|
| 222 |
fix_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 |
|
| 231 |
create_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 |
}
|