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

Contents of /eclass/x-modular.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations) (download)
Sun Aug 21 04:56:53 2005 UTC (8 years, 11 months ago) by spyderous
Branch: MAIN
Changes since 1.5: +10 -2 lines
Create x-modular_src_configure() and x-modular_src_make() so people can do actions in-between them, if necessary.

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

  ViewVC Help
Powered by ViewVC 1.1.20