Skip to content

Instantly share code, notes, and snippets.

@peci1
Created December 3, 2018 13:16
Show Gist options
  • Save peci1/a2a0d414c4d019bb68e26806c6e18d5a to your computer and use it in GitHub Desktop.
Save peci1/a2a0d414c4d019bb68e26806c6e18d5a to your computer and use it in GitHub Desktop.
update_deb_from_github() {
repo=$1 # will use github.com/repos/${repo}/releases, so set to e.g. BoostIO/boostnote
pkg=$2 # name of the Deiban package e.g. apt can use, so e.g. boostnote
deb_type=$3 # a substring of the deb file on github releases which uniquely tells the requested deb from other deb files on the latest releases page
version_installed=$(LANG=C aptitude show boostnote | grep Version | grep -o '[0-9]\{1,2\}\.[0-9]\{1,2\}\.[0-9]\{1,2\}')
download_link=$(curl -s https://api.github.com/repos/${repo}/releases/latest | jq -r ".assets[] | .browser_download_url" | grep "${deb_type}.*\.deb")
version_upstream=$(echo ${download_link} | grep -o '[0-9]\{1,2\}\.[0-9]\{1,2\}\.[0-9]\{1,2\}' | head -n1)
if [[ "${version_installed}" != "${version_upstream}" ]]; then
wget -O "/tmp/${pkg}.deb" "${download_link}"
sudo dpkg -i "/tmp/${pkg}.deb"
else
echo "${pkg} version ${version_installed} is up to date"
fi
}
@peci1
Copy link
Author

peci1 commented Dec 3, 2018

Automatically update a debian package that is only released on github releases page.

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