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

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.28

  ViewVC Help
Powered by ViewVC 1.1.20