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

Contents of /eclass/x-modular.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.13 - (show annotations) (download)
Mon Sep 12 21:44:16 2005 UTC (9 years, 3 months ago) by spyderous
Branch: MAIN
Changes since 1.12: +4 -5 lines
Add blocker on <x11-base/xorg-x11-7.

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

  ViewVC Help
Powered by ViewVC 1.1.20