| 1 | # Copyright 1999-2005 Gentoo Foundation |
1 | # Copyright 1999-2005 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/x-modular.eclass,v 1.24 2005/12/06 02:22:16 spyderous Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/x-modular.eclass,v 1.26 2005/12/07 22:10:45 joshuabaergen Exp $ |
| 4 | # |
4 | # |
| 5 | # Author: Donnie Berkholz <spyderous@gentoo.org> |
5 | # Author: Donnie Berkholz <spyderous@gentoo.org> |
| 6 | # |
6 | # |
| 7 | # This eclass is designed to reduce code duplication in the modularized X11 |
7 | # This eclass is designed to reduce code duplication in the modularized X11 |
| 8 | # ebuilds. |
8 | # ebuilds. |
| 9 | # |
9 | # |
| 10 | # If the ebuild installs fonts, set FONT="yes" at the top and set FONT_DIRS to |
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. |
11 | # the subdirectories within /usr/share/fonts to which it installs fonts. |
| 12 | |
12 | |
| 13 | EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst |
13 | EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst pkg_postrm |
| 14 | |
14 | |
| 15 | inherit eutils libtool |
15 | inherit eutils libtool toolchain-funcs |
| 16 | |
16 | |
| 17 | # Directory prefix to use for everything |
17 | # Directory prefix to use for everything |
| 18 | XDIR="/usr" |
18 | XDIR="/usr" |
| 19 | |
19 | |
| 20 | IUSE="" |
20 | IUSE="" |
| … | |
… | |
| 35 | >=sys-devel/libtool-1.5 |
35 | >=sys-devel/libtool-1.5 |
| 36 | >=sys-devel/m4-1.4" |
36 | >=sys-devel/m4-1.4" |
| 37 | fi |
37 | fi |
| 38 | |
38 | |
| 39 | # If we're a font package, but not the font.alias one |
39 | # If we're a font package, but not the font.alias one |
| 40 | if [[ "${PN/#font-}" != "${PN}" ]] && [[ "${PN}" != "font-alias" ]]; then |
40 | if [[ "${PN/#font-}" != "${PN}" ]] \ |
|
|
41 | && [[ "${PN}" != "font-alias" ]] \ |
|
|
42 | && [[ "${PN}" != "font-util" ]]; then |
| 41 | # Activate font code in the rest of the eclass |
43 | # Activate font code in the rest of the eclass |
| 42 | FONT="yes" |
44 | FONT="yes" |
| 43 | |
45 | |
| 44 | RDEPEND="${RDEPEND} |
46 | RDEPEND="${RDEPEND} |
| 45 | media-fonts/encodings" |
47 | media-fonts/encodings" |
| 46 | PDEPEND="${PDEPEND} |
48 | PDEPEND="${PDEPEND} |
| 47 | media-fonts/font-alias" |
49 | media-fonts/font-alias" |
|
|
50 | |
|
|
51 | # Starting with 7.0RC3, we can specify the font directory |
|
|
52 | # But oddly, we can't do the same for encodings or font-alias |
|
|
53 | |
|
|
54 | # Wrap in `if` so ebuilds can set it too |
|
|
55 | if [[ -z ${FONT_DIR} ]]; then |
|
|
56 | FONT_DIR=${PN##*-} |
|
|
57 | |
|
|
58 | fi |
|
|
59 | |
|
|
60 | # Fix case of font directories |
|
|
61 | FONT_DIR=${FONT_DIR/ttf/TTF} |
|
|
62 | FONT_DIR=${FONT_DIR/otf/OTF} |
|
|
63 | FONT_DIR=${FONT_DIR/type1/Type1} |
|
|
64 | FONT_DIR=${FONT_DIR/speedo/Speedo} |
|
|
65 | |
|
|
66 | # Set up configure option |
|
|
67 | FONT_OPTIONS="--with-fontdir=\"/usr/share/fonts/${FONT_DIR}\"" |
|
|
68 | |
|
|
69 | if [[ -n "${FONT}" ]]; then |
|
|
70 | if [[ ${PN##*-} = misc ]] || [[ ${PN##*-} = 75dpi ]] || [[ ${PN##*-} = 100dpi ]]; then |
|
|
71 | IUSE="${IUSE} nls" |
|
|
72 | fi |
|
|
73 | fi |
| 48 | fi |
74 | fi |
| 49 | |
75 | |
| 50 | # If we're a driver package |
76 | # If we're a driver package |
| 51 | if [[ "${PN/#xf86-video}" != "${PN}" ]] || [[ "${PN/#xf86-input}" != "${PN}" ]]; then |
77 | if [[ "${PN/#xf86-video}" != "${PN}" ]] || [[ "${PN/#xf86-input}" != "${PN}" ]]; then |
| 52 | # Don't build static driver modules |
78 | # Don't build static driver modules |
| … | |
… | |
| 69 | cd ${S} |
95 | cd ${S} |
| 70 | |
96 | |
| 71 | # Joshua Baergen - October 23, 2005 |
97 | # Joshua Baergen - October 23, 2005 |
| 72 | # Fix shared lib issues on MIPS, FBSD, etc etc |
98 | # Fix shared lib issues on MIPS, FBSD, etc etc |
| 73 | elibtoolize |
99 | elibtoolize |
|
|
100 | |
|
|
101 | if [[ -n ${FONT_OPTIONS} ]]; then |
|
|
102 | einfo "Detected font directory: ${FONT_DIR}" |
|
|
103 | fi |
| 74 | } |
104 | } |
| 75 | |
105 | |
| 76 | x-modular_patch_source() { |
106 | x-modular_patch_source() { |
| 77 | # Use standardized names and locations with bulk patching |
107 | # Use standardized names and locations with bulk patching |
| 78 | # Patch directory is ${WORKDIR}/patch |
108 | # Patch directory is ${WORKDIR}/patch |
| … | |
… | |
| 109 | fi |
139 | fi |
| 110 | |
140 | |
| 111 | } |
141 | } |
| 112 | |
142 | |
| 113 | x-modular_src_unpack() { |
143 | x-modular_src_unpack() { |
|
|
144 | for x in xorg-server xf86-video- xf86-input- ; do |
|
|
145 | if [[ ${PN:0:11} = $x ]] && gcc-specs-now; then |
|
|
146 | msg="Do not emerge ${PN} without vanilla gcc!" |
|
|
147 | eerror "$msg" |
|
|
148 | die "$msg" |
|
|
149 | fi |
|
|
150 | done |
|
|
151 | |
| 114 | x-modular_unpack_source |
152 | x-modular_unpack_source |
| 115 | x-modular_patch_source |
153 | x-modular_patch_source |
| 116 | x-modular_reconf_source |
154 | x-modular_reconf_source |
| 117 | } |
155 | } |
| 118 | |
156 | |
|
|
157 | x-modular_font_configure() { |
|
|
158 | if [[ -n "${FONT}" ]]; then |
|
|
159 | # Might be worth adding an option to configure your desired font |
|
|
160 | # and exclude all others. Also, should this USE be nls or minimal? |
|
|
161 | if ! use nls; then |
|
|
162 | FONT_OPTIONS="${FONT_OPTIONS} |
|
|
163 | --disable-iso8859-2 |
|
|
164 | --disable-iso8859-3 |
|
|
165 | --disable-iso8859-4 |
|
|
166 | --disable-iso8859-5 |
|
|
167 | --disable-iso8859-6 |
|
|
168 | --disable-iso8859-7 |
|
|
169 | --disable-iso8859-8 |
|
|
170 | --disable-iso8859-9 |
|
|
171 | --disable-iso8859-10 |
|
|
172 | --disable-iso8859-11 |
|
|
173 | --disable-iso8859-12 |
|
|
174 | --disable-iso8859-13 |
|
|
175 | --disable-iso8859-14 |
|
|
176 | --disable-iso8859-15 |
|
|
177 | --disable-iso8859-16 |
|
|
178 | --disable-jisx0201 |
|
|
179 | --disable-koi8-r" |
|
|
180 | fi |
|
|
181 | fi |
|
|
182 | } |
|
|
183 | |
| 119 | x-modular_src_configure() { |
184 | x-modular_src_configure() { |
|
|
185 | x-modular_font_configure |
|
|
186 | |
| 120 | # If prefix isn't set here, .pc files cause problems |
187 | # If prefix isn't set here, .pc files cause problems |
| 121 | if [ -x ./configure ]; then |
188 | if [ -x ./configure ]; then |
| 122 | econf --prefix=${XDIR} \ |
189 | econf --prefix=${XDIR} \ |
| 123 | --datadir=${XDIR}/share \ |
190 | --datadir=${XDIR}/share \ |
|
|
191 | ${FONT_OPTIONS} \ |
| 124 | ${DRIVER_OPTIONS} \ |
192 | ${DRIVER_OPTIONS} \ |
| 125 | ${CONFIGURE_OPTIONS} |
193 | ${CONFIGURE_OPTIONS} |
| 126 | fi |
194 | fi |
| 127 | } |
195 | } |
| 128 | |
196 | |
| … | |
… | |
| 162 | if [[ -n "${FONT}" ]]; then |
230 | if [[ -n "${FONT}" ]]; then |
| 163 | setup_fonts |
231 | setup_fonts |
| 164 | fi |
232 | fi |
| 165 | } |
233 | } |
| 166 | |
234 | |
|
|
235 | x-modular_pkg_postrm() { |
|
|
236 | if [[ -n "${FONT}" ]]; then |
|
|
237 | cleanup_fonts |
|
|
238 | fi |
|
|
239 | } |
|
|
240 | |
|
|
241 | cleanup_fonts() { |
|
|
242 | local ALLOWED_FILES="encodings.dir fonts.cache-1 fonts.dir fonts.scale" |
|
|
243 | for DIR in ${FONT_DIR}; do |
|
|
244 | unset KEEP_FONTDIR |
|
|
245 | REAL_DIR=${ROOT}usr/share/fonts/${DIR} |
|
|
246 | |
|
|
247 | ebegin "Checking ${REAL_DIR} for useless files" |
|
|
248 | pushd ${REAL_DIR} &> /dev/null |
|
|
249 | for FILE in *; do |
|
|
250 | unset MATCH |
|
|
251 | for ALLOWED_FILE in ${ALLOWED_FILES}; do |
|
|
252 | if [[ ${FILE} = ${ALLOWED_FILE} ]]; then |
|
|
253 | # If it's allowed, then move on to the next file |
|
|
254 | MATCH="yes" |
|
|
255 | break |
|
|
256 | fi |
|
|
257 | done |
|
|
258 | # If we found a match in allowed files, move on to the next file |
|
|
259 | if [[ -n ${MATCH} ]]; then |
|
|
260 | continue |
|
|
261 | fi |
|
|
262 | # If we get this far, there wasn't a match in the allowed files |
|
|
263 | KEEP_FONTDIR="yes" |
|
|
264 | # We don't need to check more files if we're already keeping it |
|
|
265 | break |
|
|
266 | done |
|
|
267 | popd &> /dev/null |
|
|
268 | # If there are no files worth keeping, then get rid of the dir |
|
|
269 | if [[ -z "${KEEP_FONTDIR}" ]]; then |
|
|
270 | rm -rf ${REAL_DIR} |
|
|
271 | fi |
|
|
272 | eend 0 |
|
|
273 | done |
|
|
274 | } |
|
|
275 | |
| 167 | setup_fonts() { |
276 | setup_fonts() { |
| 168 | if [[ ! -n "${FONT_DIRS}" ]]; then |
277 | if [[ ! -n "${FONT_DIRS}" ]]; then |
| 169 | msg="FONT_DIRS empty. Set it to at least one subdir of /usr/share/fonts." |
278 | msg="FONT_DIRS is empty. The ebuild should set it to at least one subdir of /usr/share/fonts." |
| 170 | eerror ${msg} |
279 | eerror "${msg}" |
| 171 | die ${msg} |
280 | die "${msg}" |
| 172 | fi |
281 | fi |
| 173 | |
282 | |
| 174 | create_fonts_scale |
283 | create_fonts_scale |
| 175 | create_fonts_dir |
284 | create_fonts_dir |
| 176 | fix_font_permissions |
285 | fix_font_permissions |