From 7748bc8b7ae8a634dbb01ce59ae5ee74d172d016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20=C3=9Acar?= Date: Sat, 9 Dec 2023 13:42:07 +0100 Subject: [PATCH] export missing_sysreqs() for debugging purposes --- DESCRIPTION | 2 +- NAMESPACE | 1 + NEWS.md | 4 ++++ R/manager.R | 27 ++++++++++++++++++++++----- man/manager.Rd | 7 ++++++- 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4c8bbf6..ece690a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: rspm Type: Package Title: 'RStudio' Package Manager -Version: 0.5.0 +Version: 0.5.0.1 Authors@R: c( person("IƱaki", "Ucar", email="iucar@fedoraproject.org", role=c("aut", "cph", "cre"), comment=c(ORCID="0000-0001-6403-5550")), diff --git a/NAMESPACE b/NAMESPACE index 895e680..62e74c5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,4 +3,5 @@ export(disable) export(enable) export(install_sysreqs) +export(missing_sysreqs) export(renv_init) diff --git a/NEWS.md b/NEWS.md index aa68622..cc1d71b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# rspm devel + +- Export `missing_sysreqs()` for debugging purposes. + # rspm 0.5.0 - Move to cran4linux org on GitHub, update URLs. diff --git a/R/manager.R b/R/manager.R index 7a87c9b..327a516 100644 --- a/R/manager.R +++ b/R/manager.R @@ -4,7 +4,7 @@ #' automatically called when the package is enabled via \code{\link{enable}}. #' It can also be called manually at any time to update the system requirements. #' -#' @return No return value, called for side effects. +#' @return \code{install_sysreqs}: No return value, called for side effects. #' #' @examples #' \dontrun{ @@ -20,7 +20,7 @@ install_sysreqs <- function() { message("Inspecting installed packages...") # get missing libraries - if (!length(libs <- ldd_missing())) + if (!length(libs <- unique(unlist(missing_sysreqs())))) return(invisible()) # install sysreqs and update rpath @@ -28,14 +28,31 @@ install_sysreqs <- function() { if (!root()) set_rpath() } -ldd_missing <- function(lib.loc = NULL) { +#' @return \code{missing_sysreqs}: A list of missing libraries, for debugging. +#' @name manager +#' @export +missing_sysreqs <- function() { + libs <- ldd() + lib.loc <- attr(libs, "lib.loc") + + libs <- lapply(libs, function(x) grep("not found$", x, value=TRUE)) + libs <- lapply(libs, function(x) sapply(strsplit(x, " => "), "[", 1)) + + attr(libs, "lib.loc") <- lib.loc + libs +} + +ldd <- function(lib.loc = NULL) { lib.loc <- user_lib(lib.loc) ldd <- check_requirements("ldd") libs <- list.files(lib.loc, "\\.so$", full.names=TRUE, recursive=TRUE) libs <- system_(ldd, p(libs), "2>&1") - libs <- grep("not found$", libs, value=TRUE) - libs <- sapply(strsplit(trimws(libs), " => "), "[", 1) + libs <- split(libs, findInterval(seq_along(libs), grep(":$", libs))) + names(libs) <- gsub(paste0(lib.loc, "/|:"), "", sapply(libs, "[", 1)) + libs <- lapply(lapply(libs, "[", -1), trimws) + + attr(libs, "lib.loc") <- lib.loc libs } diff --git a/man/manager.Rd b/man/manager.Rd index d799b55..046d74d 100644 --- a/man/manager.Rd +++ b/man/manager.Rd @@ -3,12 +3,17 @@ \name{manager} \alias{manager} \alias{install_sysreqs} +\alias{missing_sysreqs} \title{Manage System Requirements} \usage{ install_sysreqs() + +missing_sysreqs() } \value{ -No return value, called for side effects. +\code{install_sysreqs}: No return value, called for side effects. + +\code{missing_sysreqs}: A list of missing libraries, for debugging. } \description{ Detect, install and configure system requirements. This function is