PKGBUILD 9.6 KB

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