-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Oefenweb/add-functionality-for-installing-…
…and-removing-r-packages Add functionality for installing and removing R packages
- Loading branch information
Showing
9 changed files
with
99 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,9 @@ | |
- configuration | ||
- r | ||
- r-install | ||
|
||
- include: packages.yml | ||
tags: | ||
- configuration | ||
- r | ||
- r-packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# tasks file for r | ||
--- | ||
- name: packages | copy littler scripts | ||
template: | ||
src: "usr/local/bin/{{ item.src }}" | ||
dest: "/usr/local/bin/{{ item.dest }}" | ||
owner: root | ||
group: root | ||
mode: 0755 | ||
with_items: | ||
- src: R-install-package.j2 | ||
dest: R-install-package | ||
- src: R-remove-package.j2 | ||
dest: R-remove-package | ||
|
||
- name: packages | install | ||
command: "R-install-package {{ item.name }}{% if item.lib is defined %} {{ item.lib }}{% endif %}{% if item.repos is defined %} {{ item.repos }}{% endif %}" | ||
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 | ||
when: item.state is undefined or item.state == 'present' | ||
tags: | ||
- r-packages-install | ||
|
||
- name: packages | remove | ||
command: "R-remove-package {{ item.name }}{% if item.lib is defined %} {{ item.lib }}{% endif %}" | ||
register: r_remove_package | ||
changed_when: "r_remove_package.stdout_lines[-1] is defined and r_remove_package.stdout_lines[-1] == 'changed'" | ||
with_items: r_packages | ||
when: item.state is defined and item.state == 'absent' | ||
tags: | ||
- r-packages-remove |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env r | ||
|
||
if (is.null(argv) | length(argv) < 1) { | ||
cat("Usage: R-install-package package [lib] [repos]\n"); | ||
q(status = 1); | ||
} | ||
|
||
package = argv[1] | ||
lib = ifelse(is.na(argv[2]), '{{ r_packages_lib }}', argv[2]); | ||
repos = ifelse(is.na(argv[3]), '{{ r_packages_repos }}', argv[3]); | ||
|
||
if (!(package %in% installed.packages(lib.loc = lib)[,'Package'])) { | ||
withCallingHandlers(install.packages(package, lib, repos), warning = stop); | ||
cat("changed\n"); | ||
} else { | ||
cat("unchanged\n"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env r | ||
|
||
if (is.null(argv) | length(argv) < 1) { | ||
cat("Usage: R-remove-package package [lib]\n"); | ||
q(status = 1); | ||
} | ||
|
||
package = argv[1] | ||
lib = ifelse(is.na(argv[2]), '{{ r_packages_lib }}', argv[2]); | ||
|
||
if (package %in% installed.packages(lib.loc = lib)[,'Package']) { | ||
withCallingHandlers(remove.packages(package, lib), warning = stop); | ||
cat("changed\n"); | ||
} else { | ||
cat("unchanged\n"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters