/[gentoo-x86]/eclass/font.eclass
Gentoo

Diff of /eclass/font.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.47 Revision 1.48
1# Copyright 1999-2007 Gentoo Foundation 1# Copyright 1999-2010 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/font.eclass,v 1.47 2009/10/11 11:44:42 maekke Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/font.eclass,v 1.48 2010/02/09 17:15:08 scarabeus Exp $
4 4
5# @ECLASS: font.eclass 5# @ECLASS: font.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# fonts@gentoo.org 7# fonts@gentoo.org
8# 8
9# Author: Tomáš Chvátal <scarabeus@gentoo.org>
9# Author: foser <foser@gentoo.org> 10# Author: foser <foser@gentoo.org>
10# @BLURB: Eclass to make font installation uniform 11# @BLURB: Eclass to make font installation uniform
11 12
12inherit eutils 13inherit eutils
13 14
14
15EXPORT_FUNCTIONS pkg_setup src_install pkg_postinst pkg_postrm 15EXPORT_FUNCTIONS pkg_setup src_install pkg_postinst pkg_postrm
16
17#
18# Variable declarations
19#
20 16
21# @ECLASS-VARIABLE: FONT_SUFFIX 17# @ECLASS-VARIABLE: FONT_SUFFIX
22# @DESCRIPTION: 18# @DESCRIPTION:
23# Space delimited list of font suffixes to install 19# Space delimited list of font suffixes to install
24FONT_SUFFIX=${FONT_SUFFIX:-} 20FONT_SUFFIX=${FONT_SUFFIX:=}
25 21
26# @ECLASS-VARIABLE: FONT_S 22# @ECLASS-VARIABLE: FONT_S
27# @DESCRIPTION: 23# @DESCRIPTION:
28# Dir containing the fonts 24# Dir containing the fonts
29FONT_S=${S} 25FONT_S=${FONT_S:=${S}}
30 26
31# @ECLASS-VARIABLE: FONT_PN 27# @ECLASS-VARIABLE: FONT_PN
32# @DESCRIPTION: 28# @DESCRIPTION:
33# Last part of $FONTDIR 29# Last part of $FONTDIR
34FONT_PN=${FONT_PN:-${PN}} 30FONT_PN=${FONT_PN:=${PN}}
35 31
36# @ECLASS-VARIABLE: FONTDIR 32# @ECLASS-VARIABLE: FONTDIR
37# @DESCRIPTION: 33# @DESCRIPTION:
38# This is where the fonts are installed 34# This is where the fonts are installed
39FONTDIR=${FONTDIR:-/usr/share/fonts/${FONT_PN}} 35FONTDIR=${FONTDIR:-/usr/share/fonts/${FONT_PN}}
48# Docs to install 44# Docs to install
49DOCS=${DOCS:-} 45DOCS=${DOCS:-}
50 46
51IUSE="X" 47IUSE="X"
52 48
53DEPEND="X? ( x11-apps/mkfontdir 49DEPEND="X? (
50 x11-apps/mkfontdir
54 media-fonts/encodings ) 51 media-fonts/encodings
52 )
55 media-libs/fontconfig" 53 >=media-libs/fontconfig-2.4.0"
56
57#
58# Public functions
59#
60 54
61# @FUNCTION: font_xfont_config 55# @FUNCTION: font_xfont_config
62# @DESCRIPTION: 56# @DESCRIPTION:
63# Creates the Xfont files. 57# Creates the Xfont files.
64font_xfont_config() { 58font_xfont_config() {
65 # create Xfont files 59 # create Xfont files
66 if use X ; then 60 if has X ${IUSE//+} && use X ; then
67 einfo "Creating fonts.scale & fonts.dir ..." 61 ebegin "Creating fonts.scale & fonts.dir"
68 rm -f "${D}${FONTDIR}"/fonts.{dir,scale} 62 rm -f "${ED}${FONTDIR}"/fonts.{dir,scale}
69 mkfontscale "${D}${FONTDIR}" 63 mkfontscale "${ED}${FONTDIR}"
70 mkfontdir \ 64 mkfontdir \
71 -e /usr/share/fonts/encodings \ 65 -e ${EPREFIX}/usr/share/fonts/encodings \
72 -e /usr/share/fonts/encodings/large \ 66 -e ${EPREFIX}/usr/share/fonts/encodings/large \
73 "${D}${FONTDIR}" 67 "${ED}${FONTDIR}"
68 eend $?
74 if [ -e "${FONT_S}/fonts.alias" ] ; then 69 if [ -e "${FONT_S}/fonts.alias" ] ; then
75 doins "${FONT_S}/fonts.alias" 70 doins "${FONT_S}/fonts.alias"
76 fi 71 fi
77 fi
78}
79
80# @FUNCTION: font_xft_config
81# @DESCRIPTION:
82# Creates the fontconfig cache if necessary.
83font_xft_config() {
84 if ! has_version '>=media-libs/fontconfig-2.4'; then
85 # create fontconfig cache
86 einfo "Creating fontconfig cache ..."
87 fc-cache -sf "${D}${FONTDIR}"
88 fi 72 fi
89} 73}
90 74
91# @FUNCTION: font_fontconfig 75# @FUNCTION: font_fontconfig
92# @DESCRIPTION: 76# @DESCRIPTION:
93# Installs the fontconfig config files of FONT_CONF. 77# Installs the fontconfig config files of FONT_CONF.
94font_fontconfig() { 78font_fontconfig() {
95 local conffile 79 local conffile
96 if [[ -n ${FONT_CONF[@]} ]]; then 80 if [[ -n ${FONT_CONF[@]} ]]; then
97 if has_version '>=media-libs/fontconfig-2.4'; then
98 insinto /etc/fonts/conf.avail/ 81 insinto /etc/fonts/conf.avail/
99 for conffile in "${FONT_CONF[@]}"; do 82 for conffile in "${FONT_CONF[@]}"; do
100 [[ -e ${conffile} ]] && doins ${conffile} 83 [[ -e ${conffile} ]] && doins ${conffile}
101 done 84 done
102 fi
103 fi 85 fi
104} 86}
105 87
106#
107# Public inheritable functions
108#
109
110# @FUNCTION: font_src_install 88# @FUNCTION: font_src_install
111# @DESCRIPTION: 89# @DESCRIPTION:
112# The font src_install function, which is exported. 90# The font src_install function.
113font_src_install() { 91font_src_install() {
114 local suffix commondoc 92 local suffix commondoc
115 93
116 cd "${FONT_S}" 94 pushd "${FONT_S}" > /dev/null
117 95
118 insinto "${FONTDIR}" 96 insinto "${FONTDIR}"
119 97
120 for suffix in ${FONT_SUFFIX}; do 98 for suffix in ${FONT_SUFFIX}; do
121 doins *.${suffix} 99 doins *.${suffix}
122 done 100 done
123 101
124 rm -f fonts.{dir,scale} encodings.dir 102 rm -f fonts.{dir,scale} encodings.dir
125 103
126 font_xfont_config 104 font_xfont_config
127 font_xft_config
128 font_fontconfig 105 font_fontconfig
129 106
130 cd "${S}" 107 popd > /dev/null
131 dodoc ${DOCS} 2> /dev/null 108
109 [[ -n ${DOCS} ]] && { dodoc ${DOCS} || die "docs installation failed" ; }
132 110
133 # install common docs 111 # install common docs
134 for commondoc in COPYRIGHT README{,.txt} NEWS AUTHORS BUGS ChangeLog FONTLOG.txt; do 112 for commondoc in COPYRIGHT README{,.txt} NEWS AUTHORS BUGS ChangeLog FONTLOG.txt; do
135 [[ -s ${commondoc} ]] && dodoc ${commondoc} 113 [[ -s ${commondoc} ]] && dodoc ${commondoc}
136 done 114 done
137} 115}
138 116
139# @FUNCTION: font_pkg_setup 117# @FUNCTION: font_pkg_setup
140# @DESCRIPTION: 118# @DESCRIPTION:
141# The font pkg_setup function, which is exported. 119# The font pkg_setup function.
120# Collision portection and Prefix compat for eapi < 3.
142font_pkg_setup() { 121font_pkg_setup() {
122 # Prefix compat
123 case ${EAPI:-0} in
124 0|1|2)
125 if ! use prefix; then
126 EPREFIX=
127 ED=${D}
128 EROOT=${ROOT}
129 [[ ${EROOT} = */ ]] || EROOT+="/"
130 fi
131 ;;
132 esac
133
143 # make sure we get no collisions 134 # make sure we get no collisions
144 # setup is not the nicest place, but preinst doesn't cut it 135 # setup is not the nicest place, but preinst doesn't cut it
145 [[ -e "${FONTDIR}/fonts.cache-1" ]] && rm -f "${FONTDIR}/fonts.cache-1" 136 [[ -e "${EROOT}/${FONTDIR}/fonts.cache-1" ]] && rm -f "${EROOT}/${FONTDIR}/fonts.cache-1"
146} 137}
147 138
148# @FUNCTION: font_pkg_postinst 139# @FUNCTION: font_pkg_postinst
149# @DESCRIPTION: 140# @DESCRIPTION:
150# The font pkg_postinst function, which is exported. 141# The font pkg_postinst function.
142# Update global font cache and fix permissions.
151font_pkg_postinst() { 143font_pkg_postinst() {
152 # unreadable font files = fontconfig segfaults 144 # unreadable font files = fontconfig segfaults
153 find "${ROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \ 145 find "${EROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \
154 | xargs -0 chmod -v 0644 2>/dev/null 146 | xargs -0 chmod -v 0644 2>/dev/null
155 147
156 if [[ -n ${FONT_CONF[@]} ]]; then 148 if [[ -n ${FONT_CONF[@]} ]]; then
157 if has_version '>=media-libs/fontconfig-2.4'; then
158 local conffile 149 local conffile
159 echo 150 echo
160 elog "The following fontconfig configuration files have been installed:" 151 elog "The following fontconfig configuration files have been installed:"
161 elog 152 elog
162 for conffile in "${FONT_CONF[@]}"; do 153 for conffile in "${FONT_CONF[@]}"; do
163 if [[ -e ${ROOT}etc/fonts/conf.avail/$(basename ${conffile}) ]]; then 154 if [[ -e ${EROOT}etc/fonts/conf.avail/$(basename ${conffile}) ]]; then
164 elog " $(basename ${conffile})" 155 elog " $(basename ${conffile})"
165 fi 156 fi
166 done 157 done
167 elog 158 elog
168 elog "Use \`eselect fontconfig\` to enable/disable them." 159 elog "Use \`eselect fontconfig\` to enable/disable them."
169 echo 160 echo
170 fi
171 fi 161 fi
172 162
173 if has_version '>=media-libs/fontconfig-2.4'; then
174 if [[ ${ROOT} == "/" ]]; then 163 if [[ ${ROOT} == / ]]; then
175 ebegin "Updating global fontcache" 164 ebegin "Updating global fontcache"
176 fc-cache -fs 165 fc-cache -fs
177 eend $? 166 eend $?
178 fi
179 fi 167 fi
180} 168}
181 169
182# @FUNCTION: font_pkg_postrm 170# @FUNCTION: font_pkg_postrm
183# @DESCRIPTION: 171# @DESCRIPTION:
184# The font pkg_postrm function, which is exported. 172# The font pkg_postrm function.
173# Updates global font cache
185font_pkg_postrm() { 174font_pkg_postrm() {
186 # unreadable font files = fontconfig segfaults 175 # unreadable font files = fontconfig segfaults
187 find "${ROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \ 176 find "${EROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \
188 | xargs -0 chmod -v 0644 2>/dev/null 177 | xargs -0 chmod -v 0644 2>/dev/null
189 178
190 if has_version '>=media-libs/fontconfig-2.4'; then
191 if [[ ${ROOT} == "/" ]]; then 179 if [[ ${ROOT} == / ]]; then
192 ebegin "Updating global fontcache" 180 ebegin "Updating global fontcache"
193 fc-cache -fs 181 fc-cache -fs
194 eend $? 182 eend $?
195 fi
196 fi 183 fi
197} 184}

Legend:
Removed from v.1.47  
changed lines
  Added in v.1.48

  ViewVC Help
Powered by ViewVC 1.1.20