Gentoo Archives: gentoo-commits

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