tryCatch error in pkgbuild::build
This commit is contained in:
parent
830390dc31
commit
b4ff36dfa8
1 changed files with 30 additions and 12 deletions
|
|
@ -69,7 +69,7 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL,
|
|||
},
|
||||
# NB: here we need to use conditionMessage() to extract the actual error - as opposed to using $stderr for errors within the tryCatch used in the future* calls
|
||||
error = function(e) {
|
||||
message(sprintf("Error in installing dependencies for package %s with tag %s: %s", package_name[1], tag[1], e))
|
||||
cli::cli_alert_warning("Error in installing dependencies for package {.pkg {package_name{1]}} with tag {.field {tag[1]}}: {e}")
|
||||
store_build_metadata(package_name[1], tag[1], platform, error_occurred = TRUE, force = TRUE, error = conditionMessage(e))
|
||||
return(TRUE)
|
||||
}
|
||||
|
|
@ -101,7 +101,7 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL,
|
|||
dbDisconnect(con)
|
||||
},
|
||||
error = function(e) {
|
||||
message(sprintf("Error in processing package %s with tag %s: %s", x, y, e))
|
||||
cli::cli_alert_warning("Error in starting build command for package {.pkg {package_name}} with tag {.field {tag}}: {e}")
|
||||
local_clone_dir_single <- sprintf("%s/%s_%s", local_clone_dir, x, y)
|
||||
unlink(local_clone_dir_single, force = TRUE, recursive = TRUE)
|
||||
# only stderr contains the important information why the build failed
|
||||
|
|
@ -159,15 +159,26 @@ build_single_tag <- function(
|
|||
cli::cli_alert("{.fun build_single_tag}: (2/3) Building package {.pkg {package_name}} with tag {.field {tag}}.")
|
||||
|
||||
t1 <- Sys.time()
|
||||
dump <- pkgbuild::build(
|
||||
path = sprintf("%s", local_clone_dir_single),
|
||||
binary = TRUE, vignettes = FALSE,
|
||||
dest_path = dir_out_bin, quiet = TRUE
|
||||
tryCatch(
|
||||
{
|
||||
dump <- pkgbuild::build(
|
||||
path = sprintf("%s", local_clone_dir_single),
|
||||
binary = TRUE, vignettes = FALSE,
|
||||
dest_path = dir_out_bin, quiet = TRUE
|
||||
)
|
||||
},
|
||||
error = function(e) {
|
||||
cli::cli_alert_warning("Error in starting build command for package {.pkg {package_name}} with tag {.field {tag}}: {e}")
|
||||
local_clone_dir_single <- sprintf("%s/%s_%s", local_clone_dir, package_name, tag)
|
||||
unlink(local_clone_dir_single, force = TRUE, recursive = TRUE)
|
||||
store_build_metadata(package_name, tag, platform, error_occurred = TRUE, force = TRUE, error = "Error trying to initiate pkgbuild - likely a non-valid R package structure")
|
||||
return(invisible(TRUE))
|
||||
}
|
||||
)
|
||||
|
||||
if (!file.exists(sprintf("%s/%s_%s.tar.gz", dir_out_bin, package_name, tag))) {
|
||||
if (debug) {
|
||||
cli::cli_alert_info('{.fun build_single_tag}: Moving package from {.path {sprintf("%s/%s_%s_R_aarch64-unknown-linux-gnu.tar.gz", dir_out_bin, package_name, tag))}} to {.path {sprintf("%s/%s_%s.tar.gz", dir_out_bin, package_name, tag)}}')
|
||||
cli::cli_alert_info('{.fun build_single_tag}: Moving package from {.path {sprintf("%s/%s_%s_R_aarch64-unknown-linux-gnu.tar.gz", dir_out_bin, package_name, tag)}} to {.path {sprintf("%s/%s_%s.tar.gz", dir_out_bin, package_name, tag)}}')
|
||||
}
|
||||
# double-check that file exists (some packages like https://github.com/cran/BACCO/tree/1.0-14 don't include R/ and hence don't procude a valid binary)
|
||||
if (fs::file_exists(sprintf("%s/%s_%s_R_aarch64-unknown-linux-gnu.tar.gz", dir_out_bin, package_name, tag))) {
|
||||
|
|
@ -177,7 +188,7 @@ build_single_tag <- function(
|
|||
sprintf("%s/%s_%s.tar.gz", dir_out_bin, package_name, tag)
|
||||
)
|
||||
} else {
|
||||
cli::cli_alert_info('{.fun build_single_tag}: File for package {.pkg {package_name}} {.field {tag}} at {.path {sprintf("%s/%s_%s_R_aarch64-unknown-linux-gnu.tar.gz", dir_out_bin, package_name, tag))}} does not exist - skipping.')
|
||||
cli::cli_alert_info('{.fun build_single_tag}: File for package {.pkg {package_name}} {.field {tag}} at {.path {sprintf("%s/%s_%s_R_aarch64-unknown-linux-gnu.tar.gz", dir_out_bin, package_name, tag)}} does not exist - skipping.')
|
||||
}
|
||||
} else {
|
||||
cli::cli_alert_warning('{.fun build_single_tag}: Binary {sprintf("%s_%s.tar.gz", package_name, tag)} already exists. Skipping copy.')
|
||||
|
|
|
|||
Loading…
Reference in a new issue