add codename support for alpine

This commit is contained in:
Patrick Schratz 2024-08-29 00:09:41 +02:00
commit 08611e8132
Signed by: pat-s
GPG key ID: 3C6318841EF78925

View file

@ -2,28 +2,34 @@
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
if (any(grepl("alpine", system2("cat", args = c("/etc/os-release"), stdout = TRUE)))) {
version <- system2("grep",
args = c("'^VERSION_ID=' /etc/os-release | cut -d'=' -f2 | tr -d '\"'"), stdout = TRUE
)
} else if (grepl("rhel|fedora", dist_fam)) {
platform_id <- system2("grep",
args = c("'^PLATFORM_ID=' /etc/os-release | cut -d'=' -f2 | tr -d '\"'"), stdout = TRUE
version_stripped <- substr(gsub("\\.", "", version), 1, 3)
codename <- paste0("alpine", version_stripped)
} else {
dist_fam <- system2("grep",
args = c("'^ID_LIKE=' /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"
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|fedora", 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)
}
return(codename)
}
#' Helper function to set the path for binary package outputs