-
Notifications
You must be signed in to change notification settings - Fork 156
Expand file tree
/
Copy pathinstall-url.R
More file actions
87 lines (77 loc) · 2.44 KB
/
install-url.R
File metadata and controls
87 lines (77 loc) · 2.44 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#' Install a package from a url
#'
#' This function is vectorised so you can install multiple packages in
#' a single command.
#'
#' @param url location of package on internet. The url should point to a
#' zip file, a tar file or a bzipped/gzipped tar file.
#' @param subdir subdirectory within url bundle that contains the R package.
#' @param ... Other arguments passed on to [utils::install.packages()].
#' @inheritParams install_github
#' @export
#'
#' @family package installation
#' @examples
#' \dontrun{
#' install_url("https://github.com/hadley/stringr/archive/HEAD.zip")
#' }
install_url <- function(url, subdir = NULL,
dependencies = NA,
upgrade = c("default", "ask", "always", "never"),
force = FALSE,
quiet = FALSE,
build = TRUE, build_opts = c("--no-resave-data", "--no-manual", "--no-build-vignettes"),
build_manual = FALSE, build_vignettes = FALSE,
repos = getOption("repos"),
type = getOption("pkgType"),
...) {
remotes <- lapply(url, url_remote, subdir = subdir)
install_remotes(remotes,
dependencies = dependencies,
upgrade = upgrade,
force = force,
quiet = quiet,
build = build,
build_opts = build_opts,
build_manual = build_manual,
build_vignettes = build_vignettes,
repos = repos,
type = type,
...)
}
url_remote <- function(url, subdir = NULL, ...) {
remote("url",
url = url,
subdir = subdir
)
}
#' @importFrom tools file_ext
#' @export
remote_download.url_remote <- function(x, quiet = FALSE) {
if (!quiet) {
message("Downloading package from url: ", x$url) # nocov
}
ext <- if (grepl("\\.tar\\.gz$", x$url)) "tar.gz" else file_ext(x$url)
bundle <- tempfile(fileext = paste0(".", ext))
download(bundle, x$url)
}
#' @export
remote_metadata.url_remote <- function(x, bundle = NULL, source = NULL, sha = NULL) {
list(
RemoteType = "url",
RemoteUrl = x$url,
RemoteSubdir = x$subdir
)
}
#' @export
remote_package_name.url_remote <- function(remote, ...) {
NA_character_
}
#' @export
remote_sha.url_remote <- function(remote, ...) {
NA_character_
}
#' @export
format.url_remote <- function(x, ...) {
"URL"
}