Skip to content

Commit

Permalink
Add sysreqs_fix_installed()
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi committed Jun 26, 2023
1 parent 141068f commit cde6d23
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions R/sysreqs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 23 additions & 1 deletion R/sysreqsdocs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#'
Expand All @@ -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"
Expand All @@ -158,6 +176,10 @@ sysreqs_db_update

sysreqs_check_installed

#' @export

sysreqs_fix_installed <- sysreqs_fix_installed

#' List installed system packages
#'
#' @usage
Expand Down
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ reference:
contents:
- pkg_sysreqs
- sysreqs_check_installed
- sysreqs_fix_installed
- sysreqs_db_list
- sysreqs_db_match
- sysreqs_db_update
Expand Down
7 changes: 5 additions & 2 deletions man/chunks/sysreqs.Rmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
output:
github_document:
always_allow_html: yes
always_allow_html: yes
---

```{r, setup, include = FALSE, cache = FALSE}
Expand Down Expand Up @@ -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}
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion man/chunks/sysreqs.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ pak::sysreqs_list_system_packages()

</div>

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:

Expand Down Expand Up @@ -463,6 +463,9 @@ pak::sysreqs_check_installed()

</div>

`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
Expand Down
4 changes: 0 additions & 4 deletions man/pkg_name_check.Rd

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

6 changes: 5 additions & 1 deletion man/sysreqs.Rd

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

21 changes: 19 additions & 2 deletions man/sysreqs_check_installed.Rd

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

0 comments on commit cde6d23

Please sign in to comment.