kde-plasma/breeze-gtk: x86 stable wrt bug #613144
[gentoo.git] / eclass / chromium.eclass
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 # DEPRECATED
5 # This eclass has been deprecated and should not be used by any new ebuilds.
6
7 # @DEAD
8
9 # @ECLASS: chromium.eclass
10 # @MAINTAINER:
11 # Chromium Herd <chromium@gentoo.org>
12 # @AUTHOR:
13 # Mike Gilbert <floppym@gentoo.org>
14 # @BLURB: Shared functions for chromium and google-chrome
15
16 inherit eutils fdo-mime gnome2-utils linux-info
17
18 eqawarn "chromium.eclass is deprecated"
19
20 if [[ ${CHROMIUM_EXPORT_PHASES} != no ]]; then
21         EXPORT_FUNCTIONS pkg_preinst pkg_postinst pkg_postrm
22 fi
23
24 if [[ ${PN} == chromium ]]; then
25         IUSE+=" custom-cflags"
26 fi
27
28 # @FUNCTION: chromium_suid_sandbox_check_kernel_config
29 # @USAGE:
30 # @DESCRIPTION:
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"
34
35         if [[ "${MERGE_TYPE}" == "source" || "${MERGE_TYPE}" == "binary" ]]; then
36                 # Warn if the kernel does not support features needed for sandboxing.
37                 # Bug #363987.
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"
47                 check_extra_config
48         fi
49 }
50
51 # @ECLASS-VARIABLE: CHROMIUM_LANGS
52 # @DEFAULT_UNSET
53 # @DESCRIPTION:
54 # List of language packs available for this package.
55
56 _chromium_set_linguas_IUSE() {
57         [[ ${EAPI:-0} == 0 ]] && die "EAPI=${EAPI} is not supported"
58
59         local lang
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}"
65         done
66 }
67
68 if [[ ${CHROMIUM_LANGS} ]]; then
69         _chromium_set_linguas_IUSE
70 fi
71
72 _chromium_crlang() {
73         echo "${@/_/-}"
74 }
75
76 _chromium_syslang() {
77         echo "${@/-/_}"
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-frameworks/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 }