Skip to content

Commit

Permalink
Implemented r-proxy check for installed package.
Browse files Browse the repository at this point in the history
  • Loading branch information
lpaolini committed Oct 4, 2023
1 parent d24c508 commit e2f0d5b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
15 changes: 12 additions & 3 deletions modules/r-proxy/src/cran.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,14 @@ const isCranPackageCached = async (name, version) =>

const installCranPackage = async (name, version, repo) => {
try {
log.info(`Installing ${name}/${version}`)
await runScript('install_cran_package.r', [name, version, libPath, repo])
log.info(`Installed ${name}/${version}`)
try {
await runScript('check_cran_package.r', [name, version, libPath])
log.info(`Already installed ${name}/${version}`)
} catch (error) {
log.info(`Installing ${name}/${version}`)
await runScript('install_cran_package.r', [name, version, libPath, repo])
log.info(`Installed ${name}/${version}`)
}
return true
} catch (error) {
log.warn(`Could not install ${name}/${version}`, error)
Expand Down Expand Up @@ -196,6 +201,10 @@ const checkCranUpdates = async enqueueUpdateCranPackage => {
} else {
// no more properties: process previous entry
const {Package: name, Version: version, Depends: depends} = entry.get()
// if (depends) {
// const foo = depends?.replaceAll(/\s+/g, '').split(',')
// log.fatal(foo)
// }
if (name && version) {
if (isVersionSatisfied({name, version, depends, installedVersion})) {
enqueueUpdateCranPackage(name, version)
Expand Down
13 changes: 13 additions & 0 deletions modules/r-proxy/src/script/check_cran_package.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env Rscript

args = commandArgs(trailingOnly = TRUE)

name <- args[1]
version <- args[2]
lib <- args[3]

.libPaths(lib)

if ( ! packageVersion(name, lib.loc = lib) == version) {
quit(status = 10, save = 'no')
}

0 comments on commit e2f0d5b

Please sign in to comment.