84 lines
2.7 KiB
R
84 lines
2.7 KiB
R
#' @export
|
|
set_codename <- function(codename) {
|
|
if (is.null(codename)) {
|
|
if (Sys.info()["sysname"] == "Linux") {
|
|
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
|
|
)
|
|
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 (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"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return(codename)
|
|
} else {
|
|
return(codename)
|
|
}
|
|
}
|
|
|
|
#' Helper function to set the path for binary package outputs
|
|
#' @export
|
|
set_bin_path <- function(
|
|
r_minor_version, build_for_minor,
|
|
local_build_root, codename) {
|
|
|
|
local_arch = Sys.info()[["machine"]]
|
|
if (grepl("arm64", local_arch) || grepl("aarch64", local_arch)) {
|
|
arch <- "arm64"
|
|
} else if (grepl("amd64", local_arch) || grepl("x86_64", local_arch)) {
|
|
arch <- "amd64"
|
|
}
|
|
|
|
if (!build_for_minor) {
|
|
path <- sprintf(
|
|
"%s/%s/%s/latest/src/contrib",
|
|
local_build_root, arch, codename
|
|
)
|
|
} else {
|
|
path <- sprintf(
|
|
"%s/%s/%s/%s/latest/src/contrib",
|
|
local_build_root, arch, codename, r_minor_version
|
|
)
|
|
}
|
|
return(path)
|
|
}
|
|
|
|
add_column_if_not_exists <- function(db_name, table_name, column_name, column_type) {
|
|
# Connect to the database
|
|
conn <- dbConnect(SQLite(), dbname = db_name)
|
|
|
|
# Get the list of columns in the table
|
|
columns <- dbGetQuery(conn, paste0("PRAGMA table_info(", table_name, ");"))
|
|
|
|
# Check if the column already exists
|
|
column_exists <- any(columns$name == column_name)
|
|
|
|
# Add the column if it doesn't exist
|
|
if (!column_exists) {
|
|
dbExecute(conn, paste0("ALTER TABLE ", table_name, " ADD COLUMN ", column_name, " ", column_type, ";"))
|
|
message(paste("Column '", column_name, "' added to table '", table_name, "'.", sep = ""))
|
|
} else {
|
|
message(paste("Column '", column_name, "' already exists in table '", table_name, "'.", sep = ""))
|
|
}
|
|
|
|
# Disconnect from the database
|
|
dbDisconnect(conn)
|
|
}
|