50 lines
2.3 KiB
R
50 lines
2.3 KiB
R
#' @export
|
|
install_package_system_dependencies <- function(package_name,
|
|
tag,
|
|
platform = platform,
|
|
local_clone_dir,
|
|
deps_verbose = FALSE) {
|
|
cli::cli_alert("{.fun install_package_system_dependencies}: Cloning package {.pkg {package_name[1]}} with tag {.field {tail(tag, 1)}}.")
|
|
|
|
t1 <- Sys.time()
|
|
|
|
local_clone_dir_single <- sprintf("%s/%s_%s", local_clone_dir, package_name[1], tail(tag, 1))
|
|
|
|
if (!dir.exists(local_clone_dir_single)) {
|
|
system2("git", args = c(
|
|
"clone", "-q", sprintf("--branch=%s", tail(tag, 1)),
|
|
sprintf("https://github.com/cran/%s", package_name[1]), local_clone_dir_single
|
|
))
|
|
}
|
|
|
|
if (grepl("alpine", platform)) {
|
|
platform <- "alpine"
|
|
}
|
|
|
|
cli::cli_alert("{.fun install_package_system_dependencies}: Installing R package dependencies for {.pkg {package_name[1]}} with tag {.field {tail(tag, 1)}}.")
|
|
# Sys.setenv(PKG_SYSREQS_PLATFORM = platform)
|
|
Sys.setenv(PKG_SYSREQS = TRUE)
|
|
Sys.setenv(PKG_SYSREQS_VERBOSE = TRUE)
|
|
# FIXME: https://github.com/r-lib/pak/issues/610
|
|
if (grepl("rhel-9", pak::system_r_platform())) {
|
|
Sys.setenv(PKG_SYSREQS_PLATFORM = "redhat-9")
|
|
# otherwise pak::pkg_history() fails with 'error setting certificate verify locations'
|
|
Sys.setenv(CURL_CA_BUNDLE = "/etc/pki/tls/certs/ca-bundle.crt")
|
|
} else if (grepl("rhel-8", pak::system_r_platform())) {
|
|
Sys.setenv(PKG_SYSREQS_PLATFORM = "redhat-8")
|
|
# otherwise pak::pkg_history() fails with 'error setting certificate verify locations'
|
|
Sys.setenv(CURL_CA_BUNDLE = "/etc/pki/tls/certs/ca-bundle.crt")
|
|
}
|
|
if (deps_verbose) {
|
|
pak::local_install_deps(sprintf("%s", local_clone_dir_single))
|
|
} else {
|
|
suppressMessages(pak::local_install_deps(sprintf("%s", local_clone_dir_single)))
|
|
}
|
|
|
|
cli::cli_alert("{.fun install_package_system_dependencies}: Removing temporary clone dir at {.path {local_clone_dir_single}}.")
|
|
|
|
total_build_time <- round(Sys.time() - t1, 2)
|
|
cli::cli_alert("Dependency installation time ({.pkg {package_name[[1]]}}): {.strong {total_build_time} {units(difftime(Sys.time(), t1))}}.")
|
|
|
|
unlink(sprintf("%s", local_clone_dir_single), recursive = TRUE, force = TRUE)
|
|
}
|