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

Diff of /eclass/x-modular.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 Revision 1.14
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.1 2005/08/08 02:57:50 spyderous Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/x-modular.eclass,v 1.14 2005/10/20 00:35: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#
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.
9 12
10EXPORT_FUNCTIONS src_unpack src_compile src_install 13EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst
11 14
12inherit eutils 15inherit eutils
13 16
14# Directory prefix to use for everything 17# Directory prefix to use for everything
15# Change to /usr/X11R6 once it's standard
16XDIR="/usr" 18XDIR="/usr"
17 19
18IUSE="" 20IUSE=""
19HOMEPAGE="http://xorg.freedesktop.org/" 21HOMEPAGE="http://xorg.freedesktop.org/"
20SRC_URI="http://xorg.freedesktop.org/X11R7.0-RC0/everything/${P}.tar.bz2" 22SRC_URI="http://xorg.freedesktop.org/releases/X11R7.0-RC1/everything/${P}.tar.bz2
23 http://xorg.freedesktop.org/releases/X11R7.0-RC0/everything/${P}.tar.bz2"
21LICENSE="X11" 24LICENSE="X11"
22SLOT="0" 25SLOT="0"
23 26
24# Set up shared dependencies 27# Set up shared dependencies
25if [ -n "${SNAPSHOT}" ]; then 28if [ -n "${SNAPSHOT}" ]; then
29 >=sys-devel/automake-1.7 32 >=sys-devel/automake-1.7
30 >=sys-devel/libtool-1.5 33 >=sys-devel/libtool-1.5
31 >=sys-devel/m4-1.4" 34 >=sys-devel/m4-1.4"
32fi 35fi
33 36
37# If we're a font package, but not the font.alias one
38if [[ "${PN/#font-}" != "${PN}" ]] && [[ "${PN}" != "font-alias" ]]; then
39 # Activate font code in the rest of the eclass
40 FONT="yes"
41
42 RDEPEND="${RDEPEND}
43 media-fonts/encodings"
44 PDEPEND="${PDEPEND}
45 media-fonts/font-alias"
46fi
47
48# If we're a driver package
49if [[ "${PN/#xf86-video}" != "${PN}" ]] || [[ "${PN/#xf86-input}" != "${PN}" ]]; then
50 # Don't build static driver modules
51 DRIVER_OPTIONS="--disable-static"
52fi
53
34DEPEND="${DEPEND} 54DEPEND="${DEPEND}
35 dev-util/pkgconfig 55 >=dev-util/pkgconfig-0.18
36 x11-misc/util-macros" 56 x11-misc/util-macros"
37 57
38RDEPEND="${RDEPEND}" 58RDEPEND="${RDEPEND}
39# Shouldn't be necessary once we're in a standard location 59 !<x11-base/xorg-x11-7"
60# Provides virtual/x11 for temporary use until packages are ported
40# x11-base/x11-env" 61# x11-base/x11-env"
41# FIXME: Uncomment once it's in portage
42# !x11-base/xorg-x11"
43 62
44x-modular_unpack_source() { 63x-modular_unpack_source() {
45 unpack ${A} 64 unpack ${A}
46 cd ${S} 65 cd ${S}
47} 66}
75 then 94 then
76 # If possible, generate configure if it doesn't exist 95 # If possible, generate configure if it doesn't exist
77 if [ -f "${S}/configure.ac" ] 96 if [ -f "${S}/configure.ac" ]
78 then 97 then
79 einfo "Running autoreconf..." 98 einfo "Running autoreconf..."
80 autoreconf -v --install 99 autoreconf -v --force --install
81 fi 100 fi
82 fi 101 fi
83 102
84} 103}
85 104
87 x-modular_unpack_source 106 x-modular_unpack_source
88 x-modular_patch_source 107 x-modular_patch_source
89 x-modular_reconf_source 108 x-modular_reconf_source
90} 109}
91 110
92x-modular_src_compile() { 111x-modular_src_configure() {
93 # If prefix isn't set here, .pc files cause problems 112 # If prefix isn't set here, .pc files cause problems
94 if [ -x ./configure ]; then 113 if [ -x ./configure ]; then
95 econf --prefix=${XDIR} \ 114 econf --prefix=${XDIR} \
96 --datadir=${XDIR}/share \ 115 --datadir=${XDIR}/share \
116 ${DRIVER_OPTIONS} \
97 ${CONFIGURE_OPTIONS} 117 ${CONFIGURE_OPTIONS}
98 fi 118 fi
119}
120
121x-modular_src_make() {
99 emake || die "emake failed" 122 emake || die "emake failed"
123}
124
125x-modular_src_compile() {
126 x-modular_src_configure
127 x-modular_src_make
100} 128}
101 129
102x-modular_src_install() { 130x-modular_src_install() {
103 # Install everything to ${XDIR} 131 # Install everything to ${XDIR}
104 make \ 132 make \
106 install 134 install
107# Shouldn't be necessary in XDIR=/usr 135# Shouldn't be necessary in XDIR=/usr
108# einstall forces datadir, so we need to re-force it 136# einstall forces datadir, so we need to re-force it
109# datadir=${XDIR}/share \ 137# datadir=${XDIR}/share \
110# mandir=${XDIR}/share/man \ 138# mandir=${XDIR}/share/man \
139
140 # Don't install libtool archives for server modules
141 if [[ -e ${D}/usr/lib/xorg/modules ]]; then
142 find ${D}/usr/lib/xorg/modules -name '*.la' \
143 | xargs rm -f
144 fi
111} 145}
146
147x-modular_pkg_preinst() {
148 if [[ -n "${FONT}" ]]; then
149 discover_font_dirs
150 fi
151}
152
153x-modular_pkg_postinst() {
154 if [[ -n "${FONT}" ]]; then
155 setup_fonts
156 fi
157}
158
159setup_fonts() {
160 if [[ ! -n "${FONT_DIRS}" ]]; then
161 msg="FONT_DIRS empty. Set it to at least one subdir of /usr/share/fonts."
162 eerror ${msg}
163 die ${msg}
164 fi
165
166 create_fonts_scale
167 create_fonts_dir
168 fix_font_permissions
169 create_font_cache
170}
171
172discover_font_dirs() {
173 pushd ${IMAGE}/usr/share/fonts
174 FONT_DIRS="$(find . -maxdepth 1 -mindepth 1 -type d)"
175 FONT_DIRS="$(echo ${FONT_DIRS} | sed -e 's:./::g')"
176 popd
177}
178
179create_fonts_scale() {
180 ebegin "Creating fonts.scale files"
181 local x
182 for FONT_DIR in ${FONT_DIRS}; do
183 x=${ROOT}/usr/share/fonts/${FONT_DIR}
184 [ -z "$(ls ${x}/)" ] && continue
185 [ "$(ls ${x}/)" = "fonts.cache-1" ] && continue
186
187 # Only generate .scale files if truetype, opentype or type1
188 # fonts are present ...
189
190 # First truetype (ttf,ttc)
191 # NOTE: ttmkfdir does NOT work on type1 fonts (#53753)
192 # Also, there is no way to regenerate Speedo/CID fonts.scale
193 # <spyderous@gentoo.org> 2 August 2004
194 if [ "${x/encodings}" = "${x}" -a \
195 -n "$(find ${x} -iname '*.tt[cf]' -print)" ]; then
196 if [ -x ${ROOT}/usr/bin/ttmkfdir ]; then
197 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
198 ${ROOT}/usr/bin/ttmkfdir -x 2 \
199 -e ${ROOT}/usr/share/fonts/encodings/encodings.dir \
200 -o ${x}/fonts.scale -d ${x}
201 # ttmkfdir fails on some stuff, so try mkfontscale if it does
202 local ttmkfdir_return=$?
203 else
204 # We didn't use ttmkfdir at all
205 local ttmkfdir_return=2
206 fi
207 if [ ${ttmkfdir_return} -ne 0 ]; then
208 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
209 ${ROOT}/usr/bin/mkfontscale \
210 -a /usr/share/fonts/encodings/encodings.dir \
211 -- ${x}
212 fi
213 # Next type1 and opentype (pfa,pfb,otf,otc)
214 elif [ "${x/encodings}" = "${x}" -a \
215 -n "$(find ${x} -iname '*.[po][ft][abcf]' -print)" ]; then
216 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
217 ${ROOT}/usr/bin/mkfontscale \
218 -a ${ROOT}/usr/share/fonts/encodings/encodings.dir \
219 -- ${x}
220 fi
221 done
222 eend 0
223}
224
225create_fonts_dir() {
226 ebegin "Generating fonts.dir files"
227 for FONT_DIR in ${FONT_DIRS}; do
228 x=${ROOT}/usr/share/fonts/${FONT_DIR}
229 [ -z "$(ls ${x}/)" ] && continue
230 [ "$(ls ${x}/)" = "fonts.cache-1" ] && continue
231
232 if [ "${x/encodings}" = "${x}" ]; then
233 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
234 ${ROOT}/usr/bin/mkfontdir \
235 -e ${ROOT}/usr/share/fonts/encodings \
236 -e ${ROOT}/usr/share/fonts/encodings/large \
237 -- ${x}
238 fi
239 done
240 eend 0
241}
242
243fix_font_permissions() {
244 ebegin "Fixing permissions"
245 for FONT_DIR in ${FONT_DIRS}; do
246 find ${ROOT}/usr/share/fonts/${FONT_DIR} -type f -name 'font.*' \
247 -exec chmod 0644 {} \;
248 done
249 eend 0
250}
251
252create_font_cache() {
253 # danarmak found out that fc-cache should be run AFTER all the above
254 # stuff, as otherwise the cache is invalid, and has to be run again
255 # as root anyway
256 if [ -x ${ROOT}/usr/bin/fc-cache ]; then
257 ebegin "Creating FC font cache"
258 HOME="/root" ${ROOT}/usr/bin/fc-cache
259 eend 0
260 fi
261}

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.20