diff --git a/R/helpers.R b/R/helpers.R index bd7ac87..ae791a7 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -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