diff --git a/R/zzz.R b/R/zzz.R index c441481..2cb9f0a 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -22,17 +22,40 @@ zipFile <- 'OMERO.java.zip' getLibs <- Sys.getenv("OMERO_LIBS_DOWNLOAD", unset = NA) - if (!is.na(getLibs) && as.logical(getLibs) == TRUE) { + if (!is.na(getLibs) && startsWith(tolower(getLibs), 'http')) { + # Allows using Java libs from merge-ci builds, e.g. + # https://merge-ci.openmicroscopy.org/jenkins/job/OMERO-build/lastBuild/ + git_info <- GET(getLibs) + status <- status_code(git_info) + if (status != 200) { + packageStartupMessage("Request failed. ", getLibs, " returned ", status) + acc <- 'n' + } else { + git_info <- content(git_info, "text") + ex <- ">(OMERO\\.java-\\S+\\.zip)<" + r <- gregexpr(ex, git_info) + res <- regmatches(git_info, r) + zipFile <- substr(res[[1]], 2, nchar(res[[1]])-1) + baseURL <- getLibs + if (endsWith(getLibs, '/')) + baseURL <- paste(baseURL, "artifact/src/target", sep = '') + else + baseURL <- paste(baseURL, "artifact/src/target", sep = '/') + acc <- 'y' + } + } + else if (!is.na(getLibs) && as.logical(getLibs) == TRUE) { acc <- 'y' } else { - packageStartupMessage('Have to download OMERO Java libraries ', baseURL, '/', zipFile, '\nProceed? [y/n]') + packageStartupMessage('Have to download OMERO Java libraries from downloads.openmicroscopy.org.\nProceed? [y/n]') acc <- readLines(con = stdin(), n=1, ok=TRUE) } if (length(acc) > 0 && (acc[[1]] == 'y' || acc[[1]] == 'Y')) { - packageStartupMessage('Downloading...') dest <- paste(omeroLibs, zipFile, sep = '/') - GET(paste(baseURL, zipFile, sep = '/'), write_disk(dest, overwrite=TRUE)) + dlURL <- paste(baseURL, zipFile, sep = '/') + packageStartupMessage(paste('Downloading', dlURL, '...')) + GET(dlURL, write_disk(dest, overwrite=TRUE)) packageStartupMessage('Extracting...') unzip(dest, exdir = omeroLibs) unzippedLibs <- NA diff --git a/jupyter/Dockerfile b/jupyter/Dockerfile index ce6ce18..8107ce3 100644 --- a/jupyter/Dockerfile +++ b/jupyter/Dockerfile @@ -6,6 +6,7 @@ ARG ROMERO_VERSION= ARG ROMERO_BRANCH_USER=ome ARG ROMERO_BRANCH=master ARG INSTALL_SCRIPT_URL=https://raw.githubusercontent.com/ome/rOMERO-gateway/master/install.R +ARG OMERO_LIBS_DOWNLOAD=TRUE USER root RUN apt-get update -y && \ @@ -30,13 +31,14 @@ RUN conda env update -n r-omero -q -f .setup/environment-r-omero.yml && \ # build/install rOMERO ENV _JAVA_OPTIONS="-Xss2560k -Xmx2g" + RUN cd /opt/romero && \ curl -sf $INSTALL_SCRIPT_URL --output install.R RUN if [ -z ${ROMERO_VERSION} ]; then \ bash -c "source activate r-omero && Rscript /opt/romero/install.R --user=$ROMERO_BRANCH_USER --branch=$ROMERO_BRANCH --quiet"; else \ bash -c "source activate r-omero && Rscript /opt/romero/install.R --version=$ROMERO_VERSION --quiet"; fi -ENV OMERO_LIBS_DOWNLOAD=TRUE +ENV OMERO_LIBS_DOWNLOAD=${OMERO_LIBS_DOWNLOAD} RUN bash -c "source activate r-omero && echo \"library('romero.gateway')\" | R --no-save" COPY --chown=1000:100 Get_Started.ipynb notebooks/