Skip to content

Instantly share code, notes, and snippets.

@stpettersens
Last active October 27, 2025 14:35
Show Gist options
  • Save stpettersens/ee8821ba1d6d45937b3eb0c841335cb7 to your computer and use it in GitHub Desktop.
Save stpettersens/ee8821ba1d6d45937b3eb0c841335cb7 to your computer and use it in GitHub Desktop.
Update Brave browser on a Void Linux system (makes use of xdeb tool and Brave Debian package releases).
#!/usr/bin/env bash
# Update Brave browser on a Void system.
install_latest_brave_deb() {
# Get machine architecture.
local arch
arch=$(uname -m)
if [ "$arch" == "x86_64" ]; then
arch="amd64"
elif [ "$arch" == "aarch64" ]; then
arch="arm64"
fi
# Download latest Brave debian package.
echo "Downloading latest stable version of Brave..."
wget "https://github.com/brave/brave-browser/releases/download/${2}/brave-browser_${1}_${arch}.deb"
# Download SHA-256 checksum file and compare package against it.
wget "https://github.com/brave/brave-browser/releases/download/${2}/brave-browser_${1}_${arch}.deb.sha256"
local chksum
chksum=$(sha256sum -c "brave-browser_${1}_${arch}.deb.sha256" > /dev/null)
rm -f "brave-browser_${1}_${arch}.deb.sha256"
if (( chksum == 0)); then
echo "SHA-256 checksum OK for downloaded Brave deb package."
else
echo "SHA-256 checksum failed for downloaded Brave deb package."
echo "Aborting..."
exit 1
fi
# Convert Debian package to XBPS installable package and install it.
echo "Installing Brave for a Void system..."
xdeb -Sedf "brave-browser_${1}_${arch}.deb"
doas xbps-install -Syu -R ./binpkgs brave-browser
rm -f "brave-browser_${1}_${arch}.deb"
rm -f shlibs
rm -rf workdir
rm -rf datadir
rm -rf destdir
rm -rf binpkgs
}
# Check latest version of Brave against currently installed version.
check_for_brave_updates() {
local vers_file
vers_file='.brave_version'
if ! [[ -f "${vers_file}" ]]; then
echo "0" > "${vers_file}" # Create 0 version as placeholder.
fi
local releases_file
releases_file='.brave_releases.json'
if ! [[ -f "${releases_file}" ]]; then
touch "${releases_file}"
fi
local now
local updated
local timediff
now=$(date +%s)
updated=$(stat -c %Y $releases_file)
time_diff=$((now - updated))
if [[ $time_diff -ge 86400 ]] || ! [[ -s "${releases_file}" ]]; then
echo "Updating Brave releases file as >= 24 hrs since last check..."
curl -s "https://api.github.com/repos/brave/brave-browser/releases?per_page=100&page=1" > "${releases_file}"
echo
fi
local vers
vers=$(grep "Release" "$releases_file" | head -n 1 | awk '{ print $3 }')
local v
v="${vers:1}"
echo "Latest Brave version is ${v}."
if [[ -s "${vers_file}" ]]; then
local installed
read -r installed < "${vers_file}"
installed=$(printf "%s" "$installed")
echo "Installed Brave version is ${installed}."
fi
if [[ "$installed" != "$v" ]]; then
echo
install_latest_brave_deb "$v" "$vers"
echo "$v" > "${vers_file}"
fi
echo "Done."
exit 0
}
check_for_brave_updates
@stpettersens
Copy link
Author

This script makes use of curl, wget and the xdeb tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment