PKGBUILD 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. # Maintainer: Seppia <seppia@seppio.fish>
  2. # Maintainer: JustKidding <jk@vin.ovh>
  3. # Based on aur/chromium-vaapi, with ungoogled-chromium patches
  4. # Maintainer: Evangelos Foutras <evangelos@foutrelis.com>
  5. # Contributor: Pierre Schmitz <pierre@archlinux.de>
  6. # Contributor: Jan "heftig" Steffens <jan.steffens@gmail.com>
  7. # Contributor: Daniel J Griffiths <ghost1227@archlinux.us>
  8. pkgname=ungoogled-chromium
  9. pkgver=94.0.4606.81
  10. pkgrel=1
  11. _launcher_ver=8
  12. _gcc_patchset=3
  13. pkgdesc="A lightweight approach to removing Google web service dependency"
  14. arch=('x86_64')
  15. url="https://github.com/Eloston/ungoogled-chromium"
  16. license=('BSD')
  17. depends=('gtk3' 'nss' 'alsa-lib' 'xdg-utils' 'libxss' 'libcups' 'libgcrypt'
  18. 'ttf-liberation' 'systemd' 'dbus' 'libpulse' 'pciutils' 'libva'
  19. 'desktop-file-utils' 'hicolor-icon-theme')
  20. makedepends=('python' 'gn' 'ninja' 'clang' 'lld' 'gperf' 'nodejs' 'pipewire'
  21. 'java-runtime-headless')
  22. optdepends=('pipewire: WebRTC desktop sharing under Wayland'
  23. 'kdialog: support for native dialogs in Plasma'
  24. 'org.freedesktop.secrets: password storage backend on GNOME / Xfce'
  25. 'kwallet: support for storing passwords in KWallet on Plasma')
  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. https://github.com/stha09/chromium-patches/releases/download/chromium-${pkgver%%.*}-patchset-$_gcc_patchset/chromium-${pkgver%%.*}-patchset-$_gcc_patchset.tar.xz
  29. replace-blacklist-with-ignorelist.patch
  30. add-a-TODO-about-a-missing-pnacl-flag.patch
  31. use-ffile-compilation-dir.patch
  32. pipewire-do-not-typecheck-the-portal-session_handle.patch
  33. sql-make-VirtualCursor-standard-layout-type.patch
  34. chromium-93-ffmpeg-4.4.patch
  35. chromium-94-ffmpeg-roll.patch
  36. unexpire-accelerated-video-decode-flag.patch
  37. use-oauth2-client-switches-as-default.patch)
  38. sha256sums=('7071aa2b2caf48094c2ae816395948b4daec940606f4982ad5bbf68e5d2de598'
  39. '213e50f48b67feb4441078d50b0fd431df34323be15be97c55302d3fdac4483a'
  40. '22692bddaf2761c6ddf9ff0bc4722972bca4d4c5b2fd3e5dbdac7eb60d914320'
  41. 'd3344ba39b8c6ed202334ba7f441c70d81ddf8cdb15af1aa8c16e9a3a75fbb35'
  42. 'd53da216538f2e741a6e048ed103964a91a98e9a3c10c27fdfa34d4692fdc455'
  43. '921010cd8fab5f30be76c68b68c9b39fac9e21f4c4133bb709879592bbdf606e'
  44. '1889d890ff512a8b82a0f88972e78c78131177d8034750ff53577dfad99b3e3e'
  45. 'dd317f85e5abfdcfc89c6f23f4c8edbcdebdd5e083dcec770e5da49ee647d150'
  46. '1a9e074f417f8ffd78bcd6874d8e2e74a239905bf662f76a7755fa40dc476b57'
  47. '56acb6e743d2ab1ed9f3eb01700ade02521769978d03ac43226dec94659b3ace'
  48. '2a97b26c3d6821b15ef4ef1369905c6fa3e9c8da4877eb9af4361452a425290b'
  49. 'e393174d7695d0bafed69e868c5fbfecf07aa6969f3b64596d0bae8b067e1711')
  50. provides=('chromium')
  51. conflicts=('chromium')
  52. source=(${source[@]}
  53. $pkgname-$pkgver-1.tar.gz::https://github.com/Eloston/ungoogled-chromium/archive/$pkgver-1.tar.gz
  54. chromium-drirc-disable-10bpc-color-configs.conf
  55. wayland-egl.patch)
  56. sha256sums=(${sha256sums[@]}
  57. 'dfb162c8824f98095bc5fa8928d44bcb5fb66a19873a5976b8059abe20cad6fe'
  58. 'babda4f5c1179825797496898d77334ac067149cac03d797ab27ac69671a7feb'
  59. '34d08ea93cb4762cb33c7cffe931358008af32265fc720f2762f0179c3973574')
  60. # Possible replacements are listed in build/linux/unbundle/replace_gn_files.py
  61. # Keys are the names in the above script; values are the dependencies in Arch
  62. declare -gA _system_libs=(
  63. [ffmpeg]=ffmpeg
  64. [flac]=flac
  65. [fontconfig]=fontconfig
  66. [freetype]=freetype2
  67. [harfbuzz-ng]=harfbuzz
  68. [icu]=icu
  69. [libdrm]=
  70. [libjpeg]=libjpeg
  71. [libpng]=libpng
  72. #[libvpx]=libvpx
  73. [libwebp]=libwebp
  74. [libxml]=libxml2
  75. [libxslt]=libxslt
  76. [opus]=opus
  77. [re2]=re2
  78. [snappy]=snappy
  79. [zlib]=minizip
  80. )
  81. _unwanted_bundled_libs=(
  82. $(printf "%s\n" ${!_system_libs[@]} | sed 's/^libjpeg$/&_turbo/')
  83. )
  84. depends+=(${_system_libs[@]})
  85. prepare() {
  86. cd "$srcdir/chromium-$pkgver"
  87. # Allow building against system libraries in official builds
  88. sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \
  89. tools/generate_shim_headers/generate_shim_headers.py
  90. # https://crbug.com/893950
  91. sed -i -e 's/\<xmlMalloc\>/malloc/' -e 's/\<xmlFree\>/free/' \
  92. third_party/blink/renderer/core/xml/*.cc \
  93. third_party/blink/renderer/core/xml/parser/xml_document_parser.cc \
  94. third_party/libxml/chromium/*.cc
  95. # Use the --oauth2-client-id= and --oauth2-client-secret= switches for
  96. # setting GOOGLE_DEFAULT_CLIENT_ID and GOOGLE_DEFAULT_CLIENT_SECRET at
  97. # runtime -- this allows signing into Chromium without baked-in values
  98. patch -Np1 -i ../use-oauth2-client-switches-as-default.patch
  99. # Fix build with older ffmpeg
  100. patch -Np1 -i ../chromium-93-ffmpeg-4.4.patch
  101. # Revert change to custom function av_stream_get_first_dts; will need to
  102. # switch to bundled ffmpeg when we're no longer using ffmpeg 4.4 in Arch
  103. # Upstream commit that made first_dts internal causing Chromium to add a
  104. # custom function: https://github.com/FFmpeg/FFmpeg/commit/591b88e6787c4
  105. # https://crbug.com/1251779
  106. patch -Rp1 -i ../chromium-94-ffmpeg-roll.patch
  107. # https://crbug.com/1207478
  108. patch -Np0 -i ../unexpire-accelerated-video-decode-flag.patch
  109. # Revert transition to -fsanitize-ignorelist (needs newer clang)
  110. patch -Rp1 -i ../replace-blacklist-with-ignorelist.patch
  111. # Revert addition of -ffile-compilation-dir= (needs newer clang)
  112. patch -Rp1 -i ../add-a-TODO-about-a-missing-pnacl-flag.patch
  113. patch -Rp1 -i ../use-ffile-compilation-dir.patch
  114. # Fix desktop sharing via Pipewire with xdg-desktop-portal 1.10
  115. patch -Np1 -d third_party/webrtc <../pipewire-do-not-typecheck-the-portal-session_handle.patch
  116. # https://chromium-review.googlesource.com/c/chromium/src/+/2862724
  117. patch -Np1 -i ../sql-make-VirtualCursor-standard-layout-type.patch
  118. # Fixes for building with libstdc++ instead of libc++
  119. patch -Np1 -i ../patches/chromium-90-ruy-include.patch
  120. patch -Np1 -i ../patches/chromium-94-CustomSpaces-include.patch
  121. # Wayland/EGL regression (crbug #1071528 #1071550)
  122. patch -Np1 -i ../wayland-egl.patch
  123. # Ungoogled Chromium changes
  124. _ungoogled_repo="$srcdir/$pkgname-$pkgver-1"
  125. _utils="${_ungoogled_repo}/utils"
  126. python "$_utils/prune_binaries.py" ./ "$_ungoogled_repo/pruning.list"
  127. python "$_utils/patches.py" apply ./ "$_ungoogled_repo/patches"
  128. python "$_utils/domain_substitution.py" apply -r "$_ungoogled_repo/domain_regex.list" \
  129. -f "$_ungoogled_repo/domain_substitution.list" -c domainsubcache.tar.gz ./
  130. # Link to system tools required by the build
  131. mkdir -p third_party/node/linux/node-linux-x64/bin
  132. ln -s /usr/bin/node third_party/node/linux/node-linux-x64/bin/
  133. ln -s /usr/bin/java third_party/jdk/current/bin/
  134. # Remove bundled libraries for which we will use the system copies; this
  135. # *should* do what the remove_bundled_libraries.py script does, with the
  136. # added benefit of not having to list all the remaining libraries
  137. local _lib
  138. for _lib in ${_unwanted_bundled_libs[@]}; do
  139. find "third_party/$_lib" -type f \
  140. \! -path "third_party/$_lib/chromium/*" \
  141. \! -path "third_party/$_lib/google/*" \
  142. \! -path "third_party/harfbuzz-ng/utils/hb_scoped.h" \
  143. \! -regex '.*\.\(gn\|gni\|isolate\)' \
  144. -delete
  145. done
  146. ./build/linux/unbundle/replace_gn_files.py \
  147. --system-libraries "${!_system_libs[@]}"
  148. }
  149. build() {
  150. make -C chromium-launcher-$_launcher_ver
  151. cd "$srcdir/chromium-$pkgver"
  152. export CC=clang
  153. export CXX=clang++
  154. export AR=ar
  155. export NM=nm
  156. local _flags=(
  157. 'custom_toolchain="//build/toolchain/linux/unbundle:default"'
  158. 'host_toolchain="//build/toolchain/linux/unbundle:default"'
  159. 'is_official_build=true' # implies is_cfi=true on x86_64
  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_gnome_keyring=false'
  167. 'use_sysroot=false'
  168. 'use_custom_libcxx=false'
  169. 'enable_widevine=true'
  170. )
  171. if [[ -n ${_system_libs[icu]+set} ]]; then
  172. _flags+=('icu_use_data_file=false')
  173. fi
  174. if check_option strip y; then
  175. _flags+=('symbol_level=0')
  176. fi
  177. # Append ungoogled chromium flags to _flags array
  178. _ungoogled_repo="$srcdir/$pkgname-$pkgver-1"
  179. readarray -t -O ${#_flags[@]} _flags < "${_ungoogled_repo}/flags.gn"
  180. # use fixed flags as system flags break build
  181. CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt"
  182. CXXFLAGS="$CFLAGS"
  183. # Facilitate deterministic builds (taken from build/config/compiler/BUILD.gn)
  184. CFLAGS+=' -Wno-builtin-macro-redefined'
  185. CXXFLAGS+=' -Wno-builtin-macro-redefined'
  186. 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'
  190. gn gen out/Release --args="${_flags[*]}"
  191. ninja -C out/Release chrome chrome_sandbox chromedriver
  192. }
  193. package() {
  194. cd chromium-launcher-$_launcher_ver
  195. make PREFIX=/usr DESTDIR="$pkgdir" install
  196. install -Dm644 LICENSE \
  197. "$pkgdir/usr/share/licenses/chromium/LICENSE.launcher"
  198. cd "$srcdir/chromium-$pkgver"
  199. install -D out/Release/chrome "$pkgdir/usr/lib/chromium/chromium"
  200. install -Dm4755 out/Release/chrome_sandbox "$pkgdir/usr/lib/chromium/chrome-sandbox"
  201. ln -s /usr/lib/chromium/chromedriver "$pkgdir/usr/bin/chromedriver"
  202. install -Dm644 ../chromium-drirc-disable-10bpc-color-configs.conf \
  203. "$pkgdir/usr/share/drirc.d/10-$pkgname.conf"
  204. install -Dm644 chrome/installer/linux/common/desktop.template \
  205. "$pkgdir/usr/share/applications/chromium.desktop"
  206. install -Dm644 chrome/app/resources/manpage.1.in \
  207. "$pkgdir/usr/share/man/man1/chromium.1"
  208. sed -i \
  209. -e 's/@@MENUNAME@@/Chromium/g' \
  210. -e 's/@@PACKAGE@@/chromium/g' \
  211. -e 's/@@USR_BIN_SYMLINK_NAME@@/chromium/g' \
  212. "$pkgdir/usr/share/applications/chromium.desktop" \
  213. "$pkgdir/usr/share/man/man1/chromium.1"
  214. install -Dm644 chrome/installer/linux/common/chromium-browser/chromium-browser.appdata.xml \
  215. "$pkgdir/usr/share/metainfo/chromium.appdata.xml"
  216. sed -ni \
  217. -e 's/chromium-browser\.desktop/chromium.desktop/' \
  218. -e '/<update_contact>/d' \
  219. -e '/<p>/N;/<p>\n.*\(We invite\|Chromium supports Vorbis\)/,/<\/p>/d' \
  220. -e '/^<?xml/,$p' \
  221. "$pkgdir/usr/share/metainfo/chromium.appdata.xml"
  222. local toplevel_files=(
  223. chrome_100_percent.pak
  224. chrome_200_percent.pak
  225. resources.pak
  226. v8_context_snapshot.bin
  227. # ANGLE
  228. libEGL.so
  229. libGLESv2.so
  230. chromedriver
  231. chrome_crashpad_handler
  232. )
  233. if [[ -z ${_system_libs[icu]+set} ]]; then
  234. toplevel_files+=(icudtl.dat)
  235. fi
  236. cp "${toplevel_files[@]/#/out/Release/}" "$pkgdir/usr/lib/chromium/"
  237. install -Dm644 -t "$pkgdir/usr/lib/chromium/locales" out/Release/locales/*.pak
  238. install -Dm755 -t "$pkgdir/usr/lib/chromium/swiftshader" out/Release/swiftshader/*.so
  239. for size in 24 48 64 128 256; do
  240. install -Dm644 "chrome/app/theme/chromium/product_logo_$size.png" \
  241. "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
  242. done
  243. for size in 16 32; do
  244. install -Dm644 "chrome/app/theme/default_100_percent/chromium/product_logo_$size.png" \
  245. "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
  246. done
  247. install -Dm644 LICENSE "$pkgdir/usr/share/licenses/chromium/LICENSE"
  248. }
  249. # vim:set ts=2 sw=2 et: