PKGBUILD 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. # Maintainer: Seppia <seppia@seppio.fish>
  2. # Contributors: Eloston
  3. # Derived from official Chromium and Inox PKGBUILDS and ungoogled-chromium buildkit
  4. pkgname=ungoogled-chromium
  5. # Commit or tag for the upstream ungoogled-chromium repo
  6. _ungoogled_version='81.0.4044.138-1'
  7. _chromium_version=${_ungoogled_version%-*}
  8. _ungoogled_revision=${_ungoogled_version#*-}
  9. pkgver=${_chromium_version}
  10. pkgrel=$_ungoogled_revision
  11. _launcher_ver=6
  12. pkgdesc="A lightweight approach to removing Google web service dependency"
  13. arch=('x86_64')
  14. url="https://github.com/Eloston/ungoogled-chromium"
  15. license=('BSD')
  16. depends=('gtk3' 'nss' 'alsa-lib' 'xdg-utils' 'libxss' 'libcups' 'libgcrypt'
  17. 'ttf-font' 'systemd' 'dbus' 'libpulse' 'pciutils' 'json-glib' 'libva'
  18. 'desktop-file-utils' 'hicolor-icon-theme' 'jsoncpp' 'openjpeg2')
  19. makedepends=('python' 'python2' 'gperf' 'yasm' 'mesa' 'ninja' 'nodejs' 'git'
  20. 'clang' 'lld' 'gn' 'llvm' 'quilt')
  21. optdepends=('pepper-flash: support for Flash content'
  22. 'kdialog: needed for file dialogs in KDE'
  23. 'gnome-keyring: for storing passwords in GNOME keyring'
  24. 'kwallet: for storing passwords in KWallet'
  25. 'libva-intel-driver: for hardware video acceleration with Intel GPUs'
  26. 'libva-mesa-driver: for hardware video acceleration with AMD/ATI GPUs'
  27. 'libva-vdpau-driver: for hardware video acceleration with NVIDIA GPUs')
  28. source=(https://commondatastorage.googleapis.com/chromium-browser-official/chromium-${_chromium_version}.tar.xz
  29. chromium-launcher-$_launcher_ver.tar.gz::https://github.com/foutrelis/chromium-launcher/archive/v$_launcher_ver.tar.gz
  30. https://github.com/Eloston/ungoogled-chromium/archive/$_ungoogled_version.tar.gz
  31. rename-Relayout-in-DesktopWindowTreeHostPlatform.patch
  32. rebuild-Linux-frame-button-cache-when-activation.patch
  33. clean-up-a-call-to-set_utf8.patch
  34. icu67.patch
  35. chromium-widevine.patch
  36. chromium-skia-harmony.patch
  37. flags.archlinux.gn
  38. chromium-drirc-disable-10bpc-color-configs.conf
  39. vdpau-support.patch
  40. vaapi-build-fix.patch
  41. eglGetMscRateCHROMIUM.patch)
  42. sha256sums=('f478f28b8111cb70231df4c36e754d812ad7a94b7c844e9d0515345a71fd77a6'
  43. '04917e3cd4307d8e31bfb0027a5dce6d086edb10ff8a716024fbb8bb0c7dccf1'
  44. 'a01a35454dcd3c789e4e536751ecd655959b544b56ffd241a7942d9912749da1'
  45. 'ae3bf107834bd8eda9a3ec7899fe35fde62e6111062e5def7d24bf49b53db3db'
  46. '46f7fc9768730c460b27681ccf3dc2685c7e1fd22d70d3a82d9e57e3389bb014'
  47. '58c41713eb6fb33b6eef120f4324fa1fb8123b1fbc4ecbe5662f1f9779b9b6af'
  48. '5315977307e69d20b3e856d3f8724835b08e02085a4444a5c5cefea83fd7d006'
  49. '709e2fddba3c1f2ed4deb3a239fc0479bfa50c46e054e7f32db4fb1365fed070'
  50. '771292942c0901092a402cc60ee883877a99fb804cb54d568c8c6c94565a48e1'
  51. '24ada570fdac8156ce91ee790a860b2cac7689da8b4fb5cfadc59f1f8df7e658'
  52. 'babda4f5c1179825797496898d77334ac067149cac03d797ab27ac69671a7feb'
  53. '0ec6ee49113cc8cc5036fa008519b94137df6987bf1f9fbffb2d42d298af868a'
  54. 'fad5e678d62de0e45db1c2aa871628fdc981f78c26392c1dccc457082906a350'
  55. '1dd330409094dc4bf393f00a51961a983360ccf99affd4f97a61d885129d326e')
  56. provides=('chromium')
  57. conflicts=('chromium')
  58. # Possible replacements are listed in build/linux/unbundle/replace_gn_files.py
  59. # Keys are the names in the above script; values are the dependencies in Arch
  60. declare -gA _system_libs=(
  61. [ffmpeg]=ffmpeg
  62. [flac]=flac
  63. [fontconfig]=fontconfig
  64. [freetype]=freetype2
  65. [harfbuzz-ng]=harfbuzz
  66. [icu]=icu
  67. [libdrm]=
  68. [libevent]=libevent
  69. [libjpeg]=libjpeg
  70. #[libpng]=libpng # https://crbug.com/752403#c10
  71. [libvpx]=libvpx
  72. [libwebp]=libwebp
  73. [libxml]=libxml2
  74. [libxslt]=libxslt
  75. [opus]=opus
  76. [re2]=re2
  77. [snappy]=snappy
  78. [yasm]=
  79. [zlib]=minizip
  80. )
  81. _unwanted_bundled_libs=(
  82. ${!_system_libs[@]}
  83. ${_system_libs[libjpeg]+libjpeg_turbo}
  84. )
  85. depends+=(${_system_libs[@]})
  86. prepare() {
  87. cd "$srcdir/chromium-${_chromium_version}"
  88. # Allow building against system libraries in official builds
  89. sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \
  90. tools/generate_shim_headers/generate_shim_headers.py
  91. # https://crbug.com/893950
  92. sed -i -e 's/\<xmlMalloc\>/malloc/' -e 's/\<xmlFree\>/free/' \
  93. third_party/blink/renderer/core/xml/*.cc \
  94. third_party/blink/renderer/core/xml/parser/xml_document_parser.cc \
  95. third_party/libxml/chromium/*.cc
  96. # https://crbug.com/1049258
  97. patch -Np1 -i ../rename-Relayout-in-DesktopWindowTreeHostPlatform.patch
  98. patch -Np1 -i ../rebuild-Linux-frame-button-cache-when-activation.patch
  99. # https://chromium-review.googlesource.com/c/chromium/src/+/2145261
  100. patch -Np1 -i ../clean-up-a-call-to-set_utf8.patch
  101. # https://crbug.com/v8/10393
  102. patch -Np3 -d v8 <../icu67.patch
  103. # Load bundled Widevine CDM if available (see chromium-widevine in the AUR)
  104. # M79 is supposed to download it as a component but it doesn't seem to work
  105. patch -Np1 -i ../chromium-widevine.patch
  106. # https://crbug.com/skia/6663#c10
  107. patch -Np0 -i ../chromium-skia-harmony.patch
  108. # Fix VA-API on Nvidia
  109. patch -Np1 -i ../vdpau-support.patch
  110. # Fix VAAPI build on chromium 81+
  111. patch -Np1 -i ../vaapi-build-fix.patch
  112. # https://bugs.chromium.org/p/chromium/issues/detail?id=1064078
  113. patch -Np1 -i ../eglGetMscRateCHROMIUM.patch
  114. msg2 'Pruning binaries'
  115. _ungoogled_repo="$srcdir/$pkgname-${_ungoogled_version}"
  116. _utils="${_ungoogled_repo}/utils"
  117. python "$_utils/prune_binaries.py" ./ "$_ungoogled_repo/pruning.list"
  118. msg2 'Applying patches'
  119. python "$_utils/patches.py" apply ./ "$_ungoogled_repo/patches"
  120. msg2 'Applying domain substitution'
  121. python "$_utils/domain_substitution.py" apply -r "$_ungoogled_repo/domain_regex.list" -f "$_ungoogled_repo/domain_substitution.list" -c domainsubcache.tar.gz ./
  122. # Force script incompatible with Python 3 to use /usr/bin/python2
  123. sed -i '1s|python$|&2|' third_party/dom_distiller_js/protoc_plugins/*.py
  124. mkdir -p third_party/node/linux/node-linux-x64/bin
  125. ln -s /usr/bin/node third_party/node/linux/node-linux-x64/bin/
  126. # Remove bundled libraries for which we will use the system copies; this
  127. # *should* do what the remove_bundled_libraries.py script does, with the
  128. # added benefit of not having to list all the remaining libraries
  129. local _lib
  130. for _lib in ${_unwanted_bundled_libs[@]}; do
  131. find -type f -path "*third_party/$_lib/*" \
  132. \! -path "*third_party/$_lib/chromium/*" \
  133. \! -path "*third_party/$_lib/google/*" \
  134. \! -path './base/third_party/icu/*' \
  135. \! -path './third_party/crashpad/crashpad/third_party/zlib/zlib_crashpad.h' \
  136. \! -path './third_party/pdfium/third_party/freetype/include/pstables.h' \
  137. \! -path './third_party/yasm/run_yasm.py' \
  138. \! -regex '.*\.\(gn\|gni\|isolate\)' \
  139. -delete
  140. done
  141. python2 build/linux/unbundle/replace_gn_files.py \
  142. --system-libraries "${!_system_libs[@]}"
  143. }
  144. build() {
  145. make -C chromium-launcher-$_launcher_ver
  146. cd "$srcdir/chromium-${_chromium_version}"
  147. if check_buildoption ccache y; then
  148. # Avoid falling back to preprocessor mode when sources contain time macros
  149. export CCACHE_SLOPPINESS=time_macros
  150. fi
  151. export CC=clang
  152. export CXX=clang++
  153. export AR=llvm-ar
  154. export NM=llvm-nm
  155. _ungoogled_repo="$srcdir/$pkgname-${_ungoogled_version}"
  156. mkdir -p out/Default
  157. # Assemble GN flags
  158. cp "$_ungoogled_repo/flags.gn" "out/Default/args.gn"
  159. printf '\n' >> "out/Default/args.gn"
  160. cat "$srcdir/flags.archlinux.gn" >> "out/Default/args.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/Default --script-executable=/usr/bin/python2 --fail-on-unused-args
  170. msg2 'Building Chromium'
  171. ninja -C out/Default 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-${_chromium_version}"
  179. install -Dm644 ../chromium-drirc-disable-10bpc-color-configs.conf \
  180. "$pkgdir/usr/share/drirc.d/10-$pkgname.conf"
  181. install -D out/Default/chrome "$pkgdir/usr/lib/chromium/chromium"
  182. install -Dm4755 out/Default/chrome_sandbox "$pkgdir/usr/lib/chromium/chrome-sandbox"
  183. ln -s /usr/lib/${pkgname#ungoogled-}/chromedriver "$pkgdir/usr/bin/chromedriver"
  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. cp \
  195. out/Default/{chrome_{100,200}_percent,resources}.pak \
  196. out/Default/{*.bin,chromedriver} \
  197. "$pkgdir/usr/lib/chromium/"
  198. install -Dm644 -t "$pkgdir/usr/lib/chromium/locales" out/Default/locales/*.pak
  199. if [[ -z ${_system_libs[icu]+set} ]]; then
  200. cp out/Default/icudtl.dat "$pkgdir/usr/lib/chromium/"
  201. fi
  202. for size in 24 48 64 128 256; do
  203. install -Dm644 "chrome/app/theme/chromium/product_logo_$size.png" \
  204. "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
  205. done
  206. for size in 16 32; do
  207. install -Dm644 "chrome/app/theme/default_100_percent/chromium/product_logo_$size.png" \
  208. "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
  209. done
  210. install -Dm644 LICENSE "$pkgdir/usr/share/licenses/chromium/LICENSE"
  211. }
  212. # vim:set ts=2 sw=2 et ft=sh: