1 |
scarabeus 10/02/09 17:15:09 |
2 |
|
3 |
Modified: font.eclass |
4 |
Log: |
5 |
Introduce fonts.eclass supporting eapi up to 3. Per disscussion on -dev. |
6 |
|
7 |
Revision Changes Path |
8 |
1.48 eclass/font.eclass |
9 |
|
10 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/font.eclass?rev=1.48&view=markup |
11 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/font.eclass?rev=1.48&content-type=text/plain |
12 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/font.eclass?r1=1.47&r2=1.48 |
13 |
|
14 |
Index: font.eclass |
15 |
=================================================================== |
16 |
RCS file: /var/cvsroot/gentoo-x86/eclass/font.eclass,v |
17 |
retrieving revision 1.47 |
18 |
retrieving revision 1.48 |
19 |
diff -u -r1.47 -r1.48 |
20 |
--- font.eclass 11 Oct 2009 11:44:42 -0000 1.47 |
21 |
+++ font.eclass 9 Feb 2010 17:15:08 -0000 1.48 |
22 |
@@ -1,37 +1,33 @@ |
23 |
-# Copyright 1999-2007 Gentoo Foundation |
24 |
+# Copyright 1999-2010 Gentoo Foundation |
25 |
# Distributed under the terms of the GNU General Public License v2 |
26 |
-# $Header: /var/cvsroot/gentoo-x86/eclass/font.eclass,v 1.47 2009/10/11 11:44:42 maekke Exp $ |
27 |
+# $Header: /var/cvsroot/gentoo-x86/eclass/font.eclass,v 1.48 2010/02/09 17:15:08 scarabeus Exp $ |
28 |
|
29 |
# @ECLASS: font.eclass |
30 |
# @MAINTAINER: |
31 |
# fonts@g.o |
32 |
-# |
33 |
+ |
34 |
+# Author: Tomáš Chvátal <scarabeus@g.o> |
35 |
# Author: foser <foser@g.o> |
36 |
# @BLURB: Eclass to make font installation uniform |
37 |
|
38 |
inherit eutils |
39 |
|
40 |
- |
41 |
EXPORT_FUNCTIONS pkg_setup src_install pkg_postinst pkg_postrm |
42 |
|
43 |
-# |
44 |
-# Variable declarations |
45 |
-# |
46 |
- |
47 |
# @ECLASS-VARIABLE: FONT_SUFFIX |
48 |
# @DESCRIPTION: |
49 |
# Space delimited list of font suffixes to install |
50 |
-FONT_SUFFIX=${FONT_SUFFIX:-} |
51 |
+FONT_SUFFIX=${FONT_SUFFIX:=} |
52 |
|
53 |
# @ECLASS-VARIABLE: FONT_S |
54 |
# @DESCRIPTION: |
55 |
# Dir containing the fonts |
56 |
-FONT_S=${S} |
57 |
+FONT_S=${FONT_S:=${S}} |
58 |
|
59 |
# @ECLASS-VARIABLE: FONT_PN |
60 |
# @DESCRIPTION: |
61 |
# Last part of $FONTDIR |
62 |
-FONT_PN=${FONT_PN:-${PN}} |
63 |
+FONT_PN=${FONT_PN:=${PN}} |
64 |
|
65 |
# @ECLASS-VARIABLE: FONTDIR |
66 |
# @DESCRIPTION: |
67 |
@@ -50,70 +46,52 @@ |
68 |
|
69 |
IUSE="X" |
70 |
|
71 |
-DEPEND="X? ( x11-apps/mkfontdir |
72 |
- media-fonts/encodings ) |
73 |
- media-libs/fontconfig" |
74 |
- |
75 |
-# |
76 |
-# Public functions |
77 |
-# |
78 |
+DEPEND="X? ( |
79 |
+ x11-apps/mkfontdir |
80 |
+ media-fonts/encodings |
81 |
+ ) |
82 |
+ >=media-libs/fontconfig-2.4.0" |
83 |
|
84 |
# @FUNCTION: font_xfont_config |
85 |
# @DESCRIPTION: |
86 |
# Creates the Xfont files. |
87 |
font_xfont_config() { |
88 |
# create Xfont files |
89 |
- if use X ; then |
90 |
- einfo "Creating fonts.scale & fonts.dir ..." |
91 |
- rm -f "${D}${FONTDIR}"/fonts.{dir,scale} |
92 |
- mkfontscale "${D}${FONTDIR}" |
93 |
+ if has X ${IUSE//+} && use X ; then |
94 |
+ ebegin "Creating fonts.scale & fonts.dir" |
95 |
+ rm -f "${ED}${FONTDIR}"/fonts.{dir,scale} |
96 |
+ mkfontscale "${ED}${FONTDIR}" |
97 |
mkfontdir \ |
98 |
- -e /usr/share/fonts/encodings \ |
99 |
- -e /usr/share/fonts/encodings/large \ |
100 |
- "${D}${FONTDIR}" |
101 |
+ -e ${EPREFIX}/usr/share/fonts/encodings \ |
102 |
+ -e ${EPREFIX}/usr/share/fonts/encodings/large \ |
103 |
+ "${ED}${FONTDIR}" |
104 |
+ eend $? |
105 |
if [ -e "${FONT_S}/fonts.alias" ] ; then |
106 |
doins "${FONT_S}/fonts.alias" |
107 |
fi |
108 |
fi |
109 |
} |
110 |
|
111 |
-# @FUNCTION: font_xft_config |
112 |
-# @DESCRIPTION: |
113 |
-# Creates the fontconfig cache if necessary. |
114 |
-font_xft_config() { |
115 |
- if ! has_version '>=media-libs/fontconfig-2.4'; then |
116 |
- # create fontconfig cache |
117 |
- einfo "Creating fontconfig cache ..." |
118 |
- fc-cache -sf "${D}${FONTDIR}" |
119 |
- fi |
120 |
-} |
121 |
- |
122 |
# @FUNCTION: font_fontconfig |
123 |
# @DESCRIPTION: |
124 |
# Installs the fontconfig config files of FONT_CONF. |
125 |
font_fontconfig() { |
126 |
local conffile |
127 |
if [[ -n ${FONT_CONF[@]} ]]; then |
128 |
- if has_version '>=media-libs/fontconfig-2.4'; then |
129 |
- insinto /etc/fonts/conf.avail/ |
130 |
- for conffile in "${FONT_CONF[@]}"; do |
131 |
- [[ -e ${conffile} ]] && doins ${conffile} |
132 |
- done |
133 |
- fi |
134 |
+ insinto /etc/fonts/conf.avail/ |
135 |
+ for conffile in "${FONT_CONF[@]}"; do |
136 |
+ [[ -e ${conffile} ]] && doins ${conffile} |
137 |
+ done |
138 |
fi |
139 |
} |
140 |
|
141 |
-# |
142 |
-# Public inheritable functions |
143 |
-# |
144 |
- |
145 |
# @FUNCTION: font_src_install |
146 |
# @DESCRIPTION: |
147 |
-# The font src_install function, which is exported. |
148 |
+# The font src_install function. |
149 |
font_src_install() { |
150 |
local suffix commondoc |
151 |
|
152 |
- cd "${FONT_S}" |
153 |
+ pushd "${FONT_S}" > /dev/null |
154 |
|
155 |
insinto "${FONTDIR}" |
156 |
|
157 |
@@ -124,11 +102,11 @@ |
158 |
rm -f fonts.{dir,scale} encodings.dir |
159 |
|
160 |
font_xfont_config |
161 |
- font_xft_config |
162 |
font_fontconfig |
163 |
|
164 |
- cd "${S}" |
165 |
- dodoc ${DOCS} 2> /dev/null |
166 |
+ popd > /dev/null |
167 |
+ |
168 |
+ [[ -n ${DOCS} ]] && { dodoc ${DOCS} || die "docs installation failed" ; } |
169 |
|
170 |
# install common docs |
171 |
for commondoc in COPYRIGHT README{,.txt} NEWS AUTHORS BUGS ChangeLog FONTLOG.txt; do |
172 |
@@ -138,60 +116,69 @@ |
173 |
|
174 |
# @FUNCTION: font_pkg_setup |
175 |
# @DESCRIPTION: |
176 |
-# The font pkg_setup function, which is exported. |
177 |
+# The font pkg_setup function. |
178 |
+# Collision portection and Prefix compat for eapi < 3. |
179 |
font_pkg_setup() { |
180 |
+ # Prefix compat |
181 |
+ case ${EAPI:-0} in |
182 |
+ 0|1|2) |
183 |
+ if ! use prefix; then |
184 |
+ EPREFIX= |
185 |
+ ED=${D} |
186 |
+ EROOT=${ROOT} |
187 |
+ [[ ${EROOT} = */ ]] || EROOT+="/" |
188 |
+ fi |
189 |
+ ;; |
190 |
+ esac |
191 |
+ |
192 |
# make sure we get no collisions |
193 |
# setup is not the nicest place, but preinst doesn't cut it |
194 |
- [[ -e "${FONTDIR}/fonts.cache-1" ]] && rm -f "${FONTDIR}/fonts.cache-1" |
195 |
+ [[ -e "${EROOT}/${FONTDIR}/fonts.cache-1" ]] && rm -f "${EROOT}/${FONTDIR}/fonts.cache-1" |
196 |
} |
197 |
|
198 |
# @FUNCTION: font_pkg_postinst |
199 |
# @DESCRIPTION: |
200 |
-# The font pkg_postinst function, which is exported. |
201 |
+# The font pkg_postinst function. |
202 |
+# Update global font cache and fix permissions. |
203 |
font_pkg_postinst() { |
204 |
# unreadable font files = fontconfig segfaults |
205 |
- find "${ROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \ |
206 |
+ find "${EROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \ |
207 |
| xargs -0 chmod -v 0644 2>/dev/null |
208 |
|
209 |
if [[ -n ${FONT_CONF[@]} ]]; then |
210 |
- if has_version '>=media-libs/fontconfig-2.4'; then |
211 |
- local conffile |
212 |
- echo |
213 |
- elog "The following fontconfig configuration files have been installed:" |
214 |
- elog |
215 |
- for conffile in "${FONT_CONF[@]}"; do |
216 |
- if [[ -e ${ROOT}etc/fonts/conf.avail/$(basename ${conffile}) ]]; then |
217 |
- elog " $(basename ${conffile})" |
218 |
- fi |
219 |
- done |
220 |
- elog |
221 |
- elog "Use \`eselect fontconfig\` to enable/disable them." |
222 |
- echo |
223 |
- fi |
224 |
- fi |
225 |
- |
226 |
- if has_version '>=media-libs/fontconfig-2.4'; then |
227 |
- if [[ ${ROOT} == "/" ]]; then |
228 |
- ebegin "Updating global fontcache" |
229 |
- fc-cache -fs |
230 |
- eend $? |
231 |
- fi |
232 |
+ local conffile |
233 |
+ echo |
234 |
+ elog "The following fontconfig configuration files have been installed:" |
235 |
+ elog |
236 |
+ for conffile in "${FONT_CONF[@]}"; do |
237 |
+ if [[ -e ${EROOT}etc/fonts/conf.avail/$(basename ${conffile}) ]]; then |
238 |
+ elog " $(basename ${conffile})" |
239 |
+ fi |
240 |
+ done |
241 |
+ elog |
242 |
+ elog "Use \`eselect fontconfig\` to enable/disable them." |
243 |
+ echo |
244 |
+ fi |
245 |
+ |
246 |
+ if [[ ${ROOT} == / ]]; then |
247 |
+ ebegin "Updating global fontcache" |
248 |
+ fc-cache -fs |
249 |
+ eend $? |
250 |
fi |
251 |
} |
252 |
|
253 |
# @FUNCTION: font_pkg_postrm |
254 |
# @DESCRIPTION: |
255 |
-# The font pkg_postrm function, which is exported. |
256 |
+# The font pkg_postrm function. |
257 |
+# Updates global font cache |
258 |
font_pkg_postrm() { |
259 |
# unreadable font files = fontconfig segfaults |
260 |
- find "${ROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \ |
261 |
+ find "${EROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \ |
262 |
| xargs -0 chmod -v 0644 2>/dev/null |
263 |
|
264 |
- if has_version '>=media-libs/fontconfig-2.4'; then |
265 |
- if [[ ${ROOT} == "/" ]]; then |
266 |
- ebegin "Updating global fontcache" |
267 |
- fc-cache -fs |
268 |
- eend $? |
269 |
- fi |
270 |
+ if [[ ${ROOT} == / ]]; then |
271 |
+ ebegin "Updating global fontcache" |
272 |
+ fc-cache -fs |
273 |
+ eend $? |
274 |
fi |
275 |
} |