diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/utils/R/utils.R b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/utils/R/utils.R new file mode 100644 index 0000000000000000000000000000000000000000..d911e336fa53aeb9266beda68f48204283c8fbc6 --- /dev/null +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/utils/R/utils.R @@ -0,0 +1,50 @@ +# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. + +eval(expression({ + excludedPkgs <- c("rJava") + excludedPkgsMsgs <- c("CRAN rJava is not supported on FastR, but you can download and install rJava compatible replacement package from https://github.com/oracle/fastr/master/com.oracle.truffle.r.pkgs/rJava") + + fastRPkgFilter <- function (av) { + # The following statement will assign the url of the FastR clone of rJava, when ready (possibly on GitHub). + #av["rJava","Repository"] <- "https://github.com/oracle/fastr/master/com.oracle.truffle.r.pkgs/rJava" + found <- rownames(av) %in% excludedPkgs + if (any(found)) { + av <- av[-which(found),] + } + av + } + options(available_packages_filters = list(add = TRUE, fastRPkgFilter)) + + getDependencies.original <- getDependencies + getDependencies <- function(pkgs, dependencies = NA, available = NULL, lib = .libPaths()[1L], binary = FALSE) { + res <- getDependencies.original(pkgs, dependencies, available, lib, binary) + + found <- excludedPkgs %in% pkgs + if (any(found)) { + foundPkgMsgs <- excludedPkgsMsgs[which(found)] + warning(paste(foundPkgMsgs, collapse="\n"), call. = FALSE) + } + + res + } + +}), asNamespace("utils")) \ No newline at end of file diff --git a/com.oracle.truffle.r.native/Makefile b/com.oracle.truffle.r.native/Makefile index 159c2720d3a39a7032180944bd783e3d5d77db06..3f7f4f4f7fae532f573b48fa79012ded73c5b680 100644 --- a/com.oracle.truffle.r.native/Makefile +++ b/com.oracle.truffle.r.native/Makefile @@ -28,6 +28,7 @@ export FASTR_R_HOME=$(abspath $(TOPDIR)/..) export FASTR_LIB_DIR=$(FASTR_R_HOME)/lib export FASTR_NATIVE_DIR = $(TOPDIR) export R_VERSION = 3.4.0 +export DEFAULT_CRAN_MIRROR = "https://mran.microsoft.com/snapshot/2018-03-20" export GNUR_HOME = $(TOPDIR)/gnur/patch-build ifeq ($(FASTR_RFFI),llvm) diff --git a/com.oracle.truffle.r.native/run/Makefile b/com.oracle.truffle.r.native/run/Makefile index 4f6aa77dec37356d4f23a409953a19c4783f357c..13f2a596fb83f3d1578ddc3a0e4f1c01810ca520 100644 --- a/com.oracle.truffle.r.native/run/Makefile +++ b/com.oracle.truffle.r.native/run/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -87,6 +87,9 @@ $(FASTR_BIN_DIR)/R: Makefile R.sh Rscript.sh Rscript_exec.sh Rclasspath.sh cp $(GNUR_HOME_BINARY)/etc/repositories $(FASTR_ETC_DIR)/repositories cp $(GNUR_HOME_BINARY)/etc/ldpaths $(FASTR_ETC_DIR)/ldpaths ed Makeconf.etc < edMakeconf.etc + + echo $(DEFAULT_CRAN_MIRROR) > $(FASTR_ETC_DIR)/DEFAULT_CRAN_MIRROR + ifeq ($(FASTR_RFFI),llvm) ed Makeconf.etc < edMakeconf.etc.llvm cp $(LLVM_TOOLS) $(FASTR_BIN_DIR) diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java index c9103b3d8c8ad6d45c6bb07cbe2d7df4e573d82b..918258922b11787e2373b7d3f5e84f9095909863 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java @@ -303,6 +303,25 @@ public final class REnvVars implements RContext.ContextState { return TimeZone.getDefault(); } + public static String getCRANMirror() { + String cranMirror = System.getenv("CRAN_MIRROR"); + if (cranMirror == null) { + Path defCranMirrorPath = Paths.get(REnvVars.rHome()).resolve("etc").resolve("DEFAULT_CRAN_MIRROR"); + if (!Files.exists(defCranMirrorPath)) { + throw RSuicide.rSuicide("Missing etc/DEFAULT_CRAN_MIRROR file"); + } + List<String> cranMirrors; + try { + cranMirrors = Files.readAllLines(defCranMirrorPath); + } catch (IOException e) { + throw RSuicide.rSuicide("Invalid etc/DEFAULT_CRAN_MIRROR file"); + } + assert !cranMirrors.isEmpty(); + cranMirror = cranMirrors.get(0); + } + return cranMirror; + } + private String expandParameters(String value) { StringBuilder result = new StringBuilder(); int x = 0; diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ROptions.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ROptions.java index ba250c7d6bdfb1dac6a3416cbed6e5dce0ea3755..7bce52adedd3450ef66005f71a54b6368fc30539 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ROptions.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ROptions.java @@ -175,6 +175,11 @@ public class ROptions { map.put("browserNLdisabled", RDataFactory.createSharedLogicalVectorFromScalar(false)); boolean cBoundsCheck = optionFromEnvVar("R_C_BOUNDS_CHECK", envVars); map.put("CBoundsCheck", RDataFactory.createSharedLogicalVectorFromScalar(cBoundsCheck)); + + String cranMirror = REnvVars.getCRANMirror(); + if (cranMirror != null) { + map.put("repos", cranMirror); + } } private static boolean optionFromEnvVar(String envVar, REnvVars envVars) { diff --git a/com.oracle.truffle.r.test.packages/r/install.packages.R b/com.oracle.truffle.r.test.packages/r/install.packages.R index acb13821f8d4fa1b22256fedda7220de7e3b528e..7dac0bf7bd406f088c13d2e1231c650111da122a 100644 --- a/com.oracle.truffle.r.test.packages/r/install.packages.R +++ b/com.oracle.truffle.r.test.packages/r/install.packages.R @@ -1,5 +1,5 @@ # -# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -304,6 +304,12 @@ set.repos <- function() { } else if (name == "FASTR") { # set the FastR internal repo repos[["FASTR"]] <- paste0("file://", normalizePath("com.oracle.truffle.r.test.native/packages/repo")) + } else if (name == "SNAPSHOT") { + con <- file("etc/DEFAULT_CRAN_MIRROR", "r"); + tryCatch({ + cran.mirror <<- readLines(con)[[1]] + }, finally=function() close(con)) + repos[["CRAN"]] <- cran.mirror } else { # User defined repos[[name]] <- uri