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

Contents of /eclass/chromium.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (show annotations) (download)
Wed Dec 4 04:23:08 2013 UTC (9 months, 1 week ago) by phajdan.jr
Branch: MAIN
CVS Tags: HEAD
Changes since 1.8: +3 -2 lines
Check SECCOMP_FILTER kernel config option for Chromium sandbox, bug #490550 by ago.

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

  ViewVC Help
Powered by ViewVC 1.1.20