Created
December 10, 2016 13:15
-
-
Save timdp/efca49afade1118406c86fdecc7ed6bd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/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