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

Contents of /eclass/font.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.48 - (show annotations) (download)
Tue Feb 9 17:15:08 2010 UTC (7 years, 10 months ago) by scarabeus
Branch: MAIN
Changes since 1.47: +72 -85 lines
Introduce fonts.eclass supporting eapi up to 3. Per disscussion on -dev.

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

  ViewVC Help
Powered by ViewVC 1.1.20