archrelease: copy trunk to extra-x86_64
[arch-packages.git] / chromium / trunk / PKGBUILD
blobbc6b13437e2835721b0fc59ef60ec3260d420a45
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.126
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         swiftshader-add-cstdint-for-uint64_t.patch
30         dawn-iwyu-add-cstdint-for-uint8_t.patch
31         iwyu-add-stdint.h-for-various-int-types-in-base.patch
32         iwyu-add-cstdint-for-uintptr_t-in-device.patch
33         iwyu-add-stdint.h-for-uint32_t-in-chrome_pdf.patch
34         iwyu-add-stdint.h-for-uint64_t-in-EncounteredSurface.patch
35         iwyu-add-stdint.h-for-integer-types-in-ui.patch
36         openscreen-iwyu-add-stdint.h.patch
37         pdfium-iwyu-add-stdint.h-for-uint32_t.patch
38         unbundle-do-not-use-ZipAnalyzer-traits-header.patch
39         iwyu-add-stdint.h-for-uint32_t-in-cc.patch
40         add-missing-includes-causing-build-errors.patch
41         iwyu-add-stdint.h-for-int-types-in-gpu_feature_info.patch
42         iwyu-add-stdint.h-for-various-int-types-in-comp.patch
43         iwyu-add-stdint.h-for-various-integer-types-in-net.patch
44         iwyu-add-cstdint-for-int-types-in-s2cellid.patch
45         download-bubble-typename.patch
46         webauthn-variant.patch
47         random-fixes-for-gcc13.patch
48         disable-GlobalMediaControlsCastStartStop.patch
49         use-oauth2-client-switches-as-default.patch)
50 sha256sums=('0def7cd594304d7675821d42a4207377af98e321a78a91ee5200aea55adc2d93'
51             '213e50f48b67feb4441078d50b0fd431df34323be15be97c55302d3fdac4483a'
52             '5f868cba9e4d387499711738adc6fd87ab9f1ef61f464016bc682660ae59206a'
53             '208f2ebcef5c690207e6e798ffbf9e92214e9d35f415c2f6b93efebad831b7e2'
54             '94baaaa6fbec0af6ec2e967f0b7440b4261a927e853e212d84f0aeaf56ae53f0'
55             '0003e737072f4f1b22ff932221595e85dd9bf65720ccac36f840cccb8000e3e1'
56             'ffe499d63c9c1074cbc3995c188c89b748388dbb9dccf975ce28a434c723acf7'
57             '7af466e4b5985cc9f0b33df2f3cd2e458c7cbfd7190505d105aad4401c9d072b'
58             '727588a1b42f6cfe54acf4759a0c3ad3778590d5a5cefcdcb54b579ba16b09c8'
59             '0914be53b2205b34e4da96f5a94505ac2a01e3639ff433535a23be2d0d581fa7'
60             '8c9662bed23bfd66ae76d044541f316624386ca4b3baef57a47289feb3db58a9'
61             '890b6836cea4c31513166db720b210da20d20bcd97a713545268cceffd707af5'
62             'ffa23c6233b47e0b4d688e30a44a2550e1236bbd0dc57b996d33dc42266530af'
63             'f6a0e149ef5195883c56a875ae366ed92d9960652f2657bfb65b5408badafc65'
64             '3255477d02d49ef86d47c727b9369f46dc787319bb648bf267a68f37e2041e50'
65             '94995b4e37671dcd27968bd5a2ebcf50e67bd22659a4bb4a5d0a4f81ff54f471'
66             '88320e0f08cc7b53807961d0735e7c1bd455a6faf9d8a5d056b7ba7809e37355'
67             '5dfbfd073f78c887bbffca2b644116571cc9b1196867e44e8fc0cbb40afcf1bc'
68             'd97dc00f66fa5868584e4b6d5ef817911eab2dc8022a37c75a00d063f4dac483'
69             'd464eed4be4e9bf6187b4c40a759c523b7befefa25ba34ad6401b2a07649ca2a'
70             '590fabbb26270947cb477378b53a9dcd17855739076b4af9983e1e54dfcab6d7'
71             'ba4dd0a25a4fc3267ed19ccb39f28b28176ca3f97f53a4e9f5e9215280040ea0'
72             '7f3b1b22d6a271431c1f9fc92b6eb49c6d80b8b3f868bdee07a6a1a16630a302'
73             'e393174d7695d0bafed69e868c5fbfecf07aa6969f3b64596d0bae8b067e1711')
75 if (( _manual_clone )); then
76   source[0]=fetch-chromium-release
77   makedepends+=('python-httplib2' 'python-pyparsing' 'python-six')
80 # Possible replacements are listed in build/linux/unbundle/replace_gn_files.py
81 # Keys are the names in the above script; values are the dependencies in Arch
82 declare -gA _system_libs=(
83   [brotli]=brotli
84   [dav1d]=dav1d
85   [ffmpeg]=ffmpeg
86   [flac]=flac
87   [fontconfig]=fontconfig
88   [freetype]=freetype2
89   [harfbuzz-ng]=harfbuzz
90   [icu]=icu
91   [jsoncpp]=jsoncpp
92   #[libaom]=aom      # https://aomedia.googlesource.com/aom/+/706ee36dcc82
93   #[libavif]=libavif # https://github.com/AOMediaCodec/libavif/commit/4d2776a3
94   [libdrm]=
95   [libjpeg]=libjpeg
96   [libpng]=libpng
97   #[libvpx]=libvpx
98   [libwebp]=libwebp
99   [libxml]=libxml2
100   [libxslt]=libxslt
101   [opus]=opus
102   [re2]=re2
103   [snappy]=snappy
104   [woff2]=woff2
105   [zlib]=minizip
107 _unwanted_bundled_libs=(
108   $(printf "%s\n" ${!_system_libs[@]} | sed 's/^libjpeg$/&_turbo/')
110 depends+=(${_system_libs[@]})
112 # Google API keys (see https://www.chromium.org/developers/how-tos/api-keys)
113 # Note: These are for Arch Linux use ONLY. For your own distribution, please
114 # get your own set of keys.
116 # Starting with Chromium 89 (2021-03-02) the OAuth2 credentials have been left
117 # out: https://archlinux.org/news/chromium-losing-sync-support-in-early-march/
118 _google_api_key=AIzaSyDwr302FpOSkGRpLlUpPThNTDPbXcIn_FM
120 prepare() {
121   if (( _manual_clone )); then
122     ./fetch-chromium-release $pkgver
123   fi
124   cd chromium-$pkgver
126   # Allow building against system libraries in official builds
127   sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \
128     tools/generate_shim_headers/generate_shim_headers.py
130   # https://crbug.com/893950
131   sed -i -e 's/\<xmlMalloc\>/malloc/' -e 's/\<xmlFree\>/free/' \
132     third_party/blink/renderer/core/xml/*.cc \
133     third_party/blink/renderer/core/xml/parser/xml_document_parser.cc \
134     third_party/libxml/chromium/*.cc \
135     third_party/maldoca/src/maldoca/ole/oss_utils.h
137   # Use the --oauth2-client-id= and --oauth2-client-secret= switches for
138   # setting GOOGLE_DEFAULT_CLIENT_ID and GOOGLE_DEFAULT_CLIENT_SECRET at
139   # runtime -- this allows signing into Chromium without baked-in values
140   patch -Np1 -i ../use-oauth2-client-switches-as-default.patch
142   # Upstream fixes
143   patch -Np1 -i ../add-cstring-for-std-strlen-in-web_view_impl.cc.patch
144   patch -Np1 -d third_party/swiftshader <../swiftshader-add-cstdint-for-uint64_t.patch
145   patch -Np1 -d third_party/dawn <../dawn-iwyu-add-cstdint-for-uint8_t.patch
146   patch -Np1 -i ../iwyu-add-stdint.h-for-various-int-types-in-base.patch
147   patch -Np1 -i ../iwyu-add-cstdint-for-uintptr_t-in-device.patch
148   patch -Np1 -i ../iwyu-add-stdint.h-for-uint32_t-in-chrome_pdf.patch
149   patch -Np1 -i ../iwyu-add-stdint.h-for-uint64_t-in-EncounteredSurface.patch
150   patch -Np1 -i ../iwyu-add-stdint.h-for-integer-types-in-ui.patch
151   patch -Np1 -d third_party/openscreen/src <../openscreen-iwyu-add-stdint.h.patch
152   patch -Np1 -d third_party/pdfium <../pdfium-iwyu-add-stdint.h-for-uint32_t.patch
153   patch -Np1 -i ../unbundle-do-not-use-ZipAnalyzer-traits-header.patch
154   patch -Np1 -i ../iwyu-add-stdint.h-for-uint32_t-in-cc.patch
155   patch -Np1 -i ../add-missing-includes-causing-build-errors.patch
156   patch -Np1 -i ../iwyu-add-stdint.h-for-int-types-in-gpu_feature_info.patch
157   patch -Np1 -i ../iwyu-add-stdint.h-for-various-int-types-in-comp.patch
158   patch -Np1 -i ../iwyu-add-stdint.h-for-various-integer-types-in-net.patch
159   patch -Np1 -i ../iwyu-add-cstdint-for-int-types-in-s2cellid.patch
161   # Disable kGlobalMediaControlsCastStartStop by default
162   # https://crbug.com/1314342
163   patch -Np1 -i ../disable-GlobalMediaControlsCastStartStop.patch
165   # Build fixes
166   patch -Np1 -i ../download-bubble-typename.patch
167   patch -Np1 -i ../webauthn-variant.patch
168   patch -Np1 -i ../random-fixes-for-gcc13.patch
170   # Link to system tools required by the build
171   mkdir -p third_party/node/linux/node-linux-x64/bin
172   ln -s /usr/bin/node third_party/node/linux/node-linux-x64/bin/
173   ln -s /usr/bin/java third_party/jdk/current/bin/
175   # Remove bundled libraries for which we will use the system copies; this
176   # *should* do what the remove_bundled_libraries.py script does, with the
177   # added benefit of not having to list all the remaining libraries
178   local _lib
179   for _lib in ${_unwanted_bundled_libs[@]}; do
180     find "third_party/$_lib" -type f \
181       \! -path "third_party/$_lib/chromium/*" \
182       \! -path "third_party/$_lib/google/*" \
183       \! -path "third_party/harfbuzz-ng/utils/hb_scoped.h" \
184       \! -regex '.*\.\(gn\|gni\|isolate\)' \
185       -delete
186   done
188   ./build/linux/unbundle/replace_gn_files.py \
189     --system-libraries "${!_system_libs[@]}"
192 build() {
193   make -C chromium-launcher-$_launcher_ver
195   cd chromium-$pkgver
197   export CC=clang
198   export CXX=clang++
199   export AR=ar
200   export NM=nm
202   local _flags=(
203     'custom_toolchain="//build/toolchain/linux/unbundle:default"'
204     'host_toolchain="//build/toolchain/linux/unbundle:default"'
205     'clang_base_path="/usr"'
206     'clang_use_chrome_plugins=false'
207     'is_official_build=true' # implies is_cfi=true on x86_64
208     'symbol_level=0' # sufficient for backtraces on x86(_64)
209     'chrome_pgo_phase=0' # needs newer clang to read the bundled PGO profile
210     'treat_warnings_as_errors=false'
211     'disable_fieldtrial_testing_config=true'
212     'blink_enable_generated_code_formatting=false'
213     'ffmpeg_branding="Chrome"'
214     'proprietary_codecs=true'
215     'rtc_use_pipewire=true'
216     'link_pulseaudio=true'
217     'use_custom_libcxx=false'
218     'use_gnome_keyring=false'
219     'use_sysroot=false'
220     'use_system_libffi=true'
221     'enable_hangout_services_extension=true'
222     'enable_widevine=true'
223     'enable_nacl=false'
224     "google_api_key=\"$_google_api_key\""
225   )
227   if [[ -n ${_system_libs[icu]+set} ]]; then
228     _flags+=('icu_use_data_file=false')
229   fi
231   # Facilitate deterministic builds (taken from build/config/compiler/BUILD.gn)
232   CFLAGS+='   -Wno-builtin-macro-redefined'
233   CXXFLAGS+=' -Wno-builtin-macro-redefined'
234   CPPFLAGS+=' -D__DATE__=  -D__TIME__=  -D__TIMESTAMP__='
236   # Do not warn about unknown warning options
237   CFLAGS+='   -Wno-unknown-warning-option'
238   CXXFLAGS+=' -Wno-unknown-warning-option'
240   # Let Chromium set its own symbol level
241   CFLAGS=${CFLAGS/-g }
242   CXXFLAGS=${CXXFLAGS/-g }
244   # https://github.com/ungoogled-software/ungoogled-chromium-archlinux/issues/123
245   CFLAGS=${CFLAGS/-fexceptions}
246   CFLAGS=${CFLAGS/-fcf-protection}
247   CXXFLAGS=${CXXFLAGS/-fexceptions}
248   CXXFLAGS=${CXXFLAGS/-fcf-protection}
250   # This appears to cause random segfaults when combined with ThinLTO
251   # https://bugs.archlinux.org/task/73518
252   CFLAGS=${CFLAGS/-fstack-clash-protection}
253   CXXFLAGS=${CXXFLAGS/-fstack-clash-protection}
255   # https://crbug.com/957519#c122
256   CXXFLAGS=${CXXFLAGS/-Wp,-D_GLIBCXX_ASSERTIONS}
258   gn gen out/Release --args="${_flags[*]}"
259   ninja -C out/Release chrome chrome_sandbox chromedriver.unstripped
262 package() {
263   cd chromium-launcher-$_launcher_ver
264   make PREFIX=/usr DESTDIR="$pkgdir" install
265   install -Dm644 LICENSE \
266     "$pkgdir/usr/share/licenses/chromium/LICENSE.launcher"
268   cd ../chromium-$pkgver
270   install -D out/Release/chrome "$pkgdir/usr/lib/chromium/chromium"
271   install -D out/Release/chromedriver.unstripped "$pkgdir/usr/bin/chromedriver"
272   install -Dm4755 out/Release/chrome_sandbox "$pkgdir/usr/lib/chromium/chrome-sandbox"
274   install -Dm644 chrome/installer/linux/common/desktop.template \
275     "$pkgdir/usr/share/applications/chromium.desktop"
276   install -Dm644 chrome/app/resources/manpage.1.in \
277     "$pkgdir/usr/share/man/man1/chromium.1"
278   sed -i \
279     -e 's/@@MENUNAME@@/Chromium/g' \
280     -e 's/@@PACKAGE@@/chromium/g' \
281     -e 's/@@USR_BIN_SYMLINK_NAME@@/chromium/g' \
282     "$pkgdir/usr/share/applications/chromium.desktop" \
283     "$pkgdir/usr/share/man/man1/chromium.1"
285   install -Dm644 chrome/installer/linux/common/chromium-browser/chromium-browser.appdata.xml \
286     "$pkgdir/usr/share/metainfo/chromium.appdata.xml"
287   sed -ni \
288     -e 's/chromium-browser\.desktop/chromium.desktop/' \
289     -e '/<update_contact>/d' \
290     -e '/<p>/N;/<p>\n.*\(We invite\|Chromium supports Vorbis\)/,/<\/p>/d' \
291     -e '/^<?xml/,$p' \
292     "$pkgdir/usr/share/metainfo/chromium.appdata.xml"
294   local toplevel_files=(
295     chrome_100_percent.pak
296     chrome_200_percent.pak
297     chrome_crashpad_handler
298     libqt5_shim.so
299     resources.pak
300     v8_context_snapshot.bin
302     # ANGLE
303     libEGL.so
304     libGLESv2.so
306     # SwiftShader ICD
307     libvk_swiftshader.so
308     vk_swiftshader_icd.json
309   )
311   if [[ -z ${_system_libs[icu]+set} ]]; then
312     toplevel_files+=(icudtl.dat)
313   fi
315   cp "${toplevel_files[@]/#/out/Release/}" "$pkgdir/usr/lib/chromium/"
316   install -Dm644 -t "$pkgdir/usr/lib/chromium/locales" out/Release/locales/*.pak
318   for size in 24 48 64 128 256; do
319     install -Dm644 "chrome/app/theme/chromium/product_logo_$size.png" \
320       "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
321   done
323   for size in 16 32; do
324     install -Dm644 "chrome/app/theme/default_100_percent/chromium/product_logo_$size.png" \
325       "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
326   done
328   install -Dm644 LICENSE "$pkgdir/usr/share/licenses/chromium/LICENSE"
331 # vim:set ts=2 sw=2 et: