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>
11 pkgdesc="A web browser built for speed, simplicity, and security"
13 url="https://www.chromium.org/Home"
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/$pkgname-$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 iwyu-add-utility-for-std-exchange.patch
29 enable-GlobalMediaControlsCastStartStop.patch
30 roll-src-third_party-ffmpeg.patch
31 chromium-libxml-unbundle.patch
32 sql-make-VirtualCursor-standard-layout-type.patch
33 remove-no-opaque-pointers-flag.patch
34 use-oauth2-client-switches-as-default.patch)
35 sha256sums=('301d40e5373b6dad9bc6aeb6898116d1f7dd2d0589ed18e108c56e2290df47e6'
36 '213e50f48b67feb4441078d50b0fd431df34323be15be97c55302d3fdac4483a'
37 '53de0f936fd571e578ba2fbf348c8741116cdcceac3ea6fae5008d8f054a7698'
38 '6f666ef0acb08704ca58cc0d5e97e7ce64d8fea51042e593adae1ce15a61231c'
39 '779fb13f2494209d3a7f1f23a823e59b9dded601866d3ab095937a1a04e19ac6'
40 '30df59a9e2d95dcb720357ec4a83d9be51e59cc5551365da4c0073e68ccdec44'
41 'fd3bf124aacc45f2d0a4f1dd86303fa7f2a3d4f4eeaf33854631d6cb39e12485'
42 'b94b2e88f63cfb7087486508b8139599c89f96d7a4181c61fec4b4e250ca327a'
43 '00c16ce83ea4ca924a50fa0cfc2b2a4d744c722f363b065323e6ba0fcbac45a5'
44 'e393174d7695d0bafed69e868c5fbfecf07aa6969f3b64596d0bae8b067e1711')
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=(
51 [fontconfig]=fontconfig
53 [harfbuzz-ng]=harfbuzz
67 _unwanted_bundled_libs=(
68 $(printf "%s\n" ${!_system_libs[@]} | sed 's/^libjpeg$/&_turbo/')
70 depends+=(${_system_libs[@]})
72 # Google API keys (see https://www.chromium.org/developers/how-tos/api-keys)
73 # Note: These are for Arch Linux use ONLY. For your own distribution, please
74 # get your own set of keys.
76 # Starting with Chromium 89 (2021-03-02) the OAuth2 credentials have been left
77 # out: https://archlinux.org/news/chromium-losing-sync-support-in-early-march/
78 _google_api_key=AIzaSyDwr302FpOSkGRpLlUpPThNTDPbXcIn_FM
81 cd "$srcdir/$pkgname-$pkgver"
83 # Allow building against system libraries in official builds
84 sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \
85 tools/generate_shim_headers/generate_shim_headers.py
87 # https://crbug.com/893950
88 sed -i -e 's/\<xmlMalloc\>/malloc/' -e 's/\<xmlFree\>/free/' \
89 third_party/blink/renderer/core/xml/*.cc \
90 third_party/blink/renderer/core/xml/parser/xml_document_parser.cc \
91 third_party/libxml/chromium/*.cc \
92 third_party/maldoca/src/maldoca/ole/oss_utils.h
94 # Use the --oauth2-client-id= and --oauth2-client-secret= switches for
95 # setting GOOGLE_DEFAULT_CLIENT_ID and GOOGLE_DEFAULT_CLIENT_SECRET at
96 # runtime -- this allows signing into Chromium without baked-in values
97 patch -Np1 -i ../use-oauth2-client-switches-as-default.patch
99 # Remove '-Xclang -no-opaque-pointers' flag not supported by our clang
100 patch -Np1 -i ../remove-no-opaque-pointers-flag.patch
103 patch -Np1 -i ../iwyu-add-utility-for-std-exchange.patch
105 # Revert kGlobalMediaControlsCastStartStop enabled by default
106 # https://crbug.com/1314342
107 patch -Rp1 -F3 -i ../enable-GlobalMediaControlsCastStartStop.patch
109 # Revert ffmpeg roll requiring new channel layout API support
110 # https://crbug.com/1325301
111 patch -Rp1 -i ../roll-src-third_party-ffmpeg.patch
113 # https://chromium-review.googlesource.com/c/chromium/src/+/3488058
114 patch -Np1 -i ../chromium-libxml-unbundle.patch
116 # https://chromium-review.googlesource.com/c/chromium/src/+/2862724
117 patch -Np1 -i ../sql-make-VirtualCursor-standard-layout-type.patch
119 # Fixes for building with libstdc++ instead of libc++
120 patch -Np1 -i ../patches/chromium-102-fenced_frame_utils-include.patch
121 patch -Np1 -i ../patches/chromium-102-regex_pattern-array.patch
123 # Link to system tools required by the build
124 mkdir -p third_party/node/linux/node-linux-x64/bin
125 ln -s /usr/bin/node third_party/node/linux/node-linux-x64/bin/
126 ln -s /usr/bin/java third_party/jdk/current/bin/
128 # Remove bundled libraries for which we will use the system copies; this
129 # *should* do what the remove_bundled_libraries.py script does, with the
130 # added benefit of not having to list all the remaining libraries
132 for _lib in ${_unwanted_bundled_libs[@]}; do
133 find "third_party/$_lib" -type f \
134 \! -path "third_party/$_lib/chromium/*" \
135 \! -path "third_party/$_lib/google/*" \
136 \! -path "third_party/harfbuzz-ng/utils/hb_scoped.h" \
137 \! -regex '.*\.\(gn\|gni\|isolate\)' \
141 ./build/linux/unbundle/replace_gn_files.py \
142 --system-libraries "${!_system_libs[@]}"
146 make -C chromium-launcher-$_launcher_ver
148 cd "$srcdir/$pkgname-$pkgver"
156 'custom_toolchain="//build/toolchain/linux/unbundle:default"'
157 'host_toolchain="//build/toolchain/linux/unbundle:default"'
158 'clang_use_chrome_plugins=false'
159 'is_official_build=true' # implies is_cfi=true on x86_64
160 'symbol_level=0' # sufficient for backtraces on x86(_64)
161 'chrome_pgo_phase=0' # needs newer clang to read the bundled PGO profile
162 'treat_warnings_as_errors=false'
163 'disable_fieldtrial_testing_config=true'
164 'blink_enable_generated_code_formatting=false'
165 'ffmpeg_branding="Chrome"'
166 'proprietary_codecs=true'
167 'rtc_use_pipewire=true'
168 'link_pulseaudio=true'
169 'use_gnome_keyring=false'
171 'use_custom_libcxx=false'
172 'enable_hangout_services_extension=true'
173 'enable_widevine=true'
175 "google_api_key=\"$_google_api_key\""
178 if [[ -n ${_system_libs[icu]+set} ]]; then
179 _flags+=('icu_use_data_file=false')
182 # Facilitate deterministic builds (taken from build/config/compiler/BUILD.gn)
183 CFLAGS+=' -Wno-builtin-macro-redefined'
184 CXXFLAGS+=' -Wno-builtin-macro-redefined'
185 CPPFLAGS+=' -D__DATE__= -D__TIME__= -D__TIMESTAMP__='
187 # Do not warn about unknown warning options
188 CFLAGS+=' -Wno-unknown-warning-option'
189 CXXFLAGS+=' -Wno-unknown-warning-option'
191 # Let Chromium set its own symbol level
193 CXXFLAGS=${CXXFLAGS/-g }
195 # https://github.com/ungoogled-software/ungoogled-chromium-archlinux/issues/123
196 CFLAGS=${CFLAGS/-fexceptions}
197 CFLAGS=${CFLAGS/-fcf-protection}
198 CXXFLAGS=${CXXFLAGS/-fexceptions}
199 CXXFLAGS=${CXXFLAGS/-fcf-protection}
201 # This appears to cause random segfaults when combined with ThinLTO
202 # https://bugs.archlinux.org/task/73518
203 CFLAGS=${CFLAGS/-fstack-clash-protection}
204 CXXFLAGS=${CXXFLAGS/-fstack-clash-protection}
206 # https://crbug.com/957519#c122
207 CXXFLAGS=${CXXFLAGS/-Wp,-D_GLIBCXX_ASSERTIONS}
209 gn gen out/Release --args="${_flags[*]}"
210 ninja -C out/Release chrome chrome_sandbox chromedriver.unstripped
214 cd chromium-launcher-$_launcher_ver
215 make PREFIX=/usr DESTDIR="$pkgdir" install
216 install -Dm644 LICENSE \
217 "$pkgdir/usr/share/licenses/chromium/LICENSE.launcher"
219 cd "$srcdir/$pkgname-$pkgver"
221 install -D out/Release/chrome "$pkgdir/usr/lib/chromium/chromium"
222 install -D out/Release/chromedriver.unstripped "$pkgdir/usr/bin/chromedriver"
223 install -Dm4755 out/Release/chrome_sandbox "$pkgdir/usr/lib/chromium/chrome-sandbox"
225 install -Dm644 chrome/installer/linux/common/desktop.template \
226 "$pkgdir/usr/share/applications/chromium.desktop"
227 install -Dm644 chrome/app/resources/manpage.1.in \
228 "$pkgdir/usr/share/man/man1/chromium.1"
230 -e 's/@@MENUNAME@@/Chromium/g' \
231 -e 's/@@PACKAGE@@/chromium/g' \
232 -e 's/@@USR_BIN_SYMLINK_NAME@@/chromium/g' \
233 "$pkgdir/usr/share/applications/chromium.desktop" \
234 "$pkgdir/usr/share/man/man1/chromium.1"
236 install -Dm644 chrome/installer/linux/common/chromium-browser/chromium-browser.appdata.xml \
237 "$pkgdir/usr/share/metainfo/chromium.appdata.xml"
239 -e 's/chromium-browser\.desktop/chromium.desktop/' \
240 -e '/<update_contact>/d' \
241 -e '/<p>/N;/<p>\n.*\(We invite\|Chromium supports Vorbis\)/,/<\/p>/d' \
243 "$pkgdir/usr/share/metainfo/chromium.appdata.xml"
245 local toplevel_files=(
246 chrome_100_percent.pak
247 chrome_200_percent.pak
248 chrome_crashpad_handler
250 v8_context_snapshot.bin
258 vk_swiftshader_icd.json
261 if [[ -z ${_system_libs[icu]+set} ]]; then
262 toplevel_files+=(icudtl.dat)
265 cp "${toplevel_files[@]/#/out/Release/}" "$pkgdir/usr/lib/chromium/"
266 install -Dm644 -t "$pkgdir/usr/lib/chromium/locales" out/Release/locales/*.pak
268 for size in 24 48 64 128 256; do
269 install -Dm644 "chrome/app/theme/chromium/product_logo_$size.png" \
270 "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
273 for size in 16 32; do
274 install -Dm644 "chrome/app/theme/default_100_percent/chromium/product_logo_$size.png" \
275 "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
278 install -Dm644 LICENSE "$pkgdir/usr/share/licenses/chromium/LICENSE"
281 # vim:set ts=2 sw=2 et: