PKGBUILD 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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=87.0.4280.141
  10. pkgrel=1
  11. _launcher_ver=6
  12. _gcc_patchset=9
  13. _pkgname=$(echo $pkgname | cut -d\- -f1-2)
  14. _pkgver=$(echo $pkgver | cut -d\. -f1-4)
  15. # ungoogled chromium variables
  16. _uc_ver=$pkgver-1
  17. _uc_usr=Eloston
  18. pkgdesc="A lightweight approach to removing Google web service dependency"
  19. arch=('x86_64')
  20. url="https://github.com/Eloston/ungoogled-chromium"
  21. license=('BSD')
  22. depends=('gtk3' 'nss' 'alsa-lib' 'xdg-utils' 'libxss' 'libcups' 'libgcrypt'
  23. 'ttf-liberation' 'systemd' 'dbus' 'libpulse' 'pciutils' 'json-glib'
  24. 'desktop-file-utils' 'hicolor-icon-theme')
  25. makedepends=('python' 'python2' 'gperf' 'mesa' 'ninja' 'nodejs' 'git' 'libva'
  26. 'libpipewire02' 'clang' 'lld' 'gn' 'java-runtime-headless'
  27. 'python2-setuptools')
  28. optdepends=('pepper-flash: support for Flash content'
  29. 'libpipewire02: WebRTC desktop sharing under Wayland'
  30. 'libva: hardware-accelerated video decode [experimental]'
  31. 'kdialog: needed for file dialogs in KDE'
  32. 'org.freedesktop.secrets: password storage backend on GNOME / Xfce'
  33. 'kwallet: for storing passwords in KWallet on KDE desktops')
  34. provides=('chromium')
  35. conflicts=('chromium')
  36. source=(https://commondatastorage.googleapis.com/chromium-browser-official/chromium-$_pkgver.tar.xz
  37. $_pkgname-$_uc_ver.tar.gz::https://github.com/$_uc_usr/ungoogled-chromium/archive/$_uc_ver.tar.gz
  38. https://github.com/foutrelis/chromium-launcher/archive/v$_launcher_ver/chromium-launcher-$_launcher_ver.tar.gz
  39. chromium-drirc-disable-10bpc-color-configs.conf
  40. https://github.com/stha09/chromium-patches/releases/download/chromium-${pkgver%%.*}-patchset-$_gcc_patchset/chromium-${pkgver%%.*}-patchset-$_gcc_patchset.tar.xz
  41. wayland-egl.patch
  42. icu68.patch
  43. v8-icu68.patch
  44. subpixel-anti-aliasing-in-FreeType-2.8.1.patch)
  45. sha256sums=('147591d7fc21e1a173701d28bbf35baddb91e64dd96ec16d8eee9a5113403375'
  46. '3c2d6711d3f9490eb68c4e2cdd653163b163305d25890ccc32cd51e53164a4bb'
  47. '04917e3cd4307d8e31bfb0027a5dce6d086edb10ff8a716024fbb8bb0c7dccf1'
  48. 'babda4f5c1179825797496898d77334ac067149cac03d797ab27ac69671a7feb'
  49. 'c99934bcd2f3ae8ea9620f5f59a94338b2cf739647f04c28c8a551d9083fa7e9'
  50. 'bf86923eaee5529ab9fb6148bd6c33a73c8746ab1b4ade0cd3b761109bc55826'
  51. '38fb5218331d6e03915490dab64f7b8bf26833a581d1aaa02090437c67e9439c'
  52. '6e919c9712d8fe6c2918778df1f8c2ee0675a87a48be5d2aaa54e320703ced4b'
  53. '1e2913e21c491d546e05f9b4edf5a6c7a22d89ed0b36ef692ca6272bcd5faec6')
  54. # Possible replacements are listed in build/linux/unbundle/replace_gn_files.py
  55. # Keys are the names in the above script; values are the dependencies in Arch
  56. declare -gA _system_libs=(
  57. [ffmpeg]=ffmpeg
  58. [flac]=flac
  59. [fontconfig]=fontconfig
  60. [freetype]=freetype2
  61. [harfbuzz-ng]=harfbuzz
  62. [icu]=icu
  63. [libdrm]=
  64. [libjpeg]=libjpeg
  65. [libpng]=libpng
  66. #[libvpx]=libvpx
  67. [libwebp]=libwebp
  68. [libxml]=libxml2
  69. [libxslt]=libxslt
  70. [opus]=opus
  71. [re2]=re2
  72. [snappy]=snappy
  73. [zlib]=minizip
  74. )
  75. _unwanted_bundled_libs=(
  76. $(printf "%s\n" ${!_system_libs[@]} | sed 's/^libjpeg$/&_turbo/')
  77. )
  78. depends+=(${_system_libs[@]})
  79. prepare() {
  80. cd "$srcdir/chromium-$_pkgver"
  81. # Allow building against system libraries in official builds
  82. sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \
  83. tools/generate_shim_headers/generate_shim_headers.py
  84. # https://crbug.com/893950
  85. sed -i -e 's/\<xmlMalloc\>/malloc/' -e 's/\<xmlFree\>/free/' \
  86. third_party/blink/renderer/core/xml/*.cc \
  87. third_party/blink/renderer/core/xml/parser/xml_document_parser.cc \
  88. third_party/libxml/chromium/*.cc
  89. # Upstream fixes
  90. patch -Np1 -i ../icu68.patch
  91. patch -Np1 -d v8 <../v8-icu68.patch
  92. patch -Np1 -d third_party/skia <../subpixel-anti-aliasing-in-FreeType-2.8.1.patch
  93. # Fixes for building with libstdc++ instead of libc++
  94. patch -Np1 -i ../patches/chromium-87-ServiceWorkerContainerHost-crash.patch
  95. patch -Np1 -i ../patches/chromium-87-openscreen-include.patch
  96. # Wayland/EGL regression (crbug #1071528 #1071550)
  97. patch -Np1 -i ../wayland-egl.patch
  98. # Ungoogled Chromium changes
  99. _ungoogled_repo="$srcdir/$_pkgname-$_uc_ver"
  100. _utils="${_ungoogled_repo}/utils"
  101. msg2 'Pruning binaries'
  102. python "$_utils/prune_binaries.py" ./ "$_ungoogled_repo/pruning.list"
  103. msg2 'Applying patches'
  104. python "$_utils/patches.py" apply ./ "$_ungoogled_repo/patches"
  105. msg2 'Applying domain substitution'
  106. python "$_utils/domain_substitution.py" apply -r "$_ungoogled_repo/domain_regex.list" \
  107. -f "$_ungoogled_repo/domain_substitution.list" -c domainsubcache.tar.gz ./
  108. # Force script incompatible with Python 3 to use /usr/bin/python2
  109. sed -i '1s|python$|&2|' third_party/dom_distiller_js/protoc_plugins/*.py
  110. mkdir -p third_party/node/linux/node-linux-x64/bin
  111. ln -s /usr/bin/node third_party/node/linux/node-linux-x64/bin/
  112. # Remove bundled libraries for which we will use the system copies; this
  113. # *should* do what the remove_bundled_libraries.py script does, with the
  114. # added benefit of not having to list all the remaining libraries
  115. local _lib
  116. for _lib in ${_unwanted_bundled_libs[@]}; do
  117. find "third_party/$_lib" -type f \
  118. \! -path "third_party/$_lib/chromium/*" \
  119. \! -path "third_party/$_lib/google/*" \
  120. \! -path "third_party/harfbuzz-ng/utils/hb_scoped.h" \
  121. \! -regex '.*\.\(gn\|gni\|isolate\)' \
  122. -delete
  123. done
  124. python2 build/linux/unbundle/replace_gn_files.py \
  125. --system-libraries "${!_system_libs[@]}"
  126. }
  127. build() {
  128. make -C chromium-launcher-$_launcher_ver
  129. cd "$srcdir/chromium-$_pkgver"
  130. if check_buildoption ccache y; then
  131. # Avoid falling back to preprocessor mode when sources contain time macros
  132. export CCACHE_SLOPPINESS=time_macros
  133. fi
  134. export CC=clang
  135. export CXX=clang++
  136. export AR=ar
  137. export NM=nm
  138. local _flags=(
  139. 'custom_toolchain="//build/toolchain/linux/unbundle:default"'
  140. 'host_toolchain="//build/toolchain/linux/unbundle:default"'
  141. 'is_official_build=true' # implies is_cfi=true on x86_64
  142. 'ffmpeg_branding="Chrome"'
  143. 'proprietary_codecs=true'
  144. 'rtc_use_pipewire=true'
  145. 'link_pulseaudio=true'
  146. 'use_gnome_keyring=false'
  147. 'use_sysroot=false'
  148. 'use_custom_libcxx=false'
  149. 'enable_widevine=true'
  150. 'use_vaapi=true'
  151. )
  152. if [[ -n ${_system_libs[icu]+set} ]]; then
  153. _flags+=('icu_use_data_file=false')
  154. fi
  155. if check_option strip y; then
  156. _flags+=('symbol_level=0')
  157. fi
  158. # Append ungoogled chromium flags to _flags array
  159. _ungoogled_repo="$srcdir/$_pkgname-$_uc_ver"
  160. readarray -t -O ${#_flags[@]} _flags < "${_ungoogled_repo}/flags.gn"
  161. # Facilitate deterministic builds (taken from build/config/compiler/BUILD.gn)
  162. CFLAGS+=' -Wno-builtin-macro-redefined'
  163. CXXFLAGS+=' -Wno-builtin-macro-redefined'
  164. CPPFLAGS+=' -D__DATE__= -D__TIME__= -D__TIMESTAMP__='
  165. # Do not warn about unknown warning options
  166. CFLAGS+=' -Wno-unknown-warning-option'
  167. CXXFLAGS+=' -Wno-unknown-warning-option'
  168. msg2 'Configuring Chromium'
  169. gn gen out/Release --args="${_flags[*]}" --script-executable=python2
  170. msg2 'Building Chromium'
  171. ninja -C out/Release chrome chrome_sandbox chromedriver
  172. }
  173. package() {
  174. cd chromium-launcher-$_launcher_ver
  175. make PREFIX=/usr DESTDIR="$pkgdir" install
  176. install -Dm644 LICENSE \
  177. "$pkgdir/usr/share/licenses/chromium/LICENSE.launcher"
  178. cd "$srcdir/chromium-$_pkgver"
  179. install -D out/Release/chrome "$pkgdir/usr/lib/chromium/chromium"
  180. install -Dm4755 out/Release/chrome_sandbox "$pkgdir/usr/lib/chromium/chrome-sandbox"
  181. ln -s /usr/lib/chromium/chromedriver "$pkgdir/usr/bin/chromedriver"
  182. install -Dm644 ../chromium-drirc-disable-10bpc-color-configs.conf \
  183. "$pkgdir/usr/share/drirc.d/10-$pkgname.conf"
  184. install -Dm644 chrome/installer/linux/common/desktop.template \
  185. "$pkgdir/usr/share/applications/chromium.desktop"
  186. install -Dm644 chrome/app/resources/manpage.1.in \
  187. "$pkgdir/usr/share/man/man1/chromium.1"
  188. sed -i \
  189. -e 's/@@MENUNAME@@/Chromium/g' \
  190. -e 's/@@PACKAGE@@/chromium/g' \
  191. -e 's/@@USR_BIN_SYMLINK_NAME@@/chromium/g' \
  192. "$pkgdir/usr/share/applications/chromium.desktop" \
  193. "$pkgdir/usr/share/man/man1/chromium.1"
  194. install -Dm644 chrome/installer/linux/common/chromium-browser/chromium-browser.appdata.xml \
  195. "$pkgdir/usr/share/metainfo/chromium.appdata.xml"
  196. sed -ni \
  197. -e 's/chromium-browser\.desktop/chromium.desktop/' \
  198. -e '/<update_contact>/d' \
  199. -e '/<p>/N;/<p>\n.*\(We invite\|Chromium supports Vorbis\)/,/<\/p>/d' \
  200. -e '/^<?xml/,$p' \
  201. "$pkgdir/usr/share/metainfo/chromium.appdata.xml"
  202. local toplevel_files=(
  203. chrome_100_percent.pak
  204. chrome_200_percent.pak
  205. resources.pak
  206. v8_context_snapshot.bin
  207. # ANGLE
  208. libEGL.so
  209. libGLESv2.so
  210. chromedriver
  211. )
  212. if [[ -z ${_system_libs[icu]+set} ]]; then
  213. toplevel_files+=(icudtl.dat)
  214. fi
  215. cp "${toplevel_files[@]/#/out/Release/}" "$pkgdir/usr/lib/chromium/"
  216. install -Dm644 -t "$pkgdir/usr/lib/chromium/locales" out/Release/locales/*.pak
  217. install -Dm755 -t "$pkgdir/usr/lib/chromium/swiftshader" out/Release/swiftshader/*.so
  218. for size in 24 48 64 128 256; do
  219. install -Dm644 "chrome/app/theme/chromium/product_logo_$size.png" \
  220. "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
  221. done
  222. for size in 16 32; do
  223. install -Dm644 "chrome/app/theme/default_100_percent/chromium/product_logo_$size.png" \
  224. "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
  225. done
  226. install -Dm644 LICENSE "$pkgdir/usr/share/licenses/chromium/LICENSE"
  227. }
  228. # vim:set ts=2 sw=2 et ft=sh: