-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_sysreqs.R
56 lines (41 loc) · 1.35 KB
/
get_sysreqs.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#' Get system requirements by R package
#'
#' @param packages character vector of packages names
#' @param quiet boolean if TRUE the function is quiet
#' @param batch_n number of simultaneous packages to ask
#'
#' @return character vector of sysreqs
#' @export
#'
#' @importFrom remotes package_deps
get_sysreqs <- function(packages, quiet = TRUE, batch_n = 30) {
all_deps <- sort(unique(c(packages, unlist(remotes::package_deps(packages)$package))))
sp <- split(all_deps, ceiling(seq_along(all_deps)/batch_n))
hold <- lapply(sp, function(.x) {
get_batch_sysreqs(.x, quiet = quiet)
}) %>%
unlist() %>%
unname() %>%
unique() %>%
sort()
setdiff(hold, sysreqs_in_base)
}
#' @keywords internal
#' @noRd
#' @importFrom fs file_temp file_delete
#' @importFrom jsonlite fromJSON
#' @importFrom utils download.file
get_batch_sysreqs <- function(all_deps, quiet = TRUE) {
url <- sprintf("https://sysreqs.r-hub.io/pkg/%s/linux-x86_64-debian-gcc",
paste(all_deps, collapse = ","))
path <- fs::file_temp()
utils::download.file(url, path, mode = "wb", quiet = quiet)
out <- jsonlite::fromJSON(path)
fs::file_delete(path)
unique(out[!is.na(out)])
}
sysreqs_in_base <- c("gdebi-core",
"git-core",
"libcurl4-gnutls-dev",
"wget")
# get_sysreqs("inst/testapp")