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