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

Contents of /eclass/x-modular.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.18 - (hide annotations) (download)
Wed Nov 2 05:51:38 2005 UTC (9 years, 1 month ago) by joshuabaergen
Branch: MAIN
Changes since 1.17: +13 -1 lines
Add an error about collision-protect in case we allow monolithic->modular
upgrade paths without unmerging the old version first.

1 spyderous 1.1 # Copyright 1999-2005 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 joshuabaergen 1.18 # $Header: /var/cvsroot/gentoo-x86/eclass/x-modular.eclass,v 1.17 2005/10/30 05:32:27 joshuabaergen 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 joshuabaergen 1.16 inherit eutils libtool
16 spyderous 1.1
17     # Directory prefix to use for everything
18     XDIR="/usr"
19    
20     IUSE=""
21     HOMEPAGE="http://xorg.freedesktop.org/"
22 spyderous 1.14 SRC_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"
24 spyderous 1.1 LICENSE="X11"
25     SLOT="0"
26    
27     # Set up shared dependencies
28     if [ -n "${SNAPSHOT}" ]; then
29     # FIXME: What's the minimal libtool version supporting arbitrary versioning?
30     DEPEND="${DEPEND}
31     >=sys-devel/autoconf-2.57
32     >=sys-devel/automake-1.7
33     >=sys-devel/libtool-1.5
34     >=sys-devel/m4-1.4"
35     fi
36    
37 spyderous 1.3 # If we're a font package, but not the font.alias one
38 spyderous 1.14 if [[ "${PN/#font-}" != "${PN}" ]] && [[ "${PN}" != "font-alias" ]]; then
39 spyderous 1.4 # Activate font code in the rest of the eclass
40     FONT="yes"
41    
42 spyderous 1.3 RDEPEND="${RDEPEND}
43     media-fonts/encodings"
44     PDEPEND="${PDEPEND}
45     media-fonts/font-alias"
46     fi
47    
48 spyderous 1.7 # If we're a driver package
49 spyderous 1.12 if [[ "${PN/#xf86-video}" != "${PN}" ]] || [[ "${PN/#xf86-input}" != "${PN}" ]]; 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.15 >=x11-misc/util-macros-0.99.0_p20051007"
57 spyderous 1.1
58 spyderous 1.13 RDEPEND="${RDEPEND}
59 joshuabaergen 1.17 !<x11-base/xorg-x11-7.0.0_rc0"
60 spyderous 1.13 # Provides virtual/x11 for temporary use until packages are ported
61 spyderous 1.1 # x11-base/x11-env"
62    
63 joshuabaergen 1.18 x-modular_pkg_setup() {
64     # Collision protect will scream bloody murder if we install over old versions
65     if $(has_version "<x11-base/xorg-x11-7.0.0_rc0"); then
66     if has collision-protect ${FEATURES}; then
67     eerror "Having collision-protect in FEATURES will disrupt upgrades"
68     eerror "from non-modular versions of xorg-x11."
69     eerror "Please remove collision-protect from FEATURES while upgrading."
70     die ""
71     fi
72     fi
73     }
74    
75 spyderous 1.1 x-modular_unpack_source() {
76     unpack ${A}
77     cd ${S}
78 joshuabaergen 1.16
79     # Joshua Baergen - October 23, 2005
80     # Fix shared lib issues on MIPS, FBSD, etc etc
81     elibtoolize
82 spyderous 1.1 }
83    
84     x-modular_patch_source() {
85     # Use standardized names and locations with bulk patching
86     # Patch directory is ${WORKDIR}/patch
87     # See epatch() in eutils.eclass for more documentation
88     if [ -z "${EPATCH_SUFFIX}" ] ; then
89     EPATCH_SUFFIX="patch"
90     fi
91    
92     # For specific list of patches
93     if [ -n "${PATCHES}" ] ; then
94     for PATCH in ${PATCHES}
95     do
96     epatch ${PATCH}
97     done
98     # For non-default directory bulk patching
99     elif [ -n "${PATCH_LOC}" ] ; then
100     epatch ${PATCH_LOC}
101     # For standard bulk patching
102     elif [ -d "${EPATCH_SOURCE}" ] ; then
103     epatch
104     fi
105     }
106    
107     x-modular_reconf_source() {
108     # Run autoreconf for CVS snapshots only
109     if [ "${SNAPSHOT}" = "yes" ]
110     then
111     # If possible, generate configure if it doesn't exist
112     if [ -f "${S}/configure.ac" ]
113     then
114     einfo "Running autoreconf..."
115 cardoe 1.8 autoreconf -v --force --install
116 spyderous 1.1 fi
117     fi
118    
119     }
120    
121     x-modular_src_unpack() {
122     x-modular_unpack_source
123     x-modular_patch_source
124     x-modular_reconf_source
125     }
126    
127 spyderous 1.6 x-modular_src_configure() {
128 spyderous 1.1 # If prefix isn't set here, .pc files cause problems
129     if [ -x ./configure ]; then
130     econf --prefix=${XDIR} \
131     --datadir=${XDIR}/share \
132 spyderous 1.7 ${DRIVER_OPTIONS} \
133 spyderous 1.1 ${CONFIGURE_OPTIONS}
134     fi
135 spyderous 1.6 }
136    
137     x-modular_src_make() {
138 spyderous 1.1 emake || die "emake failed"
139     }
140    
141 spyderous 1.6 x-modular_src_compile() {
142     x-modular_src_configure
143     x-modular_src_make
144     }
145    
146 spyderous 1.1 x-modular_src_install() {
147     # Install everything to ${XDIR}
148     make \
149     DESTDIR="${D}" \
150     install
151     # Shouldn't be necessary in XDIR=/usr
152     # einstall forces datadir, so we need to re-force it
153     # datadir=${XDIR}/share \
154     # mandir=${XDIR}/share/man \
155 spyderous 1.7
156     # Don't install libtool archives for server modules
157     if [[ -e ${D}/usr/lib/xorg/modules ]]; then
158     find ${D}/usr/lib/xorg/modules -name '*.la' \
159     | xargs rm -f
160     fi
161 spyderous 1.1 }
162 spyderous 1.2
163 spyderous 1.4 x-modular_pkg_preinst() {
164     if [[ -n "${FONT}" ]]; then
165     discover_font_dirs
166     fi
167     }
168    
169 spyderous 1.2 x-modular_pkg_postinst() {
170     if [[ -n "${FONT}" ]]; then
171     setup_fonts
172     fi
173     }
174    
175     setup_fonts() {
176     if [[ ! -n "${FONT_DIRS}" ]]; then
177     msg="FONT_DIRS empty. Set it to at least one subdir of /usr/share/fonts."
178     eerror ${msg}
179     die ${msg}
180     fi
181    
182     create_fonts_scale
183     create_fonts_dir
184     fix_font_permissions
185     create_font_cache
186     }
187    
188 spyderous 1.4 discover_font_dirs() {
189     pushd ${IMAGE}/usr/share/fonts
190     FONT_DIRS="$(find . -maxdepth 1 -mindepth 1 -type d)"
191     FONT_DIRS="$(echo ${FONT_DIRS} | sed -e 's:./::g')"
192     popd
193     }
194    
195 spyderous 1.2 create_fonts_scale() {
196     ebegin "Creating fonts.scale files"
197     local x
198     for FONT_DIR in ${FONT_DIRS}; do
199     x=${ROOT}/usr/share/fonts/${FONT_DIR}
200     [ -z "$(ls ${x}/)" ] && continue
201     [ "$(ls ${x}/)" = "fonts.cache-1" ] && continue
202    
203     # Only generate .scale files if truetype, opentype or type1
204     # fonts are present ...
205    
206     # First truetype (ttf,ttc)
207     # NOTE: ttmkfdir does NOT work on type1 fonts (#53753)
208     # Also, there is no way to regenerate Speedo/CID fonts.scale
209     # <spyderous@gentoo.org> 2 August 2004
210     if [ "${x/encodings}" = "${x}" -a \
211     -n "$(find ${x} -iname '*.tt[cf]' -print)" ]; then
212     if [ -x ${ROOT}/usr/bin/ttmkfdir ]; then
213     LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
214     ${ROOT}/usr/bin/ttmkfdir -x 2 \
215     -e ${ROOT}/usr/share/fonts/encodings/encodings.dir \
216     -o ${x}/fonts.scale -d ${x}
217     # ttmkfdir fails on some stuff, so try mkfontscale if it does
218     local ttmkfdir_return=$?
219     else
220     # We didn't use ttmkfdir at all
221     local ttmkfdir_return=2
222     fi
223     if [ ${ttmkfdir_return} -ne 0 ]; then
224     LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
225     ${ROOT}/usr/bin/mkfontscale \
226     -a /usr/share/fonts/encodings/encodings.dir \
227     -- ${x}
228     fi
229     # Next type1 and opentype (pfa,pfb,otf,otc)
230     elif [ "${x/encodings}" = "${x}" -a \
231     -n "$(find ${x} -iname '*.[po][ft][abcf]' -print)" ]; then
232     LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
233     ${ROOT}/usr/bin/mkfontscale \
234     -a ${ROOT}/usr/share/fonts/encodings/encodings.dir \
235     -- ${x}
236     fi
237     done
238     eend 0
239     }
240    
241     create_fonts_dir() {
242     ebegin "Generating fonts.dir files"
243     for FONT_DIR in ${FONT_DIRS}; do
244     x=${ROOT}/usr/share/fonts/${FONT_DIR}
245     [ -z "$(ls ${x}/)" ] && continue
246     [ "$(ls ${x}/)" = "fonts.cache-1" ] && continue
247    
248     if [ "${x/encodings}" = "${x}" ]; then
249     LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ROOT}/usr/$(get_libdir)" \
250     ${ROOT}/usr/bin/mkfontdir \
251     -e ${ROOT}/usr/share/fonts/encodings \
252     -e ${ROOT}/usr/share/fonts/encodings/large \
253     -- ${x}
254     fi
255     done
256     eend 0
257     }
258    
259     fix_font_permissions() {
260     ebegin "Fixing permissions"
261     for FONT_DIR in ${FONT_DIRS}; do
262     find ${ROOT}/usr/share/fonts/${FONT_DIR} -type f -name 'font.*' \
263     -exec chmod 0644 {} \;
264     done
265     eend 0
266     }
267    
268     create_font_cache() {
269     # danarmak found out that fc-cache should be run AFTER all the above
270     # stuff, as otherwise the cache is invalid, and has to be run again
271     # as root anyway
272     if [ -x ${ROOT}/usr/bin/fc-cache ]; then
273     ebegin "Creating FC font cache"
274     HOME="/root" ${ROOT}/usr/bin/fc-cache
275     eend 0
276     fi
277     }

  ViewVC Help
Powered by ViewVC 1.1.20