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

Contents of /eclass/chromium.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Wed Mar 14 15:54:24 2012 UTC (2 years, 5 months ago) by floppym
Branch: MAIN
New eclass.

1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 # @ECLASS: chromium.eclass
6 # @MAINTAINER:
7 # Chromium Herd <chromium@gentoo.org>
8 # @AUTHOR:
9 # Mike Gilbert <floppym@gentoo.org>
10 # @BLURB: Shared functions for chromium and google-chrome
11
12 inherit eutils fdo-mime gnome2-utils linux-info
13
14 EXPORT_FUNCTIONS pkg_preinst pkg_postinst pkg_postrm
15
16 # @FUNCTION: chromium_check_kernel_config
17 # @USAGE:
18 # @DESCRIPTION:
19 # Ensures the system kernel is configured for full Chromium functionality.
20 chromium_check_kernel_config() {
21 has "${EAPI:-0}" 0 1 2 3 && die "EAPI=${EAPI} is not supported"
22
23 if [[ "${MERGE_TYPE}" == "source" || "${MERGE_TYPE}" == "binary" ]]; then
24 # Warn if the kernel does not support features needed for sandboxing.
25 # Bug #363987.
26 ERROR_PID_NS="PID_NS is required for sandbox to work"
27 ERROR_NET_NS="NET_NS is required for sandbox to work"
28 CONFIG_CHECK="~PID_NS ~NET_NS"
29 check_extra_config
30 fi
31 }
32
33 # @ECLASS-VARIABLE: CHROMIUM_LANGS
34 # @DEFAULT_UNSET
35 # @DESCRIPTION:
36 # List of language packs available for this package.
37
38 _chromium_set_linguas_IUSE() {
39 [[ ${EAPI:-0} == 0 ]] && die "EAPI=${EAPI} is not supported"
40
41 local lang
42 for lang in ${CHROMIUM_LANGS}; do
43 # Default to enabled since we bundle them anyway.
44 # USE-expansion will take care of disabling the langs the user has not
45 # selected via LINGUAS.
46 IUSE+=" +linguas_${lang}"
47 done
48 }
49
50 if [[ ${CHROMIUM_LANGS} ]]; then
51 _chromium_set_linguas_IUSE
52 fi
53
54 _chromium_crlang() {
55 local x
56 for x in "$@"; do
57 case $x in
58 es_LA) echo es-419 ;;
59 *) echo "${x/_/-}" ;;
60 esac
61 done
62 }
63
64 _chromium_syslang() {
65 local x
66 for x in "$@"; do
67 case $x in
68 es-419) echo es_LA ;;
69 *) echo "${x/-/_}" ;;
70 esac
71 done
72 }
73
74 _chromium_strip_pak() {
75 local x
76 for x in "$@"; do
77 echo "${x%.pak}"
78 done
79 }
80
81 # @FUNCTION: chromium_remove_language_paks
82 # @USAGE:
83 # @DESCRIPTION:
84 # Removes pak files from the current directory for languages that the user has
85 # not selected via the LINGUAS variable.
86 # Also performs QA checks to ensure CHROMIUM_LANGS has been set correctly.
87 chromium_remove_language_paks() {
88 local crlangs=$(_chromium_crlang ${CHROMIUM_LANGS})
89 local present_crlangs=$(_chromium_strip_pak *.pak)
90 local present_langs=$(_chromium_syslang ${present_crlangs})
91 local lang
92
93 # Look for missing pak files.
94 for lang in ${crlangs}; do
95 if ! has ${lang} ${present_crlangs}; then
96 eqawarn "LINGUAS warning: no .pak file for ${lang} (${lang}.pak not found)"
97 fi
98 done
99
100 # Look for extra pak files.
101 # Remove pak files that the user does not want.
102 for lang in ${present_langs}; do
103 if [[ ${lang} == en_US ]]; then
104 continue
105 fi
106 if ! has ${lang} ${CHROMIUM_LANGS}; then
107 eqawarn "LINGUAS warning: no ${lang} in LANGS"
108 continue
109 fi
110 if ! use linguas_${lang}; then
111 rm -v "$(_chromium_crlang ${lang}).pak" || die
112 fi
113 done
114 }
115
116 chromium_pkg_preinst() {
117 gnome2_icon_savelist
118 }
119
120 chromium_pkg_postinst() {
121 fdo-mime_desktop_database_update
122 gnome2_icon_cache_update
123
124 # For more info see bug #292201, bug #352263, bug #361859.
125 elog
126 elog "Depending on your desktop environment, you may need"
127 elog "to install additional packages to get icons on the Downloads page."
128 elog
129 elog "For KDE, the required package is kde-base/oxygen-icons."
130 elog
131 elog "For other desktop environments, try one of the following:"
132 elog " - x11-themes/gnome-icon-theme"
133 elog " - x11-themes/tango-icon-theme"
134
135 # For more info see bug #359153.
136 elog
137 elog "Some web pages may require additional fonts to display properly."
138 elog "Try installing some of the following packages if some characters"
139 elog "are not displayed properly:"
140 elog " - media-fonts/arphicfonts"
141 elog " - media-fonts/bitstream-cyberbit"
142 elog " - media-fonts/droid"
143 elog " - media-fonts/ipamonafont"
144 elog " - media-fonts/ja-ipafonts"
145 elog " - media-fonts/takao-fonts"
146 elog " - media-fonts/wqy-microhei"
147 elog " - media-fonts/wqy-zenhei"
148 }
149
150 chromium_pkg_postrm() {
151 gnome2_icon_cache_update
152 }
153
154 chromium_pkg_die() {
155 if [[ "${EBUILD_PHASE}" != "compile" ]]; then
156 return
157 fi
158
159 # Prevent user problems like bug #348235.
160 eshopts_push -s extglob
161 if is-flagq '-g?(gdb)?([1-9])'; then
162 ewarn
163 ewarn "You have enabled debug info (i.e. -g or -ggdb in your CFLAGS/CXXFLAGS)."
164 ewarn "Please try removing -g{,gdb} before reporting a bug."
165 ewarn
166 fi
167 eshopts_pop
168
169 # ccache often causes bogus compile failures, especially when the cache gets
170 # corrupted.
171 if has ccache ${FEATURES}; then
172 ewarn
173 ewarn "You have enabled ccache. Please try disabling ccache"
174 ewarn "before reporting a bug."
175 ewarn
176 fi
177
178 # No ricer bugs.
179 if use_if_iuse custom-cflags; then
180 ewarn
181 ewarn "You have enabled the custom-cflags USE flag."
182 ewarn "Please disable it before reporting a bug."
183 ewarn
184 fi
185
186 # If the system doesn't have enough memory, the compilation is known to
187 # fail. Print info about memory to recognize this condition.
188 einfo
189 einfo "$(grep MemTotal /proc/meminfo)"
190 einfo "$(grep SwapTotal /proc/meminfo)"
191 einfo
192 }
193
194 # @VARIABLE: EGYP_CHROMIUM_COMMAND
195 # @DESCRIPTION:
196 # Path to the gyp_chromium script.
197 : ${EGYP_CHROMIUM_COMMAND:=build/gyp_chromium}
198
199 # @VARIABLE: EGYP_CHROMIUM_DEPTH
200 # @DESCRIPTION:
201 # Depth for egyp_chromium.
202 : ${EGYP_CHROMIUM_DEPTH:=.}
203
204 # @FUNCTION: egyp_chromium
205 # @USAGE: [gyp arguments]
206 # @DESCRIPTION:
207 # Calls EGYP_CHROMIUM_COMMAND with depth EGYP_CHROMIUM_DEPTH and given
208 # arguments. The full command line is echoed for logging.
209 egyp_chromium() {
210 set -- "${EGYP_CHROMIUM_COMMAND}" --depth="${EGYP_CHROMIUM_DEPTH}" "$@"
211 echo "$@"
212 "$@"
213 }
214
215 # @FUNCTION: gyp_use
216 # @USAGE: <USE flag> [GYP flag] [true suffix] [false suffix]
217 # @DESCRIPTION:
218 # If USE flag is set, echo -D[GYP flag]=[true suffix].
219 #
220 # If USE flag is not set, echo -D[GYP flag]=[false suffix].
221 #
222 # [GYP flag] defaults to use_[USE flag] with hyphens converted to underscores.
223 #
224 # [true suffix] defaults to 1. [false suffix] defaults to 0.
225 gyp_use() {
226 local gypflag="-D${2:-use_${1//-/_}}="
227 usex "$1" "${gypflag}" "${gypflag}" "${3-1}" "${4-0}"
228 }
229
230 # @FUNCTION: chromium_bundled_v8_version
231 # @USAGE: [path to version.cc]
232 # @DESCRIPTION:
233 # Outputs the version of v8 parsed from a (bundled) copy of the source code.
234 chromium_bundled_v8_version() {
235 local vf=${1:-v8/src/version.cc}
236 local major minor build patch
237 major=$(sed -ne 's/#define MAJOR_VERSION *\([0-9]*\)/\1/p' "${vf}")
238 minor=$(sed -ne 's/#define MINOR_VERSION *\([0-9]*\)/\1/p' "${vf}")
239 build=$(sed -ne 's/#define BUILD_NUMBER *\([0-9]*\)/\1/p' "${vf}")
240 patch=$(sed -ne 's/#define PATCH_LEVEL *\([0-9]*\)/\1/p' "${vf}")
241 echo "${major}.${minor}.${build}.${patch}"
242 }
243
244 # @FUNCTION: chromium_installed_v8_version
245 # @USAGE:
246 # @DESCRIPTION:
247 # Outputs the version of dev-lang/v8 currently installed on the host system.
248 chromium_installed_v8_version() {
249 local cpf=$(best_version dev-lang/v8)
250 local pvr=${cpf#dev-lang/v8-}
251 echo "${pvr%-r*}"
252 }

  ViewVC Help
Powered by ViewVC 1.1.20