From 3d1fdcc874c289f92cfd8ff22b46efa04a9d716a Mon Sep 17 00:00:00 2001 From: Florian Angerer <florian.angerer@oracle.com> Date: Fri, 23 Feb 2018 13:47:54 +0100 Subject: [PATCH] Remove system installation mode. --- .../r/install.package.R | 89 ------------------- .../r/install.packages.R | 22 ++--- 2 files changed, 5 insertions(+), 106 deletions(-) delete mode 100644 com.oracle.truffle.r.test.packages/r/install.package.R diff --git a/com.oracle.truffle.r.test.packages/r/install.package.R b/com.oracle.truffle.r.test.packages/r/install.package.R deleted file mode 100644 index 3101fe1294..0000000000 --- a/com.oracle.truffle.r.test.packages/r/install.package.R +++ /dev/null @@ -1,89 +0,0 @@ -# -# Copyright (c) 2015, 2017, 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. -# - -# A script to do a single package installation (+dependents), called from install.packages.R. -# It exists as a separate script only to avoid internal FastR errors from killing the -# entire installation process for multiple package installation tests. - -# args: -# pkgname, contriburl, lib, pkg.cache.enabled [, api.version, cache.dir ] - - -log.message <- function(..., level=0L) { - # TODO: verbosity - if (level == 0L) { - cat(..., "\n") - } -} - -args <- commandArgs(TRUE) - -parse.args <- function() { - if (length(args)) { - pkgname <<- args[[1]] - contriburl <<- strsplit(args[[2]], ",")[[1]] - lib.install <<- args[[3]] - - pkg.cache <<- as.environment(list(enabled=FALSE, table.file.name="version.table", size=2L)) - pkg.cache$enabled <- as.logical(args[[4]]) - cat("system.install, cache enabled: ", pkg.cache$enabled, "\n") - if (pkg.cache$enabled) { - pkg.cache$version <- args[[5]] - pkg.cache$dir <- args[[6]] - } - } -} - -# return code: sucess == 0L, error == 1L -run <- function() { - parse.args() - pkg.cache.internal.install(pkg.cache, pkgname, contriburl, lib.install) -} - -# Determines the directory of the script assuming that there is a "--file=" argument on the command line. -getCurrentScriptDir <- function() { - cmdArgs <- commandArgs() - res <- startsWith(cmdArgs, '--file=') - fileArg <- cmdArgs[res] - if (length(fileArg) > 0L) { - p <- strsplit(fileArg, "=")[[1]][[2]] - dirname(p) - } else { - NULL - } -} - -# load package cache code -curScriptDir <- getCurrentScriptDir() -if (!is.null(curScriptDir)) { - source(file.path(curScriptDir, "install.cache.R")) -} else { - log.message("Cannot use package cache since script directory cannot be determined") - pkg.cache.get <<- function(...) FALSE - pkg.cache.insert <<- function(...) FALSE -} - -if (!interactive()) { - status.code <- run() - quit(status = status.code) -} 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 f16cc75830..cf3901e4d8 100644 --- a/com.oracle.truffle.r.test.packages/r/install.packages.R +++ b/com.oracle.truffle.r.test.packages/r/install.packages.R @@ -741,23 +741,11 @@ fastr_error_log_size <- function() { # installs a single package or retrieves it from the cache install.pkg <- function(pkgname) { error_log_size <- fastr_error_log_size() - if (run.mode == "system") { - tryCatch( - system.install(pkgname) - , error = function(e) { - log.message(e$message) - 1L - }, warning = function(e) { - log.message(e$message) - # According to the documentation of 'system2', a warning will provide a status field. - e$status - }) - } else if (run.mode == "internal") { - pkg.cache.internal.install(pkg.cache.env=pkg.cache, pkgname=pkgname, lib.install=lib.install) - } else if (run.mode == "context") { - stop("context run-mode not implemented\n") - } - rc <- installed.ok(pkgname, error_log_size) + rc <- pkg.cache.internal.install(pkg.cache, pkgname, contrib.url(getOption("repos"), "source")[[1]], lib.install) + if (rc == 0L) { + # be paranoid and also check file system and log + rc <- installed.ok(pkgname, error_log_size) + } names(rc) <- pkgname install.status <<- append(install.status, rc) return(rc) -- GitLab