/[gentoo-x86]/eclass/x-modular.eclass
Gentoo

Contents of /eclass/x-modular.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.28 - (hide annotations) (download)
Fri Dec 9 19:21:28 2005 UTC (9 years ago) by spyderous
Branch: MAIN
Changes since 1.27: +20 -20 lines
Fix all single-bracket tests [ ] to be double-bracketed [[ ]] for consistency.

1 spyderous 1.1 # Copyright 1999-2005 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 spyderous 1.28 # $Header: /var/cvsroot/gentoo-x86/eclass/x-modular.eclass,v 1.27 2005/12/09 16:13:54 spyderous Exp $
4 spyderous 1.1 #
5     # Author: Donnie Berkholz <spyderous@gentoo.org>
6     #
7     # This eclass is designed to reduce code duplication in the modularized X11
8     # ebuilds.
9 spyderous 1.2 #
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 spyderous 1.1
13 spyderous 1.25 EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst pkg_postrm
14 spyderous 1.1
15 joshuabaergen 1.26 inherit eutils libtool toolchain-funcs
16 spyderous 1.1
17     # Directory prefix to use for everything
18     XDIR="/usr"
19    
20     IUSE=""
21     HOMEPAGE="http://xorg.freedesktop.org/"
22 joshuabaergen 1.23 SRC_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 spyderous 1.20 http://xorg.freedesktop.org/releases/X11R7.0-RC1/everything/${P}.tar.bz2
25 spyderous 1.14 http://xorg.freedesktop.org/releases/X11R7.0-RC0/everything/${P}.tar.bz2"
26 spyderous 1.1 LICENSE="X11"
27     SLOT="0"
28    
29     # Set up shared dependencies
30 spyderous 1.28 if [[ -n "${SNAPSHOT}" ]]; then
31 spyderous 1.1 # FIXME: What's the minimal libtool version supporting arbitrary versioning?
32     DEPEND="${DEPEND}
33     >=sys-devel/autoconf-2.57
34     >=sys-devel/automake-1.7
35     >=sys-devel/libtool-1.5
36     >=sys-devel/m4-1.4"
37     fi
38    
39 spyderous 1.3 # If we're a font package, but not the font.alias one
40 spyderous 1.25 if [[ "${PN/#font-}" != "${PN}" ]] \
41     && [[ "${PN}" != "font-alias" ]] \
42     && [[ "${PN}" != "font-util" ]]; then
43 spyderous 1.4 # Activate font code in the rest of the eclass
44     FONT="yes"
45    
46 spyderous 1.3 RDEPEND="${RDEPEND}
47     media-fonts/encodings"
48     PDEPEND="${PDEPEND}
49     media-fonts/font-alias"
50 spyderous 1.25
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
74 spyderous 1.3 fi
75    
76 spyderous 1.7 # If we're a driver package
77 spyderous 1.12 if [[ "${PN/#xf86-video}" != "${PN}" ]] || [[ "${PN/#xf86-input}" != "${PN}" ]]; then
78 spyderous 1.7 # Don't build static driver modules
79     DRIVER_OPTIONS="--disable-static"
80     fi
81    
82 spyderous 1.1 DEPEND="${DEPEND}
83 spyderous 1.11 >=dev-util/pkgconfig-0.18
84 spyderous 1.24 >=x11-misc/util-macros-0.99.2"
85 spyderous 1.1
86 spyderous 1.21 # >=sys-apps/man-1.6b-r2 required to look in [0-8]x/ directories
87 spyderous 1.13 RDEPEND="${RDEPEND}
88 joshuabaergen 1.22 !<=x11-base/xorg-x11-6.9
89 spyderous 1.21 >=sys-apps/man-1.6b-r2"
90 spyderous 1.13 # Provides virtual/x11 for temporary use until packages are ported
91 spyderous 1.1 # x11-base/x11-env"
92    
93     x-modular_unpack_source() {
94     unpack ${A}
95     cd ${S}
96 joshuabaergen 1.16
97 spyderous 1.25 if [[ -n ${FONT_OPTIONS} ]]; then
98     einfo "Detected font directory: ${FONT_DIR}"
99     fi
100 spyderous 1.1 }
101    
102     x-modular_patch_source() {
103     # Use standardized names and locations with bulk patching
104     # Patch directory is ${WORKDIR}/patch
105     # See epatch() in eutils.eclass for more documentation
106 spyderous 1.28 if [[ -z "${EPATCH_SUFFIX}" ]] ; then
107 spyderous 1.1 EPATCH_SUFFIX="patch"
108     fi
109    
110     # For specific list of patches
111 spyderous 1.28 if [[ -n "${PATCHES}" ]] ; then
112 spyderous 1.1 for PATCH in ${PATCHES}
113     do
114     epatch ${PATCH}
115     done
116     # For non-default directory bulk patching
117 spyderous 1.28 elif [[ -n "${PATCH_LOC}" ]] ; then
118 spyderous 1.1 epatch ${PATCH_LOC}
119     # For standard bulk patching
120 spyderous 1.28 elif [[ -d "${EPATCH_SOURCE}" ]] ; then
121 spyderous 1.1 epatch
122     fi
123     }
124    
125     x-modular_reconf_source() {
126     # Run autoreconf for CVS snapshots only
127 spyderous 1.28 if [[ "${SNAPSHOT}" = "yes" ]]
128 spyderous 1.1 then
129     # If possible, generate configure if it doesn't exist
130     if [ -f "${S}/configure.ac" ]
131     then
132     einfo "Running autoreconf..."
133 cardoe 1.8 autoreconf -v --force --install
134 spyderous 1.1 fi
135     fi
136    
137     }
138    
139     x-modular_src_unpack() {
140 joshuabaergen 1.26 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    
148 spyderous 1.1 x-modular_unpack_source
149     x-modular_patch_source
150     x-modular_reconf_source
151 spyderous 1.27
152     # Joshua Baergen - October 23, 2005
153     # Fix shared lib issues on MIPS, FBSD, etc etc
154     elibtoolize
155 spyderous 1.1 }
156    
157 spyderous 1.25 x-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    
184 spyderous 1.6 x-modular_src_configure() {
185 spyderous 1.25 x-modular_font_configure
186    
187 spyderous 1.1 # If prefix isn't set here, .pc files cause problems
188 spyderous 1.28 if [[ -x ./configure ]]; then
189 spyderous 1.1 econf --prefix=${XDIR} \
190     --datadir=${XDIR}/share \
191 spyderous 1.25 ${FONT_OPTIONS} \
192 spyderous 1.7 ${DRIVER_OPTIONS} \
193 spyderous 1.1 ${CONFIGURE_OPTIONS}
194     fi
195 spyderous 1.6 }
196    
197     x-modular_src_make() {
198 spyderous 1.1 emake || die "emake failed"
199     }
200    
201 spyderous 1.6 x-modular_src_compile() {
202     x-modular_src_configure
203     x-modular_src_make
204     }
205    
206 spyderous 1.1 x-modular_src_install() {
207     # Install everything to ${XDIR}
208     make \
209     DESTDIR="${D}" \
210     install
211     # Shouldn't be necessary in XDIR=/usr
212     # einstall forces datadir, so we need to re-force it
213     # datadir=${XDIR}/share \
214     # mandir=${XDIR}/share/man \
215 spyderous 1.7
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 spyderous 1.1 }
222 spyderous 1.2
223 spyderous 1.4 x-modular_pkg_preinst() {
224     if [[ -n "${FONT}" ]]; then
225     discover_font_dirs
226     fi
227     }
228    
229 spyderous 1.2 x-modular_pkg_postinst() {
230     if [[ -n "${FONT}" ]]; then
231     setup_fonts
232     fi
233     }
234    
235 spyderous 1.25 x-modular_pkg_postrm() {
236     if [[ -n "${FONT}" ]]; then
237     cleanup_fonts
238     fi
239     }
240    
241     cleanup_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
274     }
275    
276 spyderous 1.2 setup_fonts() {
277     if [[ ! -n "${FONT_DIRS}" ]]; then
278 spyderous 1.25 msg="FONT_DIRS is empty. The ebuild should set it to at least one subdir of /usr/share/fonts."
279     eerror "${msg}"
280     die "${msg}"
281 spyderous 1.2 fi
282    
283     create_fonts_scale
284     create_fonts_dir
285     fix_font_permissions
286     create_font_cache
287     }
288    
289 spyderous 1.4 discover_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
294     }
295    
296 spyderous 1.2 create_fonts_scale() {
297     ebegin "Creating fonts.scale files"
298     local x
299     for FONT_DIR in ${FONT_DIRS}; do
300     x=${ROOT}/usr/share/fonts/${FONT_DIR}
301 spyderous 1.28 [[ -z "$(ls ${x}/)" ]] && continue
302     [[ "$(ls ${x}/)" = "fonts.cache-1" ]] && continue
303 spyderous 1.2
304     # Only generate .scale files if truetype, opentype or type1
305     # fonts are present ...
306    
307     # First truetype (ttf,ttc)
308     # NOTE: ttmkfdir does NOT work on type1 fonts (#53753)
309     # Also, there is no way to regenerate Speedo/CID fonts.scale
310     # <spyderous@gentoo.org> 2 August 2004
311 spyderous 1.28 if [[ "${x/encodings}" = "${x}" ]] \
312     && [[ -n "$(find ${x} -iname '*.tt[cf]' -print)" ]]; then
313     if [[ -x ${ROOT}/usr/bin/ttmkfdir ]]; then
314 spyderous 1.2 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
315     ${ROOT}/usr/bin/ttmkfdir -x 2 \
316     -e ${ROOT}/usr/share/fonts/encodings/encodings.dir \
317     -o ${x}/fonts.scale -d ${x}
318     # ttmkfdir fails on some stuff, so try mkfontscale if it does
319     local ttmkfdir_return=$?
320     else
321     # We didn't use ttmkfdir at all
322     local ttmkfdir_return=2
323     fi
324 spyderous 1.28 if [[ ${ttmkfdir_return} -ne 0 ]]; then
325 spyderous 1.2 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
326     ${ROOT}/usr/bin/mkfontscale \
327     -a /usr/share/fonts/encodings/encodings.dir \
328     -- ${x}
329     fi
330     # Next type1 and opentype (pfa,pfb,otf,otc)
331 spyderous 1.28 elif [[ "${x/encodings}" = "${x}" ]] \
332     && [[ -n "$(find ${x} -iname '*.[po][ft][abcf]' -print)" ]]; then
333 spyderous 1.2 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
334     ${ROOT}/usr/bin/mkfontscale \
335     -a ${ROOT}/usr/share/fonts/encodings/encodings.dir \
336     -- ${x}
337     fi
338     done
339     eend 0
340     }
341    
342     create_fonts_dir() {
343     ebegin "Generating fonts.dir files"
344     for FONT_DIR in ${FONT_DIRS}; do
345     x=${ROOT}/usr/share/fonts/${FONT_DIR}
346 spyderous 1.28 [[ -z "$(ls ${x}/)" ]] && continue
347     [[ "$(ls ${x}/)" = "fonts.cache-1" ]] && continue
348 spyderous 1.2
349 spyderous 1.28 if [[ "${x/encodings}" = "${x}" ]]; then
350 spyderous 1.2 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
351     ${ROOT}/usr/bin/mkfontdir \
352     -e ${ROOT}/usr/share/fonts/encodings \
353     -e ${ROOT}/usr/share/fonts/encodings/large \
354     -- ${x}
355     fi
356     done
357     eend 0
358     }
359    
360     fix_font_permissions() {
361     ebegin "Fixing permissions"
362     for FONT_DIR in ${FONT_DIRS}; do
363     find ${ROOT}/usr/share/fonts/${FONT_DIR} -type f -name 'font.*' \
364     -exec chmod 0644 {} \;
365     done
366     eend 0
367     }
368    
369     create_font_cache() {
370     # danarmak found out that fc-cache should be run AFTER all the above
371     # stuff, as otherwise the cache is invalid, and has to be run again
372     # as root anyway
373 spyderous 1.28 if [[ -x ${ROOT}/usr/bin/fc-cache ]]; then
374 spyderous 1.2 ebegin "Creating FC font cache"
375     HOME="/root" ${ROOT}/usr/bin/fc-cache
376     eend 0
377     fi
378     }

  ViewVC Help
Powered by ViewVC 1.1.20