Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add build_manual and build_vignettes to install functions
Fixes #353
  • Loading branch information
jimhester committed Jun 6, 2019
1 parent 26c603e commit 7774189
Show file tree
Hide file tree
Showing 30 changed files with 394 additions and 50 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Expand Up @@ -9,6 +9,9 @@
* Fix bug in internal `parse_deps()` where test of valid comparison operators
failed due to trailing whitespaces in DESCRIPTION fields (@LiNk-NY, #366)

* `install_*()` functions gain `build_manual` and `build_vignette` arguments
that previously existed in devtools versions < 2.0 (#353).

# remotes 2.0.4

* `update.package_dependencies()` now uses the pkg_type for the cran remote
Expand Down
10 changes: 10 additions & 0 deletions R/deps.R
Expand Up @@ -243,6 +243,7 @@ update.package_deps <- function(object,
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"),
...) {
Expand All @@ -267,6 +268,8 @@ update.package_deps <- function(object,
quiet = quiet,
build = build,
build_opts = build_opts,
build_manual = build_manual,
build_vignettes = build_vignettes,
repos = repos,
type = type,
...)
Expand All @@ -287,6 +290,8 @@ update.package_deps <- function(object,
quiet = quiet,
build = build,
build_opts = build_opts,
build_manual = build_manual,
build_vignettes = build_vignettes,
repos = repos,
type = type,
...)
Expand All @@ -308,6 +313,8 @@ update.package_deps <- function(object,
quiet = quiet,
build = build,
build_opts = build_opts,
build_manual = build_manual,
build_vignettes = build_vignettes,
repos = repos,
type = type,
...)
Expand Down Expand Up @@ -425,6 +432,7 @@ update_packages <- function(packages = TRUE,
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"),
...) {
Expand All @@ -440,6 +448,8 @@ update_packages <- function(packages = TRUE,
quiet = quiet,
build = build,
build_opts = build_opts,
build_manual = build_manual,
build_vignettes = build_vignettes,
repos = repos,
type = type,
...)
Expand Down
3 changes: 3 additions & 0 deletions R/install-bioc.R
Expand Up @@ -35,6 +35,7 @@ install_bioc <- function(repo, mirror = getOption("BioC_git", download_url("git.
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"),
...) {
Expand All @@ -48,6 +49,8 @@ install_bioc <- function(repo, mirror = getOption("BioC_git", download_url("git.
quiet = quiet,
build = build,
build_opts = build_opts,
build_manual = build_manual,
build_vignettes = build_vignettes,
repos = repos,
type = type,
...)
Expand Down
3 changes: 3 additions & 0 deletions R/install-bitbucket.R
Expand Up @@ -54,6 +54,7 @@ install_bitbucket <- function(repo, ref = "master", subdir = NULL,
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"),
...) {
Expand All @@ -68,6 +69,8 @@ install_bitbucket <- function(repo, ref = "master", subdir = NULL,
quiet = quiet,
build = build,
build_opts = build_opts,
build_manual = build_manual,
build_vignettes = build_vignettes,
repos = repos,
type = type,
...)
Expand Down
3 changes: 3 additions & 0 deletions R/install-cran.R
Expand Up @@ -19,6 +19,7 @@ install_cran <- function(pkgs, repos = getOption("repos"), type = getOption("pkg
force = FALSE,
quiet = FALSE,
build = TRUE, build_opts = c("--no-resave-data", "--no-manual", "--no-build-vignettes"),
build_manual = FALSE, build_vignettes = FALSE,
...) {

remotes <- lapply(pkgs, cran_remote, repos = repos, type = type)
Expand All @@ -30,6 +31,8 @@ install_cran <- function(pkgs, repos = getOption("repos"), type = getOption("pkg
quiet = quiet,
build = build,
build_opts = build_opts,
build_manual = build_manual,
build_vignettes = build_vignettes,
repos = repos,
type = type,
...)
Expand Down
3 changes: 3 additions & 0 deletions R/install-git.R
Expand Up @@ -33,6 +33,7 @@ install_git <- function(url, subdir = NULL, ref = NULL, branch = NULL,
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"),
...) {
Expand All @@ -52,6 +53,8 @@ install_git <- function(url, subdir = NULL, ref = NULL, branch = NULL,
quiet = quiet,
build = build,
build_opts = build_opts,
build_manual = build_manual,
build_vignettes = build_vignettes,
repos = repos,
type = type,
...)
Expand Down
3 changes: 3 additions & 0 deletions R/install-github.R
Expand Up @@ -53,6 +53,7 @@ install_github <- function(repo,
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"),
...) {
Expand All @@ -67,6 +68,8 @@ install_github <- function(repo,
quiet = quiet,
build = build,
build_opts = build_opts,
build_manual = build_manual,
build_vignettes = build_vignettes,
repos = repos,
type = type,
...)
Expand Down
3 changes: 3 additions & 0 deletions R/install-gitlab.R
Expand Up @@ -30,6 +30,7 @@ install_gitlab <- function(repo,
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"),
...) {
Expand All @@ -43,6 +44,8 @@ install_gitlab <- function(repo,
quiet = quiet,
build = build,
build_opts = build_opts,
build_manual = build_manual,
build_vignettes = build_vignettes,
repos = repos,
type = type,
...)
Expand Down
3 changes: 3 additions & 0 deletions R/install-local.R
Expand Up @@ -25,6 +25,7 @@ install_local <- function(path = ".", subdir = NULL,
quiet = FALSE,
build = !is_binary_pkg(path),
build_opts = c("--no-resave-data", "--no-manual", "--no-build-vignettes"),
build_manual = FALSE, build_vignettes = FALSE,
repos = getOption("repos"),
type = getOption("pkgType"),
...) {
Expand All @@ -37,6 +38,8 @@ install_local <- function(path = ".", subdir = NULL,
quiet = quiet,
build = build,
build_opts = build_opts,
build_manual = build_manual,
build_vignettes = build_vignettes,
repos = repos,
type = type,
...)
Expand Down
4 changes: 4 additions & 0 deletions R/install-remote.R
Expand Up @@ -15,6 +15,8 @@ install_remote <- function(remote,
quiet,
build,
build_opts,
build_manual,
build_vignettes,
repos,
type,
...) {
Expand Down Expand Up @@ -66,6 +68,8 @@ install_remote <- function(remote,
quiet = quiet,
build = build,
build_opts = build_opts,
build_manual = build_manual,
build_vignettes = build_vignettes,
repos = repos,
type = type,
...)
Expand Down
3 changes: 3 additions & 0 deletions R/install-svn.R
Expand Up @@ -30,6 +30,7 @@ install_svn <- function(url, subdir = NULL, args = character(0),
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"),
...) {
Expand All @@ -44,6 +45,8 @@ install_svn <- function(url, subdir = NULL, args = character(0),
quiet = quiet,
build = build,
build_opts = build_opts,
build_manual = build_manual,
build_vignettes = build_vignettes,
repos = repos,
type = type,
...)
Expand Down
3 changes: 3 additions & 0 deletions R/install-url.R
Expand Up @@ -23,6 +23,7 @@ install_url <- function(url, subdir = NULL,
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"),
...) {
Expand All @@ -34,6 +35,8 @@ install_url <- function(url, subdir = NULL,
quiet = quiet,
build = build,
build_opts = build_opts,
build_manual = build_manual,
build_vignettes = build_vignettes,
repos = repos,
type = type,
...)
Expand Down
3 changes: 3 additions & 0 deletions R/install-version.R
Expand Up @@ -25,6 +25,7 @@ install_version <- function(package, version = NULL,
force = FALSE,
quiet = FALSE,
build = FALSE, build_opts = c("--no-resave-data", "--no-manual", "--no-build-vignettes"),
build_manual = FALSE, build_vignettes = FALSE,
repos = getOption("repos"),
type = "source",
...) {
Expand All @@ -37,6 +38,8 @@ install_version <- function(package, version = NULL,
quiet = quiet,
build = build,
build_opts = build_opts,
build_manual = build_manual,
build_vignettes = build_vignettes,
repos = repos,
type = type,
...)
Expand Down
35 changes: 30 additions & 5 deletions R/install.R
@@ -1,5 +1,5 @@
install <- function(pkgdir, dependencies, quiet, build, build_opts, upgrade,
repos, type, ...) {
install <- function(pkgdir, dependencies, quiet, build, build_opts, build_manual, build_vignettes,
upgrade, repos, type, ...) {

warn_for_potential_errors()

Expand All @@ -21,14 +21,16 @@ install <- function(pkgdir, dependencies, quiet, build, build_opts, upgrade,
}

install_deps(pkgdir, dependencies = dependencies, quiet = quiet,
build = build, build_opts = build_opts, upgrade = upgrade, repos = repos, type = type)
build = build, build_opts = build_opts, build_manual = build_manual,
build_vignettes = build_vignettes, upgrade = upgrade, repos = repos,
type = type)

if (isTRUE(build)) {
dir <- tempfile()
dir.create(dir)
on.exit(unlink(dir), add = TRUE)

pkgdir <- safe_build_package(pkgdir, build_opts, dir, quiet)
pkgdir <- safe_build_package(pkgdir, build_opts, build_manual, build_vignettes, dir, quiet)
}

safe_install_packages(
Expand Down Expand Up @@ -74,7 +76,25 @@ safe_install_packages <- function(...) {
)
}

safe_build_package <- function(pkgdir, build_opts, dest_path, quiet, use_pkgbuild = !is_standalone() && pkg_installed("pkgbuild")) {
normalize_build_opts <- function(build_opts, build_manual, build_vignettes) {
if (!isTRUE(build_manual)) {
build_opts <- c(build_opts, "--no-manual")
} else {
build_opts <- setdiff(build_opts, "--no-manual")
}

if (!isTRUE(build_vignettes)) {
build_opts <- c(build_opts, "--no-build-vignettes")
} else {
build_opts <- setdiff(build_opts, "--no-build-vignettes")
}

unique(build_opts)
}

safe_build_package <- function(pkgdir, build_opts, build_manual, build_vignettes, dest_path, quiet, use_pkgbuild = !is_standalone() && pkg_installed("pkgbuild")) {
build_opts <- normalize_build_opts(build_opts, build_manual, build_vignettes)

if (use_pkgbuild) {
vignettes <- TRUE
manual <- FALSE
Expand Down Expand Up @@ -152,6 +172,8 @@ r_error_matches <- function(msg, str) {
#' @param ... additional arguments passed to [utils::install.packages()].
#' @param build If `TRUE` build the package before installing.
#' @param build_opts Options to pass to `R CMD build`, only used when `build`
#' @param build_manual If `FALSE`, don't build PDF manual ('--no-manual').
#' @param build_vignettes If `FALSE`, don't build package vignettes ('--no-build-vignettes').
#' is `TRUE`.
#' @export
#' @examples
Expand All @@ -164,6 +186,7 @@ install_deps <- function(pkgdir = ".", dependencies = NA,
quiet = FALSE,
build = TRUE,
build_opts = c("--no-resave-data", "--no-manual", "--no-build-vignettes"),
build_manual = FALSE, build_vignettes = FALSE,
...) {
packages <- dev_package_deps(
pkgdir,
Expand All @@ -181,6 +204,8 @@ install_deps <- function(pkgdir = ".", dependencies = NA,
upgrade = upgrade,
build = build,
build_opts = build_opts,
build_manual = build_manual,
build_vignettes = build_vignettes,
type = type,
...
)
Expand Down

0 comments on commit 7774189

Please sign in to comment.