Skip to content

Commit

Permalink
export missing_sysreqs() for debugging purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
Enchufa2 committed Dec 9, 2023
1 parent a3e60a3 commit 7748bc8
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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="[email protected]",
role=c("aut", "cph", "cre"), comment=c(ORCID="0000-0001-6403-5550")),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
export(disable)
export(enable)
export(install_sysreqs)
export(missing_sysreqs)
export(renv_init)
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# rspm devel

- Export `missing_sysreqs()` for debugging purposes.

# rspm 0.5.0

- Move to cran4linux org on GitHub, update URLs.
Expand Down
27 changes: 22 additions & 5 deletions R/manager.R
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -20,22 +20,39 @@ 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
os_install_sysreqs(libs)
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
}

Expand Down
7 changes: 6 additions & 1 deletion man/manager.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7748bc8

Please sign in to comment.