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

Contents of /eclass/x-modular.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.29 - (hide annotations) (download)
Fri Dec 9 23:32:27 2005 UTC (8 years, 7 months ago) by joshuabaergen
Branch: MAIN
Changes since 1.28: +24 -4 lines
Re-enable the installation of driver manpages to 4x instead of 4. Fixes bug #29541.

1 spyderous 1.1 # Copyright 1999-2005 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 joshuabaergen 1.29 # $Header: /var/cvsroot/gentoo-x86/eclass/x-modular.eclass,v 1.28 2005/12/09 19:21:28 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 joshuabaergen 1.29 # Set up default patchset version(s) if necessary
21     # x11-driver-patches
22     if [[ -z "${XDPVER}" ]]; then
23     XDPVER="1"
24     fi
25    
26 spyderous 1.1 IUSE=""
27     HOMEPAGE="http://xorg.freedesktop.org/"
28 joshuabaergen 1.23 SRC_URI="http://xorg.freedesktop.org/releases/X11R7.0-RC3/everything/${P}.tar.bz2
29     http://xorg.freedesktop.org/releases/X11R7.0-RC2/everything/${P}.tar.bz2
30 spyderous 1.20 http://xorg.freedesktop.org/releases/X11R7.0-RC1/everything/${P}.tar.bz2
31 spyderous 1.14 http://xorg.freedesktop.org/releases/X11R7.0-RC0/everything/${P}.tar.bz2"
32 spyderous 1.1 LICENSE="X11"
33     SLOT="0"
34    
35     # Set up shared dependencies
36 spyderous 1.28 if [[ -n "${SNAPSHOT}" ]]; then
37 spyderous 1.1 # FIXME: What's the minimal libtool version supporting arbitrary versioning?
38     DEPEND="${DEPEND}
39     >=sys-devel/autoconf-2.57
40     >=sys-devel/automake-1.7
41     >=sys-devel/libtool-1.5
42     >=sys-devel/m4-1.4"
43     fi
44    
45 spyderous 1.3 # If we're a font package, but not the font.alias one
46 spyderous 1.25 if [[ "${PN/#font-}" != "${PN}" ]] \
47     && [[ "${PN}" != "font-alias" ]] \
48     && [[ "${PN}" != "font-util" ]]; then
49 spyderous 1.4 # Activate font code in the rest of the eclass
50     FONT="yes"
51    
52 spyderous 1.3 RDEPEND="${RDEPEND}
53     media-fonts/encodings"
54     PDEPEND="${PDEPEND}
55     media-fonts/font-alias"
56 spyderous 1.25
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
80 spyderous 1.3 fi
81    
82 spyderous 1.7 # If we're a driver package
83 spyderous 1.12 if [[ "${PN/#xf86-video}" != "${PN}" ]] || [[ "${PN/#xf86-input}" != "${PN}" ]]; then
84 spyderous 1.7 # Don't build static driver modules
85     DRIVER_OPTIONS="--disable-static"
86 joshuabaergen 1.29
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"
93 spyderous 1.7 fi
94    
95 spyderous 1.1 DEPEND="${DEPEND}
96 spyderous 1.11 >=dev-util/pkgconfig-0.18
97 spyderous 1.24 >=x11-misc/util-macros-0.99.2"
98 spyderous 1.1
99 spyderous 1.21 # >=sys-apps/man-1.6b-r2 required to look in [0-8]x/ directories
100 spyderous 1.13 RDEPEND="${RDEPEND}
101 joshuabaergen 1.22 !<=x11-base/xorg-x11-6.9
102 spyderous 1.21 >=sys-apps/man-1.6b-r2"
103 spyderous 1.13 # Provides virtual/x11 for temporary use until packages are ported
104 spyderous 1.1 # x11-base/x11-env"
105    
106     x-modular_unpack_source() {
107     unpack ${A}
108     cd ${S}
109 joshuabaergen 1.16
110 spyderous 1.25 if [[ -n ${FONT_OPTIONS} ]]; then
111     einfo "Detected font directory: ${FONT_DIR}"
112     fi
113 spyderous 1.1 }
114    
115     x-modular_patch_source() {
116     # Use standardized names and locations with bulk patching
117     # Patch directory is ${WORKDIR}/patch
118     # See epatch() in eutils.eclass for more documentation
119 spyderous 1.28 if [[ -z "${EPATCH_SUFFIX}" ]] ; then
120 spyderous 1.1 EPATCH_SUFFIX="patch"
121     fi
122    
123 joshuabaergen 1.29 # 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    
130 spyderous 1.1 # For specific list of patches
131 spyderous 1.28 if [[ -n "${PATCHES}" ]] ; then
132 spyderous 1.1 for PATCH in ${PATCHES}
133     do
134     epatch ${PATCH}
135     done
136     # For non-default directory bulk patching
137 spyderous 1.28 elif [[ -n "${PATCH_LOC}" ]] ; then
138 spyderous 1.1 epatch ${PATCH_LOC}
139     # For standard bulk patching
140 spyderous 1.28 elif [[ -d "${EPATCH_SOURCE}" ]] ; then
141 spyderous 1.1 epatch
142     fi
143     }
144    
145     x-modular_reconf_source() {
146     # Run autoreconf for CVS snapshots only
147 spyderous 1.28 if [[ "${SNAPSHOT}" = "yes" ]]
148 spyderous 1.1 then
149     # If possible, generate configure if it doesn't exist
150     if [ -f "${S}/configure.ac" ]
151     then
152     einfo "Running autoreconf..."
153 cardoe 1.8 autoreconf -v --force --install
154 spyderous 1.1 fi
155     fi
156    
157     }
158    
159     x-modular_src_unpack() {
160 joshuabaergen 1.29 if [[ ${PN:0:11} = "xorg-server" ]] || [[ -n "${DRIVER}" ]]; then
161     if gcc-specs-now; then
162 joshuabaergen 1.26 msg="Do not emerge ${PN} without vanilla gcc!"
163     eerror "$msg"
164     die "$msg"
165     fi
166 joshuabaergen 1.29 fi
167 joshuabaergen 1.26
168 spyderous 1.1 x-modular_unpack_source
169     x-modular_patch_source
170     x-modular_reconf_source
171 spyderous 1.27
172     # Joshua Baergen - October 23, 2005
173     # Fix shared lib issues on MIPS, FBSD, etc etc
174     elibtoolize
175 spyderous 1.1 }
176    
177 spyderous 1.25 x-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
202     }
203    
204 spyderous 1.6 x-modular_src_configure() {
205 spyderous 1.25 x-modular_font_configure
206    
207 spyderous 1.1 # If prefix isn't set here, .pc files cause problems
208 spyderous 1.28 if [[ -x ./configure ]]; then
209 spyderous 1.1 econf --prefix=${XDIR} \
210     --datadir=${XDIR}/share \
211 spyderous 1.25 ${FONT_OPTIONS} \
212 spyderous 1.7 ${DRIVER_OPTIONS} \
213 spyderous 1.1 ${CONFIGURE_OPTIONS}
214     fi
215 spyderous 1.6 }
216    
217     x-modular_src_make() {
218 spyderous 1.1 emake || die "emake failed"
219     }
220    
221 spyderous 1.6 x-modular_src_compile() {
222     x-modular_src_configure
223     x-modular_src_make
224     }
225    
226 spyderous 1.1 x-modular_src_install() {
227     # Install everything to ${XDIR}
228     make \
229     DESTDIR="${D}" \
230     install
231     # Shouldn't be necessary in XDIR=/usr
232     # einstall forces datadir, so we need to re-force it
233     # datadir=${XDIR}/share \
234     # mandir=${XDIR}/share/man \
235 spyderous 1.7
236     # Don't install libtool archives for server modules
237     if [[ -e ${D}/usr/lib/xorg/modules ]]; then
238     find ${D}/usr/lib/xorg/modules -name '*.la' \
239     | xargs rm -f
240     fi
241 spyderous 1.1 }
242 spyderous 1.2
243 spyderous 1.4 x-modular_pkg_preinst() {
244     if [[ -n "${FONT}" ]]; then
245     discover_font_dirs
246     fi
247     }
248    
249 spyderous 1.2 x-modular_pkg_postinst() {
250     if [[ -n "${FONT}" ]]; then
251     setup_fonts
252     fi
253     }
254    
255 spyderous 1.25 x-modular_pkg_postrm() {
256     if [[ -n "${FONT}" ]]; then
257     cleanup_fonts
258     fi
259     }
260    
261     cleanup_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    
296 spyderous 1.2 setup_fonts() {
297     if [[ ! -n "${FONT_DIRS}" ]]; then
298 spyderous 1.25 msg="FONT_DIRS is empty. The ebuild should set it to at least one subdir of /usr/share/fonts."
299     eerror "${msg}"
300     die "${msg}"
301 spyderous 1.2 fi
302    
303     create_fonts_scale
304     create_fonts_dir
305     fix_font_permissions
306     create_font_cache
307     }
308    
309 spyderous 1.4 discover_font_dirs() {
310     pushd ${IMAGE}/usr/share/fonts
311     FONT_DIRS="$(find . -maxdepth 1 -mindepth 1 -type d)"
312     FONT_DIRS="$(echo ${FONT_DIRS} | sed -e 's:./::g')"
313     popd
314     }
315    
316 spyderous 1.2 create_fonts_scale() {
317     ebegin "Creating fonts.scale files"
318     local x
319     for FONT_DIR in ${FONT_DIRS}; do
320     x=${ROOT}/usr/share/fonts/${FONT_DIR}
321 spyderous 1.28 [[ -z "$(ls ${x}/)" ]] && continue
322     [[ "$(ls ${x}/)" = "fonts.cache-1" ]] && continue
323 spyderous 1.2
324     # Only generate .scale files if truetype, opentype or type1
325     # fonts are present ...
326    
327     # First truetype (ttf,ttc)
328     # NOTE: ttmkfdir does NOT work on type1 fonts (#53753)
329     # Also, there is no way to regenerate Speedo/CID fonts.scale
330     # <spyderous@gentoo.org> 2 August 2004
331 spyderous 1.28 if [[ "${x/encodings}" = "${x}" ]] \
332     && [[ -n "$(find ${x} -iname '*.tt[cf]' -print)" ]]; then
333     if [[ -x ${ROOT}/usr/bin/ttmkfdir ]]; then
334 spyderous 1.2 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
335     ${ROOT}/usr/bin/ttmkfdir -x 2 \
336     -e ${ROOT}/usr/share/fonts/encodings/encodings.dir \
337     -o ${x}/fonts.scale -d ${x}
338     # ttmkfdir fails on some stuff, so try mkfontscale if it does
339     local ttmkfdir_return=$?
340     else
341     # We didn't use ttmkfdir at all
342     local ttmkfdir_return=2
343     fi
344 spyderous 1.28 if [[ ${ttmkfdir_return} -ne 0 ]]; then
345 spyderous 1.2 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
346     ${ROOT}/usr/bin/mkfontscale \
347     -a /usr/share/fonts/encodings/encodings.dir \
348     -- ${x}
349     fi
350     # Next type1 and opentype (pfa,pfb,otf,otc)
351 spyderous 1.28 elif [[ "${x/encodings}" = "${x}" ]] \
352     && [[ -n "$(find ${x} -iname '*.[po][ft][abcf]' -print)" ]]; then
353 spyderous 1.2 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
354     ${ROOT}/usr/bin/mkfontscale \
355     -a ${ROOT}/usr/share/fonts/encodings/encodings.dir \
356     -- ${x}
357     fi
358     done
359     eend 0
360     }
361    
362     create_fonts_dir() {
363     ebegin "Generating fonts.dir files"
364     for FONT_DIR in ${FONT_DIRS}; do
365     x=${ROOT}/usr/share/fonts/${FONT_DIR}
366 spyderous 1.28 [[ -z "$(ls ${x}/)" ]] && continue
367     [[ "$(ls ${x}/)" = "fonts.cache-1" ]] && continue
368 spyderous 1.2
369 spyderous 1.28 if [[ "${x/encodings}" = "${x}" ]]; then
370 spyderous 1.2 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
371     ${ROOT}/usr/bin/mkfontdir \
372     -e ${ROOT}/usr/share/fonts/encodings \
373     -e ${ROOT}/usr/share/fonts/encodings/large \
374     -- ${x}
375     fi
376     done
377     eend 0
378     }
379    
380     fix_font_permissions() {
381     ebegin "Fixing permissions"
382     for FONT_DIR in ${FONT_DIRS}; do
383     find ${ROOT}/usr/share/fonts/${FONT_DIR} -type f -name 'font.*' \
384     -exec chmod 0644 {} \;
385     done
386     eend 0
387     }
388    
389     create_font_cache() {
390     # danarmak found out that fc-cache should be run AFTER all the above
391     # stuff, as otherwise the cache is invalid, and has to be run again
392     # as root anyway
393 spyderous 1.28 if [[ -x ${ROOT}/usr/bin/fc-cache ]]; then
394 spyderous 1.2 ebegin "Creating FC font cache"
395     HOME="/root" ${ROOT}/usr/bin/fc-cache
396     eend 0
397     fi
398     }

  ViewVC Help
Powered by ViewVC 1.1.20