1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # This eclass has been deprecated and should not be used by any new ebuilds.
9 # @ECLASS: chromium.eclass
11 # Chromium Herd <chromium@gentoo.org>
13 # Mike Gilbert <floppym@gentoo.org>
14 # @BLURB: Shared functions for chromium and google-chrome
16 inherit eutils fdo-mime gnome2-utils linux-info
18 eqawarn "chromium.eclass is deprecated"
20 if [[ ${CHROMIUM_EXPORT_PHASES} != no ]]; then
21 EXPORT_FUNCTIONS pkg_preinst pkg_postinst pkg_postrm
24 if [[ ${PN} == chromium ]]; then
25 IUSE+=" custom-cflags"
28 # @FUNCTION: chromium_suid_sandbox_check_kernel_config
31 # Ensures the system kernel supports features needed for SUID sandbox to work.
32 chromium_suid_sandbox_check_kernel_config() {
33 has "${EAPI:-0}" 0 1 2 3 && die "EAPI=${EAPI} is not supported"
35 if [[ "${MERGE_TYPE}" == "source" || "${MERGE_TYPE}" == "binary" ]]; then
36 # Warn if the kernel does not support features needed for sandboxing.
38 ERROR_PID_NS="PID_NS is required for sandbox to work"
39 ERROR_NET_NS="NET_NS is required for sandbox to work"
40 ERROR_USER_NS="USER_NS is required for sandbox to work"
41 ERROR_SECCOMP_FILTER="SECCOMP_FILTER is required for sandbox to work"
42 # Warn if the kernel does not support features needed for the browser to work
43 # (bug #552576, bug #556286).
44 ERROR_ADVISE_SYSCALLS="CONFIG_ADVISE_SYSCALLS is required for the renderer (bug #552576)"
45 ERROR_COMPAT_VDSO="CONFIG_COMPAT_VDSO causes segfaults (bug #556286)"
46 CONFIG_CHECK="~PID_NS ~NET_NS ~SECCOMP_FILTER ~USER_NS ~ADVISE_SYSCALLS ~!COMPAT_VDSO"
51 # @ECLASS-VARIABLE: CHROMIUM_LANGS
54 # List of language packs available for this package.
56 _chromium_set_linguas_IUSE() {
57 [[ ${EAPI:-0} == 0 ]] && die "EAPI=${EAPI} is not supported"
60 for lang in ${CHROMIUM_LANGS}; do
61 # Default to enabled since we bundle them anyway.
62 # USE-expansion will take care of disabling the langs the user has not
63 # selected via LINGUAS.
64 IUSE+=" +linguas_${lang}"
68 if [[ ${CHROMIUM_LANGS} ]]; then
69 _chromium_set_linguas_IUSE
80 _chromium_strip_pak() {
87 # @FUNCTION: chromium_remove_language_paks
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})
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)"
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
112 if ! has ${lang} ${CHROMIUM_LANGS}; then
113 eqawarn "LINGUAS warning: no ${lang} in LANGS"
116 if ! use linguas_${lang}; then
117 rm "$(_chromium_crlang ${lang}).pak" || die
122 chromium_pkg_preinst() {
126 chromium_pkg_postinst() {
127 fdo-mime_desktop_database_update
128 gnome2_icon_cache_update
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
134 elog "Depending on your desktop environment, you may need"
135 elog "to install additional packages to get icons on the Downloads page."
137 elog "For KDE, the required package is kde-frameworks/oxygen-icons."
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"
144 # For more info see bug #359153.
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"
159 chromium_pkg_postrm() {
160 gnome2_icon_cache_update
164 if [[ "${EBUILD_PHASE}" != "compile" ]]; then
168 # Prevent user problems like bug #348235.
169 eshopts_push -s extglob
170 if is-flagq '-g?(gdb)?([1-9])'; then
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."
176 ewarn "Please try removing -g{,gdb} before reporting a bug."
181 # ccache often causes bogus compile failures, especially when the cache gets
183 if has ccache ${FEATURES}; then
185 ewarn "You have enabled ccache. Please try disabling ccache"
186 ewarn "before reporting a bug."
191 if use_if_iuse custom-cflags; then
193 ewarn "You have enabled the custom-cflags USE flag."
194 ewarn "Please disable it before reporting a bug."
198 # If the system doesn't have enough memory, the compilation is known to
199 # fail. Print info about memory to recognize this condition.
201 einfo "$(grep MemTotal /proc/meminfo)"
202 einfo "$(grep SwapTotal /proc/meminfo)"
206 # @VARIABLE: EGYP_CHROMIUM_COMMAND
208 # Path to the gyp_chromium script.
209 : ${EGYP_CHROMIUM_COMMAND:=build/gyp_chromium}
211 # @VARIABLE: EGYP_CHROMIUM_DEPTH
213 # Depth for egyp_chromium.
214 : ${EGYP_CHROMIUM_DEPTH:=.}
216 # @FUNCTION: egyp_chromium
217 # @USAGE: [gyp arguments]
219 # Calls EGYP_CHROMIUM_COMMAND with depth EGYP_CHROMIUM_DEPTH and given
220 # arguments. The full command line is echoed for logging.
222 set -- "${EGYP_CHROMIUM_COMMAND}" --depth="${EGYP_CHROMIUM_DEPTH}" "$@"
228 # @USAGE: <USE flag> [GYP flag] [true suffix] [false suffix]
230 # If USE flag is set, echo -D[GYP flag]=[true suffix].
232 # If USE flag is not set, echo -D[GYP flag]=[false suffix].
234 # [GYP flag] defaults to use_[USE flag] with hyphens converted to underscores.
236 # [true suffix] defaults to 1. [false suffix] defaults to 0.
238 local gypflag="-D${2:-use_${1//-/_}}="
239 usex "$1" "${gypflag}" "${gypflag}" "${3-1}" "${4-0}"
242 # @FUNCTION: chromium_bundled_v8_version
243 # @USAGE: [path to version.cc]
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}"
256 # @FUNCTION: chromium_installed_v8_version
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-}