| 1 |
|
| 2 |
the$distro <- NULL |
| 3 |
the$os <- NULL |
| 4 |
the$platform <- NULL |
| 5 |
the$prefix <- NULL |
| 6 |
the$sysinfo <- NULL |
| 7 |
|
| 8 |
renv_platform_init <- function() { |
| 9 |
|
| 10 |
the$sysinfo <- as.list(Sys.info()) |
| 11 |
|
| 12 |
the$platform <- if (file.exists("/etc/os-release")) { |
| 13 |
renv_properties_read( |
| 14 |
path = "/etc/os-release", |
| 15 |
delimiter = "=", |
| 16 |
dequote = TRUE, |
| 17 |
trim = TRUE |
| 18 |
) |
| 19 |
} |
| 20 |
|
| 21 |
the$os <- tolower(the$sysinfo$sysname) |
| 22 |
|
| 23 |
# NOTE: This is chosen to be compatible with the distribution field |
| 24 |
# used within r-system-requirements. |
| 25 |
if (the$os == "linux") { |
| 26 |
aliases <- list(rhel = "redhat") |
| 27 |
the$distro <- alias(the$platform$ID, aliases) |
| 28 |
} |
| 29 |
|
| 30 |
} |
| 31 |
|
| 32 |
renv_platform_unix <- function() { |
| 33 |
.Platform$OS.type == "unix" |
| 34 |
} |
| 35 |
|
| 36 |
renv_platform_windows <- function() { |
| 37 |
.Platform$OS.type == "windows" |
| 38 |
} |
| 39 |
|
| 40 |
renv_platform_macos <- function() { |
| 41 |
the$sysinfo[["sysname"]] == "Darwin" |
| 42 |
} |
| 43 |
|
| 44 |
renv_platform_linux <- function() { |
| 45 |
the$sysinfo[["sysname"]] == "Linux" |
| 46 |
} |
| 47 |
|
| 48 |
renv_platform_solaris <- function() { |
| 49 |
the$sysinfo[["sysname"]] == "SunOS" |
| 50 |
} |
| 51 |
|
| 52 |
renv_platform_wsl <- function() { |
| 53 |
|
| 54 |
pv <- "/proc/version" |
| 55 |
if (!file.exists(pv)) |
| 56 |
return(FALSE) |
| 57 |
|
| 58 |
renv_scope_options(warn = -1L) |
| 59 |
contents <- catch(readLines(pv, warn = FALSE)) |
| 60 |
if (inherits(contents, "error")) |
| 61 |
return(FALSE) |
| 62 |
|
| 63 |
any(grepl("(?:Microsoft|WSL)", contents, ignore.case = TRUE)) |
| 64 |
|
| 65 |
} |
| 66 |
|
| 67 |
renv_platform_prefix <- function() { |
| 68 |
(the$prefix <- the$prefix %||% renv_bootstrap_platform_prefix()) |
| 69 |
} |
| 70 |
|
| 71 |
renv_platform_machine <- function() { |
| 72 |
the$sysinfo[["machine"]] |
| 73 |
} |