library/roles/R/templates/update_r_packages.sh.j2: Change the behaviour of the github installations. Now if there's a release label we'll use that instead of master.

This commit is contained in:
Andrea Dell'Amico 2018-02-09 19:09:34 +01:00
parent e8a566e35d
commit 88d51b2740
2 changed files with 12 additions and 9 deletions

View File

@ -1,5 +1,5 @@
--- ---
- include: r-packages_cleanup.yml - import_tasks: r-packages_cleanup.yml
when: r_packages_cleanup when: r_packages_cleanup
- include: r-installation.yml - import_tasks: r-installation.yml
- include: r-packages-updater.yml - import_tasks: r-packages-updater.yml

View File

@ -78,10 +78,10 @@ function init_env() {
OLDPROC_RUNNING=$( ps auwwx | grep -v grep | grep $OLDPROC | awk '{ print $2 }' ) OLDPROC_RUNNING=$( ps auwwx | grep -v grep | grep $OLDPROC | awk '{ print $2 }' )
RETVAL=$? RETVAL=$?
if [ $RETVAL -eq 0 ] ; then if [ $RETVAL -eq 0 ] ; then
logger "update_r_packages: $OLDPROC_RUNNING" logger "update_r_packages: pid of the already running process: $OLDPROC_RUNNING"
OLDPROC_RUNNING_TIME=$( ps -o etimes= -p ${PROCNUM} ) OLDPROC_RUNNING_TIME=$( ps -o etimes= -p ${OLDPROC_RUNNING} )
if [ $OLDPROC_RUNNING_TIME > $UPDATER_PROCESS_MAX_RUNTIME ] ; then if [ $OLDPROC_RUNNING_TIME -gt $UPDATER_PROCESS_MAX_RUNTIME ] ; then
logger "update_r_packages: process $OLDPROC_RUNNING got stuck, killing it" logger "update_r_packages: process $OLDPROC_RUNNING was running for $OLDPROC_RUNNING_TIME seconds. Got stuck, killing it"
kill -9 $OLDPROC_RUNNING kill -9 $OLDPROC_RUNNING
cleanup cleanup
else else
@ -198,9 +198,12 @@ function r_github_pkgs() {
for l in $( cat $R_PKGS_GITHUB ) ; do for l in $( cat $R_PKGS_GITHUB ) ; do
pkg=$( echo $l | cut -d "/" -f 2 ) pkg=$( echo $l | cut -d "/" -f 2 )
if [ "$ACTION" == "upgrade" ] ; then if [ "$ACTION" == "upgrade" ] ; then
Rscript --slave --no-save --no-restore-history -e "require(devtools); require(methods); install_github('$l');" #Rscript --slave --no-save --no-restore-history -e "require(devtools); require(methods); install_github('$l');"
Rscript --slave --no-save --no-restore-history -e "require(devtools); require(methods); require(jsonlite) ; package_to_install <- '$l' ; refs <- jsonlite::read_json(sprintf('https://api.github.com/repos/%s/releases', package_to_install)) ; ref_to_install <- 'master'; if(length(refs)>0) { ref_to_install <- refs[[1]][['tag_name']] } ; devtools::install_github(package_to_install, ref = ref_to_install)"
else else
Rscript --slave --no-save --no-restore-history -e "if (! ('$pkg' %in% installed.packages()[,'Package'])) { require(devtools); require(methods) ; install_github('$l'); }" #Rscript --slave --no-save --no-restore-history -e "if (! ('$pkg' %in% installed.packages()[,'Package'])) { require(devtools); require(methods) ; install_github('$l'); }"
Rscript --slave --no-save --no-restore-history -e "if (! ('$pkg' %in% installed.packages()[,'Package'])) { require(devtools); require(methods); require(jsonlite) ; package_to_install <- '$l' ; refs <- jsonlite::read_json(sprintf('https://api.github.com/repos/%s/releases', package_to_install)) ; ref_to_install <- 'master'; if(length(refs)>0) { ref_to_install <- refs[[1]][['tag_name']] } ; devtools::install_github(package_to_install, ref = ref_to_install) }"
fi fi
done done
else else