PKGBUILD 9.6 KB

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