PKGBUILD 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. # Maintainer: Noah Vogt (noahvogt) <noah@noahvogt.com>
  2. # Maintainer: Seppia <seppia@seppio.fish>
  3. # Maintainer: JustKidding <jk@vin.ovh>
  4. # Based on aur/chromium-vaapi, with ungoogled-chromium patches
  5. # Maintainer: Evangelos Foutras <evangelos@foutrelis.com>
  6. # Contributor: Pierre Schmitz <pierre@archlinux.de>
  7. # Contributor: Jan "heftig" Steffens <jan.steffens@gmail.com>
  8. # Contributor: Daniel J Griffiths <ghost1227@archlinux.us>
  9. pkgname=ungoogled-chromium-xdg
  10. pkgver=99.0.4844.51
  11. pkgrel=1
  12. _launcher_ver=8
  13. _gcc_patchset=3
  14. pkgdesc="A lightweight approach to removing Google web service dependency - without creating a useless ~/.pki directory"
  15. arch=('x86_64')
  16. url="https://github.com/Eloston/ungoogled-chromium"
  17. license=('BSD')
  18. depends=('gtk3' 'nss' 'alsa-lib' 'xdg-utils' 'libxss' 'libcups' 'libgcrypt'
  19. 'ttf-liberation' 'systemd' 'dbus' 'libpulse' 'pciutils' 'libva'
  20. 'desktop-file-utils' 'hicolor-icon-theme')
  21. makedepends=('python' 'gn' 'ninja' 'clang' 'lld' 'gperf' 'nodejs' 'pipewire'
  22. 'java-runtime-headless')
  23. optdepends=('pipewire: WebRTC desktop sharing under Wayland'
  24. 'kdialog: support for native dialogs in Plasma'
  25. 'org.freedesktop.secrets: password storage backend on GNOME / Xfce'
  26. 'kwallet: support for storing passwords in KWallet on Plasma')
  27. options=('!lto') # Chromium adds its own flags for ThinLTO
  28. source=(https://commondatastorage.googleapis.com/chromium-browser-official/chromium-$pkgver.tar.xz
  29. https://github.com/foutrelis/chromium-launcher/archive/v$_launcher_ver/chromium-launcher-$_launcher_ver.tar.gz
  30. https://github.com/stha09/chromium-patches/releases/download/chromium-${pkgver%%.*}-patchset-$_gcc_patchset/chromium-${pkgver%%.*}-patchset-$_gcc_patchset.tar.xz
  31. fix-build-break-with-system-libdrm.patch
  32. sandbox-build-if-glibc-2.34-dynamic-stack-size-is-en.patch
  33. webcodecs-stop-using-AudioOpusEncoder.patch
  34. use-FT_Done_MM_Var-in-CFX_Font-AdjustMMParams.patch
  35. sql-make-VirtualCursor-standard-layout-type.patch
  36. use-oauth2-client-switches-as-default.patch
  37. xdg-basedir.patch
  38. no-omnibox-suggestion-autocomplete.patch)
  39. sha256sums=('97c52e57eca0dc8b752d274047f38c88aaa86036c0587b26b056efbd3fb2bae3'
  40. '213e50f48b67feb4441078d50b0fd431df34323be15be97c55302d3fdac4483a'
  41. '9cd2570e92e9bfeff3faf0d5b56334535cb2313f99ab0d9019b74d18ae1c7d0a'
  42. 'edf4d973ff197409d319bb6fbbaa529e53bc62347d26b0733c45a116a1b23f37'
  43. 'f910be9370c880de6e1d61cc30383c069e421d7acf406166e4fbfad324fc7d61'
  44. '064daaa2b9d95b96ec04d8ddebf4af441f92263d123365b58fe73966866080af'
  45. '34bcb151c0bc51ada5aa7beda6e87356e0eaafa83a621e11e5803717adc39ffc'
  46. 'b94b2e88f63cfb7087486508b8139599c89f96d7a4181c61fec4b4e250ca327a'
  47. 'e393174d7695d0bafed69e868c5fbfecf07aa6969f3b64596d0bae8b067e1711'
  48. 'cd844867b5b2197ad097662fee32579a7091dfba1d46cb438c4c7e696690440a'
  49. 'a0aae463d3190c358b018922aa25ef8b0d4dabf46d4e1a29437e983a2ea125c6')
  50. provides=('chromium')
  51. conflicts=('chromium')
  52. source=(${source[@]}
  53. $pkgname-$pkgver-1.tar.gz::https://github.com/Eloston/ungoogled-chromium/archive/$pkgver-1.tar.gz
  54. chromium-drirc-disable-10bpc-color-configs.conf
  55. wayland-egl.patch)
  56. sha256sums=(${sha256sums[@]}
  57. '8aa65f6d96cb1400b83092adab9a64e0d81a7f12bd6ee5e2b090d2d9407e645d'
  58. 'babda4f5c1179825797496898d77334ac067149cac03d797ab27ac69671a7feb'
  59. '34d08ea93cb4762cb33c7cffe931358008af32265fc720f2762f0179c3973574')
  60. # Possible replacements are listed in build/linux/unbundle/replace_gn_files.py
  61. # Keys are the names in the above script; values are the dependencies in Arch
  62. declare -gA _system_libs=(
  63. [ffmpeg]=ffmpeg
  64. [flac]=flac
  65. [fontconfig]=fontconfig
  66. [freetype]=freetype2
  67. [harfbuzz-ng]=harfbuzz
  68. [icu]=icu
  69. [libdrm]=
  70. [libjpeg]=libjpeg
  71. [libpng]=libpng
  72. #[libvpx]=libvpx
  73. [libwebp]=libwebp
  74. [libxml]=libxml2
  75. [libxslt]=libxslt
  76. [opus]=opus
  77. [re2]=re2
  78. [snappy]=snappy
  79. [zlib]=minizip
  80. )
  81. _unwanted_bundled_libs=(
  82. $(printf "%s\n" ${!_system_libs[@]} | sed 's/^libjpeg$/&_turbo/')
  83. )
  84. depends+=(${_system_libs[@]})
  85. prepare() {
  86. cd "$srcdir/chromium-$pkgver"
  87. # Allow building against system libraries in official builds
  88. sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \
  89. tools/generate_shim_headers/generate_shim_headers.py
  90. # https://crbug.com/893950
  91. sed -i -e 's/\<xmlMalloc\>/malloc/' -e 's/\<xmlFree\>/free/' \
  92. third_party/blink/renderer/core/xml/*.cc \
  93. third_party/blink/renderer/core/xml/parser/xml_document_parser.cc \
  94. third_party/libxml/chromium/*.cc \
  95. third_party/maldoca/src/maldoca/ole/oss_utils.h
  96. # Use the --oauth2-client-id= and --oauth2-client-secret= switches for
  97. # setting GOOGLE_DEFAULT_CLIENT_ID and GOOGLE_DEFAULT_CLIENT_SECRET at
  98. # runtime -- this allows signing into Chromium without baked-in values
  99. patch -Np1 -i ../use-oauth2-client-switches-as-default.patch
  100. # Upstream fixes
  101. patch -Np1 -i ../fix-build-break-with-system-libdrm.patch
  102. patch -Np1 -i ../sandbox-build-if-glibc-2.34-dynamic-stack-size-is-en.patch
  103. patch -Np1 -i ../webcodecs-stop-using-AudioOpusEncoder.patch
  104. patch -Np1 -d third_party/pdfium <../use-FT_Done_MM_Var-in-CFX_Font-AdjustMMParams.patch
  105. # https://chromium-review.googlesource.com/c/chromium/src/+/2862724
  106. patch -Np1 -i ../sql-make-VirtualCursor-standard-layout-type.patch
  107. # move ~/.pki directory to ${XDG_DATA_HOME:-$HOME/.local}/share/pki
  108. patch -p1 -i ../xdg-basedir.patch
  109. # You can now set '1' in the flag #omnibox-ui-max-autocomplete-matches to
  110. # effectively disable autocompletion in the url bar (and therefore the so-
  111. # called 'shoulder surfing').
  112. patch -p1 -i ../no-omnibox-suggestion-autocomplete.patch
  113. # Fixes for building with libstdc++ instead of libc++
  114. #patch -Np1 -i ../patches/
  115. # Wayland/EGL regression (crbug #1071528 #1071550)
  116. patch -Np1 -i ../wayland-egl.patch
  117. # Ungoogled Chromium changes
  118. _ungoogled_repo="$srcdir/${pkgname%xdg*}$pkgver-1"
  119. _utils="${_ungoogled_repo}/utils"
  120. python "$_utils/prune_binaries.py" ./ "$_ungoogled_repo/pruning.list"
  121. python "$_utils/patches.py" apply ./ "$_ungoogled_repo/patches"
  122. python "$_utils/domain_substitution.py" apply -r "$_ungoogled_repo/domain_regex.list" \
  123. -f "$_ungoogled_repo/domain_substitution.list" -c domainsubcache.tar.gz ./
  124. # Link to system tools required by the build
  125. mkdir -p third_party/node/linux/node-linux-x64/bin
  126. ln -s /usr/bin/node third_party/node/linux/node-linux-x64/bin/
  127. ln -s /usr/bin/java third_party/jdk/current/bin/
  128. # Remove bundled libraries for which we will use the system copies; this
  129. # *should* do what the remove_bundled_libraries.py script does, with the
  130. # added benefit of not having to list all the remaining libraries
  131. local _lib
  132. for _lib in ${_unwanted_bundled_libs[@]}; do
  133. find "third_party/$_lib" -type f \
  134. \! -path "third_party/$_lib/chromium/*" \
  135. \! -path "third_party/$_lib/google/*" \
  136. \! -path "third_party/harfbuzz-ng/utils/hb_scoped.h" \
  137. \! -regex '.*\.\(gn\|gni\|isolate\)' \
  138. -delete
  139. done
  140. ./build/linux/unbundle/replace_gn_files.py \
  141. --system-libraries "${!_system_libs[@]}"
  142. }
  143. build() {
  144. make -C chromium-launcher-$_launcher_ver
  145. cd "$srcdir/chromium-$pkgver"
  146. export CC=clang
  147. export CXX=clang++
  148. export AR=ar
  149. export NM=nm
  150. local _flags=(
  151. 'custom_toolchain="//build/toolchain/linux/unbundle:default"'
  152. 'host_toolchain="//build/toolchain/linux/unbundle:default"'
  153. 'is_official_build=true' # implies is_cfi=true on x86_64
  154. 'disable_fieldtrial_testing_config=true'
  155. 'blink_enable_generated_code_formatting=false'
  156. 'ffmpeg_branding="Chrome"'
  157. 'proprietary_codecs=true'
  158. 'rtc_use_pipewire=true'
  159. 'link_pulseaudio=true'
  160. 'use_gnome_keyring=false'
  161. 'use_sysroot=false'
  162. 'use_custom_libcxx=false'
  163. 'enable_widevine=true'
  164. )
  165. if [[ -n ${_system_libs[icu]+set} ]]; then
  166. _flags+=('icu_use_data_file=false')
  167. fi
  168. if check_option strip y; then
  169. _flags+=('symbol_level=0')
  170. fi
  171. # Append ungoogled chromium flags to _flags array
  172. _ungoogled_repo="$srcdir/${pkgname%xdg*}$pkgver-1"
  173. readarray -t -O ${#_flags[@]} _flags < "${_ungoogled_repo}/flags.gn"
  174. # Facilitate deterministic builds (taken from build/config/compiler/BUILD.gn)
  175. CFLAGS+=' -Wno-builtin-macro-redefined'
  176. CXXFLAGS+=' -Wno-builtin-macro-redefined'
  177. CPPFLAGS+=' -D__DATE__= -D__TIME__= -D__TIMESTAMP__='
  178. # Do not warn about unknown warning options
  179. CFLAGS+=' -Wno-unknown-warning-option'
  180. CXXFLAGS+=' -Wno-unknown-warning-option'
  181. # Let Chromium set its own symbol level
  182. CFLAGS=${CFLAGS/-g }
  183. CXXFLAGS=${CXXFLAGS/-g }
  184. # -fvar-tracking-assignments is not recognized by clang
  185. CFLAGS=${CFLAGS/-fvar-tracking-assignments}
  186. CXXFLAGS=${CXXFLAGS/-fvar-tracking-assignments}
  187. # https://github.com/ungoogled-software/ungoogled-chromium-archlinux/issues/123
  188. CFLAGS=${CFLAGS/-fexceptions}
  189. CFLAGS=${CFLAGS/-fcf-protection}
  190. CXXFLAGS=${CXXFLAGS/-fexceptions}
  191. CXXFLAGS=${CXXFLAGS/-fcf-protection}
  192. # This appears to cause random segfaults when combined with ThinLTO
  193. # https://bugs.archlinux.org/task/73518
  194. CFLAGS=${CFLAGS/-fstack-clash-protection}
  195. CXXFLAGS=${CXXFLAGS/-fstack-clash-protection}
  196. # https://crbug.com/957519#c122
  197. CXXFLAGS=${CXXFLAGS/-Wp,-D_GLIBCXX_ASSERTIONS}
  198. gn gen out/Release --args="${_flags[*]}"
  199. ninja -C out/Release chrome chrome_sandbox chromedriver
  200. }
  201. package() {
  202. cd chromium-launcher-$_launcher_ver
  203. make PREFIX=/usr DESTDIR="$pkgdir" install
  204. install -Dm644 LICENSE \
  205. "$pkgdir/usr/share/licenses/chromium/LICENSE.launcher"
  206. cd "$srcdir/chromium-$pkgver"
  207. install -D out/Release/chrome "$pkgdir/usr/lib/chromium/chromium"
  208. install -Dm4755 out/Release/chrome_sandbox "$pkgdir/usr/lib/chromium/chrome-sandbox"
  209. ln -s /usr/lib/chromium/chromedriver "$pkgdir/usr/bin/chromedriver"
  210. install -Dm644 ../chromium-drirc-disable-10bpc-color-configs.conf \
  211. "$pkgdir/usr/share/drirc.d/10-$pkgname.conf"
  212. install -Dm644 chrome/installer/linux/common/desktop.template \
  213. "$pkgdir/usr/share/applications/chromium.desktop"
  214. install -Dm644 chrome/app/resources/manpage.1.in \
  215. "$pkgdir/usr/share/man/man1/chromium.1"
  216. sed -i \
  217. -e 's/@@MENUNAME@@/Chromium/g' \
  218. -e 's/@@PACKAGE@@/chromium/g' \
  219. -e 's/@@USR_BIN_SYMLINK_NAME@@/chromium/g' \
  220. "$pkgdir/usr/share/applications/chromium.desktop" \
  221. "$pkgdir/usr/share/man/man1/chromium.1"
  222. install -Dm644 chrome/installer/linux/common/chromium-browser/chromium-browser.appdata.xml \
  223. "$pkgdir/usr/share/metainfo/chromium.appdata.xml"
  224. sed -ni \
  225. -e 's/chromium-browser\.desktop/chromium.desktop/' \
  226. -e '/<update_contact>/d' \
  227. -e '/<p>/N;/<p>\n.*\(We invite\|Chromium supports Vorbis\)/,/<\/p>/d' \
  228. -e '/^<?xml/,$p' \
  229. "$pkgdir/usr/share/metainfo/chromium.appdata.xml"
  230. local toplevel_files=(
  231. chrome_100_percent.pak
  232. chrome_200_percent.pak
  233. chrome_crashpad_handler
  234. chromedriver
  235. resources.pak
  236. v8_context_snapshot.bin
  237. # ANGLE
  238. libEGL.so
  239. libGLESv2.so
  240. # SwiftShader ICD
  241. libvk_swiftshader.so
  242. vk_swiftshader_icd.json
  243. )
  244. if [[ -z ${_system_libs[icu]+set} ]]; then
  245. toplevel_files+=(icudtl.dat)
  246. fi
  247. cp "${toplevel_files[@]/#/out/Release/}" "$pkgdir/usr/lib/chromium/"
  248. install -Dm644 -t "$pkgdir/usr/lib/chromium/locales" out/Release/locales/*.pak
  249. install -Dm755 -t "$pkgdir/usr/lib/chromium/swiftshader" out/Release/swiftshader/*.so
  250. for size in 24 48 64 128 256; do
  251. install -Dm644 "chrome/app/theme/chromium/product_logo_$size.png" \
  252. "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
  253. done
  254. for size in 16 32; do
  255. install -Dm644 "chrome/app/theme/default_100_percent/chromium/product_logo_$size.png" \
  256. "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/chromium.png"
  257. done
  258. install -Dm644 LICENSE "$pkgdir/usr/share/licenses/chromium/LICENSE"
  259. }
  260. # vim:set ts=2 sw=2 et: