Merge remote-tracking branch 'github/pr/481'.
[gentoo.git] / www-client / chromium / chromium-47.0.2526.106.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="5"
6 PYTHON_COMPAT=( python2_7 )
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"
11
12 inherit check-reqs chromium eutils flag-o-matic multilib multiprocessing pax-utils \
13         portability python-any-r1 readme.gentoo toolchain-funcs versionator virtualx
14
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"
18
19 LICENSE="BSD hotwording? ( no-source-code )"
20 SLOT="0"
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 ) )"
24
25 # Native Client binaries are compiled with different set of flags, bug #452066.
26 QA_FLAGS_IGNORED=".*\.nexe"
27
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"
31
32 RDEPEND=">=app-accessibility/speech-dispatcher-0.8:=
33         app-arch/bzip2:=
34         app-arch/snappy:=
35         cups? ( >=net-print/cups-1.3.11:= )
36         >=dev-libs/elfutils-0.149
37         dev-libs/expat:=
38         dev-libs/glib:=
39         >=dev-libs/icu-55.1:=
40         >=dev-libs/jsoncpp-0.5.0-r1:=
41         >=dev-libs/libevent-1.4.13:=
42         dev-libs/libxml2:=[icu]
43         dev-libs/libxslt:=
44         dev-libs/nspr:=
45         >=dev-libs/nss-3.14.3:=
46         dev-libs/re2:=
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:=
50         media-libs/flac:=
51         media-libs/fontconfig:=
52         media-libs/freetype:=
53         media-libs/harfbuzz:=[icu(+)]
54         media-libs/libexif:=
55         >=media-libs/libjpeg-turbo-1.2.0-r1:=
56         media-libs/libpng:0=
57         >=media-libs/libwebp-0.4.0:=
58         media-libs/speex:=
59         pulseaudio? ( media-sound/pulseaudio:= )
60         system-ffmpeg? ( >=media-video/ffmpeg-2.7.2:=[opus,vorbis,vpx] )
61         sys-apps/dbus:=
62         sys-apps/pciutils:=
63         >=sys-libs/libcap-2.22:=
64         sys-libs/zlib:=[minizip]
65         virtual/udev
66         x11-libs/cairo:=
67         x11-libs/gdk-pixbuf:=
68         gtk3? ( x11-libs/gtk+:3= )
69         !gtk3? ( x11-libs/gtk+:2= )
70         x11-libs/libdrm
71         x11-libs/libX11:=
72         x11-libs/libXcomposite:=
73         x11-libs/libXcursor:=
74         x11-libs/libXdamage:=
75         x11-libs/libXext:=
76         x11-libs/libXfixes:=
77         >=x11-libs/libXi-1.6.0:=
78         x11-libs/libXinerama:=
79         x11-libs/libXrandr:=
80         x11-libs/libXrender:=
81         x11-libs/libXScrnSaver:=
82         x11-libs/libXtst:=
83         x11-libs/pango:=
84         kerberos? ( virtual/krb5 )"
85 DEPEND="${RDEPEND}
86         !arm? (
87                 dev-lang/yasm
88         )
89         dev-lang/perl
90         dev-perl/JSON
91         >=dev-util/gperf-3.0.3
92         dev-util/ninja
93         sys-apps/hwids[usb(+)]
94         >=sys-devel/bison-2.4.3
95         sys-devel/flex
96         virtual/pkgconfig"
97
98 # For nvidia-drivers blocker, see bug #413637 .
99 RDEPEND+="
100         !=www-client/chromium-9999
101         !<www-plugins/chrome-binary-plugins-37
102         x11-misc/xdg-utils
103         virtual/opengl
104         virtual/ttf-fonts
105         selinux? ( sec-policy/selinux-chromium )
106         tcmalloc? ( !<x11-drivers/nvidia-drivers-331.20 )
107         widevine? ( www-plugins/chrome-binary-plugins[widevine(-)] )"
108
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}]
118 ')"
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}]"
126 }
127
128 if ! has chromium_pkg_die ${EBUILD_DEATH_HOOKS}; then
129         EBUILD_DEATH_HOOKS+=" chromium_pkg_die";
130 fi
131
132 DISABLE_AUTOFORMATTING="yes"
133 DOC_CONTENTS="
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
139 - media-fonts/droid
140 - media-fonts/ipamonafont
141 - media-fonts/ja-ipafonts
142 - media-fonts/takao-fonts
143 - media-fonts/wqy-microhei
144 - media-fonts/wqy-zenhei
145
146 Depending on your desktop environment, you may need
147 to install additional packages to get icons on the Downloads page.
148
149 For KDE, the required package is kde-frameworks/oxygen-icons.
150
151 For other desktop environments, try one of the following:
152 - x11-themes/gnome-icon-theme
153 - x11-themes/tango-icon-theme
154 "
155
156 pkg_pretend() {
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.'
160         fi
161
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"
168         fi
169         eshopts_pop
170         check-reqs_pkg_pretend
171 }
172
173 pkg_setup() {
174         if [[ "${SLOT}" == "0" ]]; then
175                 CHROMIUM_SUFFIX=""
176         else
177                 CHROMIUM_SUFFIX="-${SLOT}"
178         fi
179         CHROMIUM_HOME="/usr/$(get_libdir)/chromium-browser${CHROMIUM_SUFFIX}"
180
181         # Make sure the build system will use the right python, bug #344367.
182         python-any-r1_pkg_setup
183
184         chromium_suid_sandbox_check_kernel_config
185 }
186
187 src_prepare() {
188         # if ! use arm; then
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
194         # fi
195
196         epatch "${FILESDIR}/${PN}-system-ffmpeg-r0.patch"
197         epatch "${FILESDIR}/${PN}-system-jinja-r7.patch"
198         epatch "${FILESDIR}/chromium-widevine-r1.patch"
199
200         epatch_user
201
202         local conditional_bundled_libraries=""
203         if ! use system-ffmpeg; then
204                 conditional_bundled_libraries+=" third_party/ffmpeg"
205         fi
206
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' \
247                 'third_party/flot' \
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' \
269                 'third_party/lss' \
270                 'third_party/lzma_sdk' \
271                 'third_party/mesa' \
272                 'third_party/modp_b64' \
273                 'third_party/mojo' \
274                 'third_party/mt19937ar' \
275                 'third_party/npapi' \
276                 'third_party/openmax_dl' \
277                 'third_party/opus' \
278                 'third_party/ots' \
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' \
290                 'third_party/qcms' \
291                 'third_party/readability' \
292                 'third_party/sfntly' \
293                 'third_party/skia' \
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' \
307                 --do-remove || die
308 }
309
310 src_configure() {
311         local myconf=""
312
313         # Never tell the build system to "enable" SSE2, it has a few unexpected
314         # additions, bug #336871.
315         myconf+=" -Ddisable_sse2=1"
316
317         # Disable nacl, we can't build without pnacl (http://crbug.com/269560).
318         myconf+=" -Ddisable_nacl=1"
319
320         # Disable glibc Native Client toolchain, we don't need it (bug #417019).
321         # myconf+=" -Ddisable_glibc=1"
322
323         # TODO: also build with pnacl
324         # myconf+=" -Ddisable_pnacl=1"
325
326         # It would be awkward for us to tar the toolchain and get it untarred again
327         # during the build.
328         # myconf+=" -Ddisable_newlib_untar=1"
329
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"
333
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).
343         myconf+="
344                 -Duse_system_bzip2=1
345                 -Duse_system_ffmpeg=$(usex system-ffmpeg 1 0)
346                 -Duse_system_flac=1
347                 -Duse_system_harfbuzz=1
348                 -Duse_system_icu=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
357                 -Duse_system_nspr=1
358                 -Duse_system_re2=1
359                 -Duse_system_snappy=1
360                 -Duse_system_speex=1
361                 -Duse_system_xdg_utils=1
362                 -Duse_system_zlib=1"
363
364         # Needed for system icu - we don't need additional data files.
365         myconf+=" -Dicu_use_data_file_flag=0"
366
367         # TODO: patch gyp so that this arm conditional is not needed.
368         if ! use arm; then
369                 myconf+="
370                         -Duse_system_yasm=1"
371         fi
372
373         # Optional dependencies.
374         # TODO: linux_link_kerberos, bug #381289.
375         myconf+="
376                 $(gyp_use cups)
377                 $(gyp_use gnome use_gconf)
378                 $(gyp_use gnome-keyring use_gnome_keyring)
379                 $(gyp_use gnome-keyring linux_link_gnome_keyring)
380                 $(gyp_use gtk3)
381                 $(gyp_use hangouts enable_hangout_services_extension)
382                 $(gyp_use hidpi enable_hidpi)
383                 $(gyp_use hotwording enable_hotwording)
384                 $(gyp_use kerberos)
385                 $(gyp_use pulseaudio)
386                 $(gyp_use tcmalloc use_allocator tcmalloc none)
387                 $(gyp_use widevine enable_widevine)"
388
389         # Use explicit library dependencies instead of dlopen.
390         # This makes breakages easier to detect by revdep-rebuild.
391         myconf+="
392                 -Dlinux_link_gsettings=1
393                 -Dlinux_link_libpci=1
394                 -Dlinux_link_libspeechd=1
395                 -Dlibspeechd_h_prefix=speech-dispatcher/"
396
397         # TODO: use the file at run time instead of effectively compiling it in.
398         myconf+="
399                 -Dusb_ids_path=/usr/share/misc/usb.ids"
400
401         # Save space by removing DLOG and DCHECK messages (about 6% reduction).
402         myconf+="
403                 -Dlogging_like_official_build=1"
404
405         if [[ $(tc-getCC) == *clang* ]]; then
406                 myconf+=" -Dclang=1"
407         else
408                 myconf+=" -Dclang=0"
409         fi
410
411         # Never use bundled gold binary. Disable gold linker flags for now.
412         # Do not use bundled clang.
413         myconf+="
414                 -Dclang_use_chrome_plugins=0
415                 -Dhost_clang=0
416                 -Dlinux_use_bundled_binutils=0
417                 -Dlinux_use_bundled_gold=0
418                 -Dlinux_use_gold_flags=0"
419
420         ffmpeg_branding="$(usex proprietary-codecs Chrome Chromium)"
421         myconf+=" -Dproprietary_codecs=1 -Dffmpeg_branding=${ffmpeg_branding}"
422
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
426         # for more info.
427         myconf+=" -Dgoogle_api_key=AIzaSyDEAOvatFo0eTgsV_ZlEzx0ObmepsMzfAc
428                 -Dgoogle_default_client_id=329227923882.apps.googleusercontent.com
429                 -Dgoogle_default_client_secret=vgKG0NNv7GoDpbtoFNLxCUXu"
430
431         local myarch="$(tc-arch)"
432         if [[ $myarch = amd64 ]] ; then
433                 target_arch=x64
434                 ffmpeg_target_arch=x64
435         elif [[ $myarch = x86 ]] ; then
436                 target_arch=ia32
437                 ffmpeg_target_arch=ia32
438         elif [[ $myarch = arm ]] ; then
439                 target_arch=arm
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
444
445                         myconf+=" -Darm_float_abi=hard"
446                 fi
447                 filter-flags "-mfpu=*"
448                 use neon || myconf+=" -Darm_fpu=${ARM_FPU:-vfpv3-d16}"
449
450                 if [[ ${CTARGET} == armv[78]* ]]; then
451                         myconf+=" -Darmv7=1"
452                 else
453                         myconf+=" -Darmv7=0"
454                 fi
455                 myconf+=" -Dsysroot=
456                         $(gyp_use neon arm_neon)
457                         -Ddisable_nacl=1"
458         else
459                 die "Failed to determine target arch, got '$myarch'."
460         fi
461
462         myconf+=" -Dtarget_arch=${target_arch}"
463
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.
467         myconf+=" -Dwerror="
468
469         # Disable fatal linker warnings, bug 506268.
470         myconf+=" -Ddisable_fatal_linker_warnings=1"
471
472         # Avoid CFLAGS problems, bug #352457, bug #390147.
473         if ! use custom-cflags; then
474                 replace-flags "-Os" "-O2"
475                 strip-flags
476
477                 # Prevent linker from running out of address space, bug #471810 .
478                 if use x86; then
479                         filter-flags "-g*"
480                 fi
481
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
485                 fi
486         fi
487
488         # Make sure the build system will use the right tools, bug #340795.
489         tc-export AR CC CXX NM
490
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)
497         fi
498
499         # Bug 491582.
500         export TMPDIR="${WORKDIR}/temp"
501         mkdir -p -m 755 "${TMPDIR}" || die
502
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"
507                 fi
508
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
517         fi
518
519         third_party/libaddressinput/chromium/tools/update-strings.py || die
520
521         touch chrome/test/data/webui/i18n_process_css_test.html || die
522
523         einfo "Configuring Chromium..."
524         build/linux/unbundle/replace_gyp_files.py ${myconf} || die
525         egyp_chromium ${myconf} || die
526 }
527
528 eninja() {
529         if [[ -z ${NINJAOPTS+set} ]]; then
530                 local jobs=$(makeopts_jobs)
531                 local loadavg=$(makeopts_loadavg)
532
533                 if [[ ${MAKEOPTS} == *-j* && ${jobs} != 999 ]]; then
534                         NINJAOPTS+=" -j ${jobs}"
535                 fi
536                 if [[ ${MAKEOPTS} == *-l* && ${loadavg} != 999 ]]; then
537                         NINJAOPTS+=" -l ${loadavg}"
538                 fi
539         fi
540         set -- ninja -v ${NINJAOPTS} "$@"
541         echo "$@"
542         "$@"
543 }
544
545 src_compile() {
546         local ninja_targets="chrome chrome_sandbox chromedriver"
547
548         # Build mksnapshot and pax-mark it.
549         eninja -C out/Release mksnapshot || die
550         pax-mark m out/Release/mksnapshot
551
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
555
556         pax-mark m out/Release/chrome
557 }
558
559 src_install() {
560         exeinto "${CHROMIUM_HOME}"
561         doexe out/Release/chrome || die
562
563         newexe out/Release/chrome_sandbox chrome-sandbox || die
564         fperms 4755 "${CHROMIUM_HOME}/chrome-sandbox"
565
566         doexe out/Release/chromedriver || die
567         use widevine && doexe out/Release/libwidevinecdmadapter.so
568
569         # if ! use arm; then
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
574         # fi
575
576         local sedargs=( -e "s:/usr/lib/:/usr/$(get_libdir)/:g" )
577         if [[ -n ${CHROMIUM_SUFFIX} ]]; then
578                 sedargs+=(
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}:"
582                 )
583         fi
584         sed "${sedargs[@]}" "${FILESDIR}/chromium-launcher-r3.sh" > chromium-launcher.sh || die
585         doexe chromium-launcher.sh
586
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
592
593         dosym "${CHROMIUM_HOME}/chromedriver" /usr/bin/chromedriver${CHROMIUM_SUFFIX} || die
594
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
599
600         pushd out/Release/locales > /dev/null || die
601         chromium_remove_language_paks
602         popd
603
604         insinto "${CHROMIUM_HOME}"
605         doins out/Release/*.bin || die
606         doins out/Release/*.pak || die
607
608         doins -r out/Release/locales || die
609         doins -r out/Release/resources || die
610
611         newman out/Release/chrome.1 chromium${CHROMIUM_SUFFIX}.1 || die
612         newman out/Release/chrome.1 chromium-browser${CHROMIUM_SUFFIX}.1 || die
613
614         # Install icons and desktop entry.
615         local branding size
616         for size in 16 22 24 32 48 64 128 256 ; do
617                 case ${size} in
618                         16|32) branding="chrome/app/theme/default_100_percent/chromium" ;;
619                                 *) branding="chrome/app/theme/chromium" ;;
620                 esac
621                 newicon -s ${size} "${branding}/product_logo_${size}.png" \
622                         chromium-browser${CHROMIUM_SUFFIX}.png
623         done
624
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
629         make_desktop_entry \
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
636
637         # Install GNOME default application entry (bug #303100).
638         if use gnome; then
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
645                 fi
646         fi
647
648         readme.gentoo_create_doc
649 }
650
651 pkg_postinst() {
652         fdo-mime_desktop_database_update
653         gnome2_icon_cache_update
654         readme.gentoo_print_elog
655 }