-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.R
51 lines (41 loc) · 1.29 KB
/
install.R
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
#!/usr/bin/env Rscript
# Usage R -f install.R
# Tested on ubuntu, centos and rocky
#
# This will not work with opensuse and sle,
# naming inconsistencies across distros is hard
# This is not an R project, so need to manually "activate" renv
source("renv/activate.R")
install.packages("pkgcache")
# Moving on to installing r and system dependencies with renv.lock
# Have R obtain the current platform distro and release
# pak & pkgcache **should** be installed with renv
os <- data.frame(
distribution = pkgcache::current_r_platform_data()$distribution,
release = pkgcache::current_r_platform_data()$release
)
os$release <- round(as.numeric((os$release)))
# Some wrangling to make matching more reliable across distros
ppm_platforms <- pkgcache::ppm_platforms()
# Take the word "linux" out of distribution names
ppm_platforms$distribution <- gsub("linux", "", ppm_platforms$distribution)
ppm_platforms$release <- round(as.numeric((ppm_platforms$release)))
# Match with pak's ppm_platforms
os_table <- merge(
os,
ppm_platforms
)
if (os_table$os == "linux") {
p3m_url <- paste0(
"https://p3m.dev/cran/__linux__/",
os_table$binary_url,
"/latest"
)
} else{
p3m_url <- "https://p3m.dev/cran/latest"
}
renv::lockfile_modify(repos = c(
P3M = p3m_url
)) |>
renv::lockfile_write()
renv::restore()