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

Contents of /eclass/x-modular.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations) (download)
Sun Aug 14 23:04:02 2005 UTC (8 years, 10 months ago) by spyderous
Branch: MAIN
Changes since 1.2: +9 -1 lines
Add encodings as RDEPEND and font-alias as PDEPEND for all font packages.

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

  ViewVC Help
Powered by ViewVC 1.1.20