From 7b5e07f26661e99dab08bb6727be7bef8bf082cc Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Tue, 19 Jan 2021 23:30:25 +0100 Subject: [PATCH] Allow R4 install (#49) * enable install of R 4.0 * add a warning about r_version_35 * update readme about r_version and r_version_35 * Allow R4 install * Fixes Co-authored-by: Fanch --- README.md | 2 +- Vagrantfile | 14 +++++++------- defaults/main.yml | 2 +- tasks/packages.yml | 20 ++++++++++---------- templates/usr/local/bin/R-install-package.j2 | 2 +- templates/usr/local/bin/R-update-package.j2 | 2 +- vars/main.yml | 3 ++- 7 files changed, 23 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 20f1f42..8f2c0d6 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Set up the latest version of R in Ubuntu systems. #### Variables -* `r_version_35`: [default: `false`, for `Ubuntu >= 18.04` always `true`]: Whether or not to install R 3.5+ +* `r_version`: [default: `34`, `35` for `Ubuntu >= 18.04`, `40` for `Ubuntu >= 20.04`]: Version to install * `r_cran_mirror`: [default: `https://cran.rstudio.com/`]: Your favorite [CRAN mirror](https://cran.r-project.org/mirrors.html) * `r_bioclite_url`: [default: `https://bioconductor.org/biocLite.R`]: The `biocLite.R` script URL for [Bioconductor](https://bioconductor.org/) installs diff --git a/Vagrantfile b/Vagrantfile index 1f70387..8868feb 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -5,22 +5,22 @@ role = File.basename(File.expand_path(File.dirname(__FILE__))) boxes = [ { - :name => "ubuntu-1404", - :box => "bento/ubuntu-14.04", + :name => "ubuntu-1604", + :box => "bento/ubuntu-16.04", :ip => '10.0.0.12', :cpu => "50", :ram => "256" }, { - :name => "ubuntu-1604", - :box => "bento/ubuntu-16.04", + :name => "ubuntu-1804", + :box => "bento/ubuntu-18.04", :ip => '10.0.0.13', :cpu => "50", - :ram => "256" + :ram => "384" }, { - :name => "ubuntu-1804", - :box => "bento/ubuntu-18.04", + :name => "ubuntu-2004", + :box => "bento/ubuntu-20.04", :ip => '10.0.0.14', :cpu => "50", :ram => "384" diff --git a/defaults/main.yml b/defaults/main.yml index bff984f..418b90a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,6 +1,6 @@ # defaults file for r --- -r_version_35: "{{ (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('18.04', '>=')) }}" +r_version: "{{ '40' if ansible_distribution_version is version('20.04', '>=') else '35' if ansible_distribution_version is version('18.04', '>=') else '34' }}" r_cran_mirror: https://cran.rstudio.com/ r_bioclite_url: https://bioconductor.org/biocLite.R diff --git a/tasks/packages.yml b/tasks/packages.yml index c66f1bc..da763db 100644 --- a/tasks/packages.yml +++ b/tasks/packages.yml @@ -32,11 +32,11 @@ register: _r_install_package changed_when: "_r_install_package.stdout_lines[-1] is defined and _r_install_package.stdout_lines[-1] == 'changed'" with_items: - "{{ - r_packages_from_github | ternary (r_preset_package_remotes, []) + - r_packages_from_bioconductor | ternary ((r_version_35 | ternary (r_preset_package_bioconductor, [])), []) + - r_packages - }}" + "{{ + r_packages_from_github | ternary (r_preset_package_remotes, []) + + r_packages_from_bioconductor | ternary ((r_version is version('35', '>=') | ternary (r_preset_package_bioconductor, [])), []) + + r_packages + }}" when: item.state is undefined or item.state == 'present' tags: - r-packages-install @@ -67,11 +67,11 @@ register: _r_update_package changed_when: "_r_update_package.stdout_lines[-1] is defined and _r_update_package.stdout_lines[-1] == 'changed'" with_items: - "{{ - r_packages_from_github | ternary (r_preset_package_remotes, []) + - r_packages_from_bioconductor | ternary ((r_version_35 | ternary (r_preset_package_bioconductor, [])), []) + - r_packages - }}" + "{{ + r_packages_from_github | ternary (r_preset_package_remotes, []) + + r_packages_from_bioconductor | ternary ((r_version is version('35', '>=') | ternary (r_preset_package_bioconductor, [])), []) + + r_packages + }}" when: - item.state is defined - item.state == 'updated' diff --git a/templates/usr/local/bin/R-install-package.j2 b/templates/usr/local/bin/R-install-package.j2 index 71a915f..970cc16 100644 --- a/templates/usr/local/bin/R-install-package.j2 +++ b/templates/usr/local/bin/R-install-package.j2 @@ -34,7 +34,7 @@ if (!(package %in% installed.packages(lib.loc = lib)[, 'Package'])) { }, warning = stop); } else if (type == 'bioconductor') { withCallingHandlers({ - {% if r_version_35 %} + {% if r_version is version('35', '>=') %} BiocManager::install(package, lib = lib, update = FALSE) {% else %} source('{{ r_bioclite_url }}') diff --git a/templates/usr/local/bin/R-update-package.j2 b/templates/usr/local/bin/R-update-package.j2 index b50f8af..46d5613 100644 --- a/templates/usr/local/bin/R-update-package.j2 +++ b/templates/usr/local/bin/R-update-package.j2 @@ -26,7 +26,7 @@ if (package %in% old.packages(lib.loc = lib, repos = repos)[, 'Package'] & type if (type == 'bioconductor') { withCallingHandlers({ - {% if r_version_35 %} + {% if r_version is version('35', '>=') %} BiocManager::install(package, lib = lib, update = FALSE) {% else %} source('{{ r_bioclite_url }}') diff --git a/vars/main.yml b/vars/main.yml index 72e5a63..d547a7d 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,8 +1,9 @@ # vars file for r --- +r_repository_suffix: "{{ '-cran' + r_version if r_version is version('35', '>=') else '' }}" r_repository: - type: deb - url: "{{ r_cran_mirror }}/bin/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }}{{ r_version_35 | ternary('-cran35', '') }}/" + url: "{{ r_cran_mirror }}/bin/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }}{{ r_repository_suffix }}/" r_dependencies_pre: - apt-transport-https