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

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.31

  ViewVC Help
Powered by ViewVC 1.1.20