diff --git a/.travis.yml b/.travis.yml index f4a9ba3..776736a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -70,8 +70,7 @@ script: # Test r installation - > - echo 'print(gsub("I","O","PING"))' - | r + Rscript -e 'print(gsub("I","O","PING"))' | grep -q 'PONG' && (echo 'Availability test: pass' && exit 0) || (echo 'Availability test: fail' && exit 1) diff --git a/README.md b/README.md index 4300bf2..f6be438 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Set up the latest version of R in Ubuntu systems. * `r_bioclite_url`: [default: `https://bioconductor.org/biocLite.R`]: The `biocLite.R` script URL for [Bioconductor](http://bioconductor.org/) installs * `r_install_dev`: [default: `false`]: Whether or not install the `r-base-dev` package -* `r_install`: [default: `[]`]: Additional (apt) packages to install (e.g. `r-recommended`) +* `r_install`: [default: `['littler']`]: Additional (apt) packages to install (e.g. `r-recommended`) * `r_packages_lib`: [default: `/usr/local/lib/R/site-library`]: The (default) library directory to install packages to * `r_packages_repos`: [default: `"{{ r_cran_mirror }}"`]: The (default) URL to install packages from diff --git a/defaults/main.yml b/defaults/main.yml index 35b6142..267a64d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -4,7 +4,8 @@ r_cran_mirror: http://cran.rstudio.com/ r_bioclite_url: https://bioconductor.org/biocLite.R r_install_dev: false -r_install: [] +r_install: + - littler r_packages_type: cran r_packages_repos: "{{ r_cran_mirror }}" diff --git a/tasks/packages.yml b/tasks/packages.yml index 9a99254..d43574d 100644 --- a/tasks/packages.yml +++ b/tasks/packages.yml @@ -1,6 +1,6 @@ # tasks file for r --- -- name: packages | copy littler scripts +- name: packages | copy r scripts template: src: "usr/local/bin/{{ item.src }}" dest: "/usr/local/bin/{{ item.dest }}" diff --git a/templates/usr/local/bin/R-install-package.j2 b/templates/usr/local/bin/R-install-package.j2 index a6e7251..584e4bc 100644 --- a/templates/usr/local/bin/R-install-package.j2 +++ b/templates/usr/local/bin/R-install-package.j2 @@ -1,23 +1,24 @@ -#!/usr/bin/env r +#!/usr/bin/env Rscript +argv = commandArgs(trailingOnly = TRUE); if (is.null(argv) | length(argv) < 1) { cat("Usage: R-install-package package [type] [lib] [repos]\n"); q(status = 1); } -package = argv[1] +package = argv[1]; type = ifelse(is.na(argv[2]), '{{ r_packages_type }}', argv[2]); lib = ifelse(is.na(argv[3]), '{{ r_packages_lib }}', argv[3]); if (!(package %in% installed.packages(lib.loc = lib)[, 'Package'])) { - if (type == "cran") { + if (type == 'cran') { repos = ifelse(is.na(argv[4]), '{{ r_packages_repos }}', argv[4]); withCallingHandlers(install.packages(package, lib, repos), warning = stop); - } else if (type == "bioconductor") { + } else if (type == 'bioconductor') { withCallingHandlers({ - source("{{ r_bioclite_url }}"); - biocLite(package, lib=lib, suppressUpdates=TRUE, suppressAutoUpdate=TRUE, ask=FALSE); - }, warning = stop) + source('{{ r_bioclite_url }}') + biocLite(package, lib = lib, suppressUpdates = TRUE, suppressAutoUpdate = TRUE, ask = FALSE) + }, warning = stop); } else { cat("Unrecognised type\n"); q(status = 1); diff --git a/templates/usr/local/bin/R-remove-package.j2 b/templates/usr/local/bin/R-remove-package.j2 index 3f6a666..7a20662 100644 --- a/templates/usr/local/bin/R-remove-package.j2 +++ b/templates/usr/local/bin/R-remove-package.j2 @@ -1,14 +1,15 @@ -#!/usr/bin/env r +#!/usr/bin/env Rscript +argv = commandArgs(trailingOnly = TRUE); if (is.null(argv) | length(argv) < 1) { cat("Usage: R-remove-package package [lib]\n"); q(status = 1); } -package = argv[1] +package = argv[1]; lib = ifelse(is.na(argv[2]), '{{ r_packages_lib }}', argv[2]); -if (package %in% installed.packages(lib.loc = lib)[,'Package']) { +if (package %in% installed.packages(lib.loc = lib)[, 'Package']) { withCallingHandlers(remove.packages(package, lib), warning = stop); cat("changed\n"); } else { diff --git a/vars/main.yml b/vars/main.yml index 33c5521..3d74358 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -6,5 +6,4 @@ r_repository: r_dependencies: - r-base - - littler - "{{ 'r-base-dev' if r_install_dev else '' }}"