diff --git a/DESCRIPTION b/DESCRIPTION index eb2cd104c..3c7cbe686 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -38,7 +38,7 @@ Suggests: jsonlite (>= 1.8.0), pkgbuild (>= 1.4.1.9000), pkgcache (>= 2.0.4), - pkgdepends (>= 0.4.0), + pkgdepends (>= 0.5.0.9001), pkgsearch (>= 3.1.0), prettyunits, processx (>= 3.8.1), diff --git a/NAMESPACE b/NAMESPACE index 69c2218e1..f904762ba 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -63,6 +63,7 @@ export(sysreqs_check_installed) export(sysreqs_db_list) export(sysreqs_db_match) export(sysreqs_db_update) +export(sysreqs_fix_installed) export(sysreqs_is_supported) export(sysreqs_list_system_packages) export(sysreqs_platforms) diff --git a/R/sysreqs.R b/R/sysreqs.R index 75aacf859..0cb0d198c 100644 --- a/R/sysreqs.R +++ b/R/sysreqs.R @@ -53,6 +53,18 @@ sysreqs_check_installed <- function(packages = NULL, ) } +sysreqs_fix_installed <- function(packages = NULL, + library = .libPaths()[1]) { + load_extra("pillar") + remote( + function(...) { + ret <- pkgdepends::sysreqs_fix_installed(...) + asNamespace("pak")$pak_preformat(ret) + }, + list(packages = packages, library = library) + ) +} + #' Calculate system requirements of one of more packages #' #' @inheritParams pkg_install diff --git a/R/sysreqsdocs.R b/R/sysreqsdocs.R index 430f928d5..a01680c7a 100644 --- a/R/sysreqsdocs.R +++ b/R/sysreqsdocs.R @@ -131,9 +131,16 @@ sysreqs_db_update #' #' @usage #' sysreqs_check_installed(packages = NULL, library = .libPaths()[1]) +#' sysreqs_fix_installed(packages = NULL, library = .libPaths()[1]) +#' +#' @description +#' `sysreqs_check_installed()` checks if the system requirements of all +#' packages (or a subset of packages) are installed. +#' +#' `sysreqs_fix_installed()` installs the missing system packages. #' #' @details -#' This function uses the `sysreqs_platform` configuration option, +#' These functions use the `sysreqs_platform` configuration option, #' see \eval{man_config_link("Configuration")}. Set this if #' `r pak_or_pkgdepends()` does not detect your platform correctly. #' @@ -148,8 +155,19 @@ sysreqs_db_update #' installed. #' * `packages`: list column of character vectors. The names of the #' installed R packages that need this system package. +#' * `pre_install`: list column of character vectors. Commands to run +#' before the installation of the the system package. +#' * `post_install`: list column of character vectors. Commands to run +#' after the installation of the system package. +#' +#' The data frame also have two attributes with additional data: +#' * `sysreqs_records`: the raw system requirements records, and +#' * `system_packages`: the list of the installed system packages. +#' +#' `sysreqs_fix_packages()` returns the same value, but invisibly. #' #' @name sysreqs_check_installed +#' @aliases sysreqs_fix_installed #' @export #' @family system requirements functions #' @examplesIf Sys.getenv("IN_PKGDOWN") == "true" && Sys.info()[["sysname"]] == "Linux" @@ -158,6 +176,10 @@ sysreqs_db_update sysreqs_check_installed +#' @export + +sysreqs_fix_installed <- sysreqs_fix_installed + #' List installed system packages #' #' @usage diff --git a/_pkgdown.yml b/_pkgdown.yml index e455b0e0f..b8a60d379 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -75,6 +75,7 @@ reference: contents: - pkg_sysreqs - sysreqs_check_installed + - sysreqs_fix_installed - sysreqs_db_list - sysreqs_db_match - sysreqs_db_update diff --git a/man/chunks/sysreqs.Rmd b/man/chunks/sysreqs.Rmd index 6a20f92e3..553e8f4c7 100644 --- a/man/chunks/sysreqs.Rmd +++ b/man/chunks/sysreqs.Rmd @@ -1,7 +1,7 @@ --- output: github_document: -always_allow_html: yes + always_allow_html: yes --- ```{r, setup, include = FALSE, cache = FALSE} @@ -172,7 +172,7 @@ installed system packages and capabilities: pak::sysreqs_list_system_packages() ``` -Finally, `sysreqs_check_installed()` is a handy function that checks if all +`sysreqs_check_installed()` is a handy function that checks if all system requirements are installed for some or all R packages that are installed in your library: ```{asciicast check-installed-setup, include = FALSE} @@ -183,6 +183,9 @@ installed in your library: pak::sysreqs_check_installed() ``` +`sysreqs_fix_installed()` goes one step further and also tries to install +the missing system requirements. + # Build-time and run-time dependencies The system requirements database that pak uses does not currently diff --git a/man/chunks/sysreqs.md b/man/chunks/sysreqs.md index e5cbb9d14..83a471916 100644 --- a/man/chunks/sysreqs.md +++ b/man/chunks/sysreqs.md @@ -425,7 +425,7 @@ pak::sysreqs_list_system_packages() -Finally, `sysreqs_check_installed()` is a handy function that checks if +`sysreqs_check_installed()` is a handy function that checks if all system requirements are installed for some or all R packages that are installed in your library: @@ -463,6 +463,9 @@ pak::sysreqs_check_installed() +`sysreqs_fix_installed()` goes one step further and also tries to install +the missing system requirements. + # Build-time and run-time dependencies The system requirements database that pak uses does not currently diff --git a/man/pkg_name_check.Rd b/man/pkg_name_check.Rd index c77ac4837..07db18810 100644 --- a/man/pkg_name_check.Rd +++ b/man/pkg_name_check.Rd @@ -13,7 +13,6 @@ pkg_name_check(name, dictionaries = NULL) Available dictionaries: * \code{wikipedia} * \code{wiktionary}, -* \code{acromine} (\url{http://www.nactem.ac.uk/software/acromine/}), * \code{sentiment} (\url{https://github.com/fnielsen/afinn}), * \code{urban} (Urban Dictionary). If \code{NULL} (by default), the Urban Dictionary is omitted, as it @@ -82,9 +81,6 @@ See the \code{dictionaries} argument. #> Wiktionary ──────────────────────────────────────────────────────────┐ #> sicily No English definition found #> └──────────────────────────────────────────────────────────────────── ┘ -#> Acroynms (from Acromine) ────────────────────────────────────────────┐ -#> No acronyms found. -#> └──────────────────────────────────────────────────────────────────────┘ #> ┌──────────────────────────────────────────────────────────────────────┐ #> Sentiment: 😐 (0) #> └──────────────────────────────────────────────────────────────────────┘ diff --git a/man/sysreqs.Rd b/man/sysreqs.Rd index df9c530ab..51cee7586 100644 --- a/man/sysreqs.Rd +++ b/man/sysreqs.Rd @@ -454,7 +454,7 @@ installed system packages and capabilities: }} -Finally, \code{sysreqs_check_installed()} is a handy function that checks if +\code{sysreqs_check_installed()} is a handy function that checks if all system requirements are installed for some or all R packages that are installed in your library: @@ -492,6 +492,10 @@ are installed in your library: \if{html}{\out{ }} + + +\code{sysreqs_fix_installed()} goes one step further and also tries to install +the missing system requirements. } \section{Build-time and run-time dependencies}{ diff --git a/man/sysreqs_check_installed.Rd b/man/sysreqs_check_installed.Rd index 482490cf7..d229dcac1 100644 --- a/man/sysreqs_check_installed.Rd +++ b/man/sysreqs_check_installed.Rd @@ -2,9 +2,11 @@ % Please edit documentation in R/sysreqsdocs.R \name{sysreqs_check_installed} \alias{sysreqs_check_installed} +\alias{sysreqs_fix_installed} \title{Check if installed packages have all their system requirements} \usage{ sysreqs_check_installed(packages = NULL, library = .libPaths()[1]) +sysreqs_fix_installed(packages = NULL, library = .libPaths()[1]) } \arguments{ \item{packages}{If not \code{NULL}, then only these packages are checked. @@ -22,13 +24,28 @@ Data frame with a custom print and format method, and a installed. \item \code{packages}: list column of character vectors. The names of the installed R packages that need this system package. +\item \code{pre_install}: list column of character vectors. Commands to run +before the installation of the the system package. +\item \code{post_install}: list column of character vectors. Commands to run +after the installation of the system package. } + +The data frame also have two attributes with additional data: +\itemize{ +\item \code{sysreqs_records}: the raw system requirements records, and +\item \code{system_packages}: the list of the installed system packages. +} + +\code{sysreqs_fix_packages()} returns the same value, but invisibly. } \description{ -Check if installed packages have all their system requirements +\code{sysreqs_check_installed()} checks if the system requirements of all +packages (or a subset of packages) are installed. + +\code{sysreqs_fix_installed()} installs the missing system packages. } \details{ -This function uses the \code{sysreqs_platform} configuration option, +These functions use the \code{sysreqs_platform} configuration option, see \eval{man_config_link("Configuration")}. Set this if pak does not detect your platform correctly. }