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

Contents of /eclass/x-modular.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.11 - (hide annotations) (download)
Mon Sep 5 20:36:30 2005 UTC (8 years, 10 months ago) by spyderous
Branch: MAIN
Changes since 1.10: +2 -2 lines
Requires >=dev-util/pkgconfig-0.18 for PKG_CHECK_EXISTS.

1 spyderous 1.1 # Copyright 1999-2005 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 spyderous 1.11 # $Header: /var/cvsroot/gentoo-x86/eclass/x-modular.eclass,v 1.10 2005/09/04 15:15:37 swegener 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.4 EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst
14 spyderous 1.1
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 spyderous 1.3 # If we're a font package, but not the font.alias one
37     if [[ "${PN/#font}" != "${PN}" ]] && [[ "${PN}" != "font-alias" ]]; then
38 spyderous 1.4 # Activate font code in the rest of the eclass
39     FONT="yes"
40    
41 spyderous 1.3 RDEPEND="${RDEPEND}
42     media-fonts/encodings"
43     PDEPEND="${PDEPEND}
44     media-fonts/font-alias"
45     fi
46    
47 spyderous 1.7 # If we're a driver package
48 swegener 1.10 if [[ "${PN/#xf86-video}" != "${PN}" || "${PN/#xf86-input}" != "${PN}" ]]
49 cardoe 1.9 then
50 spyderous 1.7 # Don't build static driver modules
51     DRIVER_OPTIONS="--disable-static"
52     fi
53    
54 spyderous 1.1 DEPEND="${DEPEND}
55 spyderous 1.11 >=dev-util/pkgconfig-0.18
56 spyderous 1.1 x11-misc/util-macros"
57    
58     RDEPEND="${RDEPEND}"
59     # Shouldn't be necessary once we're in a standard location
60     # x11-base/x11-env"
61     # FIXME: Uncomment once it's in portage
62     # !x11-base/xorg-x11"
63    
64     x-modular_unpack_source() {
65     unpack ${A}
66     cd ${S}
67     }
68    
69     x-modular_patch_source() {
70     # Use standardized names and locations with bulk patching
71     # Patch directory is ${WORKDIR}/patch
72     # See epatch() in eutils.eclass for more documentation
73     if [ -z "${EPATCH_SUFFIX}" ] ; then
74     EPATCH_SUFFIX="patch"
75     fi
76    
77     # For specific list of patches
78     if [ -n "${PATCHES}" ] ; then
79     for PATCH in ${PATCHES}
80     do
81     epatch ${PATCH}
82     done
83     # For non-default directory bulk patching
84     elif [ -n "${PATCH_LOC}" ] ; then
85     epatch ${PATCH_LOC}
86     # For standard bulk patching
87     elif [ -d "${EPATCH_SOURCE}" ] ; then
88     epatch
89     fi
90     }
91    
92     x-modular_reconf_source() {
93     # Run autoreconf for CVS snapshots only
94     if [ "${SNAPSHOT}" = "yes" ]
95     then
96     # If possible, generate configure if it doesn't exist
97     if [ -f "${S}/configure.ac" ]
98     then
99     einfo "Running autoreconf..."
100 cardoe 1.8 autoreconf -v --force --install
101 spyderous 1.1 fi
102     fi
103    
104     }
105    
106     x-modular_src_unpack() {
107     x-modular_unpack_source
108     x-modular_patch_source
109     x-modular_reconf_source
110     }
111    
112 spyderous 1.6 x-modular_src_configure() {
113 spyderous 1.1 # If prefix isn't set here, .pc files cause problems
114     if [ -x ./configure ]; then
115     econf --prefix=${XDIR} \
116     --datadir=${XDIR}/share \
117 spyderous 1.7 ${DRIVER_OPTIONS} \
118 spyderous 1.1 ${CONFIGURE_OPTIONS}
119     fi
120 spyderous 1.6 }
121    
122     x-modular_src_make() {
123 spyderous 1.1 emake || die "emake failed"
124     }
125    
126 spyderous 1.6 x-modular_src_compile() {
127     x-modular_src_configure
128     x-modular_src_make
129     }
130    
131 spyderous 1.1 x-modular_src_install() {
132     # Install everything to ${XDIR}
133     make \
134     DESTDIR="${D}" \
135     install
136     # Shouldn't be necessary in XDIR=/usr
137     # einstall forces datadir, so we need to re-force it
138     # datadir=${XDIR}/share \
139     # mandir=${XDIR}/share/man \
140 spyderous 1.7
141     # Don't install libtool archives for server modules
142     if [[ -e ${D}/usr/lib/xorg/modules ]]; then
143     find ${D}/usr/lib/xorg/modules -name '*.la' \
144     | xargs rm -f
145     fi
146 spyderous 1.1 }
147 spyderous 1.2
148 spyderous 1.4 x-modular_pkg_preinst() {
149     if [[ -n "${FONT}" ]]; then
150     discover_font_dirs
151     fi
152     }
153    
154 spyderous 1.2 x-modular_pkg_postinst() {
155     if [[ -n "${FONT}" ]]; then
156     setup_fonts
157     fi
158     }
159    
160     setup_fonts() {
161     if [[ ! -n "${FONT_DIRS}" ]]; then
162     msg="FONT_DIRS empty. Set it to at least one subdir of /usr/share/fonts."
163     eerror ${msg}
164     die ${msg}
165     fi
166    
167     create_fonts_scale
168     create_fonts_dir
169     fix_font_permissions
170     create_font_cache
171     }
172    
173 spyderous 1.4 discover_font_dirs() {
174     pushd ${IMAGE}/usr/share/fonts
175     FONT_DIRS="$(find . -maxdepth 1 -mindepth 1 -type d)"
176     FONT_DIRS="$(echo ${FONT_DIRS} | sed -e 's:./::g')"
177     popd
178     }
179    
180 spyderous 1.2 create_fonts_scale() {
181     ebegin "Creating fonts.scale files"
182     local x
183     for FONT_DIR in ${FONT_DIRS}; do
184     x=${ROOT}/usr/share/fonts/${FONT_DIR}
185     [ -z "$(ls ${x}/)" ] && continue
186     [ "$(ls ${x}/)" = "fonts.cache-1" ] && continue
187    
188     # Only generate .scale files if truetype, opentype or type1
189     # fonts are present ...
190    
191     # First truetype (ttf,ttc)
192     # NOTE: ttmkfdir does NOT work on type1 fonts (#53753)
193     # Also, there is no way to regenerate Speedo/CID fonts.scale
194     # <spyderous@gentoo.org> 2 August 2004
195     if [ "${x/encodings}" = "${x}" -a \
196     -n "$(find ${x} -iname '*.tt[cf]' -print)" ]; then
197     if [ -x ${ROOT}/usr/bin/ttmkfdir ]; then
198     LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
199     ${ROOT}/usr/bin/ttmkfdir -x 2 \
200     -e ${ROOT}/usr/share/fonts/encodings/encodings.dir \
201     -o ${x}/fonts.scale -d ${x}
202     # ttmkfdir fails on some stuff, so try mkfontscale if it does
203     local ttmkfdir_return=$?
204     else
205     # We didn't use ttmkfdir at all
206     local ttmkfdir_return=2
207     fi
208     if [ ${ttmkfdir_return} -ne 0 ]; then
209     LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
210     ${ROOT}/usr/bin/mkfontscale \
211     -a /usr/share/fonts/encodings/encodings.dir \
212     -- ${x}
213     fi
214     # Next type1 and opentype (pfa,pfb,otf,otc)
215     elif [ "${x/encodings}" = "${x}" -a \
216     -n "$(find ${x} -iname '*.[po][ft][abcf]' -print)" ]; then
217     LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
218     ${ROOT}/usr/bin/mkfontscale \
219     -a ${ROOT}/usr/share/fonts/encodings/encodings.dir \
220     -- ${x}
221     fi
222     done
223     eend 0
224     }
225    
226     create_fonts_dir() {
227     ebegin "Generating fonts.dir files"
228     for FONT_DIR in ${FONT_DIRS}; do
229     x=${ROOT}/usr/share/fonts/${FONT_DIR}
230     [ -z "$(ls ${x}/)" ] && continue
231     [ "$(ls ${x}/)" = "fonts.cache-1" ] && continue
232    
233     if [ "${x/encodings}" = "${x}" ]; then
234     LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
235     ${ROOT}/usr/bin/mkfontdir \
236     -e ${ROOT}/usr/share/fonts/encodings \
237     -e ${ROOT}/usr/share/fonts/encodings/large \
238     -- ${x}
239     fi
240     done
241     eend 0
242     }
243    
244     fix_font_permissions() {
245     ebegin "Fixing permissions"
246     for FONT_DIR in ${FONT_DIRS}; do
247     find ${ROOT}/usr/share/fonts/${FONT_DIR} -type f -name 'font.*' \
248     -exec chmod 0644 {} \;
249     done
250     eend 0
251     }
252    
253     create_font_cache() {
254     # danarmak found out that fc-cache should be run AFTER all the above
255     # stuff, as otherwise the cache is invalid, and has to be run again
256     # as root anyway
257     if [ -x ${ROOT}/usr/bin/fc-cache ]; then
258     ebegin "Creating FC font cache"
259     HOME="/root" ${ROOT}/usr/bin/fc-cache
260     eend 0
261     fi
262     }

  ViewVC Help
Powered by ViewVC 1.1.20