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 'wayland' '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 unbundle-jsoncpp-avoid-CFI-faults-with-is_cfi-true.patch
29 re-fix-TFLite-build-error-on-linux-with-system-zlib.patch
30 REVERT-enable-GlobalMediaControlsCastStartStop.patch
31 REVERT-roll-src-third_party-ffmpeg-m102.patch
32 REVERT-roll-src-third_party-ffmpeg-m106.patch
33 angle-wayland-include-protocol.patch
34 use-oauth2-client-switches-as-default.patch)
35 sha256sums=('6c0e00c186e22a1be29177ea410ba40ff0bf65f3ded67a345eb5b17f76c93c59'
36 '213e50f48b67feb4441078d50b0fd431df34323be15be97c55302d3fdac4483a'
37 '2b26c16f8326803ef287fb443a17bc139a440673955c5a6a38e9368bcaeed7c4'
38 'b908f37c5a886e855953f69e4dd6b90baa35e79f5c74673f7425f2cdb642eb00'
39 '9015b9d6d5b4c1e7248d6477a4b4b6bd6a3ebdc57225d2d8efcd79fc61790716'
40 '779fb13f2494209d3a7f1f23a823e59b9dded601866d3ab095937a1a04e19ac6'
41 '30df59a9e2d95dcb720357ec4a83d9be51e59cc5551365da4c0073e68ccdec44'
42 '4c12d31d020799d31355faa7d1fe2a5a807f7458e7f0c374adf55edb37032152'
43 'cd0d9d2a1d6a522d47c3c0891dabe4ad72eabbebc0fe5642b9e22efa3d5ee572'
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=(
53 [fontconfig]=fontconfig
55 [harfbuzz-ng]=harfbuzz
59 #[libavif]=libavif # needs https://github.com/AOMediaCodec/libavif/commit/d22d4de94120
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
89 # Allow building against system libraries in official builds
90 sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \
91 tools/generate_shim_headers/generate_shim_headers.py
93 # https://crbug.com/893950
94 sed -i -e 's/\<xmlMalloc\>/malloc/' -e 's/\<xmlFree\>/free/' \
95 third_party/blink/renderer/core/xml/*.cc \
96 third_party/blink/renderer/core/xml/parser/xml_document_parser.cc \
97 third_party/libxml/chromium/*.cc \
98 third_party/maldoca/src/maldoca/ole/oss_utils.h
100 # Use the --oauth2-client-id= and --oauth2-client-secret= switches for
101 # setting GOOGLE_DEFAULT_CLIENT_ID and GOOGLE_DEFAULT_CLIENT_SECRET at
102 # runtime -- this allows signing into Chromium without baked-in values
103 patch -Np1 -i ../use-oauth2-client-switches-as-default.patch
106 patch -Np1 -i ../unbundle-jsoncpp-avoid-CFI-faults-with-is_cfi-true.patch
107 patch -Np1 -i ../re-fix-TFLite-build-error-on-linux-with-system-zlib.patch
109 # Revert kGlobalMediaControlsCastStartStop enabled by default
110 # https://crbug.com/1314342
111 patch -Rp1 -F3 -i ../REVERT-enable-GlobalMediaControlsCastStartStop.patch
113 # Revert ffmpeg roll requiring new channel layout API support
114 # https://crbug.com/1325301
115 patch -Rp1 -i ../REVERT-roll-src-third_party-ffmpeg-m102.patch
116 # Revert switch from AVFrame::pkt_duration to AVFrame::duration
117 patch -Rp1 -i ../REVERT-roll-src-third_party-ffmpeg-m106.patch
119 # https://crbug.com/angleproject/7582
120 patch -Np0 -i ../angle-wayland-include-protocol.patch
122 # Fixes for building with libstdc++ instead of libc++
123 patch -Np1 -i ../patches/chromium-103-VirtualCursor-std-layout.patch
125 # Link to system tools required by the build
126 mkdir -p third_party/node/linux/node-linux-x64/bin
127 ln -s /usr/bin/node third_party/node/linux/node-linux-x64/bin/
128 ln -s /usr/bin/java third_party/jdk/current/bin/
130 # Remove bundled libraries for which we will use the system copies; this
131 # *should* do what the remove_bundled_libraries.py script does, with the
132 # added benefit of not having to list all the remaining libraries
134 for _lib in ${_unwanted_bundled_libs[@]}; do
135 find "third_party/$_lib" -type f \
136 \! -path "third_party/$_lib/chromium/*" \
137 \! -path "third_party/$_lib/google/*" \
138 \! -path "third_party/harfbuzz-ng/utils/hb_scoped.h" \
139 \! -regex '.*\.\(gn\|gni\|isolate\)' \
143 ./build/linux/unbundle/replace_gn_files.py \
144 --system-libraries "${!_system_libs[@]}"
148 make -C chromium-launcher-$_launcher_ver
158 'custom_toolchain="//build/toolchain/linux/unbundle:default"'
159 'host_toolchain="//build/toolchain/linux/unbundle:default"'
160 'clang_base_path="/usr"'
161 'clang_use_chrome_plugins=false'
162 'is_official_build=true' # implies is_cfi=true on x86_64
163 'symbol_level=0' # sufficient for backtraces on x86(_64)
164 'chrome_pgo_phase=0' # needs newer clang to read the bundled PGO profile
165 'treat_warnings_as_errors=false'
166 'disable_fieldtrial_testing_config=true'
167 'blink_enable_generated_code_formatting=false'
168 'ffmpeg_branding="Chrome"'
169 'proprietary_codecs=true'
170 'rtc_use_pipewire=true'
171 'link_pulseaudio=true'
172 'use_custom_libcxx=false'
173 'use_gnome_keyring=false'
174 'use_qt=false' # look into enabling this for M108
176 'use_system_libwayland_server=true'
177 'use_system_wayland_scanner=true'
178 'enable_hangout_services_extension=true'
179 'enable_widevine=true'
181 "google_api_key=\"$_google_api_key\""
184 if [[ -n ${_system_libs[icu]+set} ]]; then
185 _flags+=('icu_use_data_file=false')
188 # Facilitate deterministic builds (taken from build/config/compiler/BUILD.gn)
189 CFLAGS+=' -Wno-builtin-macro-redefined'
190 CXXFLAGS+=' -Wno-builtin-macro-redefined'
191 CPPFLAGS+=' -D__DATE__= -D__TIME__= -D__TIMESTAMP__='
193 # Do not warn about unknown warning options
194 CFLAGS+=' -Wno-unknown-warning-option'
195 CXXFLAGS+=' -Wno-unknown-warning-option'
197 # Let Chromium set its own symbol level
199 CXXFLAGS=${CXXFLAGS/-g }
201 # https://github.com/ungoogled-software/ungoogled-chromium-archlinux/issues/123
202 CFLAGS=${CFLAGS/-fexceptions}
203 CFLAGS=${CFLAGS/-fcf-protection}
204 CXXFLAGS=${CXXFLAGS/-fexceptions}
205 CXXFLAGS=${CXXFLAGS/-fcf-protection}
207 # This appears to cause random segfaults when combined with ThinLTO
208 # https://bugs.archlinux.org/task/73518
209 CFLAGS=${CFLAGS/-fstack-clash-protection}
210 CXXFLAGS=${CXXFLAGS/-fstack-clash-protection}
212 # https://crbug.com/957519#c122
213 CXXFLAGS=${CXXFLAGS/-Wp,-D_GLIBCXX_ASSERTIONS}
215 gn gen out/Release --args="${_flags[*]}"
216 ninja -C out/Release chrome chrome_sandbox chromedriver.unstripped
220 cd chromium-launcher-$_launcher_ver
221 make PREFIX=/usr DESTDIR="$pkgdir" install
222 install -Dm644 LICENSE \
223 "$pkgdir/usr/share/licenses/chromium/LICENSE.launcher"
225 cd ../chromium-$pkgver
227 install -D out/Release/chrome "$pkgdir/usr/lib/chromium/chromium"
228 install -D out/Release/chromedriver.unstripped "$pkgdir/usr/bin/chromedriver"
229 install -Dm4755 out/Release/chrome_sandbox "$pkgdir/usr/lib/chromium/chrome-sandbox"
231 install -Dm644 chrome/installer/linux/common/desktop.template \
232 "$pkgdir/usr/share/applications/chromium.desktop"
233 install -Dm644 chrome/app/resources/manpage.1.in \
234 "$pkgdir/usr/share/man/man1/chromium.1"
236 -e 's/@@MENUNAME@@/Chromium/g' \
237 -e 's/@@PACKAGE@@/chromium/g' \
238 -e 's/@@USR_BIN_SYMLINK_NAME@@/chromium/g' \
239 "$pkgdir/usr/share/applications/chromium.desktop" \
240 "$pkgdir/usr/share/man/man1/chromium.1"
242 install -Dm644 chrome/installer/linux/common/chromium-browser/chromium-browser.appdata.xml \
243 "$pkgdir/usr/share/metainfo/chromium.appdata.xml"
245 -e 's/chromium-browser\.desktop/chromium.desktop/' \
246 -e '/<update_contact>/d' \
247 -e '/<p>/N;/<p>\n.*\(We invite\|Chromium supports Vorbis\)/,/<\/p>/d' \
249 "$pkgdir/usr/share/metainfo/chromium.appdata.xml"
251 local toplevel_files=(
252 chrome_100_percent.pak
253 chrome_200_percent.pak
254 chrome_crashpad_handler
256 v8_context_snapshot.bin
264 vk_swiftshader_icd.json
267 if [[ -z ${_system_libs[icu]+set} ]]; then
268 toplevel_files+=(icudtl.dat)
271 cp "${toplevel_files[@]/#/out/Release/}" "$pkgdir/usr/lib/chromium/"
272 install -Dm644 -t "$pkgdir/usr/lib/chromium/locales" out/Release/locales/*.pak
274 for size in 24 48 64 128 256; do
275 install -Dm644 "chrome/app/theme/chromium/product_logo_$size.png" \
276 "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
279 for size in 16 32; do
280 install -Dm644 "chrome/app/theme/default_100_percent/chromium/product_logo_$size.png" \
281 "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
284 install -Dm644 LICENSE "$pkgdir/usr/share/licenses/chromium/LICENSE"
287 # vim:set ts=2 sw=2 et: