PKGBUILD 9.8 KB

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