| 1 | # Copyright 1999-2004 Gentoo Technologies, Inc. |
1 | # Copyright 1999-2004 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.1 2004/05/31 14:21:06 foser Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/font.eclass,v 1.23 2007/06/24 06:15:21 dirtyepic Exp $ |
| 4 | |
4 | |
| 5 | # Author: foser <foser@gentoo.org> |
5 | # Author: foser <foser@gentoo.org> |
| 6 | |
6 | |
| 7 | # Font Eclass |
7 | # Font Eclass |
| 8 | # |
8 | # |
| 9 | # Eclass to make font installation more uniform |
9 | # Eclass to make font installation uniform |
| 10 | |
10 | |
| 11 | ECLASS="font" |
11 | inherit eutils |
| 12 | INHERITED="$INHERITED $ECLASS" |
|
|
| 13 | |
12 | |
| 14 | # |
13 | # |
| 15 | # Variable declarations |
14 | # Variable declarations |
| 16 | # |
15 | # |
| 17 | |
16 | |
| 18 | FONT_SUFFIX="" # Space delimited list of font suffixes to install |
17 | FONT_SUFFIX="" # Space delimited list of font suffixes to install |
| 19 | |
18 | |
|
|
19 | FONT_S="${S}" # Dir containing the fonts |
|
|
20 | |
|
|
21 | FONT_PN="${PN}" # Last part of $FONTDIR |
|
|
22 | |
|
|
23 | FONTDIR="/usr/share/fonts/${FONT_PN}" # this is where the fonts are installed |
|
|
24 | |
| 20 | DOCS="" # Docs to install |
25 | DOCS="" # Docs to install |
| 21 | |
26 | |
| 22 | IUSE="${IUSE} X" |
27 | IUSE="X" |
| 23 | |
28 | |
| 24 | DEPEND="${DEPEND} \ |
29 | DEPEND="X? ( x11-apps/mkfontdir ) |
| 25 | X? ( virtual/x11 ) \ |
|
|
| 26 | media-libs/fontconfig" |
30 | media-libs/fontconfig" |
|
|
31 | |
|
|
32 | # |
|
|
33 | # Public functions |
|
|
34 | # |
|
|
35 | |
|
|
36 | font_xfont_config() { |
|
|
37 | |
|
|
38 | # create Xfont files |
|
|
39 | if use X ; then |
|
|
40 | einfo "Creating fonts.scale & fonts.dir ..." |
|
|
41 | mkfontscale "${D}${FONTDIR}" |
|
|
42 | mkfontdir \ |
|
|
43 | -e /usr/share/fonts/encodings \ |
|
|
44 | -e /usr/share/fonts/encodings/large \ |
|
|
45 | "${D}${FONTDIR}" |
|
|
46 | if [ -e "${FONT_S}/fonts.alias" ] ; then |
|
|
47 | doins "${FONT_S}/fonts.alias" |
|
|
48 | fi |
|
|
49 | fi |
|
|
50 | |
|
|
51 | } |
|
|
52 | |
|
|
53 | font_xft_config() { |
|
|
54 | |
|
|
55 | if ! has_version '>=media-libs/fontconfig-2.4'; then |
|
|
56 | # create fontconfig cache |
|
|
57 | einfo "Creating fontconfig cache ..." |
|
|
58 | # Mac OS X has fc-cache at /usr/X11R6/bin |
|
|
59 | HOME="/root" fc-cache -f "${D}${FONTDIR}" |
|
|
60 | fi |
|
|
61 | } |
| 27 | |
62 | |
| 28 | # |
63 | # |
| 29 | # Public inheritable functions |
64 | # Public inheritable functions |
| 30 | # |
65 | # |
| 31 | |
66 | |
| 32 | font_src_install() { |
67 | font_src_install() { |
| 33 | |
68 | |
| 34 | local suffix, doc |
69 | local suffix commondoc |
| 35 | |
70 | |
| 36 | insinto /usr/share/fonts/${PN} |
71 | cd "${FONT_S}" |
|
|
72 | |
|
|
73 | insinto "${FONTDIR}" |
| 37 | |
74 | |
| 38 | for suffix in ${FONT_SUFFIX}; do |
75 | for suffix in ${FONT_SUFFIX}; do |
| 39 | doins ${S}/*.${suffix} |
76 | doins *.${suffix} |
| 40 | done |
77 | done |
| 41 | |
78 | |
| 42 | rm -f fonts.{dir,scale} encodings.dir |
79 | rm -f fonts.{dir,scale} encodings.dir |
| 43 | |
80 | |
| 44 | # create Xfont files |
81 | font_xfont_config |
| 45 | if [ -n "`use X`" ] ; |
82 | font_xft_config |
| 46 | then |
|
|
| 47 | einfo "Creating fonts.scale & fonts.dir..." |
|
|
| 48 | mkfontscale ${D}/usr/share/fonts/${PN} |
|
|
| 49 | mkfontdir \ |
|
|
| 50 | -e /usr/share/fonts/encodings \ |
|
|
| 51 | -e /usr/share/fonts/encodings/large \ |
|
|
| 52 | -e /usr/X11R6/lib/X11/fonts/encodings ${D}/usr/share/fonts/${PN} |
|
|
| 53 | doins fonts.alias |
|
|
| 54 | fi |
|
|
| 55 | |
83 | |
| 56 | # create fontconfig cache |
84 | cd "${S}" |
| 57 | einfo "Creating fontconfig cache..." |
85 | dodoc ${DOCS} 2> /dev/null |
| 58 | HOME="/root" /usr/bin/fc-cache -f ${D}/usr/share/fonts/${PN} |
|
|
| 59 | |
86 | |
| 60 | # try to install some common docs |
87 | # install common docs |
| 61 | DOCS="${DOCS} COPYRIGHT README NEWS" |
88 | for commondoc in COPYRIGHT README NEWS AUTHORS BUGS ChangeLog; do |
| 62 | for doc in ${DOCS}; do |
89 | [ -s ${commondoc} ] && dodoc ${commondoc} |
| 63 | dodoc ${doc} |
|
|
| 64 | done |
90 | done |
|
|
91 | } |
|
|
92 | |
|
|
93 | font_pkg_setup() { |
|
|
94 | |
|
|
95 | # make sure we get no colissions |
|
|
96 | # setup is not the nicest place, but preinst doesn't cut it |
|
|
97 | [[ -e "${FONTDIR}/fonts.cache-1" ]] && rm -f "${FONTDIR}/fonts.cache-1" |
| 65 | |
98 | |
| 66 | } |
99 | } |
| 67 | |
100 | |
| 68 | EXPORT_FUNCTIONS src_install |
101 | font_pkg_postinst() { |
|
|
102 | |
|
|
103 | if has_version '>=media-libs/fontconfig-2.4'; then |
|
|
104 | if [ ${ROOT} == "/" ]; then |
|
|
105 | ebegin "Updating global fontcache" |
|
|
106 | fc-cache -s |
|
|
107 | eend $? |
|
|
108 | fi |
|
|
109 | fi |
|
|
110 | |
|
|
111 | } |
|
|
112 | |
|
|
113 | font_pkg_postrm() { |
|
|
114 | |
|
|
115 | if has_version '>=media-libs/fontconfig-2.4'; then |
|
|
116 | if [ ${ROOT} == "/" ]; then |
|
|
117 | ebegin "Updating global fontcache" |
|
|
118 | fc-cache -s |
|
|
119 | eend $? |
|
|
120 | fi |
|
|
121 | fi |
|
|
122 | |
|
|
123 | } |
|
|
124 | |
|
|
125 | EXPORT_FUNCTIONS src_install pkg_setup pkg_postinst pkg_postrm |