8000 reflects the upstream install2.r script updates by eitsupi · Pull Request #625 · rocker-org/rocker-versioned2 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

reflects the upstream install2.r script updates #625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments. 8000
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/r-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ on:
paths:
- scripts/install_R_source.sh
- scripts/setup_R.sh
- scripts/bin/**
- dockerfiles/r-ver_devel.Dockerfile
- "!**.md"
workflow_dispatch:

concurrency:
Expand Down
26 changes: 18 additions & 8 deletions scripts/bin/install2.r
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# Copyright (C) 2011 - 2014 Dirk Eddelbuettel
# Copyright (C) 2014 - 2017 Carl Boettiger and Dirk Eddelbuettel
# Copyright (C) 2018 - 2022 Carl Boettiger, Dirk Eddelbuettel, Brandon Bertelsen, and SHIMA Tatsuya
# Copyright (C) 2018 - 2023 Carl Boettiger, Dirk Eddelbuettel, Brandon Bertelsen, and SHIMA Tatsuya
#
# Released under GPL (>= 2)

Expand All @@ -15,16 +15,17 @@ library(docopt)
libloc <- .libPaths()[1]

## configuration for docopt
doc <- paste0("Usage: install2.r [-l LIBLOC] [-h] [-x] [-s] [-d DEPS] [-n NCPUS] [-r REPOS...] [-m METHOD] [--error] [--skipmissing] [--] [PACKAGES ...]
doc <- paste0("Usage: install2.r [-l LIBLOC] [-h] [-x] [-s] [-d DEPS] [-n NCPUS] [-r REPOS...] [-m METHOD] [-t TYPE] [--error] [--skipmissing] [--] [PACKAGES ...]

-l --libloc LIBLOC location in which to install [default: ", libloc, "]
-d --deps DEPS install suggested dependencies as well [default: NA]
-n --ncpus NCPUS number of processes to use for parallel install [default: getOption]
-n --ncpus NCPUS number of processes to use for parallel install, -1 selects all cores [default: getOption]
-r --repos REPOS repositor(y|ies) to use, or NULL for file [default: getOption]
-e --error throw error and halt instead of a warning [default: FALSE]
--skipmissing use with the --error option, skip the packages missing error [default: FALSE]
-s --skipinstalled skip installing already installed packages [default: FALSE]
-m --method METHOD method to be used for downloading files [default: auto]
-t --type TYPE installation type as used by `install.packages` [default: getOption]
-h --help show this help text
-x --usage show help and short example usage")
opt <- docopt(doc) # docopt parsing
Expand All @@ -44,7 +45,7 @@ Examples:
install2.r -n 6 ggplot2 # parallel install: (6 processes)

install2.r is part of littler which brings 'r' to the command-line.
See http://dirk.eddelbuettel.com/code/littler.html for more information.\n")
See https://dirk.eddelbuettel.com/code/littler.html for more information.\n")
q("no")
}

Expand All @@ -71,6 +72,13 @@ if (opt$ncpus == "getOption") {
opt$ncpus <- max(1L, parallel::detectCores())
}

## type should reflects bspm where available
if (opt$type == "getOption") {
opt$type <- getOption("pkgType")
#if (requireNamespace("bspm", quietly=TRUE) && Sys.info()[["sysname"]] == "Linux") opt$type <- "binary-source"

}

## ensure installation is stripped
Sys.setenv("_R_SHLIB_STRIP_"="true")

Expand All @@ -79,10 +87,10 @@ install_packages2 <- function(pkgs, ..., error = FALSE, skipmissing = FALSE, ski
capture <- function(e) {
if (error) {
catch <-
grepl("download of package .* failed", e$message) ||
grepl("(download|installation) of package .* failed", e$message) ||
(grepl("(dependenc|package).*(is|are) not available", e$message) && !skipmissing) ||
grepl("installation of package.*had non-zero exit status", e$message) ||
grepl("installation of .+ packages failed", e$message)
grepl("installation of .+ package(|s) failed", e$message)
if (catch) {
e <<- e
}
Expand All @@ -103,14 +111,15 @@ install_packages2 <- function(pkgs, ..., error = FALSE, skipmissing = FALSE, ski
isMatchingFile <- function(f) (file.exists(f) && grepl("(\\.tar\\.gz|\\.tgz|\\.zip)$", f)) || (f == ".")

## helper function which switches to local (ie NULL) repo if matching file is presented
installArg <- function(f, lib, rep, dep, iopts, error, skipmissing, skipinstalled, ncpus, method) {
installArg <- function(f, lib, rep, dep, iopts, error, skipmissing, skipinstalled, ncpus, method, type) {
install_packages2(pkgs=f,
lib=lib,
repos=if (isMatchingFile(f)) NULL else rep,
dependencies=dep,
INSTALL_opts=iopts,
Ncpus = ncpus,
method = method,
type = type,
error = error,
skipmissing = skipmissing,
skipinstalled = skipinstalled)
Expand Down Expand Up @@ -140,7 +149,7 @@ isLocal <- sapply(opt$PACKAGES, isMatchingFile)
## possibly in parallel using up to ncpus)
if (any(isLocal)) {
sapply(opt$PACKAGES, installArg, opt$libloc, opt$repos, opt$deps,
installOpts, opt$error, opt$skipmissing, opt$skipinstalled, opt$ncpus, opt$method)
installOpts, opt$error, opt$skipmissing, opt$skipinstalled, opt$ncpus, opt$method, opt$type)
} else {
install_packages2(pkgs = opt$PACKAGES,
lib = opt$libloc,
Expand All @@ -149,6 +158,7 @@ if (any(isLocal)) {
INSTALL_opts = installOpts,
Ncpus = opt$ncpus,
method = opt$method,
type = opt$type,
error = opt$error,
skipmissing = opt$skipmissing,
skipinstalled = opt$skipinstalled)
Expand Down
0