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

Contents of /eclass/x-modular.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations) (download)
Sun Aug 14 23:45:52 2005 UTC (8 years, 10 months ago) by spyderous
Branch: MAIN
Changes since 1.3: +17 -1 lines
Autodiscover font directories so there's no need to specify FONT or FONT_DIRS in font ebuilds.

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

  ViewVC Help
Powered by ViewVC 1.1.20