Created
December 3, 2018 13:16
-
-
Save peci1/a2a0d414c4d019bb68e26806c6e18d5a to your computer and use it in GitHub Desktop.
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
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Automatically update a debian package that is only released on github releases page.