Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ENH: Update RStudio
  • Loading branch information
pan14001 committed Aug 15, 2016
1 parent 128d8b7 commit 4b25f43
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions cgi-updater-payload.sh
Expand Up @@ -48,6 +48,36 @@ biocLite(c(${pkgs:3}))
EOF
}

rstudio_url() {
python - <<EOF
import urllib2
from lxml import etree
# Provide a header to avoid HTTP 403 Forbidden.
headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11'}
request = urllib2.Request("https://www.rstudio.com/products/rstudio/download2/", headers=headers)
response = urllib2.urlopen(request)
html = response.read()
root = etree.HTML(html)
urls = root.xpath('.//table[@class="downloads"][1]/tbody/tr/td/a/@href')
url = next(url for url in urls if url.endswith('amd64.deb'))
print(url)
EOF
}

rstudio_install() {
url=$(rstudio_url)
pkg=$(basename $url)
ver_new=$(echo $pkg | awk -vFS=- '{print $2}')
ver_old=$(dpkg-query --showformat='${Version}' --show rstudio) || ver_old=
if [[ ! $ver_new == $ver_old ]]; then
wget -qc $url
dpkg -i $pkg
fi
}

main () {
ubuntu_update
ubuntu_install_r_cran
Expand All @@ -60,6 +90,8 @@ main () {
export -f r_install_packages
su cgi_user -c "bash -c \"r_install_packages ${r_pkgs[*]}\""
unset r_install_packages

rstudio_install
}

main

0 comments on commit 4b25f43

Please sign in to comment.