Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
BUG: Fix R updater function
- For some reason the exported bash function has trouble scoping the
  exported variable, so pass it explicitly as a function parameter.

- Create R_LIBS_USER directory if necessary.

- Correct printf expansion of R packages.

- Fix various typos.

- Use setwd() because we are spawning R in the /root directory.  This
  more robust that relying on `su - $user`.

- Enable echo for debugging.
  • Loading branch information
pan14001 committed Aug 15, 2016
1 parent 264ed80 commit e06845a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions cgi-updater-payload.sh
Expand Up @@ -34,10 +34,15 @@ python_install_packages() {
}

r_install_packages() {
local pkgs=\"$(sprintf "\",%s\"" "${r_pkgs[@]}")\"
R --quiet -vanilla -e <<EOF
local pkgs=$@
pkgs=\"$(printf "\",\"%s" $pkgs)\"
Rscript --vanilla - <<EOF
options(echo = TRUE)
dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE)
.libPaths(Sys.getenv("R_LIBS_USER"))
setwd(paste(Sys.getenv("R_HOME")))
source("https://bioconductor.org/biocLite.R")
biocLite(c(${pkgs:3})
biocLite(c(${pkgs:3}))
EOF
}

Expand All @@ -50,10 +55,9 @@ main () {
# Install R libraries in the user home directory so that updating
# the libraries later on does not triggering the "unwritable
# directory" warning.
export r_pkgs
export -f r_install packages
su cgi_user -c "bash -c r_install_packages"
unset r_pkgs r_install_packages
export -f r_install_packages
su cgi_user -c "bash -c \"r_install_packages ${r_pkgs[*]}\""
unset r_install_packages
}

main

0 comments on commit e06845a

Please sign in to comment.