File: rprofile

package info (click to toggle)
apache-arrow 23.0.1-1
  • links: PTS
  • area: main
  • in suites: sid
  • size: 76,220 kB
  • sloc: cpp: 654,608; python: 70,522; ruby: 45,964; ansic: 18,742; sh: 7,365; makefile: 669; javascript: 125; xml: 41
file content (64 lines) | stat: -rw-r--r-- 2,262 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
local({
  .pick_cran <- function() {
    # Return a CRAN repo URL, preferring RSPM binaries if available for this OS
    rspm_template <- "https://packagemanager.rstudio.com/cran/__linux__/%s/latest"
    # See https://github.com/rstudio/r-docker#releases-and-tags,
    # but note that RSPM still uses "centos8"
    supported_os <- c("bionic", "focal", "jammy", "centos7", "centos8", "opensuse153")

    if (nzchar(Sys.which("lsb_release"))) {
      os <- tolower(system("lsb_release -cs", intern = TRUE))
      if (os %in% supported_os) {
        return(sprintf(rspm_template, os))
      }
    }
    if (file.exists("/etc/os-release")) {
      os_release <- readLines("/etc/os-release")
      vals <- sub("^.*=(.*)$", "\\1", os_release)
      os <- intersect(vals, supported_os)
      if (length(os)) {
        # e.g. "bionic"
        return(sprintf(rspm_template, os))
      } else {
        names(vals) <- sub("^(.*)=.*$", "\\1", os_release)
        if (grepl("opensuse", vals["ID"])) {
          version <- sub('^"?([0-9]+)\\.?([0-9]+).*"?.*$', "\\1\\2", vals["VERSION_ID"])
          os <- paste0("opensuse", version)
          if (os %in% supported_os) {
            return(sprintf(rspm_template, os))
          }
        }
      }
    }
    if (file.exists("/etc/system-release")) {
      # Something like "CentOS Linux release 7.7.1908 (Core)"
      system_release <- tolower(utils::head(readLines("/etc/system-release"), 1))
      # Extract from that the distro and the major version number
      os <- sub("^([a-z]+) .* ([0-9]+).*$", "\\1\\2", system_release)
      if (os %in% supported_os) {
        return(sprintf(rspm_template, os))
      }
    }

    return(NULL)
  }

  options(
    Ncpus = parallel::detectCores(),
    repos = c(tryCatch(.pick_cran(), error = function(e) NULL), "https://cloud.r-project.org"),
    HTTPUserAgent = sprintf(
      "R/%s R (%s)",
      getRversion(),
      paste(getRversion(), R.version$platform, R.version$arch, R.version$os)
    )
  )

  # there's a bug in 3.5 that will warn/error on these, so only set it around that
  if (getRversion() >= "3.6.0" || getRversion() < "3.5.0") {
    options(
      warnPartialMatchAttr = TRUE,
      warnPartialMatchDollar = TRUE,
      warnPartialMatchArgs = TRUE
    )
  }
})