archrelease: copy trunk to extra-x86_64
[arch-packages.git] / chromium / repos / extra-x86_64 / PKGBUILD
bloba3a7004eac66b82bc6eb6180d727341957516f19
1 # Maintainer: Evangelos Foutras <evangelos@foutrelis.com>
2 # Contributor: Pierre Schmitz <pierre@archlinux.de>
3 # Contributor: Jan "heftig" Steffens <jan.steffens@gmail.com>
4 # Contributor: Daniel J Griffiths <ghost1227@archlinux.us>
6 pkgname=chromium
7 pkgver=104.0.5112.79
8 pkgrel=1
9 _launcher_ver=8
10 _gcc_patchset=2
11 pkgdesc="A web browser built for speed, simplicity, and security"
12 arch=('x86_64')
13 url="https://www.chromium.org/Home"
14 license=('BSD')
15 depends=('gtk3' 'nss' 'alsa-lib' 'xdg-utils' 'libxss' 'libcups' 'libgcrypt'
16          'ttf-liberation' 'systemd' 'dbus' 'libpulse' 'pciutils' 'libva'
17          'desktop-file-utils' 'hicolor-icon-theme')
18 makedepends=('python' 'gn' 'ninja' 'clang' 'lld' 'gperf' 'nodejs' 'pipewire'
19              'java-runtime-headless' 'git')
20 optdepends=('pipewire: WebRTC desktop sharing under Wayland'
21             'kdialog: support for native dialogs in Plasma'
22             'org.freedesktop.secrets: password storage backend on GNOME / Xfce'
23             'kwallet: support for storing passwords in KWallet on Plasma')
24 options=('debug' '!lto') # Chromium adds its own flags for ThinLTO
25 source=(https://commondatastorage.googleapis.com/chromium-browser-official/chromium-$pkgver.tar.xz
26         https://github.com/foutrelis/chromium-launcher/archive/v$_launcher_ver/chromium-launcher-$_launcher_ver.tar.gz
27         https://github.com/stha09/chromium-patches/releases/download/chromium-${pkgver%%.*}-patchset-$_gcc_patchset/chromium-${pkgver%%.*}-patchset-$_gcc_patchset.tar.xz
28         x11-ozone-fix-X11-screensaver-suspension.patch
29         enable-GlobalMediaControlsCastStartStop.patch
30         roll-src-third_party-ffmpeg.patch
31         chromium-tflite-system-zlib.patch
32         remove-no-opaque-pointers-flag.patch
33         use-oauth2-client-switches-as-default.patch)
34 sha256sums=('9cc662f1a84c796521ee17ed2808795ca937fe7f77bc605e788f0304a81dabf3'
35             '213e50f48b67feb4441078d50b0fd431df34323be15be97c55302d3fdac4483a'
36             'ce702099849465927cf47f7bc3a4a27045d0e35e16b17481ebf35e14506bafa7'
37             '9956a843bc8a765c130080616ccd3ebc46ea95c3a2324c4b403bc293a8705eb2'
38             '779fb13f2494209d3a7f1f23a823e59b9dded601866d3ab095937a1a04e19ac6'
39             '30df59a9e2d95dcb720357ec4a83d9be51e59cc5551365da4c0073e68ccdec44'
40             '588c166bf748793758a7df438cfa665b32e09ca8fbd6380be28bc5984a33523c'
41             'ab46b2c26a4dfe86486fd7e31bfc7211c515994a61a8c0cbd742f9c9e3c91873'
42             'e393174d7695d0bafed69e868c5fbfecf07aa6969f3b64596d0bae8b067e1711')
44 # Possible replacements are listed in build/linux/unbundle/replace_gn_files.py
45 # Keys are the names in the above script; values are the dependencies in Arch
46 declare -gA _system_libs=(
47   [ffmpeg]=ffmpeg
48   [flac]=flac
49   [fontconfig]=fontconfig
50   [freetype]=freetype2
51   [harfbuzz-ng]=harfbuzz
52   [icu]=icu
53   [libdrm]=
54   [libjpeg]=libjpeg
55   [libpng]=libpng
56   #[libvpx]=libvpx
57   [libwebp]=libwebp
58   [libxml]=libxml2
59   [libxslt]=libxslt
60   [opus]=opus
61   [re2]=re2
62   [snappy]=snappy
63   [zlib]=minizip
65 _unwanted_bundled_libs=(
66   $(printf "%s\n" ${!_system_libs[@]} | sed 's/^libjpeg$/&_turbo/')
68 depends+=(${_system_libs[@]})
70 # Google API keys (see https://www.chromium.org/developers/how-tos/api-keys)
71 # Note: These are for Arch Linux use ONLY. For your own distribution, please
72 # get your own set of keys.
74 # Starting with Chromium 89 (2021-03-02) the OAuth2 credentials have been left
75 # out: https://archlinux.org/news/chromium-losing-sync-support-in-early-march/
76 _google_api_key=AIzaSyDwr302FpOSkGRpLlUpPThNTDPbXcIn_FM
78 prepare() {
79   cd chromium-$pkgver
81   # Allow building against system libraries in official builds
82   sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \
83     tools/generate_shim_headers/generate_shim_headers.py
85   # https://crbug.com/893950
86   sed -i -e 's/\<xmlMalloc\>/malloc/' -e 's/\<xmlFree\>/free/' \
87     third_party/blink/renderer/core/xml/*.cc \
88     third_party/blink/renderer/core/xml/parser/xml_document_parser.cc \
89     third_party/libxml/chromium/*.cc \
90     third_party/maldoca/src/maldoca/ole/oss_utils.h
92   # Use the --oauth2-client-id= and --oauth2-client-secret= switches for
93   # setting GOOGLE_DEFAULT_CLIENT_ID and GOOGLE_DEFAULT_CLIENT_SECRET at
94   # runtime -- this allows signing into Chromium without baked-in values
95   patch -Np1 -i ../use-oauth2-client-switches-as-default.patch
97   # Remove '-Xclang -no-opaque-pointers' flag not supported by our clang
98   patch -Np1 -i ../remove-no-opaque-pointers-flag.patch
100   # Fix build with unbundled zlip (patch from Gentoo)
101   patch -Np1 -i ../chromium-tflite-system-zlib.patch
103   # Upstream fixes
104   patch -Np1 -i ../x11-ozone-fix-X11-screensaver-suspension.patch
106   # Revert kGlobalMediaControlsCastStartStop enabled by default
107   # https://crbug.com/1314342
108   patch -Rp1 -F3 -i ../enable-GlobalMediaControlsCastStartStop.patch
110   # Revert ffmpeg roll requiring new channel layout API support
111   # https://crbug.com/1325301
112   patch -Rp1 -i ../roll-src-third_party-ffmpeg.patch
114   # Fixes for building with libstdc++ instead of libc++
115   patch -Np1 -i ../patches/chromium-103-VirtualCursor-std-layout.patch
117   # Link to system tools required by the build
118   mkdir -p third_party/node/linux/node-linux-x64/bin
119   ln -s /usr/bin/node third_party/node/linux/node-linux-x64/bin/
120   ln -s /usr/bin/java third_party/jdk/current/bin/
122   # Remove bundled libraries for which we will use the system copies; this
123   # *should* do what the remove_bundled_libraries.py script does, with the
124   # added benefit of not having to list all the remaining libraries
125   local _lib
126   for _lib in ${_unwanted_bundled_libs[@]}; do
127     find "third_party/$_lib" -type f \
128       \! -path "third_party/$_lib/chromium/*" \
129       \! -path "third_party/$_lib/google/*" \
130       \! -path "third_party/harfbuzz-ng/utils/hb_scoped.h" \
131       \! -regex '.*\.\(gn\|gni\|isolate\)' \
132       -delete
133   done
135   ./build/linux/unbundle/replace_gn_files.py \
136     --system-libraries "${!_system_libs[@]}"
139 build() {
140   make -C chromium-launcher-$_launcher_ver
142   cd chromium-$pkgver
144   export CC=clang
145   export CXX=clang++
146   export AR=ar
147   export NM=nm
149   local _flags=(
150     'custom_toolchain="//build/toolchain/linux/unbundle:default"'
151     'host_toolchain="//build/toolchain/linux/unbundle:default"'
152     'clang_use_chrome_plugins=false'
153     'is_official_build=true' # implies is_cfi=true on x86_64
154     'symbol_level=0' # sufficient for backtraces on x86(_64)
155     'chrome_pgo_phase=0' # needs newer clang to read the bundled PGO profile
156     'treat_warnings_as_errors=false'
157     'disable_fieldtrial_testing_config=true'
158     'blink_enable_generated_code_formatting=false'
159     'ffmpeg_branding="Chrome"'
160     'proprietary_codecs=true'
161     'rtc_use_pipewire=true'
162     'link_pulseaudio=true'
163     'use_gnome_keyring=false'
164     'use_sysroot=false'
165     'use_custom_libcxx=false'
166     'enable_hangout_services_extension=true'
167     'enable_widevine=true'
168     'enable_nacl=false'
169     "google_api_key=\"$_google_api_key\""
170   )
172   if [[ -n ${_system_libs[icu]+set} ]]; then
173     _flags+=('icu_use_data_file=false')
174   fi
176   # Facilitate deterministic builds (taken from build/config/compiler/BUILD.gn)
177   CFLAGS+='   -Wno-builtin-macro-redefined'
178   CXXFLAGS+=' -Wno-builtin-macro-redefined'
179   CPPFLAGS+=' -D__DATE__=  -D__TIME__=  -D__TIMESTAMP__='
181   # Do not warn about unknown warning options
182   CFLAGS+='   -Wno-unknown-warning-option'
183   CXXFLAGS+=' -Wno-unknown-warning-option'
185   # Let Chromium set its own symbol level
186   CFLAGS=${CFLAGS/-g }
187   CXXFLAGS=${CXXFLAGS/-g }
189   # https://github.com/ungoogled-software/ungoogled-chromium-archlinux/issues/123
190   CFLAGS=${CFLAGS/-fexceptions}
191   CFLAGS=${CFLAGS/-fcf-protection}
192   CXXFLAGS=${CXXFLAGS/-fexceptions}
193   CXXFLAGS=${CXXFLAGS/-fcf-protection}
195   # This appears to cause random segfaults when combined with ThinLTO
196   # https://bugs.archlinux.org/task/73518
197   CFLAGS=${CFLAGS/-fstack-clash-protection}
198   CXXFLAGS=${CXXFLAGS/-fstack-clash-protection}
200   # https://crbug.com/957519#c122
201   CXXFLAGS=${CXXFLAGS/-Wp,-D_GLIBCXX_ASSERTIONS}
203   gn gen out/Release --args="${_flags[*]}"
204   ninja -C out/Release chrome chrome_sandbox chromedriver.unstripped
207 package() {
208   cd chromium-launcher-$_launcher_ver
209   make PREFIX=/usr DESTDIR="$pkgdir" install
210   install -Dm644 LICENSE \
211     "$pkgdir/usr/share/licenses/chromium/LICENSE.launcher"
213   cd ../chromium-$pkgver
215   install -D out/Release/chrome "$pkgdir/usr/lib/chromium/chromium"
216   install -D out/Release/chromedriver.unstripped "$pkgdir/usr/bin/chromedriver"
217   install -Dm4755 out/Release/chrome_sandbox "$pkgdir/usr/lib/chromium/chrome-sandbox"
219   install -Dm644 chrome/installer/linux/common/desktop.template \
220     "$pkgdir/usr/share/applications/chromium.desktop"
221   install -Dm644 chrome/app/resources/manpage.1.in \
222     "$pkgdir/usr/share/man/man1/chromium.1"
223   sed -i \
224     -e 's/@@MENUNAME@@/Chromium/g' \
225     -e 's/@@PACKAGE@@/chromium/g' \
226     -e 's/@@USR_BIN_SYMLINK_NAME@@/chromium/g' \
227     "$pkgdir/usr/share/applications/chromium.desktop" \
228     "$pkgdir/usr/share/man/man1/chromium.1"
230   install -Dm644 chrome/installer/linux/common/chromium-browser/chromium-browser.appdata.xml \
231     "$pkgdir/usr/share/metainfo/chromium.appdata.xml"
232   sed -ni \
233     -e 's/chromium-browser\.desktop/chromium.desktop/' \
234     -e '/<update_contact>/d' \
235     -e '/<p>/N;/<p>\n.*\(We invite\|Chromium supports Vorbis\)/,/<\/p>/d' \
236     -e '/^<?xml/,$p' \
237     "$pkgdir/usr/share/metainfo/chromium.appdata.xml"
239   local toplevel_files=(
240     chrome_100_percent.pak
241     chrome_200_percent.pak
242     chrome_crashpad_handler
243     resources.pak
244     v8_context_snapshot.bin
246     # ANGLE
247     libEGL.so
248     libGLESv2.so
250     # SwiftShader ICD
251     libvk_swiftshader.so
252     vk_swiftshader_icd.json
253   )
255   if [[ -z ${_system_libs[icu]+set} ]]; then
256     toplevel_files+=(icudtl.dat)
257   fi
259   cp "${toplevel_files[@]/#/out/Release/}" "$pkgdir/usr/lib/chromium/"
260   install -Dm644 -t "$pkgdir/usr/lib/chromium/locales" out/Release/locales/*.pak
262   for size in 24 48 64 128 256; do
263     install -Dm644 "chrome/app/theme/chromium/product_logo_$size.png" \
264       "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
265   done
267   for size in 16 32; do
268     install -Dm644 "chrome/app/theme/default_100_percent/chromium/product_logo_$size.png" \
269       "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
270   done
272   install -Dm644 LICENSE "$pkgdir/usr/share/licenses/chromium/LICENSE"
275 # vim:set ts=2 sw=2 et: