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

Contents of /eclass/x-modular.eclass

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.20