Skip to content

Instantly share code, notes, and snippets.

@timdp
Created December 10, 2016 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timdp/efca49afade1118406c86fdecc7ed6bd to your computer and use it in GitHub Desktop.
Save timdp/efca49afade1118406c86fdecc7ed6bd to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
SELECTOR='string(//*[local-name()="entry"]/*[local-name()="title"][not(contains(text(), "beta"))])'
INSTALLED="dpkg-query -W -f '\${Version}' atom"
ARTIFACT='atom-amd64.deb'
INSTALL='sudo dpkg --skip-same-version --install'
version=$(
curl --silent https://github.com/atom/atom/tags.atom |
xmllint --xpath "$SELECTOR" -
)
test -z "$version" && {
echo "Latest version not found" >&2
exit 1
}
installed=$( eval "$INSTALLED" )
test "$version" = "$installed" && {
echo "Version $version already installed"
exit
}
url="https://github.com/atom/atom/releases/download/v$version/$ARTIFACT"
file=$( mktemp --tmpdir atomXXXX.deb )
cmd="$INSTALL $file"
echo "Downloading $url to $file ..."
curl -L -o "$file" "$url"
echo "Running install: $cmd"
eval "$cmd"
echo "Removing temporary file: $file"
rm -f "$file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment