db-move: moved polari from [testing] to [extra] (x86_64)
[arch-packages.git] / chromium / trunk / PKGBUILD
blobe91c7bc8f43e5fd410753c1f2698ab61d8bf4dbe
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=113.0.5672.63
8 pkgrel=1
9 _launcher_ver=8
10 _manual_clone=0
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          'libffi' 'desktop-file-utils' 'hicolor-icon-theme')
18 makedepends=('python' 'gn' 'ninja' 'clang' 'lld' 'gperf' 'nodejs' 'pipewire'
19              'qt5-base' 'java-runtime-headless' 'git')
20 optdepends=('pipewire: WebRTC desktop sharing under Wayland'
21             'kdialog: support for native dialogs in Plasma'
22             'qt5-base: enable Qt5 with --enable-features=AllowQt'
23             'org.freedesktop.secrets: password storage backend on GNOME / Xfce'
24             'kwallet: support for storing passwords in KWallet on Plasma')
25 options=('!lto') # Chromium adds its own flags for ThinLTO
26 source=(https://commondatastorage.googleapis.com/chromium-browser-official/chromium-$pkgver.tar.xz
27         https://github.com/foutrelis/chromium-launcher/archive/v$_launcher_ver/chromium-launcher-$_launcher_ver.tar.gz
28         add-cstring-for-std-strlen-in-web_view_impl.cc.patch
29         download-bubble-typename.patch
30         webauthn-variant.patch
31         disable-GlobalMediaControlsCastStartStop.patch
32         use-oauth2-client-switches-as-default.patch)
33 sha256sums=('76cec11dc13abe6703305b0300e1fe24c8f547c1ff313f7be09db0e23d12ee1e'
34             '213e50f48b67feb4441078d50b0fd431df34323be15be97c55302d3fdac4483a'
35             '5f868cba9e4d387499711738adc6fd87ab9f1ef61f464016bc682660ae59206a'
36             'd464eed4be4e9bf6187b4c40a759c523b7befefa25ba34ad6401b2a07649ca2a'
37             '590fabbb26270947cb477378b53a9dcd17855739076b4af9983e1e54dfcab6d7'
38             '7f3b1b22d6a271431c1f9fc92b6eb49c6d80b8b3f868bdee07a6a1a16630a302'
39             'e393174d7695d0bafed69e868c5fbfecf07aa6969f3b64596d0bae8b067e1711')
41 if (( _manual_clone )); then
42   source[0]=fetch-chromium-release
43   makedepends+=('python-httplib2' 'python-pyparsing' 'python-six')
46 # Possible replacements are listed in build/linux/unbundle/replace_gn_files.py
47 # Keys are the names in the above script; values are the dependencies in Arch
48 declare -gA _system_libs=(
49   [brotli]=brotli
50   [dav1d]=dav1d
51   [ffmpeg]=ffmpeg
52   [flac]=flac
53   [fontconfig]=fontconfig
54   [freetype]=freetype2
55   [harfbuzz-ng]=harfbuzz
56   [icu]=icu
57   [jsoncpp]=jsoncpp
58   #[libaom]=aom      # https://aomedia.googlesource.com/aom/+/706ee36dcc82
59   #[libavif]=libavif # https://github.com/AOMediaCodec/libavif/commit/4d2776a3
60   [libdrm]=
61   [libjpeg]=libjpeg
62   [libpng]=libpng
63   #[libvpx]=libvpx
64   [libwebp]=libwebp
65   [libxml]=libxml2
66   [libxslt]=libxslt
67   [opus]=opus
68   [re2]=re2
69   [snappy]=snappy
70   [woff2]=woff2
71   #[zlib]=minizip    # broken include from chrome/common/safe_browsing/zip_analyzer.h
73 _unwanted_bundled_libs=(
74   $(printf "%s\n" ${!_system_libs[@]} | sed 's/^libjpeg$/&_turbo/')
76 depends+=(${_system_libs[@]})
78 # Google API keys (see https://www.chromium.org/developers/how-tos/api-keys)
79 # Note: These are for Arch Linux use ONLY. For your own distribution, please
80 # get your own set of keys.
82 # Starting with Chromium 89 (2021-03-02) the OAuth2 credentials have been left
83 # out: https://archlinux.org/news/chromium-losing-sync-support-in-early-march/
84 _google_api_key=AIzaSyDwr302FpOSkGRpLlUpPThNTDPbXcIn_FM
86 prepare() {
87   if (( _manual_clone )); then
88     ./fetch-chromium-release $pkgver
89   fi
90   cd chromium-$pkgver
92   # Allow building against system libraries in official builds
93   sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \
94     tools/generate_shim_headers/generate_shim_headers.py
96   # https://crbug.com/893950
97   sed -i -e 's/\<xmlMalloc\>/malloc/' -e 's/\<xmlFree\>/free/' \
98     third_party/blink/renderer/core/xml/*.cc \
99     third_party/blink/renderer/core/xml/parser/xml_document_parser.cc \
100     third_party/libxml/chromium/*.cc \
101     third_party/maldoca/src/maldoca/ole/oss_utils.h
103   # Use the --oauth2-client-id= and --oauth2-client-secret= switches for
104   # setting GOOGLE_DEFAULT_CLIENT_ID and GOOGLE_DEFAULT_CLIENT_SECRET at
105   # runtime -- this allows signing into Chromium without baked-in values
106   patch -Np1 -i ../use-oauth2-client-switches-as-default.patch
108   # Upstream fixes
109   patch -Np1 -i ../add-cstring-for-std-strlen-in-web_view_impl.cc.patch
111   # Disable kGlobalMediaControlsCastStartStop by default
112   # https://crbug.com/1314342
113   patch -Np1 -i ../disable-GlobalMediaControlsCastStartStop.patch
115   # Build fixes
116   patch -Np1 -i ../download-bubble-typename.patch
117   patch -Np1 -i ../webauthn-variant.patch
119   # Link to system tools required by the build
120   mkdir -p third_party/node/linux/node-linux-x64/bin
121   ln -s /usr/bin/node third_party/node/linux/node-linux-x64/bin/
122   ln -s /usr/bin/java third_party/jdk/current/bin/
124   # Remove bundled libraries for which we will use the system copies; this
125   # *should* do what the remove_bundled_libraries.py script does, with the
126   # added benefit of not having to list all the remaining libraries
127   local _lib
128   for _lib in ${_unwanted_bundled_libs[@]}; do
129     find "third_party/$_lib" -type f \
130       \! -path "third_party/$_lib/chromium/*" \
131       \! -path "third_party/$_lib/google/*" \
132       \! -path "third_party/harfbuzz-ng/utils/hb_scoped.h" \
133       \! -regex '.*\.\(gn\|gni\|isolate\)' \
134       -delete
135   done
137   ./build/linux/unbundle/replace_gn_files.py \
138     --system-libraries "${!_system_libs[@]}"
141 build() {
142   make -C chromium-launcher-$_launcher_ver
144   cd chromium-$pkgver
146   export CC=clang
147   export CXX=clang++
148   export AR=ar
149   export NM=nm
151   local _flags=(
152     'custom_toolchain="//build/toolchain/linux/unbundle:default"'
153     'host_toolchain="//build/toolchain/linux/unbundle:default"'
154     'clang_base_path="/usr"'
155     'clang_use_chrome_plugins=false'
156     'is_official_build=true' # implies is_cfi=true on x86_64
157     'symbol_level=0' # sufficient for backtraces on x86(_64)
158     'chrome_pgo_phase=0' # needs newer clang to read the bundled PGO profile
159     'treat_warnings_as_errors=false'
160     'disable_fieldtrial_testing_config=true'
161     'blink_enable_generated_code_formatting=false'
162     'ffmpeg_branding="Chrome"'
163     'proprietary_codecs=true'
164     'rtc_use_pipewire=true'
165     'link_pulseaudio=true'
166     'use_custom_libcxx=false'
167     'use_gnome_keyring=false'
168     'use_sysroot=false'
169     'use_system_libffi=true'
170     'enable_hangout_services_extension=true'
171     'enable_widevine=true'
172     'enable_nacl=false'
173     "google_api_key=\"$_google_api_key\""
174   )
176   if [[ -n ${_system_libs[icu]+set} ]]; then
177     _flags+=('icu_use_data_file=false')
178   fi
180   # Facilitate deterministic builds (taken from build/config/compiler/BUILD.gn)
181   CFLAGS+='   -Wno-builtin-macro-redefined'
182   CXXFLAGS+=' -Wno-builtin-macro-redefined'
183   CPPFLAGS+=' -D__DATE__=  -D__TIME__=  -D__TIMESTAMP__='
185   # Do not warn about unknown warning options
186   CFLAGS+='   -Wno-unknown-warning-option'
187   CXXFLAGS+=' -Wno-unknown-warning-option'
189   # Let Chromium set its own symbol level
190   CFLAGS=${CFLAGS/-g }
191   CXXFLAGS=${CXXFLAGS/-g }
193   # https://github.com/ungoogled-software/ungoogled-chromium-archlinux/issues/123
194   CFLAGS=${CFLAGS/-fexceptions}
195   CFLAGS=${CFLAGS/-fcf-protection}
196   CXXFLAGS=${CXXFLAGS/-fexceptions}
197   CXXFLAGS=${CXXFLAGS/-fcf-protection}
199   # This appears to cause random segfaults when combined with ThinLTO
200   # https://bugs.archlinux.org/task/73518
201   CFLAGS=${CFLAGS/-fstack-clash-protection}
202   CXXFLAGS=${CXXFLAGS/-fstack-clash-protection}
204   # https://crbug.com/957519#c122
205   CXXFLAGS=${CXXFLAGS/-Wp,-D_GLIBCXX_ASSERTIONS}
207   gn gen out/Release --args="${_flags[*]}"
208   ninja -C out/Release chrome chrome_sandbox chromedriver.unstripped
211 package() {
212   cd chromium-launcher-$_launcher_ver
213   make PREFIX=/usr DESTDIR="$pkgdir" install
214   install -Dm644 LICENSE \
215     "$pkgdir/usr/share/licenses/chromium/LICENSE.launcher"
217   cd ../chromium-$pkgver
219   install -D out/Release/chrome "$pkgdir/usr/lib/chromium/chromium"
220   install -D out/Release/chromedriver.unstripped "$pkgdir/usr/bin/chromedriver"
221   install -Dm4755 out/Release/chrome_sandbox "$pkgdir/usr/lib/chromium/chrome-sandbox"
223   install -Dm644 chrome/installer/linux/common/desktop.template \
224     "$pkgdir/usr/share/applications/chromium.desktop"
225   install -Dm644 chrome/app/resources/manpage.1.in \
226     "$pkgdir/usr/share/man/man1/chromium.1"
227   sed -i \
228     -e 's/@@MENUNAME@@/Chromium/g' \
229     -e 's/@@PACKAGE@@/chromium/g' \
230     -e 's/@@USR_BIN_SYMLINK_NAME@@/chromium/g' \
231     "$pkgdir/usr/share/applications/chromium.desktop" \
232     "$pkgdir/usr/share/man/man1/chromium.1"
234   install -Dm644 chrome/installer/linux/common/chromium-browser/chromium-browser.appdata.xml \
235     "$pkgdir/usr/share/metainfo/chromium.appdata.xml"
236   sed -ni \
237     -e 's/chromium-browser\.desktop/chromium.desktop/' \
238     -e '/<update_contact>/d' \
239     -e '/<p>/N;/<p>\n.*\(We invite\|Chromium supports Vorbis\)/,/<\/p>/d' \
240     -e '/^<?xml/,$p' \
241     "$pkgdir/usr/share/metainfo/chromium.appdata.xml"
243   local toplevel_files=(
244     chrome_100_percent.pak
245     chrome_200_percent.pak
246     chrome_crashpad_handler
247     libqt5_shim.so
248     resources.pak
249     v8_context_snapshot.bin
251     # ANGLE
252     libEGL.so
253     libGLESv2.so
255     # SwiftShader ICD
256     libvk_swiftshader.so
257     vk_swiftshader_icd.json
258   )
260   if [[ -z ${_system_libs[icu]+set} ]]; then
261     toplevel_files+=(icudtl.dat)
262   fi
264   cp "${toplevel_files[@]/#/out/Release/}" "$pkgdir/usr/lib/chromium/"
265   install -Dm644 -t "$pkgdir/usr/lib/chromium/locales" out/Release/locales/*.pak
267   for size in 24 48 64 128 256; do
268     install -Dm644 "chrome/app/theme/chromium/product_logo_$size.png" \
269       "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
270   done
272   for size in 16 32; do
273     install -Dm644 "chrome/app/theme/default_100_percent/chromium/product_logo_$size.png" \
274       "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
275   done
277   install -Dm644 LICENSE "$pkgdir/usr/share/licenses/chromium/LICENSE"
280 # vim:set ts=2 sw=2 et: