Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
pkg-scripts/brave-browser-1.20.108-0.build.sh
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
367 lines (302 sloc)
11.3 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=brave | |
# | |
PKG=brave-browser | |
VERSION=1.20.108 | |
BUILD=0 | |
PATH=/bin:/usr/bin:/usr/sbin:/usr/local/package/bin:/usr/local/bin | |
PREFIX=/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 </dev/null | |
mkdir -p $PREFIX | |
cat >$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_ | |
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=('git' 'npm<7.0.0' 'python' 'python2' 'icu' 'glibc' 'gperf' 'java-runtime-headless' 'clang' 'python2-setuptools') | |
optdepends=('cups: Printer support' | |
'libpipewire02: WebRTC desktop sharing under Wayland' | |
'org.freedesktop.secrets: password storage backend on GNOME / Xfce' | |
'kwallet: for storing passwords in KWallet on KDE desktops' | |
'sccache: For faster builds') | |
chromium_base_ver="88" | |
patchset="3" | |
patchset_name="chromium-${chromium_base_ver}-patchset-${patchset}" | |
_launcher_ver=6 | |
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" "chromium-no-history2.patch") | |
arch_revision=bbf06a92e65eeccade2e484562ecd81b89756df0 | |
[ -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 /pkg/brave-browser-1.20.108-0/build/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 chromium-no-history2.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 \ | |
subpixel-anti-aliasing-in-FreeType-2.8.1.patch \ | |
chromium-glibc-2.33.patch | |
do | |
[ -e ${P} ] || wget "https://git.archlinux.org/svntogit/packages.git/plain/trunk/${P}?h=packages/chromium&id=${arch_revision}" -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}" | |
echo "Prepare the environment..." | |
npm install | |
patch -Np1 -i ../chromium-no-history.patch||echo | |
git submodule init | |
git config submodule.depot_tools.url "${srcdir}"/depot_tools | |
git config submodule.brave-core.url "${srcdir}"/brave | |
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 | |
patch -Np1 -i ../chromium-no-history2.patch | |
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/\<xmlMalloc\>/malloc/' -e 's/\<xmlFree\>/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 -d third_party/skia <../../subpixel-anti-aliasing-in-FreeType-2.8.1.patch | |
patch -Np1 -i ../../chromium-glibc-2.33.patch | |
# Fixes for building with libstdc++ instead of libc++ | |
patch -Np1 -i ../../patches/chromium-87-openscreen-include.patch | |
patch -Np1 -i ../../patches/chromium-88-CompositorFrameReporter-dcheck.patch | |
patch -Np1 -i ../../patches/chromium-88-ideographicSpaceCharacter.patch | |
patch -Np1 -i ../../patches/chromium-88-AXTreeFormatter-include.patch | |
# Force script incompatible with Python 3 to use /usr/bin/python2 | |
sed -i '1s|python$|&2|' third_party/dom_distiller_js/protoc_plugins/*.py | |
# 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 "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=ar | |
export NM=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 | |
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() { | |
# 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" | |
} | |
# prepare | |
# build | |
package | |
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 |