Different way to manage the github upgrades.

This commit is contained in:
Andrea Dell'Amico 2021-09-21 17:16:43 +02:00
parent 4a4eec4589
commit 3c17fa3db0
Signed by: andrea.dellamico
GPG Key ID: 147ABE6CEB9E20FF
2 changed files with 16 additions and 6 deletions

View File

@ -43,7 +43,8 @@ r_package_updater_via_git: True
r_package_updater_git_repo: 'https://code-repo.d4science.org/gCubeSystem/r-packages-list' r_package_updater_git_repo: 'https://code-repo.d4science.org/gCubeSystem/r-packages-list'
r_packages_git_base_dir: /srv/r_updater r_packages_git_base_dir: /srv/r_updater
r_packages_files_prefix: '' r_packages_files_prefix: ''
r_packages_updater_also_upgrades_installed_packages: False r_packages_updater_also_upgrades_installed_packages: True
r_packages_updater_for_github_only: True
# They need to be flat text files # They need to be flat text files
# 1 package per line # 1 package per line
#r_debian_packages_list_url #r_debian_packages_list_url

View File

@ -37,6 +37,11 @@ R_PKGS_FILES_PREFIX="{{ r_packages_files_prefix }}"
RSCRIPT_OPTIONS="--slave --no-site-file --no-init-file --no-save --no-restore-history" RSCRIPT_OPTIONS="--slave --no-site-file --no-init-file --no-save --no-restore-history"
# In seconds. 60*60*6=21600s (6h) # In seconds. 60*60*6=21600s (6h)
UPDATER_PROCESS_MAX_RUNTIME=21600 UPDATER_PROCESS_MAX_RUNTIME=21600
{% if r_packages_updater_for_github_only %}
UPDATER_DEFAULT_BEHAVIOUR="github_only"
{% else %}
UPDATER_DEFAULT_BEHAVIOUR="everything"
{% endif %}
# - debian packages list format: # - debian packages list format:
# one package per line # one package per line
DEB_PKGS_SKIP=0 DEB_PKGS_SKIP=0
@ -250,7 +255,9 @@ function r_cran_pkgs() {
mirror=$R_CRAN_MIRROR mirror=$R_CRAN_MIRROR
fi fi
if [ "$ACTION" == "upgrade" ] ; then if [ "$ACTION" == "upgrade" ] ; then
Rscript $RSCRIPT_OPTIONS -e "install.packages(pkgs='$pkg', repos=c('$mirror/'));" if [ "$UPDATER_DEFAULT_BEHAVIOUR" == "everything" ] ; then
Rscript $RSCRIPT_OPTIONS -e "install.packages(pkgs='$pkg', repos=c('$mirror/'));"
fi
else else
Rscript $RSCRIPT_OPTIONS -e "if (! ('$pkg' %in% installed.packages()[,'Package'])) { install.packages(pkgs='$pkg', repos=c('$mirror/')); }" Rscript $RSCRIPT_OPTIONS -e "if (! ('$pkg' %in% installed.packages()[,'Package'])) { install.packages(pkgs='$pkg', repos=c('$mirror/')); }"
fi fi
@ -267,7 +274,9 @@ function r_cran_versioned_pkgs() {
pkg=$( echo $l | cut -d : -f 1 ) pkg=$( echo $l | cut -d : -f 1 )
version=$( echo $l | cut -d : -f 2 ) version=$( echo $l | cut -d : -f 2 )
if [ "$ACTION" == "upgrade" ] ; then if [ "$ACTION" == "upgrade" ] ; then
Rscript $RSCRIPT_OPTIONS -e "require(devtools); install_version('$pkg', '$version', repos=c('$mirror/'));" if [ "$UPDATER_DEFAULT_BEHAVIOUR" == "everything" ] ; then
Rscript $RSCRIPT_OPTIONS -e "require(devtools); install_version('$pkg', '$version', repos=c('$mirror/'));"
fi
else else
Rscript $RSCRIPT_OPTIONS -e "if (! ('$pkg' %in% installed.packages()[,'Package'])) { require(devtools); install_version('$pkg', '$version', repos=c('$mirror/')); }" Rscript $RSCRIPT_OPTIONS -e "if (! ('$pkg' %in% installed.packages()[,'Package'])) { require(devtools); install_version('$pkg', '$version', repos=c('$mirror/')); }"
fi fi
@ -289,7 +298,7 @@ function r_github_pkgs() {
else else
github_version_to_install="$github_pkg_version" github_version_to_install="$github_pkg_version"
fi fi
if [ "$ACTION" == "upgrade" -o "$R_PKGS_ALWAYS_UPGRADE_GITHUB" ] ; then if [ "$ACTION" == "upgrade" ] ; then
Rscript $RSCRIPT_OPTIONS -e "require(devtools); require(methods); require(jsonlite) ; package_to_install <- '$github_pkg' ; refs <- jsonlite::read_json(sprintf('https://api.github.com/repos/%s/releases', package_to_install)) ; ref_to_install <- '$github_pkg_version'; if(length(refs)>0) { ref_to_install <- refs[[1]][['tag_name']] } ; devtools::install_github(package_to_install, ref = ref_to_install, upgrade='never')" Rscript $RSCRIPT_OPTIONS -e "require(devtools); require(methods); require(jsonlite) ; package_to_install <- '$github_pkg' ; refs <- jsonlite::read_json(sprintf('https://api.github.com/repos/%s/releases', package_to_install)) ; ref_to_install <- '$github_pkg_version'; if(length(refs)>0) { ref_to_install <- refs[[1]][['tag_name']] } ; devtools::install_github(package_to_install, ref = ref_to_install, upgrade='never')"
else else
@ -311,14 +320,14 @@ init_env
if [ $R_PKGS_FROM_GIT == 'True' ] ; then if [ $R_PKGS_FROM_GIT == 'True' ] ; then
get_data_files_from_git get_data_files_from_git
if [ $GIT_UPDATE_STATUS -ne 1 -a "$ACTION" == "install" ] ; then if [ $GIT_UPDATE_STATUS -ne 1 -a "$ACTION" == "install" ] ; then
logger "update_r_packages: nothing new to install from git, exiting" logger "update_r_packages: nothing new to install from git"
cleanup cleanup
exit 0 exit 0
fi fi
elif [ $R_PKGS_FROM_SVN == 'True' ] ; then elif [ $R_PKGS_FROM_SVN == 'True' ] ; then
get_data_files_from_svn get_data_files_from_svn
if [ $SVN_UPDATE_STATUS -ne 0 -a "$ACTION" == "install" ] ; then if [ $SVN_UPDATE_STATUS -ne 0 -a "$ACTION" == "install" ] ; then
logger "update_r_packages: nothing new to install from SVN, exiting" logger "update_r_packages: nothing new to install from SVN."
cleanup cleanup
exit 0 exit 0
fi fi