sbcl rebuild
[arch-packages.git] / chromium / trunk / PKGBUILD
blob1be74958796b44c3e6ab0ae40724676c52f7b6d6
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=107.0.5304.87
8 pkgrel=1
9 _launcher_ver=8
10 _gcc_patchset=1
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          '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=(
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
59   #[libavif]=libavif  # needs https://github.com/AOMediaCodec/libavif/commit/d22d4de94120
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
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   cd chromium-$pkgver
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
105   # Upstream fixes
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
133   local _lib
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\)' \
140       -delete
141   done
143   ./build/linux/unbundle/replace_gn_files.py \
144     --system-libraries "${!_system_libs[@]}"
147 build() {
148   make -C chromium-launcher-$_launcher_ver
150   cd chromium-$pkgver
152   export CC=clang
153   export CXX=clang++
154   export AR=ar
155   export NM=nm
157   local _flags=(
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
175     'use_sysroot=false'
176     'use_system_libwayland_server=true'
177     'use_system_wayland_scanner=true'
178     'enable_hangout_services_extension=true'
179     'enable_widevine=true'
180     'enable_nacl=false'
181     "google_api_key=\"$_google_api_key\""
182   )
184   if [[ -n ${_system_libs[icu]+set} ]]; then
185     _flags+=('icu_use_data_file=false')
186   fi
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
198   CFLAGS=${CFLAGS/-g }
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
219 package() {
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"
235   sed -i \
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"
244   sed -ni \
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' \
248     -e '/^<?xml/,$p' \
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
255     resources.pak
256     v8_context_snapshot.bin
258     # ANGLE
259     libEGL.so
260     libGLESv2.so
262     # SwiftShader ICD
263     libvk_swiftshader.so
264     vk_swiftshader_icd.json
265   )
267   if [[ -z ${_system_libs[icu]+set} ]]; then
268     toplevel_files+=(icudtl.dat)
269   fi
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"
277   done
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"
282   done
284   install -Dm644 LICENSE "$pkgdir/usr/share/licenses/chromium/LICENSE"
287 # vim:set ts=2 sw=2 et: