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

Contents of /eclass/chromium.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (show annotations) (download)
Sun Aug 11 02:42:54 2013 UTC (18 months, 2 weeks ago) by floppym
Branch: MAIN
Changes since 1.7: +5 -3 lines
Don't call EXPORT_FUNCTONS if CHROMIUM_EXPORT_PHASES is set to 'no'.

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

  ViewVC Help
Powered by ViewVC 1.1.20