1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python2_7 )
8 CHROMIUM_LANGS="am ar bg bn ca cs da de el en_GB es es_LA et fa fi fil fr gu he
9 hi hr hu id it ja kn ko lt lv ml mr ms nb nl pl pt_BR pt_PT ro ru sk sl sr
10 sv sw ta te th tr uk vi zh_CN zh_TW"
12 inherit check-reqs chromium eutils flag-o-matic multilib multiprocessing pax-utils \
13 portability python-any-r1 readme.gentoo toolchain-funcs versionator virtualx
15 DESCRIPTION="Open-source version of Google Chrome web browser"
16 HOMEPAGE="http://chromium.org/"
17 SRC_URI="https://commondatastorage.googleapis.com/chromium-browser-official/${P}-lite.tar.xz"
19 LICENSE="BSD hotwording? ( no-source-code )"
21 KEYWORDS="~amd64 ~arm ~x86"
22 IUSE="cups gnome gnome-keyring gtk3 +hangouts hidpi hotwording kerberos neon pic +proprietary-codecs pulseaudio selinux +system-ffmpeg +tcmalloc widevine"
23 RESTRICT="!system-ffmpeg? ( proprietary-codecs? ( bindist ) )"
25 # Native Client binaries are compiled with different set of flags, bug #452066.
26 QA_FLAGS_IGNORED=".*\.nexe"
28 # Native Client binaries may be stripped by the build system, which uses the
29 # right tools for it, bug #469144 .
30 QA_PRESTRIPPED=".*\.nexe"
32 RDEPEND=">=app-accessibility/speech-dispatcher-0.8:=
35 cups? ( >=net-print/cups-1.3.11:= )
36 >=dev-libs/elfutils-0.149
40 >=dev-libs/jsoncpp-0.5.0-r1:=
41 >=dev-libs/libevent-1.4.13:=
42 dev-libs/libxml2:=[icu]
45 >=dev-libs/nss-3.14.3:=
47 gnome? ( >=gnome-base/gconf-2.24.0:= )
48 gnome-keyring? ( >=gnome-base/libgnome-keyring-3.12:= )
49 >=media-libs/alsa-lib-1.0.19:=
51 media-libs/fontconfig:=
53 media-libs/harfbuzz:=[icu(+)]
55 >=media-libs/libjpeg-turbo-1.2.0-r1:=
57 >=media-libs/libwebp-0.4.0:=
59 pulseaudio? ( media-sound/pulseaudio:= )
60 system-ffmpeg? ( >=media-video/ffmpeg-2.7.2:=[opus,vorbis,vpx] )
63 >=sys-libs/libcap-2.22:=
64 sys-libs/zlib:=[minizip]
68 gtk3? ( x11-libs/gtk+:3= )
69 !gtk3? ( x11-libs/gtk+:2= )
72 x11-libs/libXcomposite:=
77 >=x11-libs/libXi-1.6.0:=
78 x11-libs/libXinerama:=
81 x11-libs/libXScrnSaver:=
84 kerberos? ( virtual/krb5 )"
91 >=dev-util/gperf-3.0.3
93 sys-apps/hwids[usb(+)]
94 >=sys-devel/bison-2.4.3
98 # For nvidia-drivers blocker, see bug #413637 .
100 !=www-client/chromium-9999
101 !<www-plugins/chrome-binary-plugins-37
105 selinux? ( sec-policy/selinux-chromium )
106 tcmalloc? ( !<x11-drivers/nvidia-drivers-331.20 )
107 widevine? ( www-plugins/chrome-binary-plugins[widevine(-)] )"
109 # Python dependencies. The DEPEND part needs to be kept in sync
110 # with python_check_deps.
111 DEPEND+=" $(python_gen_any_dep '
112 dev-python/beautifulsoup:python-2[${PYTHON_USEDEP}]
113 dev-python/beautifulsoup:4[${PYTHON_USEDEP}]
114 dev-python/html5lib[${PYTHON_USEDEP}]
115 dev-python/jinja[${PYTHON_USEDEP}]
116 dev-python/ply[${PYTHON_USEDEP}]
117 dev-python/simplejson[${PYTHON_USEDEP}]
119 python_check_deps() {
120 has_version "dev-python/beautifulsoup:python-2[${PYTHON_USEDEP}]" && \
121 has_version "dev-python/beautifulsoup:4[${PYTHON_USEDEP}]" && \
122 has_version "dev-python/html5lib[${PYTHON_USEDEP}]" && \
123 has_version "dev-python/jinja[${PYTHON_USEDEP}]" && \
124 has_version "dev-python/ply[${PYTHON_USEDEP}]" && \
125 has_version "dev-python/simplejson[${PYTHON_USEDEP}]"
128 if ! has chromium_pkg_die ${EBUILD_DEATH_HOOKS}; then
129 EBUILD_DEATH_HOOKS+=" chromium_pkg_die";
132 DISABLE_AUTOFORMATTING="yes"
134 Some web pages may require additional fonts to display properly.
135 Try installing some of the following packages if some characters
136 are not displayed properly:
137 - media-fonts/arphicfonts
138 - media-fonts/bitstream-cyberbit
140 - media-fonts/ipamonafont
141 - media-fonts/ja-ipafonts
142 - media-fonts/takao-fonts
143 - media-fonts/wqy-microhei
144 - media-fonts/wqy-zenhei
146 Depending on your desktop environment, you may need
147 to install additional packages to get icons on the Downloads page.
149 For KDE, the required package is kde-frameworks/oxygen-icons.
151 For other desktop environments, try one of the following:
152 - x11-themes/gnome-icon-theme
153 - x11-themes/tango-icon-theme
157 if [[ $(tc-getCC)$ == *gcc* ]] && \
158 [[ $(gcc-major-version)$(gcc-minor-version) -lt 48 ]]; then
159 die 'At least gcc 4.8 is required, see bugs: #535730, #525374, #518668.'
162 # Check build requirements, bug #541816 and bug #471810 .
163 CHECKREQS_MEMORY="3G"
164 CHECKREQS_DISK_BUILD="5G"
165 eshopts_push -s extglob
166 if is-flagq '-g?(gdb)?([1-9])'; then
167 CHECKREQS_DISK_BUILD="25G"
170 check-reqs_pkg_pretend
174 if [[ "${SLOT}" == "0" ]]; then
177 CHROMIUM_SUFFIX="-${SLOT}"
179 CHROMIUM_HOME="/usr/$(get_libdir)/chromium-browser${CHROMIUM_SUFFIX}"
181 # Make sure the build system will use the right python, bug #344367.
182 python-any-r1_pkg_setup
184 chromium_suid_sandbox_check_kernel_config
189 # mkdir -p out/Release/gen/sdk/toolchain || die
190 # # Do not preserve SELinux context, bug #460892 .
191 # cp -a --no-preserve=context /usr/$(get_libdir)/nacl-toolchain-newlib \
192 # out/Release/gen/sdk/toolchain/linux_x86_newlib || die
193 # touch out/Release/gen/sdk/toolchain/linux_x86_newlib/stamp.untar || die
196 epatch "${FILESDIR}/${PN}-system-ffmpeg-r0.patch"
197 epatch "${FILESDIR}/${PN}-system-jinja-r7.patch"
198 epatch "${FILESDIR}/chromium-widevine-r1.patch"
202 local conditional_bundled_libraries=""
203 if ! use system-ffmpeg; then
204 conditional_bundled_libraries+=" third_party/ffmpeg"
207 # Remove most bundled libraries. Some are still needed.
208 build/linux/unbundle/remove_bundled_libraries.py \
209 ${conditional_bundled_libraries} \
210 'base/third_party/dmg_fp' \
211 'base/third_party/dynamic_annotations' \
212 'base/third_party/icu' \
213 'base/third_party/nspr' \
214 'base/third_party/superfasthash' \
215 'base/third_party/symbolize' \
216 'base/third_party/valgrind' \
217 'base/third_party/xdg_mime' \
218 'base/third_party/xdg_user_dirs' \
219 'breakpad/src/third_party/curl' \
220 'chrome/third_party/mozilla_security_manager' \
221 'courgette/third_party' \
222 'crypto/third_party/nss' \
223 'net/third_party/mozilla_security_manager' \
224 'net/third_party/nss' \
225 'third_party/WebKit' \
226 'third_party/analytics' \
227 'third_party/angle' \
228 'third_party/angle/src/third_party/compiler' \
229 'third_party/boringssl' \
230 'third_party/brotli' \
231 'third_party/cacheinvalidation' \
232 'third_party/catapult' \
233 'third_party/catapult/tracing/third_party/components/polymer' \
234 'third_party/catapult/tracing/third_party/d3' \
235 'third_party/catapult/tracing/third_party/gl-matrix' \
236 'third_party/catapult/tracing/third_party/jszip' \
237 'third_party/catapult/tracing/third_party/tvcm' \
238 'third_party/catapult/tracing/third_party/tvcm/third_party/rcssmin' \
239 'third_party/catapult/tracing/third_party/tvcm/third_party/rjsmin' \
240 'third_party/cld_2' \
241 'third_party/cros_system_api' \
242 'third_party/cython/python_flags.py' \
243 'third_party/devscripts' \
244 'third_party/dom_distiller_js' \
245 'third_party/dom_distiller_js/dist/proto_gen/third_party/dom_distiller_js' \
246 'third_party/fips181' \
248 'third_party/google_input_tools' \
249 'third_party/google_input_tools/third_party/closure_library' \
250 'third_party/google_input_tools/third_party/closure_library/third_party/closure' \
251 'third_party/hunspell' \
252 'third_party/iccjpeg' \
253 'third_party/jstemplate' \
254 'third_party/khronos' \
255 'third_party/leveldatabase' \
256 'third_party/libXNVCtrl' \
257 'third_party/libaddressinput' \
258 'third_party/libjingle' \
259 'third_party/libphonenumber' \
260 'third_party/libsecret' \
261 'third_party/libsrtp' \
262 'third_party/libudev' \
263 'third_party/libusb' \
264 'third_party/libvpx_new' \
265 'third_party/libvpx_new/source/libvpx/third_party/x86inc' \
266 'third_party/libxml/chromium' \
267 'third_party/libwebm' \
268 'third_party/libyuv' \
270 'third_party/lzma_sdk' \
272 'third_party/modp_b64' \
274 'third_party/mt19937ar' \
275 'third_party/npapi' \
276 'third_party/openmax_dl' \
279 'third_party/pdfium' \
280 'third_party/pdfium/third_party/agg23' \
281 'third_party/pdfium/third_party/base' \
282 'third_party/pdfium/third_party/bigint' \
283 'third_party/pdfium/third_party/freetype' \
284 'third_party/pdfium/third_party/lcms2-2.6' \
285 'third_party/pdfium/third_party/libjpeg' \
286 'third_party/pdfium/third_party/libopenjpeg20' \
287 'third_party/pdfium/third_party/zlib_v128' \
288 'third_party/polymer' \
289 'third_party/protobuf' \
291 'third_party/readability' \
292 'third_party/sfntly' \
294 'third_party/smhasher' \
295 'third_party/sqlite' \
296 'third_party/tcmalloc' \
297 'third_party/usrsctp' \
298 'third_party/web-animations-js' \
299 'third_party/webdriver' \
300 'third_party/webrtc' \
301 'third_party/widevine' \
302 'third_party/x86inc' \
303 'third_party/zlib/google' \
304 'url/third_party/mozilla' \
305 'v8/src/third_party/fdlibm' \
306 'v8/src/third_party/valgrind' \
313 # Never tell the build system to "enable" SSE2, it has a few unexpected
314 # additions, bug #336871.
315 myconf+=" -Ddisable_sse2=1"
317 # Disable nacl, we can't build without pnacl (http://crbug.com/269560).
318 myconf+=" -Ddisable_nacl=1"
320 # Disable glibc Native Client toolchain, we don't need it (bug #417019).
321 # myconf+=" -Ddisable_glibc=1"
323 # TODO: also build with pnacl
324 # myconf+=" -Ddisable_pnacl=1"
326 # It would be awkward for us to tar the toolchain and get it untarred again
328 # myconf+=" -Ddisable_newlib_untar=1"
330 # Make it possible to remove third_party/adobe.
331 echo > "${T}/flapper_version.h" || die
332 myconf+=" -Dflapper_version_h_file=${T}/flapper_version.h"
334 # Use system-provided libraries.
335 # TODO: use_system_hunspell (upstream changes needed).
336 # TODO: use_system_libsrtp (bug #459932).
337 # TODO: use_system_libusb (http://crbug.com/266149).
338 # TODO: use_system_libvpx (http://crbug.com/494939).
339 # TODO: use_system_opus (https://code.google.com/p/webrtc/issues/detail?id=3077).
340 # TODO: use_system_protobuf (bug #525560).
341 # TODO: use_system_ssl (http://crbug.com/58087).
342 # TODO: use_system_sqlite (http://crbug.com/22208).
345 -Duse_system_ffmpeg=$(usex system-ffmpeg 1 0)
347 -Duse_system_harfbuzz=1
349 -Duse_system_jsoncpp=1
350 -Duse_system_libevent=1
351 -Duse_system_libjpeg=1
352 -Duse_system_libpng=1
353 -Duse_system_libwebp=1
354 -Duse_system_libxml=1
355 -Duse_system_libxslt=1
356 -Duse_system_minizip=1
359 -Duse_system_snappy=1
361 -Duse_system_xdg_utils=1
364 # Needed for system icu - we don't need additional data files.
365 myconf+=" -Dicu_use_data_file_flag=0"
367 # TODO: patch gyp so that this arm conditional is not needed.
373 # Optional dependencies.
374 # TODO: linux_link_kerberos, bug #381289.
377 $(gyp_use gnome use_gconf)
378 $(gyp_use gnome-keyring use_gnome_keyring)
379 $(gyp_use gnome-keyring linux_link_gnome_keyring)
381 $(gyp_use hangouts enable_hangout_services_extension)
382 $(gyp_use hidpi enable_hidpi)
383 $(gyp_use hotwording enable_hotwording)
385 $(gyp_use pulseaudio)
386 $(gyp_use tcmalloc use_allocator tcmalloc none)
387 $(gyp_use widevine enable_widevine)"
389 # Use explicit library dependencies instead of dlopen.
390 # This makes breakages easier to detect by revdep-rebuild.
392 -Dlinux_link_gsettings=1
393 -Dlinux_link_libpci=1
394 -Dlinux_link_libspeechd=1
395 -Dlibspeechd_h_prefix=speech-dispatcher/"
397 # TODO: use the file at run time instead of effectively compiling it in.
399 -Dusb_ids_path=/usr/share/misc/usb.ids"
401 # Save space by removing DLOG and DCHECK messages (about 6% reduction).
403 -Dlogging_like_official_build=1"
405 if [[ $(tc-getCC) == *clang* ]]; then
411 # Never use bundled gold binary. Disable gold linker flags for now.
412 # Do not use bundled clang.
414 -Dclang_use_chrome_plugins=0
416 -Dlinux_use_bundled_binutils=0
417 -Dlinux_use_bundled_gold=0
418 -Dlinux_use_gold_flags=0"
420 ffmpeg_branding="$(usex proprietary-codecs Chrome Chromium)"
421 myconf+=" -Dproprietary_codecs=1 -Dffmpeg_branding=${ffmpeg_branding}"
423 # Set up Google API keys, see http://www.chromium.org/developers/how-tos/api-keys .
424 # Note: these are for Gentoo use ONLY. For your own distribution,
425 # please get your own set of keys. Feel free to contact chromium@gentoo.org
427 myconf+=" -Dgoogle_api_key=AIzaSyDEAOvatFo0eTgsV_ZlEzx0ObmepsMzfAc
428 -Dgoogle_default_client_id=329227923882.apps.googleusercontent.com
429 -Dgoogle_default_client_secret=vgKG0NNv7GoDpbtoFNLxCUXu"
431 local myarch="$(tc-arch)"
432 if [[ $myarch = amd64 ]] ; then
434 ffmpeg_target_arch=x64
435 elif [[ $myarch = x86 ]] ; then
437 ffmpeg_target_arch=ia32
438 elif [[ $myarch = arm ]] ; then
440 ffmpeg_target_arch=$(usex neon arm-neon arm)
441 # TODO: re-enable NaCl (NativeClient).
442 local CTARGET=${CTARGET:-${CHOST}}
443 if [[ $(tc-is-softfloat) == "no" ]]; then
445 myconf+=" -Darm_float_abi=hard"
447 filter-flags "-mfpu=*"
448 use neon || myconf+=" -Darm_fpu=${ARM_FPU:-vfpv3-d16}"
450 if [[ ${CTARGET} == armv[78]* ]]; then
456 $(gyp_use neon arm_neon)
459 die "Failed to determine target arch, got '$myarch'."
462 myconf+=" -Dtarget_arch=${target_arch}"
464 # Make sure that -Werror doesn't get added to CFLAGS by the build system.
465 # Depending on GCC version the warnings are different and we don't want
466 # the build to fail because of that.
469 # Disable fatal linker warnings, bug 506268.
470 myconf+=" -Ddisable_fatal_linker_warnings=1"
472 # Avoid CFLAGS problems, bug #352457, bug #390147.
473 if ! use custom-cflags; then
474 replace-flags "-Os" "-O2"
477 # Prevent linker from running out of address space, bug #471810 .
482 # Prevent libvpx build failures. Bug 530248, 544702, 546984.
483 if [[ ${myarch} == amd64 || ${myarch} == x86 ]]; then
484 filter-flags -mno-mmx -mno-sse2 -mno-ssse3 -mno-sse4.1 -mno-avx -mno-avx2
488 # Make sure the build system will use the right tools, bug #340795.
489 tc-export AR CC CXX NM
491 # Tools for building programs to be executed on the build system, bug #410883.
492 if tc-is-cross-compiler; then
493 export AR_host=$(tc-getBUILD_AR)
494 export CC_host=$(tc-getBUILD_CC)
495 export CXX_host=$(tc-getBUILD_CXX)
496 export NM_host=$(tc-getBUILD_NM)
500 export TMPDIR="${WORKDIR}/temp"
501 mkdir -p -m 755 "${TMPDIR}" || die
503 if ! use system-ffmpeg; then
504 local build_ffmpeg_args=""
505 if use pic && [[ "${ffmpeg_target_arch}" == "ia32" ]]; then
506 build_ffmpeg_args+=" --disable-asm"
509 # Re-configure bundled ffmpeg. See bug #491378 for example reasons.
510 einfo "Configuring bundled ffmpeg..."
511 pushd third_party/ffmpeg > /dev/null || die
512 chromium/scripts/build_ffmpeg.py linux ${ffmpeg_target_arch} \
513 --branding ${ffmpeg_branding} -- ${build_ffmpeg_args} || die
514 chromium/scripts/copy_config.sh || die
515 chromium/scripts/generate_gyp.py || die
516 popd > /dev/null || die
519 third_party/libaddressinput/chromium/tools/update-strings.py || die
521 touch chrome/test/data/webui/i18n_process_css_test.html || die
523 einfo "Configuring Chromium..."
524 build/linux/unbundle/replace_gyp_files.py ${myconf} || die
525 egyp_chromium ${myconf} || die
529 if [[ -z ${NINJAOPTS+set} ]]; then
530 local jobs=$(makeopts_jobs)
531 local loadavg=$(makeopts_loadavg)
533 if [[ ${MAKEOPTS} == *-j* && ${jobs} != 999 ]]; then
534 NINJAOPTS+=" -j ${jobs}"
536 if [[ ${MAKEOPTS} == *-l* && ${loadavg} != 999 ]]; then
537 NINJAOPTS+=" -l ${loadavg}"
540 set -- ninja -v ${NINJAOPTS} "$@"
546 local ninja_targets="chrome chrome_sandbox chromedriver"
548 # Build mksnapshot and pax-mark it.
549 eninja -C out/Release mksnapshot || die
550 pax-mark m out/Release/mksnapshot
552 # Even though ninja autodetects number of CPUs, we respect
553 # user's options, for debugging with -j 1 or any other reason.
554 eninja -C out/Release ${ninja_targets} || die
556 pax-mark m out/Release/chrome
560 exeinto "${CHROMIUM_HOME}"
561 doexe out/Release/chrome || die
563 newexe out/Release/chrome_sandbox chrome-sandbox || die
564 fperms 4755 "${CHROMIUM_HOME}/chrome-sandbox"
566 doexe out/Release/chromedriver || die
567 use widevine && doexe out/Release/libwidevinecdmadapter.so
570 # doexe out/Release/nacl_helper{,_bootstrap} || die
571 # insinto "${CHROMIUM_HOME}"
572 # doins out/Release/nacl_irt_*.nexe || die
573 # doins out/Release/libppGoogleNaClPluginChrome.so || die
576 local sedargs=( -e "s:/usr/lib/:/usr/$(get_libdir)/:g" )
577 if [[ -n ${CHROMIUM_SUFFIX} ]]; then
579 -e "s:chromium-browser:chromium-browser${CHROMIUM_SUFFIX}:g"
580 -e "s:chromium.desktop:chromium${CHROMIUM_SUFFIX}.desktop:g"
581 -e "s:plugins:plugins --user-data-dir=\${HOME}/.config/chromium${CHROMIUM_SUFFIX}:"
584 sed "${sedargs[@]}" "${FILESDIR}/chromium-launcher-r3.sh" > chromium-launcher.sh || die
585 doexe chromium-launcher.sh
587 # It is important that we name the target "chromium-browser",
588 # xdg-utils expect it; bug #355517.
589 dosym "${CHROMIUM_HOME}/chromium-launcher.sh" /usr/bin/chromium-browser${CHROMIUM_SUFFIX} || die
590 # keep the old symlink around for consistency
591 dosym "${CHROMIUM_HOME}/chromium-launcher.sh" /usr/bin/chromium${CHROMIUM_SUFFIX} || die
593 dosym "${CHROMIUM_HOME}/chromedriver" /usr/bin/chromedriver${CHROMIUM_SUFFIX} || die
595 # Allow users to override command-line options, bug #357629.
596 dodir /etc/chromium || die
597 insinto /etc/chromium
598 newins "${FILESDIR}/chromium.default" "default" || die
600 pushd out/Release/locales > /dev/null || die
601 chromium_remove_language_paks
604 insinto "${CHROMIUM_HOME}"
605 doins out/Release/*.bin || die
606 doins out/Release/*.pak || die
608 doins -r out/Release/locales || die
609 doins -r out/Release/resources || die
611 newman out/Release/chrome.1 chromium${CHROMIUM_SUFFIX}.1 || die
612 newman out/Release/chrome.1 chromium-browser${CHROMIUM_SUFFIX}.1 || die
614 # Install icons and desktop entry.
616 for size in 16 22 24 32 48 64 128 256 ; do
618 16|32) branding="chrome/app/theme/default_100_percent/chromium" ;;
619 *) branding="chrome/app/theme/chromium" ;;
621 newicon -s ${size} "${branding}/product_logo_${size}.png" \
622 chromium-browser${CHROMIUM_SUFFIX}.png
625 local mime_types="text/html;text/xml;application/xhtml+xml;"
626 mime_types+="x-scheme-handler/http;x-scheme-handler/https;" # bug #360797
627 mime_types+="x-scheme-handler/ftp;" # bug #412185
628 mime_types+="x-scheme-handler/mailto;x-scheme-handler/webcal;" # bug #416393
630 chromium-browser${CHROMIUM_SUFFIX} \
631 "Chromium${CHROMIUM_SUFFIX}" \
632 chromium-browser${CHROMIUM_SUFFIX} \
633 "Network;WebBrowser" \
634 "MimeType=${mime_types}\nStartupWMClass=chromium-browser"
635 sed -e "/^Exec/s/$/ %U/" -i "${ED}"/usr/share/applications/*.desktop || die
637 # Install GNOME default application entry (bug #303100).
639 dodir /usr/share/gnome-control-center/default-apps || die
640 insinto /usr/share/gnome-control-center/default-apps
641 newins "${FILESDIR}"/chromium-browser.xml chromium-browser${CHROMIUM_SUFFIX}.xml || die
642 if [[ "${CHROMIUM_SUFFIX}" != "" ]]; then
643 sed "s:chromium-browser:chromium-browser${CHROMIUM_SUFFIX}:g" -i \
644 "${ED}"/usr/share/gnome-control-center/default-apps/chromium-browser${CHROMIUM_SUFFIX}.xml
648 readme.gentoo_create_doc
652 fdo-mime_desktop_database_update
653 gnome2_icon_cache_update
654 readme.gentoo_print_elog