-
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.
Add R-update-package(s) script(s) (#20)
* Add R-update-package(s) script(s) * Improved documentation [ci skip] * Add support for private bitbucket packages
- Loading branch information
1 parent
fb8a57f
commit 1333b74
Showing
7 changed files
with
119 additions
and
13 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
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,48 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# {{ ansible_managed }} | ||
# | ||
# set -x; | ||
set -e; | ||
set -o pipefail; | ||
# | ||
thisFile="$(readlink -f "${0}")"; | ||
thisFilePath="$(dirname "${thisFile}")"; | ||
|
||
if [ -z "${1}" ] || [ "${1}" != '-r' ] || [ -z "${2}" ]; then | ||
echo "Usage: ${0} -r requirements.txt"; | ||
exit 1; | ||
fi | ||
|
||
if [ ! -f "${2}" ]; then | ||
echo "Could not open requirements file for reading"; | ||
exit 1; | ||
fi | ||
|
||
requirementsFile="${2}"; | ||
shift 2; | ||
|
||
while IFS= read -r requirement; do | ||
requirementType="$(echo "${requirement}" | awk -F'::' '{ print $1}')"; | ||
requirementName="$(echo "${requirement}" | awk -F'::' '{ print $2}' | awk -F'@' '{ print $1}')"; | ||
requirementVersion="$(echo "${requirement}" | awk -F'::' '{ print $2}' | awk -F'@' '{ print $2}')"; | ||
|
||
if [ "${requirementType}" == 'github' ]; then | ||
installCommand="devtools::install_github(\"${requirementName}\")"; | ||
if [ -n "${requirementVersion}" ]; then | ||
installCommand="devtools::install_github(\"${requirementName}\", ref=\"${requirementVersion}\")"; | ||
fi | ||
elif [ "${requirementType}" == 'bitbucket' ]; then | ||
installCommand="devtools::install_bitbucket(\"${requirementName}\", auth_user = Sys.getenv(\"BITBUCKET_AUTH_USER\"), password = Sys.getenv(\"BITBUCKET_AUTH_PASSWORD\"))"; | ||
if [ -n "${requirementVersion}" ]; then | ||
installCommand="devtools::install_bitbucket(\"${requirementName}\", ref=\"${requirementVersion}\", auth_user = Sys.getenv(\"BITBUCKET_AUTH_USER\"), password = Sys.getenv(\"BITBUCKET_AUTH_PASSWORD\"))"; | ||
fi | ||
else | ||
installCommand="devtools::install_cran(\"${requirementName}\")"; | ||
if [ -n "${requirementVersion}" ]; then | ||
installCommand="devtools::install_version(\"${requirementName}\", version=\"${requirementVersion}\")"; | ||
fi | ||
fi | ||
|
||
Rscript -e "withCallingHandlers(${installCommand}, warning = stop)"; | ||
done < "${requirementsFile}" |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env Rscript | ||
|
||
argv = commandArgs(trailingOnly = TRUE); | ||
if (is.null(argv) | length(argv) < 1) { | ||
cat("Usage: R-update-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% old.packages(lib.loc = lib)[, 'Package']) { | ||
withCallingHandlers({ | ||
update.packages(package, lib, repos, ask = FALSE); | ||
cat("changed\n"); | ||
}, warning = stop); | ||
} |
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 Rscript | ||
|
||
argv = commandArgs(trailingOnly = TRUE); | ||
if (is.null(argv) | length(argv) < 0) { | ||
cat("Usage: R-update-packages [lib] [repos]\n"); | ||
q(status = 1); | ||
} | ||
|
||
lib = ifelse(is.na(argv[1]), '{{ r_packages_lib }}', argv[1]); | ||
repos = ifelse(is.na(argv[2]), '{{ r_packages_repos.rstrip('/') }}', argv[2]); | ||
|
||
if (!is.null(old.packages(lib.loc = lib))) { | ||
withCallingHandlers({ | ||
update.packages(lib, repos, ask = FALSE); | ||
cat("changed\n"); | ||
}, warning = stop); | ||
} |