PKGBUILD 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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=92.0.4515.131
  10. pkgrel=1
  11. _launcher_ver=8
  12. _gcc_patchset=7
  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' 'python2')
  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. extend-enable-accelerated-video-decode-flag.patch
  30. linux-sandbox-syscall-broker-use-struct-kernel_stat.patch
  31. linux-sandbox-fix-fstatat-crash.patch
  32. sql-make-VirtualCursor-standard-layout-type.patch
  33. chromium-freetype-2.11.patch
  34. use-oauth2-client-switches-as-default.patch)
  35. sha256sums=('b6ac840ed5390de69f962e922649bf1df895ff0f5db8e5f656b5191e0cf4ce3a'
  36. '213e50f48b67feb4441078d50b0fd431df34323be15be97c55302d3fdac4483a'
  37. '53a2cbb1b58d652d5424ff9040b6a51b9dc6348ce3edc68344cd0d25f1f4beb2'
  38. '66db9132d6f5e06aa26e5de0924f814224a76a9bdf4b61afce161fb1d7643b22'
  39. '268e18ad56e5970157b51ec9fc8eb58ba93e313ea1e49c842a1ed0820d9c1fa3'
  40. '253348550d54b8ae317fd250f772f506d2bae49fb5dc75fe15d872ea3d0e04a5'
  41. 'dd317f85e5abfdcfc89c6f23f4c8edbcdebdd5e083dcec770e5da49ee647d150'
  42. '7ef689cd6b2f85f2b76b2a10ecede003cfa0c2da15acc998ecbc445f2c95ced6'
  43. 'e393174d7695d0bafed69e868c5fbfecf07aa6969f3b64596d0bae8b067e1711')
  44. provides=('chromium')
  45. conflicts=('chromium')
  46. source=(${source[@]}
  47. $pkgname-$pkgver-1.tar.gz::https://github.com/Eloston/ungoogled-chromium/archive/$pkgver-1.tar.gz
  48. chromium-drirc-disable-10bpc-color-configs.conf
  49. wayland-egl.patch)
  50. sha256sums=(${sha256sums[@]}
  51. '417ed82d81895d3cd2773e9a44406dc676810e1faf09947be3084c53afcdaee4'
  52. 'babda4f5c1179825797496898d77334ac067149cac03d797ab27ac69671a7feb'
  53. '34d08ea93cb4762cb33c7cffe931358008af32265fc720f2762f0179c3973574')
  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. # Use the --oauth2-client-id= and --oauth2-client-secret= switches for
  90. # setting GOOGLE_DEFAULT_CLIENT_ID and GOOGLE_DEFAULT_CLIENT_SECRET at
  91. # runtime -- this allows signing into Chromium without baked-in values
  92. patch -Np1 -i ../use-oauth2-client-switches-as-default.patch
  93. # Fix build with FreeType 2.11 (patch from Gentoo)
  94. patch -Np1 -i ../chromium-freetype-2.11.patch
  95. # Upstream fixes
  96. patch -Np1 -i ../extend-enable-accelerated-video-decode-flag.patch
  97. patch -Np1 -i ../linux-sandbox-syscall-broker-use-struct-kernel_stat.patch
  98. patch -Np1 -i ../linux-sandbox-fix-fstatat-crash.patch
  99. # https://chromium-review.googlesource.com/c/chromium/src/+/2862724
  100. patch -Np1 -i ../sql-make-VirtualCursor-standard-layout-type.patch
  101. # Fixes for building with libstdc++ instead of libc++
  102. patch -Np1 -i ../patches/chromium-90-ruy-include.patch
  103. # Wayland/EGL regression (crbug #1071528 #1071550)
  104. patch -Np1 -i ../wayland-egl.patch
  105. # Ungoogled Chromium changes
  106. _ungoogled_repo="$srcdir/$pkgname-$pkgver-1"
  107. _utils="${_ungoogled_repo}/utils"
  108. python "$_utils/prune_binaries.py" ./ "$_ungoogled_repo/pruning.list"
  109. python "$_utils/patches.py" apply ./ "$_ungoogled_repo/patches"
  110. python "$_utils/domain_substitution.py" apply -r "$_ungoogled_repo/domain_regex.list" \
  111. -f "$_ungoogled_repo/domain_substitution.list" -c domainsubcache.tar.gz ./
  112. # Link to system tools required by the build
  113. mkdir -p third_party/node/linux/node-linux-x64/bin
  114. ln -s /usr/bin/node third_party/node/linux/node-linux-x64/bin/
  115. ln -s /usr/bin/java third_party/jdk/current/bin/
  116. # Remove bundled libraries for which we will use the system copies; this
  117. # *should* do what the remove_bundled_libraries.py script does, with the
  118. # added benefit of not having to list all the remaining libraries
  119. local _lib
  120. for _lib in ${_unwanted_bundled_libs[@]}; do
  121. find "third_party/$_lib" -type f \
  122. \! -path "third_party/$_lib/chromium/*" \
  123. \! -path "third_party/$_lib/google/*" \
  124. \! -path "third_party/harfbuzz-ng/utils/hb_scoped.h" \
  125. \! -regex '.*\.\(gn\|gni\|isolate\)' \
  126. -delete
  127. done
  128. ./build/linux/unbundle/replace_gn_files.py \
  129. --system-libraries "${!_system_libs[@]}"
  130. }
  131. build() {
  132. make -C chromium-launcher-$_launcher_ver
  133. cd "$srcdir/chromium-$pkgver"
  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. )
  151. if [[ -n ${_system_libs[icu]+set} ]]; then
  152. _flags+=('icu_use_data_file=false')
  153. fi
  154. if check_option strip y; then
  155. _flags+=('symbol_level=0')
  156. fi
  157. # Append ungoogled chromium flags to _flags array
  158. _ungoogled_repo="$srcdir/$pkgname-$pkgver-1"
  159. readarray -t -O ${#_flags[@]} _flags < "${_ungoogled_repo}/flags.gn"
  160. # use fixed flags as system flags break build
  161. CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt"
  162. CXXFLAGS="$CFLAGS"
  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. gn gen out/Release --args="${_flags[*]}"
  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. crashpad_handler
  212. )
  213. if [[ -z ${_system_libs[icu]+set} ]]; then
  214. toplevel_files+=(icudtl.dat)
  215. fi
  216. cp "${toplevel_files[@]/#/out/Release/}" "$pkgdir/usr/lib/chromium/"
  217. install -Dm644 -t "$pkgdir/usr/lib/chromium/locales" out/Release/locales/*.pak
  218. install -Dm755 -t "$pkgdir/usr/lib/chromium/swiftshader" out/Release/swiftshader/*.so
  219. for size in 24 48 64 128 256; do
  220. install -Dm644 "chrome/app/theme/chromium/product_logo_$size.png" \
  221. "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
  222. done
  223. for size in 16 32; do
  224. install -Dm644 "chrome/app/theme/default_100_percent/chromium/product_logo_$size.png" \
  225. "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
  226. done
  227. install -Dm644 LICENSE "$pkgdir/usr/share/licenses/chromium/LICENSE"
  228. }
  229. # vim:set ts=2 sw=2 et: