| 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.5 2005/08/15 00:33:31 spyderous Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/x-modular.eclass,v 1.46 2006/02/28 01:27:21 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 | # Using this eclass: |
| 11 | # the subdirectories within /usr/share/fonts to which it installs fonts. |
11 | # |
|
|
12 | # Inherit it. If you need to run autoreconf for any reason (e.g., your patches |
|
|
13 | # apply to the autotools files rather than configure), set SNAPSHOT="yes". Set |
|
|
14 | # CONFIGURE_OPTIONS to everything you want to pass to the configure script. |
|
|
15 | # |
|
|
16 | # If you have any patches to apply, set PATCHES to their locations and epatch |
|
|
17 | # will apply them. It also handles epatch-style bulk patches, if you know how to |
|
|
18 | # use them and set the correct variables. If you don't, read eutils.eclass. |
|
|
19 | # |
|
|
20 | # If you're creating a font package and the suffix of PN is not equal to the |
|
|
21 | # subdirectory of /usr/share/fonts/ it should install into, set FONT_DIR to that |
|
|
22 | # directory or directories. |
|
|
23 | # |
|
|
24 | # IMPORTANT: Both SNAPSHOT and FONT_DIR must be set _before_ the inherit. |
|
|
25 | # |
|
|
26 | # Pretty much everything else should be automatic. |
| 12 | |
27 | |
| 13 | EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst |
28 | EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst pkg_postrm |
| 14 | |
29 | |
| 15 | inherit eutils |
30 | inherit eutils libtool toolchain-funcs flag-o-matic |
| 16 | |
31 | |
| 17 | # Directory prefix to use for everything |
32 | # Directory prefix to use for everything |
| 18 | XDIR="/usr" |
33 | XDIR="/usr" |
| 19 | |
34 | |
|
|
35 | # Set up default patchset version(s) if necessary |
|
|
36 | # x11-driver-patches |
|
|
37 | if [[ -z "${XDPVER}" ]]; then |
|
|
38 | XDPVER="1" |
|
|
39 | fi |
|
|
40 | |
| 20 | IUSE="" |
41 | IUSE="" |
| 21 | HOMEPAGE="http://xorg.freedesktop.org/" |
42 | HOMEPAGE="http://xorg.freedesktop.org/" |
|
|
43 | |
|
|
44 | # Set up SRC_URI for individual modular releases |
|
|
45 | BASE_INDIVIDUAL_URI="http://xorg.freedesktop.org/releases/individual" |
|
|
46 | if [[ ${CATEGORY} = x11-apps ]]; then |
|
|
47 | SRC_URI="${SRC_URI} |
|
|
48 | ${BASE_INDIVIDUAL_URI}/app/${P}.tar.bz2" |
|
|
49 | elif [[ ${CATEGORY} = app-doc ]]; then |
|
|
50 | SRC_URI="${SRC_URI} |
|
|
51 | ${BASE_INDIVIDUAL_URI}/doc/${P}.tar.bz2" |
|
|
52 | # x11-misc contains data and util, x11-themes contains data |
|
|
53 | elif [[ ${CATEGORY} = x11-misc ]] || [[ ${CATEGORY} = x11-themes ]]; then |
|
|
54 | SRC_URI="${SRC_URI} |
|
|
55 | ${BASE_INDIVIDUAL_URI}/data/${P}.tar.bz2 |
|
|
56 | ${BASE_INDIVIDUAL_URI}/util/${P}.tar.bz2" |
|
|
57 | elif [[ ${CATEGORY} = x11-drivers ]]; then |
|
|
58 | SRC_URI="${SRC_URI} |
|
|
59 | ${BASE_INDIVIDUAL_URI}/driver/${P}.tar.bz2" |
|
|
60 | elif [[ ${CATEGORY} = media-fonts ]]; then |
|
|
61 | SRC_URI="${SRC_URI} |
|
|
62 | ${BASE_INDIVIDUAL_URI}/font/${P}.tar.bz2" |
|
|
63 | elif [[ ${CATEGORY} = x11-libs ]]; then |
|
|
64 | SRC_URI="${SRC_URI} |
|
|
65 | ${BASE_INDIVIDUAL_URI}/lib/${P}.tar.bz2" |
|
|
66 | elif [[ ${CATEGORY} = x11-proto ]]; then |
|
|
67 | SRC_URI="${SRC_URI} |
|
|
68 | ${BASE_INDIVIDUAL_URI}/proto/${P}.tar.bz2" |
|
|
69 | elif [[ ${CATEGORY} = x11-base ]]; then |
|
|
70 | SRC_URI="${SRC_URI} |
|
|
71 | ${BASE_INDIVIDUAL_URI}/xserver/${P}.tar.bz2" |
|
|
72 | fi |
|
|
73 | |
|
|
74 | # SRC_URI for full releases |
|
|
75 | SRC_URI="${SRC_URI} |
| 22 | SRC_URI="http://xorg.freedesktop.org/X11R7.0-RC0/everything/${P}.tar.bz2" |
76 | http://xorg.freedesktop.org/releases/X11R7.0/src/everything/${P}.tar.bz2" |
| 23 | LICENSE="X11" |
77 | |
| 24 | SLOT="0" |
78 | SLOT="0" |
| 25 | |
79 | |
|
|
80 | # Set the license for the package. This can be overridden by setting |
|
|
81 | # LICENSE after the inherit. |
|
|
82 | LICENSE=${PN} |
|
|
83 | |
| 26 | # Set up shared dependencies |
84 | # Set up shared dependencies |
| 27 | if [ -n "${SNAPSHOT}" ]; then |
85 | if [[ -n "${SNAPSHOT}" ]]; then |
| 28 | # FIXME: What's the minimal libtool version supporting arbitrary versioning? |
86 | # FIXME: What's the minimal libtool version supporting arbitrary versioning? |
| 29 | DEPEND="${DEPEND} |
87 | DEPEND="${DEPEND} |
| 30 | >=sys-devel/autoconf-2.57 |
88 | >=sys-devel/autoconf-2.57 |
| 31 | >=sys-devel/automake-1.7 |
89 | >=sys-devel/automake-1.7 |
| 32 | >=sys-devel/libtool-1.5 |
90 | >=sys-devel/libtool-1.5 |
| 33 | >=sys-devel/m4-1.4" |
91 | >=sys-devel/m4-1.4" |
| 34 | fi |
92 | fi |
| 35 | |
93 | |
| 36 | # If we're a font package, but not the font.alias one |
94 | # If we're a font package, but not the font.alias one |
| 37 | if [[ "${PN/#font}" != "${PN}" ]] && [[ "${PN}" != "font-alias" ]]; then |
95 | if [[ "${PN/#font-}" != "${PN}" ]] \ |
|
|
96 | && [[ "${PN}" != "font-alias" ]] \ |
|
|
97 | && [[ "${PN}" != "font-util" ]]; then |
| 38 | # Activate font code in the rest of the eclass |
98 | # Activate font code in the rest of the eclass |
| 39 | FONT="yes" |
99 | FONT="yes" |
| 40 | |
100 | |
| 41 | RDEPEND="${RDEPEND} |
101 | RDEPEND="${RDEPEND} |
| 42 | media-fonts/encodings" |
102 | media-fonts/encodings |
|
|
103 | x11-apps/mkfontscale |
|
|
104 | x11-apps/mkfontdir" |
| 43 | PDEPEND="${PDEPEND} |
105 | PDEPEND="${PDEPEND} |
| 44 | media-fonts/font-alias" |
106 | media-fonts/font-alias" |
|
|
107 | |
|
|
108 | # Starting with 7.0RC3, we can specify the font directory |
|
|
109 | # But oddly, we can't do the same for encodings or font-alias |
|
|
110 | |
|
|
111 | # Wrap in `if` so ebuilds can set it too |
|
|
112 | if [[ -z ${FONT_DIR} ]]; then |
|
|
113 | FONT_DIR=${PN##*-} |
|
|
114 | |
|
|
115 | fi |
|
|
116 | |
|
|
117 | # Fix case of font directories |
|
|
118 | FONT_DIR=${FONT_DIR/ttf/TTF} |
|
|
119 | FONT_DIR=${FONT_DIR/otf/OTF} |
|
|
120 | FONT_DIR=${FONT_DIR/type1/Type1} |
|
|
121 | FONT_DIR=${FONT_DIR/speedo/Speedo} |
|
|
122 | |
|
|
123 | # Set up configure option |
|
|
124 | FONT_OPTIONS="--with-fontdir=\"/usr/share/fonts/${FONT_DIR}\"" |
|
|
125 | |
|
|
126 | if [[ -n "${FONT}" ]]; then |
|
|
127 | if [[ ${PN##*-} = misc ]] || [[ ${PN##*-} = 75dpi ]] || [[ ${PN##*-} = 100dpi ]]; then |
|
|
128 | IUSE="${IUSE} nls" |
|
|
129 | fi |
|
|
130 | fi |
|
|
131 | fi |
|
|
132 | |
|
|
133 | # If we're a driver package |
|
|
134 | if [[ "${PN/#xf86-video}" != "${PN}" ]] || [[ "${PN/#xf86-input}" != "${PN}" ]]; then |
|
|
135 | # Enable driver code in the rest of the eclass |
|
|
136 | DRIVER="yes" |
|
|
137 | |
|
|
138 | # Add driver patchset to SRC_URI |
|
|
139 | SRC_URI="${SRC_URI} |
|
|
140 | http://dev.gentoo.org/~joshuabaergen/distfiles/x11-driver-patches-${XDPVER}.tar.bz2" |
|
|
141 | fi |
|
|
142 | |
|
|
143 | # Debugging -- ignore packages that can't be built with debugging |
|
|
144 | if [[ -z "${FONT}" ]] \ |
|
|
145 | || [[ "${PN/app-doc}" != "${PN}" ]] \ |
|
|
146 | || [[ "${PN/x11-proto}" != "${PN}" ]] \ |
|
|
147 | || [[ "${PN/util-macros}" != "${PN}" ]] \ |
|
|
148 | || [[ "${PN/xbitmaps}" != "${PN}" ]] \ |
|
|
149 | || [[ "${PN/xkbdata}" != "${PN}" ]] \ |
|
|
150 | || [[ "${PN/xorg-cf-files}" != "${PN}" ]] \ |
|
|
151 | || [[ "${PN/xcursor}" != "${PN}" ]] \ |
|
|
152 | ; then |
|
|
153 | DEBUGGABLE="yes" |
|
|
154 | IUSE="${IUSE} debug" |
|
|
155 | if use debug; then |
|
|
156 | if ! has splitdebug ${FEATURES}; then |
|
|
157 | RESTRICT="${RESTRICT} nostrip" |
|
|
158 | fi |
|
|
159 | fi |
| 45 | fi |
160 | fi |
| 46 | |
161 | |
| 47 | DEPEND="${DEPEND} |
162 | DEPEND="${DEPEND} |
| 48 | dev-util/pkgconfig |
163 | >=dev-util/pkgconfig-0.18" |
|
|
164 | |
|
|
165 | if [[ "${PN/util-macros}" = "${PN}" ]]; then |
|
|
166 | DEPEND="${DEPEND} |
| 49 | x11-misc/util-macros" |
167 | >=x11-misc/util-macros-0.99.2" |
|
|
168 | fi |
| 50 | |
169 | |
|
|
170 | # >=sys-apps/man-1.6b-r2 required to look in [0-8]x/ directories |
| 51 | RDEPEND="${RDEPEND}" |
171 | RDEPEND="${RDEPEND} |
| 52 | # Shouldn't be necessary once we're in a standard location |
172 | !<=x11-base/xorg-x11-6.9 |
|
|
173 | >=sys-apps/man-1.6b-r2" |
|
|
174 | # Provides virtual/x11 for temporary use until packages are ported |
| 53 | # x11-base/x11-env" |
175 | # x11-base/x11-env" |
| 54 | # FIXME: Uncomment once it's in portage |
|
|
| 55 | # !x11-base/xorg-x11" |
|
|
| 56 | |
176 | |
| 57 | x-modular_unpack_source() { |
177 | x-modular_unpack_source() { |
| 58 | unpack ${A} |
178 | unpack ${A} |
| 59 | cd ${S} |
179 | cd ${S} |
|
|
180 | |
|
|
181 | if [[ -n ${FONT_OPTIONS} ]]; then |
|
|
182 | einfo "Detected font directory: ${FONT_DIR}" |
|
|
183 | fi |
| 60 | } |
184 | } |
| 61 | |
185 | |
| 62 | x-modular_patch_source() { |
186 | x-modular_patch_source() { |
| 63 | # Use standardized names and locations with bulk patching |
187 | # Use standardized names and locations with bulk patching |
| 64 | # Patch directory is ${WORKDIR}/patch |
188 | # Patch directory is ${WORKDIR}/patch |
| 65 | # See epatch() in eutils.eclass for more documentation |
189 | # See epatch() in eutils.eclass for more documentation |
| 66 | if [ -z "${EPATCH_SUFFIX}" ] ; then |
190 | if [[ -z "${EPATCH_SUFFIX}" ]] ; then |
| 67 | EPATCH_SUFFIX="patch" |
191 | EPATCH_SUFFIX="patch" |
| 68 | fi |
192 | fi |
| 69 | |
193 | |
|
|
194 | # If this is a driver package we need to fix man page install location. |
|
|
195 | # Running autoreconf will use the patched util-macros to make the |
|
|
196 | # change for us, so we only need to patch if it is not going to run. |
|
|
197 | if [[ -n "${DRIVER}" ]] && [[ "${SNAPSHOT}" != "yes" ]]; then |
|
|
198 | PATCHES="${PATCHES} ${DISTDIR}/x11-driver-patches-${XDPVER}.tar.bz2" |
|
|
199 | fi |
|
|
200 | |
| 70 | # For specific list of patches |
201 | # For specific list of patches |
| 71 | if [ -n "${PATCHES}" ] ; then |
202 | if [[ -n "${PATCHES}" ]] ; then |
| 72 | for PATCH in ${PATCHES} |
203 | for PATCH in ${PATCHES} |
| 73 | do |
204 | do |
| 74 | epatch ${PATCH} |
205 | epatch ${PATCH} |
| 75 | done |
206 | done |
| 76 | # For non-default directory bulk patching |
207 | # For non-default directory bulk patching |
| 77 | elif [ -n "${PATCH_LOC}" ] ; then |
208 | elif [[ -n "${PATCH_LOC}" ]] ; then |
| 78 | epatch ${PATCH_LOC} |
209 | epatch ${PATCH_LOC} |
| 79 | # For standard bulk patching |
210 | # For standard bulk patching |
| 80 | elif [ -d "${EPATCH_SOURCE}" ] ; then |
211 | elif [[ -d "${EPATCH_SOURCE}" ]] ; then |
| 81 | epatch |
212 | epatch |
| 82 | fi |
213 | fi |
| 83 | } |
214 | } |
| 84 | |
215 | |
| 85 | x-modular_reconf_source() { |
216 | x-modular_reconf_source() { |
| 86 | # Run autoreconf for CVS snapshots only |
217 | # Run autoreconf for CVS snapshots only |
| 87 | if [ "${SNAPSHOT}" = "yes" ] |
218 | if [[ "${SNAPSHOT}" = "yes" ]] |
| 88 | then |
219 | then |
| 89 | # If possible, generate configure if it doesn't exist |
220 | # If possible, generate configure if it doesn't exist |
| 90 | if [ -f "${S}/configure.ac" ] |
221 | if [ -f "${S}/configure.ac" ] |
| 91 | then |
222 | then |
| 92 | einfo "Running autoreconf..." |
223 | einfo "Running autoreconf..." |
| 93 | autoreconf -v --install |
224 | autoreconf -v --force --install |
| 94 | fi |
225 | fi |
| 95 | fi |
226 | fi |
| 96 | |
227 | |
| 97 | } |
228 | } |
| 98 | |
229 | |
| 99 | x-modular_src_unpack() { |
230 | x-modular_src_unpack() { |
|
|
231 | if [[ ${PN:0:11} = "xorg-server" ]] || [[ -n "${DRIVER}" ]]; then |
|
|
232 | if gcc-specs-now; then |
|
|
233 | msg="Do not emerge ${PN} without vanilla gcc!" |
|
|
234 | eerror "$msg" |
|
|
235 | die "$msg" |
|
|
236 | fi |
|
|
237 | fi |
|
|
238 | |
| 100 | x-modular_unpack_source |
239 | x-modular_unpack_source |
| 101 | x-modular_patch_source |
240 | x-modular_patch_source |
| 102 | x-modular_reconf_source |
241 | x-modular_reconf_source |
| 103 | } |
|
|
| 104 | |
242 | |
|
|
243 | # Joshua Baergen - October 23, 2005 |
|
|
244 | # Fix shared lib issues on MIPS, FBSD, etc etc |
|
|
245 | elibtoolize |
|
|
246 | } |
|
|
247 | |
|
|
248 | x-modular_font_configure() { |
|
|
249 | if [[ -n "${FONT}" ]]; then |
|
|
250 | # Might be worth adding an option to configure your desired font |
|
|
251 | # and exclude all others. Also, should this USE be nls or minimal? |
|
|
252 | if ! use nls; then |
|
|
253 | FONT_OPTIONS="${FONT_OPTIONS} |
|
|
254 | --disable-iso8859-2 |
|
|
255 | --disable-iso8859-3 |
|
|
256 | --disable-iso8859-4 |
|
|
257 | --disable-iso8859-5 |
|
|
258 | --disable-iso8859-6 |
|
|
259 | --disable-iso8859-7 |
|
|
260 | --disable-iso8859-8 |
|
|
261 | --disable-iso8859-9 |
|
|
262 | --disable-iso8859-10 |
|
|
263 | --disable-iso8859-11 |
|
|
264 | --disable-iso8859-12 |
|
|
265 | --disable-iso8859-13 |
|
|
266 | --disable-iso8859-14 |
|
|
267 | --disable-iso8859-15 |
|
|
268 | --disable-iso8859-16 |
|
|
269 | --disable-jisx0201 |
|
|
270 | --disable-koi8-r" |
|
|
271 | fi |
|
|
272 | fi |
|
|
273 | } |
|
|
274 | |
|
|
275 | x-modular_debug_setup() { |
|
|
276 | if [[ -n "${DEBUGGABLE}" ]]; then |
|
|
277 | if use debug; then |
|
|
278 | strip-flags |
|
|
279 | append-flags -g |
|
|
280 | fi |
|
|
281 | fi |
|
|
282 | } |
|
|
283 | |
| 105 | x-modular_src_compile() { |
284 | x-modular_src_configure() { |
|
|
285 | x-modular_font_configure |
|
|
286 | x-modular_debug_setup |
|
|
287 | |
| 106 | # If prefix isn't set here, .pc files cause problems |
288 | # If prefix isn't set here, .pc files cause problems |
| 107 | if [ -x ./configure ]; then |
289 | if [[ -x ./configure ]]; then |
| 108 | econf --prefix=${XDIR} \ |
290 | econf --prefix=${XDIR} \ |
| 109 | --datadir=${XDIR}/share \ |
291 | --datadir=${XDIR}/share \ |
|
|
292 | ${FONT_OPTIONS} \ |
|
|
293 | ${DRIVER_OPTIONS} \ |
| 110 | ${CONFIGURE_OPTIONS} |
294 | ${CONFIGURE_OPTIONS} |
| 111 | fi |
295 | fi |
|
|
296 | } |
|
|
297 | |
|
|
298 | x-modular_src_make() { |
| 112 | emake || die "emake failed" |
299 | emake || die "emake failed" |
|
|
300 | } |
|
|
301 | |
|
|
302 | x-modular_src_compile() { |
|
|
303 | x-modular_src_configure |
|
|
304 | x-modular_src_make |
| 113 | } |
305 | } |
| 114 | |
306 | |
| 115 | x-modular_src_install() { |
307 | x-modular_src_install() { |
| 116 | # Install everything to ${XDIR} |
308 | # Install everything to ${XDIR} |
| 117 | make \ |
309 | make \ |
| … | |
… | |
| 119 | install |
311 | install |
| 120 | # Shouldn't be necessary in XDIR=/usr |
312 | # Shouldn't be necessary in XDIR=/usr |
| 121 | # einstall forces datadir, so we need to re-force it |
313 | # einstall forces datadir, so we need to re-force it |
| 122 | # datadir=${XDIR}/share \ |
314 | # datadir=${XDIR}/share \ |
| 123 | # mandir=${XDIR}/share/man \ |
315 | # mandir=${XDIR}/share/man \ |
|
|
316 | |
|
|
317 | # Don't install libtool archives for server modules |
|
|
318 | if [[ -e ${D}/usr/lib/xorg/modules ]]; then |
|
|
319 | find ${D}/usr/lib/xorg/modules -name '*.la' \ |
|
|
320 | | xargs rm -f |
|
|
321 | fi |
| 124 | } |
322 | } |
| 125 | |
323 | |
| 126 | x-modular_pkg_preinst() { |
324 | x-modular_pkg_preinst() { |
| 127 | if [[ -n "${FONT}" ]]; then |
325 | if [[ -n "${FONT}" ]]; then |
| 128 | discover_font_dirs |
326 | discover_font_dirs |
| … | |
… | |
| 133 | if [[ -n "${FONT}" ]]; then |
331 | if [[ -n "${FONT}" ]]; then |
| 134 | setup_fonts |
332 | setup_fonts |
| 135 | fi |
333 | fi |
| 136 | } |
334 | } |
| 137 | |
335 | |
|
|
336 | x-modular_pkg_postrm() { |
|
|
337 | if [[ -n "${FONT}" ]]; then |
|
|
338 | cleanup_fonts |
|
|
339 | fi |
|
|
340 | } |
|
|
341 | |
|
|
342 | cleanup_fonts() { |
|
|
343 | local ALLOWED_FILES="encodings.dir fonts.cache-1 fonts.dir fonts.scale" |
|
|
344 | for DIR in ${FONT_DIR}; do |
|
|
345 | unset KEEP_FONTDIR |
|
|
346 | REAL_DIR=${ROOT}usr/share/fonts/${DIR} |
|
|
347 | |
|
|
348 | ebegin "Checking ${REAL_DIR} for useless files" |
|
|
349 | pushd ${REAL_DIR} &> /dev/null |
|
|
350 | for FILE in *; do |
|
|
351 | unset MATCH |
|
|
352 | for ALLOWED_FILE in ${ALLOWED_FILES}; do |
|
|
353 | if [[ ${FILE} = ${ALLOWED_FILE} ]]; then |
|
|
354 | # If it's allowed, then move on to the next file |
|
|
355 | MATCH="yes" |
|
|
356 | break |
|
|
357 | fi |
|
|
358 | done |
|
|
359 | # If we found a match in allowed files, move on to the next file |
|
|
360 | if [[ -n ${MATCH} ]]; then |
|
|
361 | continue |
|
|
362 | fi |
|
|
363 | # If we get this far, there wasn't a match in the allowed files |
|
|
364 | KEEP_FONTDIR="yes" |
|
|
365 | # We don't need to check more files if we're already keeping it |
|
|
366 | break |
|
|
367 | done |
|
|
368 | popd &> /dev/null |
|
|
369 | # If there are no files worth keeping, then get rid of the dir |
|
|
370 | if [[ -z "${KEEP_FONTDIR}" ]]; then |
|
|
371 | rm -rf ${REAL_DIR} |
|
|
372 | fi |
|
|
373 | eend 0 |
|
|
374 | done |
|
|
375 | } |
|
|
376 | |
| 138 | setup_fonts() { |
377 | setup_fonts() { |
| 139 | if [[ ! -n "${FONT_DIRS}" ]]; then |
378 | if [[ ! -n "${FONT_DIRS}" ]]; then |
| 140 | msg="FONT_DIRS empty. Set it to at least one subdir of /usr/share/fonts." |
379 | msg="FONT_DIRS is empty. The ebuild should set it to at least one subdir of /usr/share/fonts." |
| 141 | eerror ${msg} |
380 | eerror "${msg}" |
| 142 | die ${msg} |
381 | die "${msg}" |
| 143 | fi |
382 | fi |
| 144 | |
383 | |
| 145 | create_fonts_scale |
384 | create_fonts_scale |
| 146 | create_fonts_dir |
385 | create_fonts_dir |
| 147 | fix_font_permissions |
386 | fix_font_permissions |
| … | |
… | |
| 158 | create_fonts_scale() { |
397 | create_fonts_scale() { |
| 159 | ebegin "Creating fonts.scale files" |
398 | ebegin "Creating fonts.scale files" |
| 160 | local x |
399 | local x |
| 161 | for FONT_DIR in ${FONT_DIRS}; do |
400 | for FONT_DIR in ${FONT_DIRS}; do |
| 162 | x=${ROOT}/usr/share/fonts/${FONT_DIR} |
401 | x=${ROOT}/usr/share/fonts/${FONT_DIR} |
| 163 | [ -z "$(ls ${x}/)" ] && continue |
402 | [[ -z "$(ls ${x}/)" ]] && continue |
| 164 | [ "$(ls ${x}/)" = "fonts.cache-1" ] && continue |
403 | [[ "$(ls ${x}/)" = "fonts.cache-1" ]] && continue |
| 165 | |
404 | |
| 166 | # Only generate .scale files if truetype, opentype or type1 |
405 | # Only generate .scale files if truetype, opentype or type1 |
| 167 | # fonts are present ... |
406 | # fonts are present ... |
| 168 | |
407 | |
| 169 | # First truetype (ttf,ttc) |
408 | # First truetype (ttf,ttc) |
| 170 | # NOTE: ttmkfdir does NOT work on type1 fonts (#53753) |
409 | # NOTE: ttmkfdir does NOT work on type1 fonts (#53753) |
| 171 | # Also, there is no way to regenerate Speedo/CID fonts.scale |
410 | # Also, there is no way to regenerate Speedo/CID fonts.scale |
| 172 | # <spyderous@gentoo.org> 2 August 2004 |
411 | # <spyderous@gentoo.org> 2 August 2004 |
| 173 | if [ "${x/encodings}" = "${x}" -a \ |
412 | if [[ "${x/encodings}" = "${x}" ]] \ |
| 174 | -n "$(find ${x} -iname '*.tt[cf]' -print)" ]; then |
413 | && [[ -n "$(find ${x} -iname '*.tt[cf]' -print)" ]]; then |
| 175 | if [ -x ${ROOT}/usr/bin/ttmkfdir ]; then |
414 | if [[ -x ${ROOT}/usr/bin/ttmkfdir ]]; then |
| 176 | LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \ |
415 | LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \ |
| 177 | ${ROOT}/usr/bin/ttmkfdir -x 2 \ |
416 | ${ROOT}/usr/bin/ttmkfdir -x 2 \ |
| 178 | -e ${ROOT}/usr/share/fonts/encodings/encodings.dir \ |
417 | -e ${ROOT}/usr/share/fonts/encodings/encodings.dir \ |
| 179 | -o ${x}/fonts.scale -d ${x} |
418 | -o ${x}/fonts.scale -d ${x} |
| 180 | # ttmkfdir fails on some stuff, so try mkfontscale if it does |
419 | # ttmkfdir fails on some stuff, so try mkfontscale if it does |
| 181 | local ttmkfdir_return=$? |
420 | local ttmkfdir_return=$? |
| 182 | else |
421 | else |
| 183 | # We didn't use ttmkfdir at all |
422 | # We didn't use ttmkfdir at all |
| 184 | local ttmkfdir_return=2 |
423 | local ttmkfdir_return=2 |
| 185 | fi |
424 | fi |
| 186 | if [ ${ttmkfdir_return} -ne 0 ]; then |
425 | if [[ ${ttmkfdir_return} -ne 0 ]]; then |
| 187 | LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \ |
426 | LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \ |
| 188 | ${ROOT}/usr/bin/mkfontscale \ |
427 | ${ROOT}/usr/bin/mkfontscale \ |
| 189 | -a /usr/share/fonts/encodings/encodings.dir \ |
428 | -a /usr/share/fonts/encodings/encodings.dir \ |
| 190 | -- ${x} |
429 | -- ${x} |
| 191 | fi |
430 | fi |
| 192 | # Next type1 and opentype (pfa,pfb,otf,otc) |
431 | # Next type1 and opentype (pfa,pfb,otf,otc) |
| 193 | elif [ "${x/encodings}" = "${x}" -a \ |
432 | elif [[ "${x/encodings}" = "${x}" ]] \ |
| 194 | -n "$(find ${x} -iname '*.[po][ft][abcf]' -print)" ]; then |
433 | && [[ -n "$(find ${x} -iname '*.[po][ft][abcf]' -print)" ]]; then |
| 195 | LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \ |
434 | LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \ |
| 196 | ${ROOT}/usr/bin/mkfontscale \ |
435 | ${ROOT}/usr/bin/mkfontscale \ |
| 197 | -a ${ROOT}/usr/share/fonts/encodings/encodings.dir \ |
436 | -a ${ROOT}/usr/share/fonts/encodings/encodings.dir \ |
| 198 | -- ${x} |
437 | -- ${x} |
| 199 | fi |
438 | fi |
| … | |
… | |
| 203 | |
442 | |
| 204 | create_fonts_dir() { |
443 | create_fonts_dir() { |
| 205 | ebegin "Generating fonts.dir files" |
444 | ebegin "Generating fonts.dir files" |
| 206 | for FONT_DIR in ${FONT_DIRS}; do |
445 | for FONT_DIR in ${FONT_DIRS}; do |
| 207 | x=${ROOT}/usr/share/fonts/${FONT_DIR} |
446 | x=${ROOT}/usr/share/fonts/${FONT_DIR} |
| 208 | [ -z "$(ls ${x}/)" ] && continue |
447 | [[ -z "$(ls ${x}/)" ]] && continue |
| 209 | [ "$(ls ${x}/)" = "fonts.cache-1" ] && continue |
448 | [[ "$(ls ${x}/)" = "fonts.cache-1" ]] && continue |
| 210 | |
449 | |
| 211 | if [ "${x/encodings}" = "${x}" ]; then |
450 | if [[ "${x/encodings}" = "${x}" ]]; then |
| 212 | LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \ |
451 | LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \ |
| 213 | ${ROOT}/usr/bin/mkfontdir \ |
452 | ${ROOT}/usr/bin/mkfontdir \ |
| 214 | -e ${ROOT}/usr/share/fonts/encodings \ |
453 | -e ${ROOT}/usr/share/fonts/encodings \ |
| 215 | -e ${ROOT}/usr/share/fonts/encodings/large \ |
454 | -e ${ROOT}/usr/share/fonts/encodings/large \ |
| 216 | -- ${x} |
455 | -- ${x} |
| … | |
… | |
| 230 | |
469 | |
| 231 | create_font_cache() { |
470 | create_font_cache() { |
| 232 | # danarmak found out that fc-cache should be run AFTER all the above |
471 | # danarmak found out that fc-cache should be run AFTER all the above |
| 233 | # stuff, as otherwise the cache is invalid, and has to be run again |
472 | # stuff, as otherwise the cache is invalid, and has to be run again |
| 234 | # as root anyway |
473 | # as root anyway |
| 235 | if [ -x ${ROOT}/usr/bin/fc-cache ]; then |
474 | if [[ -x ${ROOT}/usr/bin/fc-cache ]]; then |
| 236 | ebegin "Creating FC font cache" |
475 | ebegin "Creating FC font cache" |
| 237 | HOME="/root" ${ROOT}/usr/bin/fc-cache |
476 | HOME="/root" ${ROOT}/usr/bin/fc-cache |
| 238 | eend 0 |
477 | eend 0 |
| 239 | fi |
478 | fi |
| 240 | } |
479 | } |