move to R package
This commit is contained in:
parent
96facfaf5a
commit
5e32452d09
1 changed files with 257 additions and 0 deletions
42
R/helpers.R
Normal file
42
R/helpers.R
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
set_codename <- function(codename) {
|
||||
if (is.null(codename)) {
|
||||
if (Sys.info()["sysname"] == "Linux") {
|
||||
dist_fam <- system2("grep",
|
||||
args = c("'^ID_LIKE=' /etc/os-release | cut -d'=' -f2 | tr -d '\"'"), stdout = TRUE
|
||||
)
|
||||
if (dist_fam == "debian") {
|
||||
codename <- system2("grep",
|
||||
args = c("'^VERSION_CODENAME=' /etc/os-release | cut -d'=' -f2 | tr -d '\"'"), stdout = TRUE
|
||||
)
|
||||
} else if (grepl("rhel", dist_fam)) {
|
||||
platform_id <- system2("grep",
|
||||
args = c("'^PLATFORM_ID=' /etc/os-release | cut -d'=' -f2 | tr -d '\"'"), stdout = TRUE
|
||||
)
|
||||
if (platform_id == "platform:el9") {
|
||||
codename <- "rhel9"
|
||||
} else if (platform_id == "platform:el8") {
|
||||
codename <- "rhel8"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
codename <- "unknown"
|
||||
}
|
||||
}
|
||||
return(codename)
|
||||
}
|
||||
|
||||
set_bin_path <- function(r_version_minor, build_for_minor, local_build_root, codename) {
|
||||
if (is.null(r_version_minor) && !build_for_minor) {
|
||||
path <- sprintf(
|
||||
"%s/__linux__/%s/latest/src/contrib",
|
||||
local_build_root, codename
|
||||
)
|
||||
} else {
|
||||
path <- sprintf(
|
||||
"%s/__linux__/%s/%s/latest/src/contrib",
|
||||
local_build_root, codename, r_version_minor
|
||||
)
|
||||
}
|
||||
|
||||
return(path)
|
||||
}
|
||||
Loading…
Reference in a new issue