From 14cdbc5c895ae2849a2ef07884fbe40dcf1ad804 Mon Sep 17 00:00:00 2001 From: Peter Marquardt Date: Fri, 8 Apr 2022 14:22:40 +0200 Subject: [PATCH] brave: add 1.29.79 - the 'bad icons version' - anyway, it builds --- brave-browser-1.29.79-0.build.sh | 420 +++++++++++++++++++++++++++++++ 1 file changed, 420 insertions(+) create mode 100755 brave-browser-1.29.79-0.build.sh diff --git a/brave-browser-1.29.79-0.build.sh b/brave-browser-1.29.79-0.build.sh new file mode 100755 index 0000000..27a1d78 --- /dev/null +++ b/brave-browser-1.29.79-0.build.sh @@ -0,0 +1,420 @@ +#!/bin/bash +# +# https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=brave +# +PKG=brave-browser +VERSION=1.29.79 +BUILD=0 + +PATH=/bin:/usr/bin:/usr/sbin:/usr/local/package/bin:/usr/local/bin + +PREFIX=/pkg/$PKG-$VERSION-$BUILD +# PREFIX=/scratch/local2/pkg/$PKG-$VERSION-$BUILD + +set -xev +umask 022 + +BUILD_TMPDIR=/scratch/local2/$PKG-$VERSION-$BUILD.build.tmp +test -d $BUILD_TMPDIR && chmod -R u+rwx $BUILD_TMPDIR && rm -rf $BUILD_TMPDIR +mkdir -p $BUILD_TMPDIR/home +export TMPDIR=$BUILD_TMPDIR +export HOME=$BUILD_TMPDIR/home + +exec $PREFIX/profile <<-EOF + PATH=$PREFIX/bin:\$PATH + if [ -d $PREFIX/.compatlibs ]; then export LD_LIBRARY_PATH=$PREFIX/.compatlibs\${LD_LIBRARY_PATH:+:\$LD_LIBRARY_PATH} ; fi +EOF + +. $PREFIX/profile + +export MAKEFLAGS="-j $(nproc)" +# export MAKEFLAGS="-j 1" + + +# +# burn python to v2 +# dont symlink so we can debug +# +#mkdir -p $PREFIX/bin +#cat >$PREFIX/bin/python <<'EOF' +##! /bin/bash +#prun python2 $(basename "$0") "$@" +#EOF +#chmod 755 $PREFIX/bin/python + +cat >>${HOME}/.wgetrc <<'_EOW_' +http_proxy = beehive:3128 +https_proxy = beehive:3128 +ftp_proxy = beehive:3128 +check-certificate = quiet +_EOW_ +# +# +# +rm ${HOME}/.wgetrc +# +# +# + + + +BUILDDIR=$PREFIX/build + +set -ex + +mkdir -p $BUILDDIR +cd $BUILDDIR + +S=brave-browser-${VERSION} + +#git config --global http.proxy http://beehive:3128 +#git config --global https.proxy https://beehive.molgen.mpg.de:3128 +git config --global advice.detachedHead false +git config --global http.sslVerify false +git config --global pack.threads 24 + +srcdir=${BUILDDIR} +pkgname=brave +pkgver=${VERSION} +pkgrel=1 +pkgdesc='A web browser that stops ads and trackers by default' +arch=('x86_64') +url='https://www.brave.com/download' +license=('custom') +depends=('gtk3' 'nss' 'alsa-lib' 'libxss' 'ttf-font' 'libva' 'json-glib') + +makedepends=(clang git glibc gperf icu java-runtime-headless llvm npm pipewire python python-protobuf python2) + +optdepends=('pipewire: WebRTC desktop sharing under Wayland' + 'kdialog: support for native dialogs in Plasma' + 'org.freedesktop.secrets: password storage backend on GNOME / Xfce' + 'kwallet: support for storing passwords in KWallet on Plasma' + 'sccache: For faster builds') + +chromium_base_ver="93" +patchset="6" +patchset_name="chromium-${chromium_base_ver}-patchset-${patchset}" +_launcher_ver=8 + +source=("brave-browser::git+https://github.com/brave/brave-browser.git#tag=v$pkgver" + 'chromium::git+https://github.com/chromium/chromium.git' + 'git+https://chromium.googlesource.com/chromium/tools/depot_tools.git' + "git+https://github.com/brave/brave-core.git#tag=v$pkgver" + 'git+https://github.com/brave/adblock-rust.git' + brave-launcher + brave-browser.desktop + "chromium-launcher-$_launcher_ver.tar.gz::https://github.com/foutrelis/chromium-launcher/archive/v$_launcher_ver.tar.gz" + "https://github.com/stha09/chromium-patches/releases/download/$_patchset_name/$_patchset_name.tar.xz" + chromium-no-history.patch) +_arch_revision=4b878998bab64f599eb2dd14e27e7fe42f69a1f2 +_patches=(extend-enable-accelerated-video-decode-flag.patch + linux-sandbox-syscall-broker-use-struct-kernel_stat.patch + linux-sandbox-fix-fstatat-crash.patch + sql-make-VirtualCursor-standard-layout-type.patch + chromium-freetype-2.11.patch) +for _patch in "${_patches[@]}"; do + source+=("$_patch::https://raw.githubusercontent.com/archlinux/svntogit-packages/$_arch_revision/chromium/trunk/$_patch") +done + +[ -d brave-browser ] || git clone https://github.com/brave/brave-browser --branch v${pkgver} +umask +[ -d chromium ] || git clone https://github.com/chromium/chromium.git +ls -la ${BUILDDIR}/chromium/.git/objects/pack/ +[ -d depot_tools ] || git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git +[ -d brave-core ] || git clone https://github.com/brave/brave-core.git --branch v${pkgver} +[ -d adblock-rust ] || git clone https://github.com/brave/adblock-rust.git +[ -d brave-aur ] || git clone https://aur.archlinux.org/brave.git brave-aur + +for aur in brave-launcher brave-browser.desktop chromium-no-history.patch; do + [ -e ${aur} ] || ln -s brave-aur/${aur} +done + +[ -e ${patchset_name}.tar.xz ] || wget "https://github.com/stha09/chromium-patches/releases/download/${patchset_name}/${patchset_name}.tar.xz" +[ -d patches ] || tar xf ${patchset_name}.tar.xz + +[ -e chromium-launcher-$_launcher_ver.tar.gz ] || wget https://github.com/foutrelis/chromium-launcher/archive/v$_launcher_ver.tar.gz -O chromium-launcher-$_launcher_ver.tar.gz + +for P in "${_patches[@]}"; +do + [ -e ${P} ] || wget "https://raw.githubusercontent.com/archlinux/svntogit-packages/$_arch_revision/chromium/trunk/${P}" -O ${P} +done + +prepare() { + cd "brave-browser" + + # Hack to prioritize python2 in PATH + mkdir -p "${srcdir}/bin" + ln -sf /usr/bin/python2 "${srcdir}/bin/python" + ln -sf /usr/bin/python2-config "${srcdir}/bin/python-config" + export PATH="${srcdir}/bin:${PATH}" + + # https://www.chromium.org/developers/how-tos/depottools/ + # - The gclient and git-cl scripts are actually wrapper scripts that will, by default, always update the depot_tools to the latest versions + export DEPOT_TOOLS_UPDATE=0 + + echo "Prepare the environment..." + npm install + patch -Np1 -i ../chromium-no-history.patch||echo + + git submodule init + git config submodule.chromium.url "${srcdir}"/chromium + git config submodule.brave-core.url "${srcdir}"/brave + git config submodule.depot_tools.url "${srcdir}"/depot_tools + git config submodule.adblock-rust.url "${srcdir}"/adblock-rust + git submodule update + [ -d src ] && rm -rf src + + cp -rlT "${srcdir}"/chromium src + cp -rlT "${srcdir}"/brave-core src/brave + cp -rl "${srcdir}"/depot_tools src/brave/vendor/ + cp -rlT "${srcdir}"/adblock-rust src/brave/vendor/adblock_rust_ffi + + cat >src/brave/vendor/adblock_rust_ffi/README.chromium <<__EOT__ +Name: adblock_rust_ffi +URL: https://github.com/brave/adblock-rust-ffi +License: Mozilla Public License 2.0 +License File: LICENSE +__EOT__ + + + echo "Running \"npm run\"" + if [ -d src/out/Release ]; then + npm run sync -- --force + else + npm run init + fi + + echo "Apply Chromium patches..." + cd src/ + + # https://crbug.com/893950 + sed -i -e 's/\/malloc/' -e 's/\/free/' \ + third_party/blink/renderer/core/xml/*.cc \ + third_party/blink/renderer/core/xml/parser/xml_document_parser.cc \ + third_party/libxml/chromium/*.cc + + # Upstream fixes + # patch -Np1 -i ../../extend-enable-accelerated-video-decode-flag.patch + patch -Np1 -i ../../linux-sandbox-syscall-broker-use-struct-kernel_stat.patch + patch -Np1 -i ../../linux-sandbox-fix-fstatat-crash.patch + + # https://chromium-review.googlesource.com/c/chromium/src/+/2862724 + patch -Np1 -i ../../sql-make-VirtualCursor-standard-layout-type.patch + + # Fix build with FreeType 2.11 (patch from Gentoo) + # patch -Np1 -i ../../chromium-freetype-2.11.patch + + # Fixes for building with libstdc++ instead of libc++ + patch -Np1 -i ../../patches/chromium-90-ruy-include.patch + + # Hacky patching + sed -e 's/enable_distro_version_check = true/enable_distro_version_check = false/g' -i chrome/installer/linux/BUILD.gn + + # Allow building against system libraries in official builds + if [ "$COMPONENT" = "4" ]; then + sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \ + tools/generate_shim_headers/generate_shim_headers.py + + echo "Add patches for custom build" + for _patch in "$srcdir/brave-patches-$brave_patchset_name"/*.patch; do + patch -Np1 -i "$_patch" + done + + # Remove bundled libraries for which we will use the system copies; this + # *should* do what the remove_bundled_libraries.py script does, with the + # added benefit of not having to list all the remaining libraries + local _lib + for _lib in ${_unwanted_bundled_libs[@]}; do + find "third_party/$_lib" -type f \ + \! -path "third_party/$_lib/chromium/*" \ + \! -path "third_party/$_lib/google/*" \ + \! -path "third_party/harfbuzz-ng/utils/hb_scoped.h" \ + \! -regex '.*\.\(gn\|gni\|isolate\)' \ + -delete + done + + python2 build/linux/unbundle/replace_gn_files.py \ + --system-libraries "${!_system_libs[@]}" + fi +} + +build() { + cd $BUILDDIR + cd "brave-browser" + + #if check_buildoption ccache y; then + # # Avoid falling back to preprocessor mode when sources contain time macros + # export CCACHE_SLOPPINESS=time_macros + #fi + + export CC=clang + export CXX=clang++ + export AR=llvm-ar + export NM=llvm-nm + + # Hack to prioritize python2 in PATH + mkdir -p "${srcdir}/bin" + ln -sf /usr/bin/python2 "${srcdir}/bin/python" + ln -sf /usr/bin/python2-config "${srcdir}/bin/python-config" + export PATH="${srcdir}/bin:${PATH}" + + if [ "$USE_SCCACHE" -eq "1" ]; then + echo "sccache = /usr/bin/sccache" >> .npmrc + fi + + + echo 'brave_variations_server_url = https://variations.brave.com/seed' >> .npmrc + echo 'brave_stats_updater_url = https://laptop-updates.brave.com' >> .npmrc + echo 'brave_stats_api_key = fe033168-0ff8-4af6-9a7f-95e2cbfc' >> .npmrc + echo 'brave_sync_endpoint = https://sync-v2.brave.com/v2' >> .npmrc + echo "uphold_client_id = 6d8d9473ed20be627f71ed46e207f40c004c5b1a" >> .npmrc + echo "uphold_client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" >> .npmrc + echo "uphold_staging_client_id = 4c2b665ca060d912fec5c735c734859a06118cc8" >> .npmrc + echo "uphold_staging_client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" >> .npmrc + echo "gemini_api_url = https://api.gemini.com/v1" >> .npmrc + echo "gemini_oauth_url = https://api.gemini.com/v1/oauth" >> .npmrc + echo "gemini_wallet_client_id = 6d8d9473ed20be627f71ed46e207f40c004c5b1a" >> .npmrc + echo "gemini_wallet_client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" >> .npmrc + + + npm_args=() + if [ "$COMPONENT" = "4" ]; then + local _flags=( + 'custom_toolchain="//build/toolchain/linux/unbundle:default"' + 'host_toolchain="//build/toolchain/linux/unbundle:default"' + 'clang_use_chrome_plugins=false' + 'treat_warnings_as_errors=false' + 'fieldtrial_testing_like_official_build=true' + 'proprietary_codecs=true' + 'rtc_use_pipewire=true' + 'link_pulseaudio=true' + 'use_gnome_keyring=false' + 'use_sysroot=false' + 'use_custom_libcxx=false' + 'use_vaapi=true' + ) + + if [[ -n ${_system_libs[icu]+set} ]]; then + _flags+=('icu_use_data_file=false') + fi + + if check_option strip y; then + _flags+=('symbol_level=0') + fi + + # Facilitate deterministic builds (taken from build/config/compiler/BUILD.gn) + CFLAGS+=' -Wno-builtin-macro-redefined' + CXXFLAGS+=' -Wno-builtin-macro-redefined' + CPPFLAGS+=' -D__DATE__= -D__TIME__= -D__TIMESTAMP__=' + + # Do not warn about unknown warning options + CFLAGS+=' -Wno-unknown-warning-option' + CXXFLAGS+=' -Wno-unknown-warning-option' + + npm_args+=( + $(echo ${_flags[@]} | tr ' ' '\n' | sed -e 's/=/:/' -e 's/^/--gn=/') + ) + fi + + ## See explanation on top to select your build + case ${COMPONENT} in + 0) + echo "Normal build (with debug)" + npm run build + ;; + 2) + echo "Static build" + npm run build -- Static + ;; + 3) + echo "Debug build" + npm run build -- Debug + ;; + 4) + echo "Release custom build" + npm run build Release -- "${npm_args[@]}" + ;; + *) + echo "Release build" + npm run build Release + ;; + esac +} + +package() { + +cd $BUILDDIR + +# install -d -m0755 "${pkgdir}/usr/lib/${pkgname}/"{,swiftshader,locales,resources} + DESTDIR="${PREFIX}/Release" + install -d -m0755 "${DESTDIR}/"{,swiftshader,locales,resources} + + # Copy necessary release files + cd "brave-browser/src/out/Release" + cp -a --reflink=auto \ + MEIPreload \ + brave \ + brave_*.pak \ + chrome_*.pak \ + resources.pak \ + v8_context_snapshot.bin \ + libGLESv2.so \ + libEGL.so \ + "${DESTDIR}/" + cp -a --reflink=auto \ + swiftshader/libGLESv2.so \ + swiftshader/libEGL.so \ + "${DESTDIR}/swiftshader/" + cp -a --reflink=auto \ + locales/*.pak \ + "${DESTDIR}/locales/" + cp -a --reflink=auto \ + resources/brave_extension \ + resources/brave_rewards \ + "${DESTDIR}/resources/" + + if [ "$COMPONENT" != "4" ] || [[ -z ${_system_libs[icu]+set} ]]; then + cp -a --reflink=auto \ + icudtl.dat \ + "${DESTDIR}/" + fi + + cd "${srcdir}" + install -Dm0755 brave-launcher "${DESTDIR}" + install -Dm0644 -t "${DESTDIR}" brave-browser.desktop + install -Dm0644 "brave-browser/src/brave/app/theme/brave/product_logo_128.png" "${DESTDIR}/brave-browser.png" + install -Dm0644 -t "${DESTDIR}" "brave-browser/LICENSE" +} + +export CARGO_NET_GIT_FETCH_WITH_CLI=true +pwd +prepare +pwd +build +pwd +package +pwd + +mkdir -p ${PREFIX}/bin + +cat >${PREFIX}/bin/brave <<__EOS__ +#!/bin/sh +export CHROME_LOG_FILE=chrome_debug.log +exec ${PREFIX}/Release/brave \ +--enable-logging \ +--v=0 \ +--disable-brave-update --disable-chrome-google-url-tracking-client \ +\$@ +__EOS__ + +chmod 755 ${PREFIX}/bin/brave + + +# +# 552 sudo -u build touch /scratch/local2/pkg/brave-browser-1.29.79-0/build/brave-browser/src/brave/components/brave_new_tab_ui/data/LICENSE +# 561 sudo -u build touch /scratch/local2/pkg/brave-browser-1.29.79-0/build/brave-browser/src/brave/components/third_party/adblock/LICENSE +# touch /scratch/local2/pkg/brave-browser-1.29.79-0/build/brave-browser/src/brave/vendor/adblock_rust_ffi/README.chromium +