Username: Password: Remember me
#Note: this PKGBUILD is made to always install the latest version of brave
 
pkgname=brave-browser
pkgver=0.68.132
pkgrel=1
pkgdesc="The web browser from Brave (stable version)"
arch=('x86_64')
url="https://www.brave.com/"
screenshot="https://i.imgur.com/zthqTAN.png"
license=('MPL')
depends=('alsa-lib' 'ttf-liberation' 'libcups' 'cairo' 'ca-certificates' 'libxss' 'libxtst' 'nss' 'kdialog' 'kwallet' 'plasma-browser-integration' 'gtk3' 'curl' 'sed' 'grep' 'coreutils')
optdepends=('breeze-gtk' 'kde-gtk-config')
# kdialog: to have kde save/load dialogs
# plasma-browser-integration: for https://chrome.google.com/webstore/detail/plasma-integration/cimiefiiaegbelhefglklhhakcgmhkai
# gtk3,breeze,kde-gtk-config: to use the systems style, font and icon settings if style is set to gtk.
# kwallet: to use kwallet instead of gnome-keyring.
# grep,sed,curl,coreutils,ping: for update checking see launch script below(should be already installed on any system)!
makedepends=('binutils')
options=('!emptydirs' '!strip')
conflicts=("${pkgname}" "${pkgname}-stable" "${pkgname}-beta" "${pkgname}-unstable")
provides=("${pkgname}")
 
pkgver() {
  cd $srcdir
_ver=$(curl -L https://raw.githubusercontent.com/brave/brave-browser/master/CHANGELOG.md|grep 'releases'|head -1|sed 's|.*tag/v||;s/[^0-9.]*//g')
  printf "$_ver"
}
 
build() {
#prepare
  cd ${srcdir}
  curl -L https://github.com/brave/brave-browser/releases/download/v${pkgver}/brave-browser_${pkgver}_amd64.deb > ${srcdir}/brave-browser_${pkgver}_amd64.deb
}
 
package() {
  ar p ${srcdir}/${pkgname}_${pkgver}_amd64.deb data.tar.xz|tar -xJp -C "$pkgdir/"
  rm -rf "$pkgdir"/etc/cron.daily "$pkgdir"/opt/brave.com/brave/cron/ "$pkgdir"/usr/share/gnome-control-center/ "$pkgdir"/usr/share/menu "$pkgdir"/usr/bin/brave-browser-stable
  install -d $pkgdir/usr/share/pixmaps
  install -Dm644 $pkgdir/opt/brave.com/brave/product_logo_256.png $pkgdir/usr/share/pixmaps/${pkgname}.png
  ln -s ${pkgname}-stable $pkgdir/usr/bin/${pkgname}
  cat <<\EOF> $pkgdir/usr/bin/${pkgname}-stable
#!/bin/sh
### Make sure we always have the latest version installed! (adds curl, sed, grep and cut to depends)
_pkgname=brave-browser
_current=$(curl -L https://raw.githubusercontent.com/brave/brave-browser/master/CHANGELOG.md|grep 'releases'|head -1|sed 's|.*tag/v||;s/[^0-9.]*//g')
 
### check for internet connection and if online check version
if ping -q -w1 -c1 google.com &>/dev/null; then
  printf "connected, checking for new version of ${_pkgname}...\n"
_installed=$(pacman -Qi ${_pkgname}|grep Version|cut -d':' -f2|sed 's/-*.$//;s/[^0-9.]*//g')
_highest=$(printf "$_current\n$_installed"|sort -V|tail -1)
    if [ "$_highest" != "$_installed" ]; then
        kdialog --error "Your version of ${_pkgname} is out-of-date, please reinstall the CCR package to update! \n\nchaser install ${_pkgname}"
    fi
else
    printf "disconnected, could not check for new version of ${_pkgname}\n"
fi
 
### Link to the plasma extension after first launch so people can install it.
if [ -d $HOME/.config/BraveSoftware/Brave-Browser ]; then
    exec /opt/brave.com/brave/brave-browser "${@}"
else
    exec /opt/brave.com/brave/brave-browser https://chrome.google.com/webstore/detail/plasma-integration/cimiefiiaegbelhefglklhhakcgmhkai "${@}"
fi
EOF
  chmod +x $pkgdir/usr/bin/${pkgname}-stable
}