template 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. # Template file for 'chromium'
  2. pkgname=chromium
  3. # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
  4. version=94.0.4606.61
  5. revision=1
  6. archs="i686* x86_64* aarch64* armv7l* ppc64le*"
  7. short_desc="Google's attempt at creating a safer, faster, and more stable browser"
  8. maintainer="Enno Boland <gottox@voidlinux.org>"
  9. license="BSD-3-Clause"
  10. homepage="https://www.chromium.org/"
  11. distfiles="https://commondatastorage.googleapis.com/chromium-browser-official/${pkgname}-${version}.tar.xz"
  12. checksum=6446db535c02c461c7e5c8d294a0300db03abba791f97f0c70bc52255aedb9bf
  13. nocross=yes
  14. lib32disabled=yes
  15. build_options="clang debug js_optimize vaapi pulseaudio sndio pipewire"
  16. build_options_default="clang js_optimize vaapi pulseaudio pipewire"
  17. desc_option_clang="Use clang to build"
  18. desc_option_debug="Build with debug symbols"
  19. desc_option_js_optimize="Optimize the JS used for Chromium's UI"
  20. desc_option_vaapi="Enable support for VA-API"
  21. desc_option_pulseaudio="Enable support for PulseAudio"
  22. desc_option_sndio="Enable support for sndio"
  23. desc_option_pipewire="Enable support for screen sharing for WebRTC via PipeWire"
  24. hostmakedepends="$(vopt_if clang "clang lld llvm12") python pkgconf perl gperf bison ninja nodejs hwids
  25. libatomic-devel libevent-devel libglib-devel $(vopt_if js_optimize openjdk)"
  26. makedepends="libpng-devel gtk+-devel gtk+3-devel nss-devel pciutils-devel
  27. libXi-devel libgcrypt-devel libgnome-keyring-devel cups-devel elfutils-devel
  28. libXcomposite-devel speech-dispatcher-devel libXrandr-devel mit-krb5-devel
  29. libXScrnSaver-devel alsa-lib-devel snappy-devel libdrm-devel
  30. libxml2-devel libxslt-devel $(vopt_if pulseaudio pulseaudio-devel) libexif-devel
  31. libXcursor-devel libflac-devel speex-devel libmtp-devel libwebp-devel
  32. libjpeg-turbo-devel libevent-devel json-c-devel harfbuzz-devel
  33. minizip-devel jsoncpp-devel zlib-devel libcap-devel libXdamage-devel
  34. re2-devel fontconfig-devel freetype-devel opus-devel
  35. ffmpeg-devel libva-devel python-setuptools xcb-proto libcurl-devel
  36. $(vopt_if pipewire pipewire-devel) $(vopt_if sndio sndio-devel)"
  37. depends="libexif hwids desktop-file-utils hicolor-icon-theme xdg-utils"
  38. case "$XBPS_TARGET_MACHINE" in
  39. ppc64*-musl) makedepends+=" libucontext-devel" ;;
  40. esac
  41. post_patch() {
  42. if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
  43. for f in "${FILESDIR}"/musl-patches/*.patch; do
  44. echo "Applying $f"
  45. patch -Np0 -i "$f"
  46. done
  47. fi
  48. case "${XBPS_TARGET_MACHINE}" in
  49. i686*)
  50. for f in "${FILESDIR}"/i686-patches/*.patch; do
  51. echo "Applying $f"
  52. patch -Np0 -i "$f"
  53. done
  54. ;;
  55. esac
  56. # Use the file at run time instead of effectively compiling it in
  57. sed 's|//third_party/usb_ids/usb.ids|/usr/share/hwdata/usb.ids|g' \
  58. -i services/device/public/cpp/usb/BUILD.gn
  59. if [ -z "$build_option_clang" ]; then
  60. # Work around bug in blink in which GCC 6 optimizes away null pointer checks
  61. # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=833524
  62. # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68853#c2
  63. sed -i '/config("compiler")/ a cflags_cc = [ "-fno-delete-null-pointer-checks" ]' \
  64. build/config/linux/BUILD.gn
  65. fi
  66. # prevent annoying errors when regenerating gni
  67. vsed -i 's,^update_readme$,#update_readme,' \
  68. third_party/libvpx/generate_gni.sh
  69. # allow system dependencies in "official builds"
  70. vsed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \
  71. tools/generate_shim_headers/generate_shim_headers.py
  72. }
  73. do_configure() {
  74. local system="" conf=()
  75. export -n CFLAGS CXXFLAGS LDFLAGS
  76. if [ "$build_option_clang" ]; then
  77. export CC=clang
  78. export CXX=clang++
  79. fi
  80. export LDFLAGS="-pthread"
  81. # compile gn early, so it can be used to generate gni stuff
  82. AR="ar" CC=$CC_FOR_BUILD CXX=$CXX_FOR_BUILD LD=$CXX_FOR_BUILD \
  83. tools/gn/bootstrap/bootstrap.py --skip-generate-buildfiles
  84. # we need to generate ppc64 stuff for libvpx as it's not shipped
  85. # this has to be done before unbundling, but after gn is built
  86. # comment out if we switch back to system libvpx again later
  87. case "$XBPS_TARGET_MACHINE" in
  88. ppc64*)
  89. pushd third_party/libvpx
  90. mkdir -p source/config/linux/ppc64
  91. # need PATH to find gn
  92. PATH="${wrksrc}/out/Release:$PATH" ./generate_gni.sh || \
  93. msg_error "failed to generate libvpx gni"
  94. popd
  95. ;;
  96. esac
  97. # Use system-provided libraries.
  98. # TODO: use_system_hunspell (upstream changes needed).
  99. # TODO: use_system_libsrtp.
  100. # TODO: use_system_libusb (http://crbug.com/266149).
  101. # TODO: use_system_ssl (http://crbug.com/58087).
  102. # TODO: use_system_sqlite (http://crbug.com/22208).
  103. # TODO: use_system_icu (segfaults)
  104. # XXX xtraeme: broken currently
  105. # use_system_protobuf
  106. # use_system_v8=1
  107. # use_system_zlib=1
  108. # bzip2 jsoncpp minizip xdg_utils speex
  109. system="
  110. ffmpeg
  111. flac
  112. fontconfig
  113. freetype
  114. harfbuzz-ng
  115. libdrm
  116. libevent
  117. libjpeg
  118. libpng
  119. libwebp
  120. libxml
  121. libxslt
  122. opus
  123. re2
  124. snappy
  125. "
  126. # remove build scripts for system provided dependencies - basically does the
  127. # same as the bundeled script to remove bundeled libs, but this way we don't
  128. # have to list the remaining libs
  129. for LIB in ${system} libjpeg_turbo; do
  130. find -type f -path "*third_party/$LIB/*" \
  131. \! -path "*third_party/$LIB/chromium/*" \
  132. \! -path "*third_party/$LIB/google/*" \
  133. \! -path './base/third_party/icu/*' \
  134. \! -path './third_party/pdfium/third_party/freetype/include/pstables.h' \
  135. \! -path './third_party/harfbuzz-ng/utils/hb_scoped.h' \
  136. \! -regex '.*\.\(gn\|gni\|isolate\|py\)' \
  137. -delete
  138. done
  139. # switch to system provided dependencies
  140. build/linux/unbundle/replace_gn_files.py --system-libraries ${system}
  141. third_party/libaddressinput/chromium/tools/update-strings.py
  142. conf=(
  143. 'enable_nacl=false'
  144. 'enable_nacl_nonsfi=false'
  145. 'use_sysroot=false'
  146. 'custom_toolchain="//build/toolchain/linux/unbundle:default"'
  147. 'host_toolchain="//build/toolchain/linux/unbundle:default"'
  148. "is_clang=$(vopt_if clang true false)"
  149. "use_lld=$(vopt_if clang true false)"
  150. 'clang_use_chrome_plugins=false'
  151. 'clang_base_path="/usr"'
  152. "gold_path=\"${XBPS_CROSS_BASE}/usr/bin/ld.gold\""
  153. 'use_custom_libcxx=false'
  154. 'use_gold=false'
  155. # is_debug makes the build a debug build, changes some things.
  156. # might be useful for real debugging vs just debug symbols.
  157. "is_debug=false"
  158. "blink_symbol_level=$(vopt_if debug 1 0)"
  159. "symbol_level=$(vopt_if debug 1 0)"
  160. 'icu_use_data_file=true'
  161. 'use_allocator="none"'
  162. 'use_allocator_shim=false'
  163. 'enable_widevine=true'
  164. 'enable_hangout_services_extension=true'
  165. 'use_system_harfbuzz=true'
  166. 'use_cups=true'
  167. "use_vaapi=$(vopt_if vaapi true false)"
  168. # https://chromium.googlesource.com/chromium/src/+/master/docs/closure_compilation.md
  169. "enable_js_type_check=$(vopt_if js_optimize true false)"
  170. "use_pulseaudio=$(vopt_if pulseaudio true false)"
  171. "link_pulseaudio=$(vopt_if pulseaudio true false)"
  172. "rtc_use_pipewire=$(vopt_if pipewire true false)"
  173. "use_sndio=$(vopt_if sndio true false)"
  174. # Always support proprietary codecs.
  175. # Enable H.264 support in bundled ffmpeg.
  176. 'proprietary_codecs=true'
  177. 'ffmpeg_branding="Chrome"'
  178. # Make sure that -Werror doesn't get added to CFLAGS by the build system.
  179. # Depending on GCC version the warnings are different and we don't want
  180. # the build to fail because of that.
  181. 'treat_warnings_as_errors=false'
  182. 'fatal_linker_warnings=false'
  183. # Save space by removing DLOG and DCHECK messages (about 6% reduction).
  184. # 'logging_like_official_build=true'
  185. 'disable_fieldtrial_testing_config=true'
  186. 'is_official_build=true'
  187. # segfaults with llvm-12.0.1
  188. 'is_cfi=false'
  189. 'use_thin_lto=false'
  190. 'use_cfi_icall=false'
  191. 'chrome_pgo_phase=0'
  192. )
  193. # this does not work on ppc64 yet
  194. case "$XBPS_TARGET_MACHINE" in
  195. ppc64*) conf+=( "enable_jxl_decoder=false" );;
  196. esac
  197. case "${XBPS_TARGET_MACHINE}" in
  198. x86_64*) conf+=( 'target_cpu="x64"' ) ;;
  199. i686*) conf+=( 'target_cpu="x86"' ) ;;
  200. arm*) conf+=( 'target_cpu="arm"' ) ;;
  201. aarch64*) conf+=( 'target_cpu="arm64"' ) ;;
  202. ppc64*) conf+=( 'target_cpu="ppc64"' ) ;;
  203. esac
  204. if [ "$build_option_clang" ]; then
  205. export CC=clang
  206. export CXX=clang++
  207. export AR=llvm-ar
  208. export NM=llvm-nm
  209. export CFLAGS="-Wno-unknown-warning-option"
  210. export CXXFLAGS="-Wno-unknown-warning-option"
  211. fi
  212. out/Release/gn gen out/Release --args="${conf[*]}"
  213. }
  214. do_build() {
  215. if [ "$build_option_clang" ]; then
  216. export CC=clang
  217. export CXX=clang++
  218. export AR=llvm-ar
  219. export NM=llvm-nm
  220. export CFLAGS="-Wno-unknown-warning-option"
  221. export CXXFLAGS="-Wno-unknown-warning-option"
  222. fi
  223. ninja -C out/Release ${makejobs} chrome chrome_sandbox chromedriver mksnapshot chrome_crashpad_handler
  224. }
  225. do_install() {
  226. vinstall out/Release/chrome 755 usr/lib/${pkgname} ${pkgname}
  227. vinstall out/Release/chrome_crashpad_handler 755 usr/lib/${pkgname} chrome_crashpad_handler
  228. vinstall out/Release/chromedriver 755 usr/lib/${pkgname} chromedriver
  229. vinstall out/Release/libEGL.so 755 usr/lib/${pkgname} libEGL.so
  230. vinstall out/Release/libGLESv2.so 755 usr/lib/${pkgname} libGLESv2.so
  231. vcopy "out/Release/*.bin" usr/lib/chromium
  232. vcopy "out/Release/*.pak" usr/lib/chromium
  233. vmkdir usr/lib/chromium/locales
  234. vcopy "out/Release/locales/*.pak" usr/lib/chromium/locales
  235. vmkdir usr/lib/chromium/swiftshader
  236. vcopy "out/Release/swiftshader/*.so" usr/lib/chromium/swiftshader
  237. vinstall ${FILESDIR}/chromium.desktop 644 usr/share/applications
  238. vinstall out/Release/icudtl.dat 0644 usr/lib/chromium
  239. for size in 24 48 64 128 256; do
  240. vinstall "chrome/app/theme/chromium/product_logo_${size}.png" \
  241. 644 \
  242. usr/share/icons/hicolor/${size}x${size}/apps chromium.png
  243. done
  244. for size in 16 32; do
  245. vinstall "chrome/app/theme/default_100_percent/chromium/product_logo_${size}.png" \
  246. 644 \
  247. usr/share/icons/hicolor/${size}x${size}/apps chromium.png
  248. done
  249. vbin ${FILESDIR}/chromium.sh chromium
  250. vlicense LICENSE
  251. ln -sf /usr/lib/chromium/chromedriver ${DESTDIR}/usr/bin/chromedriver
  252. }