From 7eae0739fe56ea716a53258342897f6bbf6657ac Mon Sep 17 00:00:00 2001 From: Alex Chubaty Date: Tue, 5 Apr 2016 09:52:37 -0600 Subject: [PATCH 01/21] addPackage() now accepts 'type' vector (closes #24) * `addPackage()`, `makeRepo()`, and `updatePackages()` will accept `type` argument specified as a character vector * updated examples * updated vignettes (@andrie note I changed the vignette engine to `rmarkdown::render` in order to satisfy R CMD Check) --- DESCRIPTION | 8 +- NEWS | 6 ++ R/addPackages.R | 51 +++++----- R/makeRepo.R | 50 +++++---- R/updatePackages.R | 128 ++++++++++++------------ inst/examples/example_checkVersions.R | 11 +- vignettes/miniCRAN-dependency-graph.rmd | 2 +- vignettes/miniCRAN-introduction.rmd | 10 +- vignettes/miniCRAN-non-CRAN-repos.rmd | 4 +- 9 files changed, 144 insertions(+), 126 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index a0db7d9..0017d72 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,13 +11,13 @@ Description: Makes it possible to create an internally consistent repository consisting of selected packages from CRAN-like repositories. The user specifies a set of desired packages, and miniCRAN recursively reads the dependency tree for these packages, then downloads only this - subset. The user can then install packages from this repository directly, - rather than from CRAN. This is useful in production settings, e.g. server + subset. The user can then install packages from this repository directly, + rather than from CRAN. This is useful in production settings, e.g. server behind a firewall, or remote locations with slow broadband access. -Version: 0.2.4 +Version: 0.2.4.9000 URL: https://github.com/RevolutionAnalytics/miniCRAN BugReports: https://github.com/RevolutionAnalytics/miniCRAN/issues -Date: 2015-03-26 +Date: 2015-04-05 Imports: tools, XML, diff --git a/NEWS b/NEWS index 811e750..b78e444 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +miniCRAN v0.2.4.9000 +==================== + +Changes: +* `addPackage()`, `makeRepo()`, and `updatePackages()` now accept a `type` argument specified as a vector (#24) + miniCRAN v0.2-2 (Release date: 2015-03-25) ============== diff --git a/R/addPackages.R b/R/addPackages.R index 68aebf2..89d3613 100644 --- a/R/addPackages.R +++ b/R/addPackages.R @@ -50,7 +50,7 @@ checkVersions <- function(pkgs=NULL, path=NULL, type="source", #' #' @param deps logical indicating whether the package dependencies should be added (default \code{TRUE}). #' -#' @return Installs the packages, rebuilds the package index, and invisibly returns the number of packages writen to the index files. +#' @return Installs the packages, rebuilds the package index, and invisibly returns the number of packages written to the index files. #' #' @importFrom tools write_PACKAGES #' @export @@ -62,27 +62,32 @@ addPackage <- function(pkgs=NULL, path=NULL, repos=getOption("repos"), type="source", Rversion=R.version, writePACKAGES=TRUE, deps=TRUE, quiet=FALSE) { if (is.null(path) || is.null(pkgs)) stop("path and pkgs must both be specified.") - prev <- checkVersions(pkgs=pkgs, path=path, type=type, Rversion=Rversion) - prev.df <- getPkgVersFromFile(prev) - if (deps) pkgs <- pkgDep(pkgs, repos=repos, type=type) + lapply(type, function(type) { + prev <- checkVersions(pkgs=pkgs, path=path, type=type, Rversion=Rversion) + prev.df <- getPkgVersFromFile(prev) - makeRepo(pkgs=pkgs, path=path, repos=repos, type=type, Rversion=Rversion, - download=TRUE, writePACKAGES=FALSE, quiet=quiet) + if (deps) pkgs <- pkgDep(pkgs, repos=repos, type=type) - if (length(prev)) { - curr <- suppressWarnings( - checkVersions(pkgs=pkgs, path=path, type=type, Rversion=Rversion) - ) - curr.df <- getPkgVersFromFile(curr) + makeRepo(pkgs=pkgs, path=path, repos=repos, type=type, Rversion=Rversion, + download=TRUE, writePACKAGES=FALSE, quiet=quiet) - dupes <- with(curr.df, package[duplicated(package)]) - if (length(dupes)) { - old <- lapply(dupes, function(x) { grep(paste0("^", x), basename(prev)) } ) - file.remove(prev[unlist(old)]) + if (length(prev)) { + curr <- suppressWarnings( + checkVersions(pkgs=pkgs, path=path, type=type, Rversion=Rversion) + ) + curr.df <- getPkgVersFromFile(curr) + + dupes <- with(curr.df, package[duplicated(package)]) + if (length(dupes)) { + old <- lapply(dupes, function(x) { grep(paste0("^", x), basename(prev)) } ) + file.remove(prev[unlist(old)]) + } } - } - if (writePACKAGES) invisible(updateRepoIndex(path=path, type=type, Rversion=Rversion)) + }) + + n <- if (writePACKAGES) updateRepoIndex(path=path, type=type, Rversion=Rversion) + return(invisible(n)) } @@ -99,7 +104,7 @@ addPackage <- function(pkgs=NULL, path=NULL, repos=getOption("repos"), #' #' @param vers The package version to install. #' -#' @return Installs the packages, rebuilds the package index, and invisibly returns the number of packages writen to the index files. +#' @return Adds the packages, rebuilds the package index, and invisibly returns the number of packages written to the index files. #' #' @note Dependencies for old package versions cannot be determined automatically and must be specified by the user in \code{pkgs} and \code{vers}. Thus, \code{deps=FALSE} is the default for this function. #' @@ -119,8 +124,8 @@ addOldPackage <- function(pkgs=NULL, path=NULL, vers=NULL, if (type!="source") stop("Older binary versions are not normally available on CRAN. ", "You must build the binary versions from source.") if(deps) { - message("Unable to automatically determine dependency version information.") - message("Use pkgs and vers to identify which dependecies and their versions to download.") + message("Unable to automatically determine dependency version information.\n", + "Use pkgs and vers to identify which dependecies and their versions to download.") } vers <- as.character(vers) oldPkgs <- file.path(repos, repoPrefix(type, R.version), "Archive", @@ -129,10 +134,8 @@ addOldPackage <- function(pkgs=NULL, path=NULL, vers=NULL, pkgPath <- repoBinPath(path=path, type=type, Rversion=Rversion) if(!file.exists(pkgPath)) dir.create(pkgPath, recursive=TRUE) sapply(oldPkgs, function(x) { - result <- download.file(x, destfile=file.path(pkgPath, basename(x)), - method="auto", - mode="wb", - quiet=quiet) + result <- utils::download.file(x, destfile=file.path(pkgPath, basename(x)), + method="auto", mode="wb", quiet=quiet) if(result!=0) warning("error downloading file ", x) }) if (writePACKAGES) invisible(updateRepoIndex(path=path, type=type, Rversion)) diff --git a/R/makeRepo.R b/R/makeRepo.R index 6cb57c0..d95c8a8 100644 --- a/R/makeRepo.R +++ b/R/makeRepo.R @@ -36,41 +36,47 @@ #' @note Internally makes use of \code{\link[utils]{download.packages}} and \code{\link{write_PACKAGES}} #' #' @inheritParams pkgDep -#' +#' #' @param pkgs Character vector of packages to download -#' +#' #' @param path Destination download path. This path is the root folder of your new repository. -#' +#' #' @param Rversion List with two named elements: `major` and `minor`. If not supplied, defaults to system version of R, using \code{\link{R.version}}. Only used if \code{type} is not "source" -#' +#' #' @param download If TRUE downloads packages. -#' +#' #' @param quiet If TRUE, suppress status messages (if any), and the progress bar during download. -#' +#' #' @param writePACKAGES If TRUE, calls \code{\link{write_PACKAGES}} to update the repository PACKAGES file. #' #' @export #' @family update repo functions -#' +#' #' @example /inst/examples/example_makeRepo.R makeRepo <- function(pkgs, path, repos=getOption("repos"), type="source", Rversion=R.version, download=TRUE, writePACKAGES=TRUE, quiet=FALSE) { if(!file.exists(path)) stop("Download path does not exist") - pkgPath <- repoBinPath(path=path, type=type, Rversion=Rversion) - if(!file.exists(pkgPath)) { - result <- dir.create(pkgPath, recursive=TRUE, showWarnings = FALSE) - if(result) { - if(!quiet) message("Created new folder: ", pkgPath) - } else { - stop("Unable to create repo path: ", pkgPath) + + lapply(type, function(type) { + pkgPath <- repoBinPath(path=path, type=type, Rversion=Rversion) + if(!file.exists(pkgPath)) { + result <- dir.create(pkgPath, recursive=TRUE, showWarnings = FALSE) + if(result) { + if(!quiet) message("Created new folder: ", pkgPath) + } else { + stop("Unable to create repo path: ", pkgPath) + } + } + + pdb <- pkgAvail(repos = repos, type=type, Rversion = Rversion) + + if(download) { + utils::download.packages(pkgs, destdir=pkgPath, available=pdb, repos=repos, + contriburl = contribUrl(repos, type, Rversion), + type=type, quiet=quiet) } - } - - pdb <- pkgAvail(repos = repos, type=type, Rversion = Rversion) + }) - if(download) utils::download.packages(pkgs, destdir=pkgPath, available=pdb, repos=repos, - contriburl = contribUrl(repos, type, Rversion), - type=type, quiet=quiet) if(writePACKAGES) updateRepoIndex(path=path, type=type, Rversion=Rversion) } @@ -80,11 +86,13 @@ makeRepo <- function(pkgs, path, repos=getOption("repos"), type="source", #' @rdname makeRepo #' @export updateRepoIndex <- function(path, type="source", Rversion=R.version) { - lapply(type, function(type){ + n <- lapply(type, function(type){ pkgPath <- repoBinPath(path=path, type=type, Rversion=Rversion) if(grepl("mac.binary", type)) type <- "mac.binary" tools::write_PACKAGES(dir=pkgPath, type=type) }) + names(n) <- type + return(n) } diff --git a/R/updatePackages.R b/R/updatePackages.R index 06802c1..a8cad35 100644 --- a/R/updatePackages.R +++ b/R/updatePackages.R @@ -5,7 +5,7 @@ #' These functions are based on \code{\link{update.packages}}. However, rather than looking for locally installed packages they look for the package source and binaries in the miniCRAN repository. #' #' @name updatePackages -#' +#' #' @inheritParams makeRepo #' @inheritParams pkgDep #' @@ -22,10 +22,10 @@ #' #' @example /inst/examples/example_updatePackages.R #' -oldPackages <- function (path = NULL, +oldPackages <- function (path = NULL, repos = getOption("repos"), availPkgs = pkgAvail(repos=repos, type=type, Rversion=Rversion), - method, + method, availableLocal = pkgAvail(repos=path, type=type, Rversion=Rversion), type="source", Rversion = R.version) { if (is.null(path)) stop("path to miniCRAN repo must be specified") @@ -35,7 +35,7 @@ oldPackages <- function (path = NULL, } if (NROW(availPkgs) == 0L) stop("Invalid remote repository") if (NROW(availableLocal) == 0L) stop("Invalid local repository") - + idx <- match(availableLocal[, "Package"], availPkgs[, "Package"]) compare <- sapply(seq_along(idx), function(i){ compareVersion( @@ -43,7 +43,7 @@ oldPackages <- function (path = NULL, (availableLocal[i, "Version"]) ) > 0 }) - + update <- cbind( availableLocal[compare, c("Package", "Version"), drop=FALSE], availPkgs[idx[compare], c("Version", "Repository"), drop=FALSE] @@ -66,72 +66,74 @@ oldPackages <- function (path = NULL, #' @export #' updatePackages <- function (path=NULL, repos=getOption("repos"), - method, ask=TRUE, + method, ask=TRUE, availPkgs=pkgAvail(repos=repos, type=type, Rversion=Rversion), oldPkgs=NULL, type="source", Rversion=R.version, quiet=FALSE) { - force(ask) - simplifyRepos <- function(repos, type) { - tail <- substring(contribUrl("---", type=type, Rversion=Rversion), 4) - ind <- regexpr(tail, repos, fixed=TRUE) - ind <- ifelse(ind > 0, ind-1, nchar(repos, type="c")) - substr(repos, 1, ind) - } - text.select <- function(old) { - update <- NULL - for (k in seq_len(nrow(old))) { - cat(old[k, "Package"], ":\n", - "Local Version", old[k, "LocalVer"], "\n", - "Repos Version", old[k, "ReposVer"], - "available at", simplifyRepos(old[k, "Repository"], type)) - cat("\n") - answer <- substr(readline("Update (y/N/c)? "), 1L, 1L) - if (answer == "c" | answer == "C") { - cat("cancelled by user\n") - return(invisible()) + lapply(type, function(type) { + force(ask) + simplifyRepos <- function(repos, type) { + tail <- substring(contribUrl("---", type=type, Rversion=Rversion), 4) + ind <- regexpr(tail, repos, fixed=TRUE) + ind <- ifelse(ind > 0, ind-1, nchar(repos, type="c")) + substr(repos, 1, ind) + } + text.select <- function(old) { + update <- NULL + for (k in seq_len(nrow(old))) { + cat(old[k, "Package"], ":\n", + "Local Version", old[k, "LocalVer"], "\n", + "Repos Version", old[k, "ReposVer"], + "available at", simplifyRepos(old[k, "Repository"], type)) + cat("\n") + answer <- substr(readline("Update (y/N/c)? "), 1L, 1L) + if (answer == "c" | answer == "C") { + cat("cancelled by user\n") + return(invisible()) + } + if (answer == "y" | answer == "Y") update <- rbind(update, old[k, ]) } - if (answer == "y" | answer == "Y") update <- rbind(update, old[k, ]) + update + } + if (is.null(path)) stop("path to miniCRAN repo must be specified") + if (!is.matrix(oldPkgs) && is.character(oldPkgs)) { + subset <- oldPkgs + oldPkgs <- NULL + } else { + subset <- NULL } - update - } - if (is.null(path)) stop("path to miniCRAN repo must be specified") - if (!is.matrix(oldPkgs) && is.character(oldPkgs)) { - subset <- oldPkgs - oldPkgs <- NULL - } else { - subset <- NULL - } - if (is.null(oldPkgs)) { - oldPkgs <- oldPackages(path=path, repos=repos, - method=method, availPkgs=availPkgs, type=type, - Rversion=Rversion) if (is.null(oldPkgs)) { - message("All packages are up to date from repos: ", names(repos)) - return(invisible()) + oldPkgs <- oldPackages(path=path, repos=repos, + method=method, availPkgs=availPkgs, type=type, + Rversion=Rversion) + if (is.null(oldPkgs)) { + message("All packages are up to date from repos: ", names(repos)) + return(invisible()) + } + } else if (!(is.matrix(oldPkgs) && is.character(oldPkgs))) { + stop("invalid 'oldPkgs'; must be a character vector or a result from oldPackages()") } - } else if (!(is.matrix(oldPkgs) && is.character(oldPkgs))) { - stop("invalid 'oldPkgs'; must be a character vector or a result from oldPackages()") - } - if (!is.null(subset)) { - oldPkgs <- oldPkgs[rownames(oldPkgs) %in% subset, , drop = FALSE] - if (nrow(oldPkgs)==0) return(invisible()) - } - update <- if (is.character(ask) && ask == "graphics") { - if (.Platform$OS.type=="windows" || .Platform$GUI == - "AQUA" || (capabilities("tcltk") && capabilities("X11"))) { - k <- select.list(oldPkgs[, 1L], oldPkgs[, 1L], multiple=TRUE, - title="Packages to be updated", graphics = TRUE) - oldPkgs[match(k, oldPkgs[, 1L]), , drop = FALSE] - } else { + if (!is.null(subset)) { + oldPkgs <- oldPkgs[rownames(oldPkgs) %in% subset, , drop = FALSE] + if (nrow(oldPkgs)==0) return(invisible()) + } + update <- if (is.character(ask) && ask == "graphics") { + if (.Platform$OS.type=="windows" || .Platform$GUI == + "AQUA" || (capabilities("tcltk") && capabilities("X11"))) { + k <- select.list(oldPkgs[, 1L], oldPkgs[, 1L], multiple=TRUE, + title="Packages to be updated", graphics = TRUE) + oldPkgs[match(k, oldPkgs[, 1L]), , drop = FALSE] + } else { + text.select(oldPkgs) + } + } else if (isTRUE(ask)) { text.select(oldPkgs) + } else { + oldPkgs } - } else if (isTRUE(ask)) { - text.select(oldPkgs) - } else { - oldPkgs - } - if (length(update[,"Package"])) { - addPackage(update[,"Package"], path=path, repos=repos, type=type, quiet=quiet, deps=FALSE, Rversion=Rversion) - } + if (length(update[,"Package"])) { + addPackage(update[,"Package"], path=path, repos=repos, type=type, quiet=quiet, deps=FALSE, Rversion=Rversion) + } + }) } diff --git a/inst/examples/example_checkVersions.R b/inst/examples/example_checkVersions.R index a02fdfe..5531c06 100644 --- a/inst/examples/example_checkVersions.R +++ b/inst/examples/example_checkVersions.R @@ -3,6 +3,7 @@ # Specify list of packages to download revolution <- c(CRAN="http://cran.revolutionanalytics.com") pkgs <- c("foreach") +pkgTypes <- c("source", "win.binary") pdb <- cranJuly2014 @@ -18,8 +19,7 @@ pkgList dir.create(pth <- file.path(tempdir(), "miniCRAN")) # Make repo for source and win.binary - makeRepo(pkgList, path=pth, repos=revolution, type="source") - makeRepo(pkgList, path=pth, repos=revolution, type="win.binary") + makeRepo(pkgList, path=pth, repos=revolution, type=pkgTypes) # Add other versions of a package (and assume these were added previously) oldVers <- data.frame(package=c("foreach", "codetools", "iterators"), @@ -39,13 +39,12 @@ pkgList file.remove(c(pkgVersionsSrc[1], pkgVersionsBin[1])) # Rebuild package index after adding/removing files - updateRepoIndex(pth, type=c("source", "win.binary"), Rversion=R.version) - + updateRepoIndex(pth, type=pkgTypes, Rversion=R.version) + pkgAvail(pth, type="source") # Add new packages (from CRAN) to the miniCRAN repo - addPackage("Matrix", path=pth, repos=revolution, type="source") - addPackage("Matrix", path=pth, repos=revolution, type="win.binary") + addPackage("Matrix", path=pth, repos=revolution, type=pkgTypes) # Delete temporary folder unlink(pth, recursive=TRUE) diff --git a/vignettes/miniCRAN-dependency-graph.rmd b/vignettes/miniCRAN-dependency-graph.rmd index 2d42cd6..40a1c40 100644 --- a/vignettes/miniCRAN-dependency-graph.rmd +++ b/vignettes/miniCRAN-dependency-graph.rmd @@ -7,7 +7,7 @@ output: self_contained: yes toc: yes vignette: > - %\VignetteEngine{knitr::knitr} + %\VignetteEngine{rmarkdown::render} %\VignetteIndexEntry{Using miniCRAN to identify package dependencies} %\VignettePackage{miniCRAN} %\VignetteKeyword{miniCRAN} diff --git a/vignettes/miniCRAN-introduction.rmd b/vignettes/miniCRAN-introduction.rmd index e41f8b7..e1808b7 100644 --- a/vignettes/miniCRAN-introduction.rmd +++ b/vignettes/miniCRAN-introduction.rmd @@ -7,7 +7,7 @@ output: self_contained: yes toc: yes vignette: > - %\VignetteEngine{knitr::knitr} + %\VignetteEngine{rmarkdown::render} %\VignetteIndexEntry{Using miniCRAN to create and maintain a local CRAN repository} %\VignettePackage{miniCRAN} %\VignetteKeyword{miniCRAN} @@ -41,8 +41,7 @@ Next, create a repository with the function `makeRepo()`. In this example, get dir.create(pth <- file.path(tempdir(), "miniCRAN")) # Make repo for source and win.binary -makeRepo(pkgList, path=pth, repos=revolution, type="source") -makeRepo(pkgList, path=pth, repos=revolution, type="win.binary") +makeRepo(pkgList, path=pth, repos=revolution, type=c("source", "win.binary")) ``` @@ -80,10 +79,11 @@ After creating a local miniCRAN repository, additional packages and their depend ```{r addto-repo-new-1, eval=FALSE} # Add new packages (from CRAN) to the miniCRAN repo -addPackage("Matrix", path=pth, repos=revolution, type="source") +addPackage("Matrix", path=pth, repos=revolution, type=c("source", "win.binary")) +pkgAvail(repos=pth, type="win.binary")[, c(1:3, 5)] ``` -The value that is returned via `addPackage` is the number of packages written to the index file, *i.e.*, the total number of packages in the repo of that type. +The value that is returned (invisibly) via `addPackage` is the number of packages written to the index file, *i.e.*, the total number of packages in the repo of that type. ## Adding an older version of a package from CRAN diff --git a/vignettes/miniCRAN-non-CRAN-repos.rmd b/vignettes/miniCRAN-non-CRAN-repos.rmd index 7837e6f..f82bdf8 100644 --- a/vignettes/miniCRAN-non-CRAN-repos.rmd +++ b/vignettes/miniCRAN-non-CRAN-repos.rmd @@ -7,7 +7,7 @@ output: self_contained: yes toc: yes vignette: > - %\VignetteEngine{knitr::knitr} + %\VignetteEngine{rmarkdown::render} %\VignetteIndexEntry{Using repositories other than CRAN with miniCRAN} %\VignettePackage{miniCRAN} %\VignetteKeyword{miniCRAN} @@ -82,4 +82,4 @@ bioc[grep("BioC", names(bioc))] index(bioc["BioCsoft"]) -``` \ No newline at end of file +``` From d5a3254a7041861c03fecbd1672ef3fb675cbf57 Mon Sep 17 00:00:00 2001 From: Alex Chubaty Date: Tue, 5 Apr 2016 10:17:40 -0600 Subject: [PATCH 02/21] consistent documentation of 'Rversion' (close #42) * Specifying `Rversion` as a character string is the easiest for the user. We can convert to to an `R_system_version` under the hood to make version string comparisons. **Note** that I'm only making the changes to the documentation -- the functions using `Rversion` (namely, `twodigitRversion`) will still work if specified using the other approaches. @andrie I had to update the vignette engine to `rmarkdown::render` in the vignettes to appease R CMD check --- DESCRIPTION | 5 +++-- NAMESPACE | 2 +- NEWS | 6 ++++++ R/addPackages.R | 4 ++-- R/helpers.R | 2 +- R/makeRepo.R | 20 ++++++++++---------- man/addOldPackage.Rd | 10 ++++------ man/addPackage.Rd | 10 ++++------ man/addPackageListingGithub.Rd | 2 +- man/basePkgs.Rd | 6 +++--- man/checkVersions.Rd | 10 ++++------ man/cranJuly2014.Rd | 2 +- man/getCranDescription.Rd | 2 +- man/makeDepGraph.Rd | 6 +++--- man/makeLibrary.Rd | 2 +- man/makeRepo.Rd | 9 ++++----- man/miniCRAN-package.Rd | 6 +++--- man/pkgAvail.Rd | 2 +- man/pkgDep.Rd | 6 +++--- man/pkgDepTools.Rd | 2 +- man/plot.pkgDepGraph.Rd | 6 +++--- man/repoBinPath.Rd | 4 ++-- man/repoPrefix.Rd | 4 ++-- man/twodigitRversion.Rd | 2 +- man/updatePackages.Rd | 10 +++++----- vignettes/miniCRAN-dependency-graph.rmd | 4 ++-- vignettes/miniCRAN-introduction.rmd | 4 ++-- vignettes/miniCRAN-non-CRAN-repos.rmd | 6 +++--- 28 files changed, 77 insertions(+), 77 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index a0db7d9..644afcc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,8 +11,8 @@ Description: Makes it possible to create an internally consistent repository consisting of selected packages from CRAN-like repositories. The user specifies a set of desired packages, and miniCRAN recursively reads the dependency tree for these packages, then downloads only this - subset. The user can then install packages from this repository directly, - rather than from CRAN. This is useful in production settings, e.g. server + subset. The user can then install packages from this repository directly, + rather than from CRAN. This is useful in production settings, e.g. server behind a firewall, or remote locations with slow broadband access. Version: 0.2.4 URL: https://github.com/RevolutionAnalytics/miniCRAN @@ -29,3 +29,4 @@ Suggests: knitr, igraph VignetteBuilder: knitr +RoxygenNote: 5.0.1 diff --git a/NAMESPACE b/NAMESPACE index c40a07b..160b2eb 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,4 +1,4 @@ -# Generated by roxygen2 (4.1.0): do not edit by hand +# Generated by roxygen2: do not edit by hand S3method(plot,pkgDepGraph) S3method(print,pkgDep) diff --git a/NEWS b/NEWS index 811e750..0258f69 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +miniCRAN v0.2.4.9001 +==================== + +Changes: +* make consistent use of Rversion argument (#42) + miniCRAN v0.2-2 (Release date: 2015-03-25) ============== diff --git a/R/addPackages.R b/R/addPackages.R index 68aebf2..6d9f9fb 100644 --- a/R/addPackages.R +++ b/R/addPackages.R @@ -8,7 +8,7 @@ #' #' @param type character, indicating the type of package to download and install. See \code{\link{install.packages}}. #' -#' @param Rversion numeric version of the R system for which to fetch packages. See \code{\link{R_system_version}}. +#' @param Rversion Version of R. Can be specified as a character string with the two digit R version, e.g. "3.1". Defaults to \code{\link{R.version}} #' #' @return Returns invisibly the filepaths to packages with multiple versions for removal. #' @@ -46,7 +46,7 @@ checkVersions <- function(pkgs=NULL, path=NULL, type="source", #' @inheritParams makeRepo #' @inheritParams pkgDep #' -#' @param Rversion numeric version of the R system for which to fetch packages. See \code{\link{R_system_version}}. +#' @param Rversion Version of R. Can be specified as a character string with the two digit R version, e.g. "3.1". Defaults to \code{\link{R.version}} #' #' @param deps logical indicating whether the package dependencies should be added (default \code{TRUE}). #' diff --git a/R/helpers.R b/R/helpers.R index 5909f52..39db057 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -1,6 +1,6 @@ #' Get the path to the repo directory containing the package files. #' -#' @param Rversion numeric version of the R system for which to fetch packages. See \code{\link{R_system_version}}. +#' @param Rversion Version of R. Can be specified as a character string with the two digit R version, e.g. "3.1". Defaults to \code{\link{R.version}} #' #' @param type character, indicating the type of package to download and install. See \code{\link{install.packages}}. #' diff --git a/R/makeRepo.R b/R/makeRepo.R index 6cb57c0..e58ef8f 100644 --- a/R/makeRepo.R +++ b/R/makeRepo.R @@ -36,22 +36,22 @@ #' @note Internally makes use of \code{\link[utils]{download.packages}} and \code{\link{write_PACKAGES}} #' #' @inheritParams pkgDep -#' +#' #' @param pkgs Character vector of packages to download -#' +#' #' @param path Destination download path. This path is the root folder of your new repository. -#' -#' @param Rversion List with two named elements: `major` and `minor`. If not supplied, defaults to system version of R, using \code{\link{R.version}}. Only used if \code{type} is not "source" -#' +#' +#' @param Rversion Version of R. Can be specified as a character string with the two digit R version, e.g. "3.1". Defaults to \code{\link{R.version}}. Only used if \code{type} is not "source". +#' #' @param download If TRUE downloads packages. -#' +#' #' @param quiet If TRUE, suppress status messages (if any), and the progress bar during download. -#' +#' #' @param writePACKAGES If TRUE, calls \code{\link{write_PACKAGES}} to update the repository PACKAGES file. #' #' @export #' @family update repo functions -#' +#' #' @example /inst/examples/example_makeRepo.R makeRepo <- function(pkgs, path, repos=getOption("repos"), type="source", Rversion=R.version, download=TRUE, writePACKAGES=TRUE, quiet=FALSE) { @@ -65,10 +65,10 @@ makeRepo <- function(pkgs, path, repos=getOption("repos"), type="source", stop("Unable to create repo path: ", pkgPath) } } - + pdb <- pkgAvail(repos = repos, type=type, Rversion = Rversion) - if(download) utils::download.packages(pkgs, destdir=pkgPath, available=pdb, repos=repos, + if(download) utils::download.packages(pkgs, destdir=pkgPath, available=pdb, repos=repos, contriburl = contribUrl(repos, type, Rversion), type=type, quiet=quiet) if(writePACKAGES) updateRepoIndex(path=path, type=type, Rversion=Rversion) diff --git a/man/addOldPackage.Rd b/man/addOldPackage.Rd index ac8986f..f2721bf 100644 --- a/man/addOldPackage.Rd +++ b/man/addOldPackage.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/addPackages.R \name{addOldPackage} \alias{addOldPackage} @@ -19,7 +19,7 @@ addOldPackage(pkgs = NULL, path = NULL, vers = NULL, \item{type}{Possible values are (currently) "source", "mac.binary" and "win.binary": the binary types can be listed and downloaded but not installed on other platforms. Passed to \code{\link{download.packages}}.} -\item{Rversion}{numeric version of the R system for which to fetch packages. See \code{\link{R_system_version}}.} +\item{Rversion}{Version of R. Can be specified as a character string with the two digit R version, e.g. "3.1". Defaults to \code{\link{R.version}}} \item{writePACKAGES}{If TRUE, calls \code{\link{write_PACKAGES}} to update the repository PACKAGES file.} @@ -91,10 +91,8 @@ pkgList } } \seealso{ -Other update repo functions: \code{\link{addPackage}}; - \code{\link{checkVersions}}; \code{\link{makeRepo}}, - \code{\link{updateRepoIndex}}; \code{\link{oldPackages}}, - \code{\link{updatePackages}}, +Other update repo functions: \code{\link{addPackage}}, + \code{\link{checkVersions}}, \code{\link{makeRepo}}, \code{\link{updatePackages}} } diff --git a/man/addPackage.Rd b/man/addPackage.Rd index aa73d0c..e7d4402 100644 --- a/man/addPackage.Rd +++ b/man/addPackage.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/addPackages.R \name{addPackage} \alias{addPackage} @@ -17,7 +17,7 @@ addPackage(pkgs = NULL, path = NULL, repos = getOption("repos"), \item{type}{Possible values are (currently) "source", "mac.binary" and "win.binary": the binary types can be listed and downloaded but not installed on other platforms. Passed to \code{\link{download.packages}}.} -\item{Rversion}{numeric version of the R system for which to fetch packages. See \code{\link{R_system_version}}.} +\item{Rversion}{Version of R. Can be specified as a character string with the two digit R version, e.g. "3.1". Defaults to \code{\link{R.version}}} \item{writePACKAGES}{If TRUE, calls \code{\link{write_PACKAGES}} to update the repository PACKAGES file.} @@ -86,10 +86,8 @@ pkgList } } \seealso{ -Other update repo functions: \code{\link{addOldPackage}}; - \code{\link{checkVersions}}; \code{\link{makeRepo}}, - \code{\link{updateRepoIndex}}; \code{\link{oldPackages}}, - \code{\link{updatePackages}}, +Other update repo functions: \code{\link{addOldPackage}}, + \code{\link{checkVersions}}, \code{\link{makeRepo}}, \code{\link{updatePackages}} } diff --git a/man/addPackageListingGithub.Rd b/man/addPackageListingGithub.Rd index 5379ab3..70eb0ec 100644 --- a/man/addPackageListingGithub.Rd +++ b/man/addPackageListingGithub.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/github-functions.R \name{addPackageListingGithub} \alias{addPackageListingGithub} diff --git a/man/basePkgs.Rd b/man/basePkgs.Rd index 3d6ccc3..99c140c 100644 --- a/man/basePkgs.Rd +++ b/man/basePkgs.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/pkgDep.R \name{basePkgs} \alias{basePkgs} @@ -12,7 +12,7 @@ Retrieves names of installed packages by calling \code{\link[utils]{installed.pa \seealso{ \code{\link{pkgDep}} -Other dependency functions: \code{\link{makeDepGraph}}; - \code{\link{pkgDep}}; \code{\link{plot.pkgDepGraph}} +Other dependency functions: \code{\link{makeDepGraph}}, + \code{\link{pkgDep}}, \code{\link{plot.pkgDepGraph}} } diff --git a/man/checkVersions.Rd b/man/checkVersions.Rd index e871598..93a76be 100644 --- a/man/checkVersions.Rd +++ b/man/checkVersions.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/addPackages.R \name{checkVersions} \alias{checkVersions} @@ -14,7 +14,7 @@ checkVersions(pkgs = NULL, path = NULL, type = "source", \item{type}{character, indicating the type of package to download and install. See \code{\link{install.packages}}.} -\item{Rversion}{numeric version of the R system for which to fetch packages. See \code{\link{R_system_version}}.} +\item{Rversion}{Version of R. Can be specified as a character string with the two digit R version, e.g. "3.1". Defaults to \code{\link{R.version}}} } \value{ Returns invisibly the filepaths to packages with multiple versions for removal. @@ -77,10 +77,8 @@ pkgList } } \seealso{ -Other update repo functions: \code{\link{addOldPackage}}; - \code{\link{addPackage}}; \code{\link{makeRepo}}, - \code{\link{updateRepoIndex}}; \code{\link{oldPackages}}, - \code{\link{updatePackages}}, +Other update repo functions: \code{\link{addOldPackage}}, + \code{\link{addPackage}}, \code{\link{makeRepo}}, \code{\link{updatePackages}} } diff --git a/man/cranJuly2014.Rd b/man/cranJuly2014.Rd index 4e3380f..d244e69 100644 --- a/man/cranJuly2014.Rd +++ b/man/cranJuly2014.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/minicran-package.R \docType{data} \name{cranJuly2014} diff --git a/man/getCranDescription.Rd b/man/getCranDescription.Rd index b287f36..3314785 100644 --- a/man/getCranDescription.Rd +++ b/man/getCranDescription.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/getCranDescription.R \name{getCranDescription} \alias{getCranDescription} diff --git a/man/makeDepGraph.Rd b/man/makeDepGraph.Rd index cc94714..554626d 100644 --- a/man/makeDepGraph.Rd +++ b/man/makeDepGraph.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/makeDepGraph.R \name{makeDepGraph} \alias{makeDepGraph} @@ -65,7 +65,7 @@ if(require(igraph)) plot(p) \seealso{ \code{\link{pkgDep}} to extract package dependencies -Other dependency functions: \code{\link{basePkgs}}; - \code{\link{pkgDep}}; \code{\link{plot.pkgDepGraph}} +Other dependency functions: \code{\link{basePkgs}}, + \code{\link{pkgDep}}, \code{\link{plot.pkgDepGraph}} } diff --git a/man/makeLibrary.Rd b/man/makeLibrary.Rd index 37182ae..14f124c 100644 --- a/man/makeLibrary.Rd +++ b/man/makeLibrary.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/makeRepo.R \name{makeLibrary} \alias{makeLibrary} diff --git a/man/makeRepo.Rd b/man/makeRepo.Rd index b17e70d..86102bc 100644 --- a/man/makeRepo.Rd +++ b/man/makeRepo.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/makeRepo.R \name{makeRepo} \alias{makeRepo} @@ -20,7 +20,7 @@ updateRepoIndex(path, type = "source", Rversion = R.version) \item{type}{Possible values are (currently) "source", "mac.binary" and "win.binary": the binary types can be listed and downloaded but not installed on other platforms. Passed to \code{\link{download.packages}}.} -\item{Rversion}{List with two named elements: `major` and `minor`. If not supplied, defaults to system version of R, using \code{\link{R.version}}. Only used if \code{type} is not "source"} +\item{Rversion}{Version of R. Can be specified as a character string with the two digit R version, e.g. "3.1". Defaults to \code{\link{R.version}}. Only used if \code{type} is not "source".} \item{download}{If TRUE downloads packages.} @@ -107,9 +107,8 @@ unlink(pth, recursive = TRUE) } } \seealso{ -Other update repo functions: \code{\link{addOldPackage}}; - \code{\link{addPackage}}; \code{\link{checkVersions}}; - \code{\link{oldPackages}}, \code{\link{updatePackages}}, +Other update repo functions: \code{\link{addOldPackage}}, + \code{\link{addPackage}}, \code{\link{checkVersions}}, \code{\link{updatePackages}} } diff --git a/man/miniCRAN-package.Rd b/man/miniCRAN-package.Rd index b7e44c7..6a5b8e0 100644 --- a/man/miniCRAN-package.Rd +++ b/man/miniCRAN-package.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/minicran-package.R \docType{package} \name{miniCRAN-package} @@ -7,9 +7,9 @@ \alias{minicran} \title{Create a Private Version of CRAN Containing Only Selected Packages} \description{ -At the end of 2014, CRAN consisted of more than 6,000 packages. Many organisations need to maintain a private mirror of CRAN, but with only a subset of packages that are relevant to them. +At the end of 2014, CRAN consisted of more than 6,000 packages. Many organisations need to maintain a private mirror of CRAN, but with only a subset of packages that are relevant to them. -\code{miniCRAN} makes it possible to create an internally consistent repository consisting of selected packages from CRAN-like repositories. The user specifies a set of desired packages, and miniCRAN recursively reads the dependency tree for these packages, then downloads only this subset. +\code{miniCRAN} makes it possible to create an internally consistent repository consisting of selected packages from CRAN-like repositories. The user specifies a set of desired packages, and miniCRAN recursively reads the dependency tree for these packages, then downloads only this subset. There are many reasons for not creating a complete mirror CRAN using \code{rsync}: diff --git a/man/pkgAvail.Rd b/man/pkgAvail.Rd index d263287..7240c2c 100644 --- a/man/pkgAvail.Rd +++ b/man/pkgAvail.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/pkgDep.R \name{pkgAvail} \alias{pkgAvail} diff --git a/man/pkgDep.Rd b/man/pkgDep.Rd index 53676c8..aae8ea6 100644 --- a/man/pkgDep.Rd +++ b/man/pkgDep.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/pkgDep.R \name{pkgDep} \alias{pkgDep} @@ -49,8 +49,8 @@ pkgDep(pkg=c("ggplot2", "plyr", "reshape2"), pdb) } \seealso{ -Other dependency functions: \code{\link{basePkgs}}; - \code{\link{makeDepGraph}}; +Other dependency functions: \code{\link{basePkgs}}, + \code{\link{makeDepGraph}}, \code{\link{plot.pkgDepGraph}} } diff --git a/man/pkgDepTools.Rd b/man/pkgDepTools.Rd index 0067924..34f4f60 100644 --- a/man/pkgDepTools.Rd +++ b/man/pkgDepTools.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/pkgDepTools.R \name{split_op_version} \alias{cleanPkgField} diff --git a/man/plot.pkgDepGraph.Rd b/man/plot.pkgDepGraph.Rd index 90aa0d9..9162ddc 100644 --- a/man/plot.pkgDepGraph.Rd +++ b/man/plot.pkgDepGraph.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/plot.pkgDepGraph.R \name{plot.pkgDepGraph} \alias{plot.pkgDepGraph} @@ -61,7 +61,7 @@ plot(dg, legendPosition=c(1, 1), vertex.size=20, cex=0.5) } \seealso{ -Other dependency functions: \code{\link{basePkgs}}; - \code{\link{makeDepGraph}}; \code{\link{pkgDep}} +Other dependency functions: \code{\link{basePkgs}}, + \code{\link{makeDepGraph}}, \code{\link{pkgDep}} } diff --git a/man/repoBinPath.Rd b/man/repoBinPath.Rd index 93c3a58..dc7cb57 100644 --- a/man/repoBinPath.Rd +++ b/man/repoBinPath.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/helpers.R \name{repoBinPath} \alias{repoBinPath} @@ -11,7 +11,7 @@ repoBinPath(path, type, Rversion) \item{type}{character, indicating the type of package to download and install. See \code{\link{install.packages}}.} -\item{Rversion}{List with two named elements: `major` and `minor`. If not supplied, defaults to system version of R, using \code{\link{R.version}}. Only used if \code{type} is not "source"} +\item{Rversion}{Version of R. Can be specified as a character string with the two digit R version, e.g. "3.1". Defaults to \code{\link{R.version}}. Only used if \code{type} is not "source".} } \description{ Construct path to full binary location diff --git a/man/repoPrefix.Rd b/man/repoPrefix.Rd index ceeea0e..eb71566 100644 --- a/man/repoPrefix.Rd +++ b/man/repoPrefix.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/helpers.R \name{repoPrefix} \alias{repoPrefix} @@ -9,7 +9,7 @@ repoPrefix(type, Rversion) \arguments{ \item{type}{character, indicating the type of package to download and install. See \code{\link{install.packages}}.} -\item{Rversion}{numeric version of the R system for which to fetch packages. See \code{\link{R_system_version}}.} +\item{Rversion}{Version of R. Can be specified as a character string with the two digit R version, e.g. "3.1". Defaults to \code{\link{R.version}}} } \value{ The filepath to the package files directory. diff --git a/man/twodigitRversion.Rd b/man/twodigitRversion.Rd index 60f47bc..530d25a 100644 --- a/man/twodigitRversion.Rd +++ b/man/twodigitRversion.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/helpers.R \name{twodigitRversion} \alias{twodigitRversion} diff --git a/man/updatePackages.Rd b/man/updatePackages.Rd index fabd005..21cd5ac 100644 --- a/man/updatePackages.Rd +++ b/man/updatePackages.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/updatePackages.R \name{updatePackages} \alias{oldPackages} @@ -28,7 +28,7 @@ updatePackages(path = NULL, repos = getOption("repos"), method, \item{type}{Possible values are (currently) "source", "mac.binary" and "win.binary": the binary types can be listed and downloaded but not installed on other platforms. Passed to \code{\link{download.packages}}.} -\item{Rversion}{List with two named elements: `major` and `minor`. If not supplied, defaults to system version of R, using \code{\link{R.version}}. Only used if \code{type} is not "source"} +\item{Rversion}{Version of R. Can be specified as a character string with the two digit R version, e.g. "3.1". Defaults to \code{\link{R.version}}. Only used if \code{type} is not "source".} \item{ask}{logical indicating whether to ask user before packages are actually downloaded and installed, or the character string "\code{graphics}", which brings up a widget to allow the user to (de-)select from the list of packages which could be updated or added. The latter value only works on systems with a GUI version of \code{\link{select.list}}, and is otherwise equivalent to \code{ask = TRUE}.} @@ -93,8 +93,8 @@ pkgList \seealso{ \code{\link{updatePackages}}, \code{\link{pkgAvail}}. -Other update repo functions: \code{\link{addOldPackage}}; - \code{\link{addPackage}}; \code{\link{checkVersions}}; - \code{\link{makeRepo}}, \code{\link{updateRepoIndex}} +Other update repo functions: \code{\link{addOldPackage}}, + \code{\link{addPackage}}, \code{\link{checkVersions}}, + \code{\link{makeRepo}} } diff --git a/vignettes/miniCRAN-dependency-graph.rmd b/vignettes/miniCRAN-dependency-graph.rmd index 2d42cd6..ae6c762 100644 --- a/vignettes/miniCRAN-dependency-graph.rmd +++ b/vignettes/miniCRAN-dependency-graph.rmd @@ -1,13 +1,13 @@ --- title: "Using miniCRAN to identify package dependencies" author: "Andrie de Vries" -date: "March 26, 2015" +date: "April 5, 2016" output: html_document: self_contained: yes toc: yes vignette: > - %\VignetteEngine{knitr::knitr} + %\VignetteEngine{rmarkdown::render} %\VignetteIndexEntry{Using miniCRAN to identify package dependencies} %\VignettePackage{miniCRAN} %\VignetteKeyword{miniCRAN} diff --git a/vignettes/miniCRAN-introduction.rmd b/vignettes/miniCRAN-introduction.rmd index e41f8b7..df48761 100644 --- a/vignettes/miniCRAN-introduction.rmd +++ b/vignettes/miniCRAN-introduction.rmd @@ -1,13 +1,13 @@ --- title: "Using miniCRAN to create a local CRAN repository" author: "Andrie de Vries and Alex Chubaty" -date: "March 26, 2015" +date: "April 5, 2016" output: html_document: self_contained: yes toc: yes vignette: > - %\VignetteEngine{knitr::knitr} + %\VignetteEngine{rmarkdown::render} %\VignetteIndexEntry{Using miniCRAN to create and maintain a local CRAN repository} %\VignettePackage{miniCRAN} %\VignetteKeyword{miniCRAN} diff --git a/vignettes/miniCRAN-non-CRAN-repos.rmd b/vignettes/miniCRAN-non-CRAN-repos.rmd index 7837e6f..9f241e1 100644 --- a/vignettes/miniCRAN-non-CRAN-repos.rmd +++ b/vignettes/miniCRAN-non-CRAN-repos.rmd @@ -1,13 +1,13 @@ --- title: "Using repositories other than CRAN with miniCRAN" author: "Andrie de Vries" -date: "March 26, 2015" +date: "April 5, 2016" output: html_document: self_contained: yes toc: yes vignette: > - %\VignetteEngine{knitr::knitr} + %\VignetteEngine{rmarkdown::render} %\VignetteIndexEntry{Using repositories other than CRAN with miniCRAN} %\VignettePackage{miniCRAN} %\VignetteKeyword{miniCRAN} @@ -82,4 +82,4 @@ bioc[grep("BioC", names(bioc))] index(bioc["BioCsoft"]) -``` \ No newline at end of file +``` From 15f11a92745ec2ed28253c125ce112b62fb0cf27 Mon Sep 17 00:00:00 2001 From: Alex Chubaty Date: Tue, 5 Apr 2016 10:18:49 -0600 Subject: [PATCH 03/21] rebuild documentation with roxygen2 (#24) --- DESCRIPTION | 1 + NAMESPACE | 2 +- man/addOldPackage.Rd | 21 +++++++++------------ man/addPackage.Rd | 21 +++++++++------------ man/addPackageListingGithub.Rd | 2 +- man/basePkgs.Rd | 6 +++--- man/checkVersions.Rd | 19 ++++++++----------- man/cranJuly2014.Rd | 2 +- man/getCranDescription.Rd | 2 +- man/makeDepGraph.Rd | 6 +++--- man/makeLibrary.Rd | 2 +- man/makeRepo.Rd | 7 +++---- man/miniCRAN-package.Rd | 6 +++--- man/pkgAvail.Rd | 2 +- man/pkgDep.Rd | 6 +++--- man/pkgDepTools.Rd | 2 +- man/plot.pkgDepGraph.Rd | 6 +++--- man/repoBinPath.Rd | 2 +- man/repoPrefix.Rd | 2 +- man/twodigitRversion.Rd | 2 +- man/updatePackages.Rd | 8 ++++---- 21 files changed, 59 insertions(+), 68 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0017d72..a540313 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -29,3 +29,4 @@ Suggests: knitr, igraph VignetteBuilder: knitr +RoxygenNote: 5.0.1 diff --git a/NAMESPACE b/NAMESPACE index c40a07b..160b2eb 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,4 +1,4 @@ -# Generated by roxygen2 (4.1.0): do not edit by hand +# Generated by roxygen2: do not edit by hand S3method(plot,pkgDepGraph) S3method(print,pkgDep) diff --git a/man/addOldPackage.Rd b/man/addOldPackage.Rd index ac8986f..9f08e53 100644 --- a/man/addOldPackage.Rd +++ b/man/addOldPackage.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/addPackages.R \name{addOldPackage} \alias{addOldPackage} @@ -28,7 +28,7 @@ addOldPackage(pkgs = NULL, path = NULL, vers = NULL, \item{quiet}{If TRUE, suppress status messages (if any), and the progress bar during download.} } \value{ -Installs the packages, rebuilds the package index, and invisibly returns the number of packages writen to the index files. +Adds the packages, rebuilds the package index, and invisibly returns the number of packages written to the index files. } \description{ Will download and add older source package versions. Older binary versions are not normally available on CRAN and should be build from source on the platform for which they are required. As such, specifying \code{type!="source"} will likely fail as the download will not be successful. @@ -42,6 +42,7 @@ Dependencies for old package versions cannot be determined automatically and mus # Specify list of packages to download revolution <- c(CRAN="http://cran.revolutionanalytics.com") pkgs <- c("foreach") +pkgTypes <- c("source", "win.binary") pdb <- cranJuly2014 @@ -57,8 +58,7 @@ pkgList dir.create(pth <- file.path(tempdir(), "miniCRAN")) # Make repo for source and win.binary - makeRepo(pkgList, path=pth, repos=revolution, type="source") - makeRepo(pkgList, path=pth, repos=revolution, type="win.binary") + makeRepo(pkgList, path=pth, repos=revolution, type=pkgTypes) # Add other versions of a package (and assume these were added previously) oldVers <- data.frame(package=c("foreach", "codetools", "iterators"), @@ -78,23 +78,20 @@ pkgList file.remove(c(pkgVersionsSrc[1], pkgVersionsBin[1])) # Rebuild package index after adding/removing files - updateRepoIndex(pth, type=c("source", "win.binary"), Rversion=R.version) - + updateRepoIndex(pth, type=pkgTypes, Rversion=R.version) + pkgAvail(pth, type="source") # Add new packages (from CRAN) to the miniCRAN repo - addPackage("Matrix", path=pth, repos=revolution, type="source") - addPackage("Matrix", path=pth, repos=revolution, type="win.binary") + addPackage("Matrix", path=pth, repos=revolution, type=pkgTypes) # Delete temporary folder unlink(pth, recursive=TRUE) } } \seealso{ -Other update repo functions: \code{\link{addPackage}}; - \code{\link{checkVersions}}; \code{\link{makeRepo}}, - \code{\link{updateRepoIndex}}; \code{\link{oldPackages}}, - \code{\link{updatePackages}}, +Other update repo functions: \code{\link{addPackage}}, + \code{\link{checkVersions}}, \code{\link{makeRepo}}, \code{\link{updatePackages}} } diff --git a/man/addPackage.Rd b/man/addPackage.Rd index aa73d0c..dc79749 100644 --- a/man/addPackage.Rd +++ b/man/addPackage.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/addPackages.R \name{addPackage} \alias{addPackage} @@ -26,7 +26,7 @@ addPackage(pkgs = NULL, path = NULL, repos = getOption("repos"), \item{quiet}{If TRUE, suppress status messages (if any), and the progress bar during download.} } \value{ -Installs the packages, rebuilds the package index, and invisibly returns the number of packages writen to the index files. +Installs the packages, rebuilds the package index, and invisibly returns the number of packages written to the index files. } \description{ Add packages to a miniCRAN repository. @@ -37,6 +37,7 @@ Add packages to a miniCRAN repository. # Specify list of packages to download revolution <- c(CRAN="http://cran.revolutionanalytics.com") pkgs <- c("foreach") +pkgTypes <- c("source", "win.binary") pdb <- cranJuly2014 @@ -52,8 +53,7 @@ pkgList dir.create(pth <- file.path(tempdir(), "miniCRAN")) # Make repo for source and win.binary - makeRepo(pkgList, path=pth, repos=revolution, type="source") - makeRepo(pkgList, path=pth, repos=revolution, type="win.binary") + makeRepo(pkgList, path=pth, repos=revolution, type=pkgTypes) # Add other versions of a package (and assume these were added previously) oldVers <- data.frame(package=c("foreach", "codetools", "iterators"), @@ -73,23 +73,20 @@ pkgList file.remove(c(pkgVersionsSrc[1], pkgVersionsBin[1])) # Rebuild package index after adding/removing files - updateRepoIndex(pth, type=c("source", "win.binary"), Rversion=R.version) - + updateRepoIndex(pth, type=pkgTypes, Rversion=R.version) + pkgAvail(pth, type="source") # Add new packages (from CRAN) to the miniCRAN repo - addPackage("Matrix", path=pth, repos=revolution, type="source") - addPackage("Matrix", path=pth, repos=revolution, type="win.binary") + addPackage("Matrix", path=pth, repos=revolution, type=pkgTypes) # Delete temporary folder unlink(pth, recursive=TRUE) } } \seealso{ -Other update repo functions: \code{\link{addOldPackage}}; - \code{\link{checkVersions}}; \code{\link{makeRepo}}, - \code{\link{updateRepoIndex}}; \code{\link{oldPackages}}, - \code{\link{updatePackages}}, +Other update repo functions: \code{\link{addOldPackage}}, + \code{\link{checkVersions}}, \code{\link{makeRepo}}, \code{\link{updatePackages}} } diff --git a/man/addPackageListingGithub.Rd b/man/addPackageListingGithub.Rd index 5379ab3..70eb0ec 100644 --- a/man/addPackageListingGithub.Rd +++ b/man/addPackageListingGithub.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/github-functions.R \name{addPackageListingGithub} \alias{addPackageListingGithub} diff --git a/man/basePkgs.Rd b/man/basePkgs.Rd index 3d6ccc3..99c140c 100644 --- a/man/basePkgs.Rd +++ b/man/basePkgs.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/pkgDep.R \name{basePkgs} \alias{basePkgs} @@ -12,7 +12,7 @@ Retrieves names of installed packages by calling \code{\link[utils]{installed.pa \seealso{ \code{\link{pkgDep}} -Other dependency functions: \code{\link{makeDepGraph}}; - \code{\link{pkgDep}}; \code{\link{plot.pkgDepGraph}} +Other dependency functions: \code{\link{makeDepGraph}}, + \code{\link{pkgDep}}, \code{\link{plot.pkgDepGraph}} } diff --git a/man/checkVersions.Rd b/man/checkVersions.Rd index e871598..4c91c74 100644 --- a/man/checkVersions.Rd +++ b/man/checkVersions.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/addPackages.R \name{checkVersions} \alias{checkVersions} @@ -28,6 +28,7 @@ Checks for previous versions, and returns the file paths for packages with multi # Specify list of packages to download revolution <- c(CRAN="http://cran.revolutionanalytics.com") pkgs <- c("foreach") +pkgTypes <- c("source", "win.binary") pdb <- cranJuly2014 @@ -43,8 +44,7 @@ pkgList dir.create(pth <- file.path(tempdir(), "miniCRAN")) # Make repo for source and win.binary - makeRepo(pkgList, path=pth, repos=revolution, type="source") - makeRepo(pkgList, path=pth, repos=revolution, type="win.binary") + makeRepo(pkgList, path=pth, repos=revolution, type=pkgTypes) # Add other versions of a package (and assume these were added previously) oldVers <- data.frame(package=c("foreach", "codetools", "iterators"), @@ -64,23 +64,20 @@ pkgList file.remove(c(pkgVersionsSrc[1], pkgVersionsBin[1])) # Rebuild package index after adding/removing files - updateRepoIndex(pth, type=c("source", "win.binary"), Rversion=R.version) - + updateRepoIndex(pth, type=pkgTypes, Rversion=R.version) + pkgAvail(pth, type="source") # Add new packages (from CRAN) to the miniCRAN repo - addPackage("Matrix", path=pth, repos=revolution, type="source") - addPackage("Matrix", path=pth, repos=revolution, type="win.binary") + addPackage("Matrix", path=pth, repos=revolution, type=pkgTypes) # Delete temporary folder unlink(pth, recursive=TRUE) } } \seealso{ -Other update repo functions: \code{\link{addOldPackage}}; - \code{\link{addPackage}}; \code{\link{makeRepo}}, - \code{\link{updateRepoIndex}}; \code{\link{oldPackages}}, - \code{\link{updatePackages}}, +Other update repo functions: \code{\link{addOldPackage}}, + \code{\link{addPackage}}, \code{\link{makeRepo}}, \code{\link{updatePackages}} } diff --git a/man/cranJuly2014.Rd b/man/cranJuly2014.Rd index 4e3380f..d244e69 100644 --- a/man/cranJuly2014.Rd +++ b/man/cranJuly2014.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/minicran-package.R \docType{data} \name{cranJuly2014} diff --git a/man/getCranDescription.Rd b/man/getCranDescription.Rd index b287f36..3314785 100644 --- a/man/getCranDescription.Rd +++ b/man/getCranDescription.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/getCranDescription.R \name{getCranDescription} \alias{getCranDescription} diff --git a/man/makeDepGraph.Rd b/man/makeDepGraph.Rd index cc94714..554626d 100644 --- a/man/makeDepGraph.Rd +++ b/man/makeDepGraph.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/makeDepGraph.R \name{makeDepGraph} \alias{makeDepGraph} @@ -65,7 +65,7 @@ if(require(igraph)) plot(p) \seealso{ \code{\link{pkgDep}} to extract package dependencies -Other dependency functions: \code{\link{basePkgs}}; - \code{\link{pkgDep}}; \code{\link{plot.pkgDepGraph}} +Other dependency functions: \code{\link{basePkgs}}, + \code{\link{pkgDep}}, \code{\link{plot.pkgDepGraph}} } diff --git a/man/makeLibrary.Rd b/man/makeLibrary.Rd index 37182ae..14f124c 100644 --- a/man/makeLibrary.Rd +++ b/man/makeLibrary.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/makeRepo.R \name{makeLibrary} \alias{makeLibrary} diff --git a/man/makeRepo.Rd b/man/makeRepo.Rd index b17e70d..0471b9d 100644 --- a/man/makeRepo.Rd +++ b/man/makeRepo.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/makeRepo.R \name{makeRepo} \alias{makeRepo} @@ -107,9 +107,8 @@ unlink(pth, recursive = TRUE) } } \seealso{ -Other update repo functions: \code{\link{addOldPackage}}; - \code{\link{addPackage}}; \code{\link{checkVersions}}; - \code{\link{oldPackages}}, \code{\link{updatePackages}}, +Other update repo functions: \code{\link{addOldPackage}}, + \code{\link{addPackage}}, \code{\link{checkVersions}}, \code{\link{updatePackages}} } diff --git a/man/miniCRAN-package.Rd b/man/miniCRAN-package.Rd index b7e44c7..6a5b8e0 100644 --- a/man/miniCRAN-package.Rd +++ b/man/miniCRAN-package.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/minicran-package.R \docType{package} \name{miniCRAN-package} @@ -7,9 +7,9 @@ \alias{minicran} \title{Create a Private Version of CRAN Containing Only Selected Packages} \description{ -At the end of 2014, CRAN consisted of more than 6,000 packages. Many organisations need to maintain a private mirror of CRAN, but with only a subset of packages that are relevant to them. +At the end of 2014, CRAN consisted of more than 6,000 packages. Many organisations need to maintain a private mirror of CRAN, but with only a subset of packages that are relevant to them. -\code{miniCRAN} makes it possible to create an internally consistent repository consisting of selected packages from CRAN-like repositories. The user specifies a set of desired packages, and miniCRAN recursively reads the dependency tree for these packages, then downloads only this subset. +\code{miniCRAN} makes it possible to create an internally consistent repository consisting of selected packages from CRAN-like repositories. The user specifies a set of desired packages, and miniCRAN recursively reads the dependency tree for these packages, then downloads only this subset. There are many reasons for not creating a complete mirror CRAN using \code{rsync}: diff --git a/man/pkgAvail.Rd b/man/pkgAvail.Rd index d263287..7240c2c 100644 --- a/man/pkgAvail.Rd +++ b/man/pkgAvail.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/pkgDep.R \name{pkgAvail} \alias{pkgAvail} diff --git a/man/pkgDep.Rd b/man/pkgDep.Rd index 53676c8..aae8ea6 100644 --- a/man/pkgDep.Rd +++ b/man/pkgDep.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/pkgDep.R \name{pkgDep} \alias{pkgDep} @@ -49,8 +49,8 @@ pkgDep(pkg=c("ggplot2", "plyr", "reshape2"), pdb) } \seealso{ -Other dependency functions: \code{\link{basePkgs}}; - \code{\link{makeDepGraph}}; +Other dependency functions: \code{\link{basePkgs}}, + \code{\link{makeDepGraph}}, \code{\link{plot.pkgDepGraph}} } diff --git a/man/pkgDepTools.Rd b/man/pkgDepTools.Rd index 0067924..34f4f60 100644 --- a/man/pkgDepTools.Rd +++ b/man/pkgDepTools.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/pkgDepTools.R \name{split_op_version} \alias{cleanPkgField} diff --git a/man/plot.pkgDepGraph.Rd b/man/plot.pkgDepGraph.Rd index 90aa0d9..9162ddc 100644 --- a/man/plot.pkgDepGraph.Rd +++ b/man/plot.pkgDepGraph.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/plot.pkgDepGraph.R \name{plot.pkgDepGraph} \alias{plot.pkgDepGraph} @@ -61,7 +61,7 @@ plot(dg, legendPosition=c(1, 1), vertex.size=20, cex=0.5) } \seealso{ -Other dependency functions: \code{\link{basePkgs}}; - \code{\link{makeDepGraph}}; \code{\link{pkgDep}} +Other dependency functions: \code{\link{basePkgs}}, + \code{\link{makeDepGraph}}, \code{\link{pkgDep}} } diff --git a/man/repoBinPath.Rd b/man/repoBinPath.Rd index 93c3a58..22d7c9f 100644 --- a/man/repoBinPath.Rd +++ b/man/repoBinPath.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/helpers.R \name{repoBinPath} \alias{repoBinPath} diff --git a/man/repoPrefix.Rd b/man/repoPrefix.Rd index ceeea0e..6b2a8be 100644 --- a/man/repoPrefix.Rd +++ b/man/repoPrefix.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/helpers.R \name{repoPrefix} \alias{repoPrefix} diff --git a/man/twodigitRversion.Rd b/man/twodigitRversion.Rd index 60f47bc..530d25a 100644 --- a/man/twodigitRversion.Rd +++ b/man/twodigitRversion.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/helpers.R \name{twodigitRversion} \alias{twodigitRversion} diff --git a/man/updatePackages.Rd b/man/updatePackages.Rd index fabd005..d95b4dc 100644 --- a/man/updatePackages.Rd +++ b/man/updatePackages.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.0): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/updatePackages.R \name{updatePackages} \alias{oldPackages} @@ -93,8 +93,8 @@ pkgList \seealso{ \code{\link{updatePackages}}, \code{\link{pkgAvail}}. -Other update repo functions: \code{\link{addOldPackage}}; - \code{\link{addPackage}}; \code{\link{checkVersions}}; - \code{\link{makeRepo}}, \code{\link{updateRepoIndex}} +Other update repo functions: \code{\link{addOldPackage}}, + \code{\link{addPackage}}, \code{\link{checkVersions}}, + \code{\link{makeRepo}} } From 91542ee282c79a1e9640b20d2fc3fac6edd2bdb7 Mon Sep 17 00:00:00 2001 From: Alex Chubaty Date: Fri, 15 Apr 2016 12:01:39 -0600 Subject: [PATCH 04/21] fix typo in addPackage lapply --- R/addPackages.R | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/R/addPackages.R b/R/addPackages.R index 89d3613..dd85f8a 100644 --- a/R/addPackages.R +++ b/R/addPackages.R @@ -63,18 +63,18 @@ addPackage <- function(pkgs=NULL, path=NULL, repos=getOption("repos"), writePACKAGES=TRUE, deps=TRUE, quiet=FALSE) { if (is.null(path) || is.null(pkgs)) stop("path and pkgs must both be specified.") - lapply(type, function(type) { - prev <- checkVersions(pkgs=pkgs, path=path, type=type, Rversion=Rversion) + lapply(type, function(t) { + prev <- checkVersions(pkgs=pkgs, path=path, type=t, Rversion=Rversion) prev.df <- getPkgVersFromFile(prev) - if (deps) pkgs <- pkgDep(pkgs, repos=repos, type=type) + if (deps) pkgs <- pkgDep(pkgs, repos=repos, type=t) - makeRepo(pkgs=pkgs, path=path, repos=repos, type=type, Rversion=Rversion, + makeRepo(pkgs=pkgs, path=path, repos=repos, type=t, Rversion=Rversion, download=TRUE, writePACKAGES=FALSE, quiet=quiet) if (length(prev)) { curr <- suppressWarnings( - checkVersions(pkgs=pkgs, path=path, type=type, Rversion=Rversion) + checkVersions(pkgs=pkgs, path=path, type=t, Rversion=Rversion) ) curr.df <- getPkgVersFromFile(curr) From 8644bb4c76cbd9ae6a16c40ff8bd223ad9f8c86c Mon Sep 17 00:00:00 2001 From: Alex Chubaty Date: Fri, 15 Apr 2016 12:20:27 -0600 Subject: [PATCH 05/21] fix typo in updatePackages lapply --- R/updatePackages.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/R/updatePackages.R b/R/updatePackages.R index a8cad35..0ad7600 100644 --- a/R/updatePackages.R +++ b/R/updatePackages.R @@ -71,10 +71,10 @@ updatePackages <- function (path=NULL, repos=getOption("repos"), oldPkgs=NULL, type="source", Rversion=R.version, quiet=FALSE) { - lapply(type, function(type) { + lapply(type, function(t) { force(ask) - simplifyRepos <- function(repos, type) { - tail <- substring(contribUrl("---", type=type, Rversion=Rversion), 4) + simplifyRepos <- function(repos, t) { + tail <- substring(contribUrl("---", type=t, Rversion=Rversion), 4) ind <- regexpr(tail, repos, fixed=TRUE) ind <- ifelse(ind > 0, ind-1, nchar(repos, type="c")) substr(repos, 1, ind) @@ -85,7 +85,7 @@ updatePackages <- function (path=NULL, repos=getOption("repos"), cat(old[k, "Package"], ":\n", "Local Version", old[k, "LocalVer"], "\n", "Repos Version", old[k, "ReposVer"], - "available at", simplifyRepos(old[k, "Repository"], type)) + "available at", simplifyRepos(old[k, "Repository"], t)) cat("\n") answer <- substr(readline("Update (y/N/c)? "), 1L, 1L) if (answer == "c" | answer == "C") { @@ -105,7 +105,7 @@ updatePackages <- function (path=NULL, repos=getOption("repos"), } if (is.null(oldPkgs)) { oldPkgs <- oldPackages(path=path, repos=repos, - method=method, availPkgs=availPkgs, type=type, + method=method, availPkgs=availPkgs, type=t, Rversion=Rversion) if (is.null(oldPkgs)) { message("All packages are up to date from repos: ", names(repos)) @@ -133,7 +133,7 @@ updatePackages <- function (path=NULL, repos=getOption("repos"), oldPkgs } if (length(update[,"Package"])) { - addPackage(update[,"Package"], path=path, repos=repos, type=type, quiet=quiet, deps=FALSE, Rversion=Rversion) + addPackage(update[,"Package"], path=path, repos=repos, type=t, quiet=quiet, deps=FALSE, Rversion=Rversion) } }) } From f40f6b160ada7e787b790634f3cee907d7ab9794 Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Thu, 23 Jun 2016 15:24:11 +0100 Subject: [PATCH 06/21] Update documentation --- man/makeRepo.Rd | 2 +- man/repoBinPath.Rd | 2 +- man/updatePackages.Rd | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/man/makeRepo.Rd b/man/makeRepo.Rd index 9ed262d..f755739 100644 --- a/man/makeRepo.Rd +++ b/man/makeRepo.Rd @@ -20,7 +20,7 @@ updateRepoIndex(path, type = "source", Rversion = R.version) \item{type}{Possible values are (currently) "source", "mac.binary" and "win.binary": the binary types can be listed and downloaded but not installed on other platforms. Passed to \code{\link{download.packages}}.} -\item{Rversion}{Version of R. Can be specified as a character string with the two digit R version, e.g. "3.1". Defaults to \code{\link{R.version}}. Only used if \code{type} is not "source".} +\item{Rversion}{List with two named elements: `major` and `minor`. If not supplied, defaults to system version of R, using \code{\link{R.version}}. Only used if \code{type} is not "source"} \item{download}{If TRUE downloads packages.} diff --git a/man/repoBinPath.Rd b/man/repoBinPath.Rd index dc7cb57..22d7c9f 100644 --- a/man/repoBinPath.Rd +++ b/man/repoBinPath.Rd @@ -11,7 +11,7 @@ repoBinPath(path, type, Rversion) \item{type}{character, indicating the type of package to download and install. See \code{\link{install.packages}}.} -\item{Rversion}{Version of R. Can be specified as a character string with the two digit R version, e.g. "3.1". Defaults to \code{\link{R.version}}. Only used if \code{type} is not "source".} +\item{Rversion}{List with two named elements: `major` and `minor`. If not supplied, defaults to system version of R, using \code{\link{R.version}}. Only used if \code{type} is not "source"} } \description{ Construct path to full binary location diff --git a/man/updatePackages.Rd b/man/updatePackages.Rd index 896c0b3..fb9bdb5 100644 --- a/man/updatePackages.Rd +++ b/man/updatePackages.Rd @@ -28,7 +28,7 @@ updatePackages(path = NULL, repos = getOption("repos"), method, \item{type}{Possible values are (currently) "source", "mac.binary" and "win.binary": the binary types can be listed and downloaded but not installed on other platforms. Passed to \code{\link{download.packages}}.} -\item{Rversion}{Version of R. Can be specified as a character string with the two digit R version, e.g. "3.1". Defaults to \code{\link{R.version}}. Only used if \code{type} is not "source".} +\item{Rversion}{List with two named elements: `major` and `minor`. If not supplied, defaults to system version of R, using \code{\link{R.version}}. Only used if \code{type} is not "source"} \item{ask}{logical indicating whether to ask user before packages are actually downloaded and installed, or the character string "\code{graphics}", which brings up a widget to allow the user to (de-)select from the list of packages which could be updated or added. The latter value only works on systems with a GUI version of \code{\link{select.list}}, and is otherwise equivalent to \code{ask = TRUE}.} From e6e30f619c87e7b212aa97d4e48fa0e7a2d866f4 Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Thu, 23 Jun 2016 15:24:43 +0100 Subject: [PATCH 07/21] Return paths to downloaded packages #65 --- R/makeRepo.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/makeRepo.R b/R/makeRepo.R index d95c8a8..215f979 100644 --- a/R/makeRepo.R +++ b/R/makeRepo.R @@ -57,7 +57,7 @@ makeRepo <- function(pkgs, path, repos=getOption("repos"), type="source", Rversion=R.version, download=TRUE, writePACKAGES=TRUE, quiet=FALSE) { if(!file.exists(path)) stop("Download path does not exist") - lapply(type, function(type) { + downloaded <- lapply(type, function(type) { pkgPath <- repoBinPath(path=path, type=type, Rversion=Rversion) if(!file.exists(pkgPath)) { result <- dir.create(pkgPath, recursive=TRUE, showWarnings = FALSE) @@ -76,8 +76,11 @@ makeRepo <- function(pkgs, path, repos=getOption("repos"), type="source", type=type, quiet=quiet) } }) + + if(writePACKAGES) updateRepoIndex(path=path, type=type, Rversion=Rversion) + if(download) sapply(downloaded, "[[", 2) else character(0) } From ce45d9e13d78250898e4318d6083630f07a4b350 Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Thu, 23 Jun 2016 17:28:55 +0100 Subject: [PATCH 08/21] Force copy files if repos is a file:/// URL #76 --- R/makeRepo.R | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/R/makeRepo.R b/R/makeRepo.R index 215f979..f967ef6 100644 --- a/R/makeRepo.R +++ b/R/makeRepo.R @@ -77,10 +77,21 @@ makeRepo <- function(pkgs, path, repos=getOption("repos"), type="source", } }) - + downloaded <- sapply(downloaded, "[[", 2) + + fromLocalRepos <- grepl("^file://", repos) + if(fromLocalRepos){ + # need to copy files to correct folder + repoPath <- gsub("^file:///", "", repos) + repoPath <- normalizePath(repoPath, winslash = "/") + newPath <- gsub(repoPath, normalizePath(path, winslash = "/"), downloaded) + file.copy(downloaded, newPath) + downloaded <- newPath + } + if(writePACKAGES) updateRepoIndex(path=path, type=type, Rversion=Rversion) - if(download) sapply(downloaded, "[[", 2) else character(0) + if(download) downloaded else character(0) } From fd3f7ea4e3339eadc5a955a02f64fc2f1cb7675b Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Thu, 23 Jun 2016 17:46:53 +0100 Subject: [PATCH 09/21] Update travis configuration file #77 --- .travis.yml | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9a49684..4b1daed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,29 +1,26 @@ -language: c - -before_install: - - curl -OL http://raw.github.com/craigcitro/r-travis/master/scripts/travis-tool.sh - - chmod 755 ./travis-tool.sh - - ./travis-tool.sh bootstrap +language: r +sudo: required env: NOT_CRAN="true" -install: - - ./travis-tool.sh install_deps - - Rscript -e 'install.packages("igraph", repos=c(CRAN="http:/cran.revolutionanalytics.com"))' - -script: ./travis-tool.sh run_tests - -after_failure: - - ./travis-tool.sh dump_logs - -notifications: - email: - on_success: change - on_failure: change +r_binary_packages: + - testthat + - knitr + - rmarkdown + - igraph + - XML + - httr branches: only: - master - release - dev - - update-repo + +notifications: + email: + on_success: change + on_failure: change + + + From 01110c1631169b35190be22fc3cab7ccdd8c79a4 Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Thu, 23 Jun 2016 17:59:03 +0100 Subject: [PATCH 10/21] Update travis configuration file #77 --- .travis.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4b1daed..144c246 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,9 @@ language: r sudo: required +cache: packages env: NOT_CRAN="true" -r_binary_packages: - - testthat - - knitr - - rmarkdown - - igraph - - XML - - httr - branches: only: - master From 97a7566bccd35f3d791396892d0e722c5086dc3e Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Thu, 23 Jun 2016 19:20:45 +0100 Subject: [PATCH 11/21] Add CRAN repo to travis configuration file #77 --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 144c246..597bfc5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,9 @@ language: r sudo: required cache: packages +repos: + CRAN: https://cloud.r-project.org + env: NOT_CRAN="true" branches: From 5b297cc0dbd58b250e8461c75b4d6eeed3eea3f8 Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Thu, 23 Jun 2016 19:34:01 +0100 Subject: [PATCH 12/21] Set sudo:false #77 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 597bfc5..c3ea78b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: r -sudo: required +sudo: false cache: packages repos: From 9809e49ec99bbcf21c5bdbc708ffd3204a894f80 Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Thu, 23 Jun 2016 19:42:10 +0100 Subject: [PATCH 13/21] Update NEWS #73 --- NEWS | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index e3fd11b..115916e 100644 --- a/NEWS +++ b/NEWS @@ -1,18 +1,21 @@ +miniCRAN v0.2-6 (Release date: 2016-06-23) +============== + + + + miniCRAN v0.2-5 (Release date: 2016-04-12) ============== * plot.pkgDepGraph() now displays legend only for edges that are actually in graph +* make consistent use of Rversion argument (#42) + miniCRAN v0.2-4 (Release date: 2016-03-27) ============== * Changed copyright to Microsoft -miniCRAN v0.2.4.9001 -==================== - -Changes: -* make consistent use of Rversion argument (#42) miniCRAN v0.2-2 (Release date: 2015-03-25) ============== From da54db4fde638d916bd5cc056302a4976e6c7655 Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Thu, 23 Jun 2016 19:42:35 +0100 Subject: [PATCH 14/21] Change CRAN mirror URL to https:// #77 --- R/MRAN.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/MRAN.R b/R/MRAN.R index ed66246..aba929c 100644 --- a/R/MRAN.R +++ b/R/MRAN.R @@ -1,5 +1,5 @@ MRAN <- function(snapshot){ - url <- "http://mran.microsoft.com" + url <- "https://mran.microsoft.com" if(missing("snapshot") || is.null(snapshot)){ url } else { From 1bf39362fd84024d0aa35ac9ead5d0ce6b6be4dc Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Thu, 23 Jun 2016 20:19:50 +0100 Subject: [PATCH 15/21] Hard code Rversion to 3.2 to match MRAN snapshot --- tests/testthat/test-3-makeRepo.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-3-makeRepo.R b/tests/testthat/test-3-makeRepo.R index 71cf833..0b7325b 100644 --- a/tests/testthat/test-3-makeRepo.R +++ b/tests/testthat/test-3-makeRepo.R @@ -23,7 +23,7 @@ for(pkg_type in names(types)){ pdb <- pkgAvail(repos = revolution, type=pkg_type) pkgList <- pkgDep(pkgs, availPkgs = pdb, repos=revolution, type=pkg_type, suggests=FALSE) - prefix <- miniCRAN:::repoPrefix(pkg_type, R.version) + prefix <- miniCRAN:::repoPrefix(pkg_type, Rversion = "3.2") dir.create(repo_root, recursive = TRUE, showWarnings = FALSE) makeRepo(pkgList, path=repo_root, repos=revolution, type=pkg_type, quiet=TRUE) From d21d5c5b8d2b4de4c57440826d80240291aca91c Mon Sep 17 00:00:00 2001 From: Alex Chubaty Date: Thu, 23 Jun 2016 13:54:14 -0600 Subject: [PATCH 16/21] fix bug in 'addPackage' & misc cleanup * correctly pass R version to `pkgDeps` call in `addPackage` * correctly specify R version to be or tests using MRAN * code formatting cleanup --- NEWS | 2 +- R/addPackages.R | 6 +-- R/makeRepo.R | 3 +- tests/testthat/test-3-makeRepo.R | 32 +++++------- tests/testthat/test-4-updateRepo.R | 84 ++++++++++++++---------------- 5 files changed, 58 insertions(+), 69 deletions(-) diff --git a/NEWS b/NEWS index 115916e..cac30b4 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@ miniCRAN v0.2-6 (Release date: 2016-06-23) ============== - +* fix bug in `addPackage` miniCRAN v0.2-5 (Release date: 2016-04-12) diff --git a/R/addPackages.R b/R/addPackages.R index 18ba00f..53e8150 100644 --- a/R/addPackages.R +++ b/R/addPackages.R @@ -67,10 +67,10 @@ addPackage <- function(pkgs=NULL, path=NULL, repos=getOption("repos"), prev <- checkVersions(pkgs=pkgs, path=path, type=t, Rversion=Rversion) prev.df <- getPkgVersFromFile(prev) - if (deps) pkgs <- pkgDep(pkgs, repos=repos, type=t) + if (deps) pkgs <- pkgDep(pkgs, repos = repos, type = t, Rversion = Rversion) - makeRepo(pkgs=pkgs, path=path, repos=repos, type=t, Rversion=Rversion, - download=TRUE, writePACKAGES=FALSE, quiet=quiet) + makeRepo(pkgs = pkgs, path = path, repos = repos, type = t, Rversion = Rversion, + download = TRUE, writePACKAGES = FALSE, quiet = quiet) if (length(prev)) { curr <- suppressWarnings( diff --git a/R/makeRepo.R b/R/makeRepo.R index f967ef6..d372c4b 100644 --- a/R/makeRepo.R +++ b/R/makeRepo.R @@ -76,7 +76,7 @@ makeRepo <- function(pkgs, path, repos=getOption("repos"), type="source", type=type, quiet=quiet) } }) - + downloaded <- sapply(downloaded, "[[", 2) fromLocalRepos <- grepl("^file://", repos) @@ -89,7 +89,6 @@ makeRepo <- function(pkgs, path, repos=getOption("repos"), type="source", downloaded <- newPath } - if(writePACKAGES) updateRepoIndex(path=path, type=type, Rversion=Rversion) if(download) downloaded else character(0) } diff --git a/tests/testthat/test-3-makeRepo.R b/tests/testthat/test-3-makeRepo.R index 0b7325b..03dec59 100644 --- a/tests/testthat/test-3-makeRepo.R +++ b/tests/testthat/test-3-makeRepo.R @@ -1,12 +1,12 @@ -if(interactive()) {library(testthat); Sys.setenv(NOT_CRAN="true")} +if (interactive()) {library(testthat); Sys.setenv(NOT_CRAN = "true")} context("makeRepo") - revolution <- MRAN("2014-10-15") +rvers = "3.2" pkgs <- c("Bmix") repo_root <- file.path(tempdir(), "miniCRAN", Sys.Date()) -if(file.exists(repo_root)) unlink(repo_root, recursive = TRUE) +if (file.exists(repo_root)) unlink(repo_root, recursive = TRUE) # list.files(repo_root, recursive = TRUE) @@ -14,20 +14,19 @@ if(file.exists(repo_root)) unlink(repo_root, recursive = TRUE) types <- c("source", "win.binary", "mac.binary", "mac.binary.mavericks") names(types) <- c("source", "win.binary", "mac.binary", "mac.binary") -for(pkg_type in names(types)){ - +for (pkg_type in names(types)) { test_that(sprintf("makeRepo downloads %s files and builds PACKAGES file", pkg_type), { - skip_on_cran() skip_if_offline() - - pdb <- pkgAvail(repos = revolution, type=pkg_type) - pkgList <- pkgDep(pkgs, availPkgs = pdb, repos=revolution, type=pkg_type, suggests=FALSE) - prefix <- miniCRAN:::repoPrefix(pkg_type, Rversion = "3.2") + + pdb <- pkgAvail(repos = revolution, type = pkg_type, Rversion = rvers) + pkgList <- pkgDep(pkgs, availPkgs = pdb, repos = revolution, type = pkg_type, + suggests = FALSE, Rversion = rvers) + prefix <- miniCRAN:::repoPrefix(pkg_type, Rversion = rvers) dir.create(repo_root, recursive = TRUE, showWarnings = FALSE) - - makeRepo(pkgList, path=repo_root, repos=revolution, type=pkg_type, quiet=TRUE) - + + makeRepo(pkgList, path = repo_root, repos = revolution, type = pkg_type, quiet = TRUE, Rversion = rvers) + expect_true( miniCRAN:::.checkForRepoFiles(repo_root, pkgList, prefix) ) @@ -36,15 +35,10 @@ for(pkg_type in names(types)){ ) expect_true( all( - pkgList %in% pkgAvail(repos = repo_root, type=pkg_type)[, "Package"] + pkgList %in% pkgAvail(repos = repo_root, type = pkg_type, Rversion = rvers)[, "Package"] ) ) - }) - } - - unlink(repo_root, recursive = TRUE) - diff --git a/tests/testthat/test-4-updateRepo.R b/tests/testthat/test-4-updateRepo.R index f7a4e5f..741acb5 100644 --- a/tests/testthat/test-4-updateRepo.R +++ b/tests/testthat/test-4-updateRepo.R @@ -1,4 +1,4 @@ -if(interactive()) {library(testthat); Sys.setenv(NOT_CRAN="true")} +if (interactive()) {library(testthat); Sys.setenv(NOT_CRAN = "true")} context("updateRepo") @@ -6,52 +6,52 @@ context("updateRepo") repo_root <- file.path(tempdir(), "miniCRAN", Sys.Date()) -if(file.exists(repo_root)) unlink(repo_root, recursive=TRUE) -dir.create(repo_root, recursive=TRUE, showWarnings=FALSE) +if (file.exists(repo_root)) unlink(repo_root, recursive = TRUE) +dir.create(repo_root, recursive = TRUE, showWarnings = FALSE) revolution <- MRAN("2014-10-15") +rvers <- "3.1" pkgs <- c("chron", "adaptivetau") types <- c("source", "win.binary", "mac.binary") names(types) <- types - test_that("sample repo is setup correctly", { skip_if_offline(revolution) - - pdb <<- lapply(types, pkgAvail, repos=revolution, Rversion = "3.1") - pkgList <<- lapply(types, function(type){ - pkgDep(pkg=pkgs, type=types[type], availPkgs=pdb[[type]], repos=revolution, suggests=FALSE, Rversion = "3.1") + + pdb <<- lapply(types, pkgAvail, repos = revolution, Rversion = rvers) + pkgList <<- lapply(types, function(type) { + pkgDep(pkg = pkgs, type = types[type], availPkgs = pdb[[type]], + repos = revolution, suggests = FALSE, Rversion = rvers) }) - - miniCRAN:::.createSampleRepo(path = repo_root, MRAN = revolution, Rversion = "3.1") + + miniCRAN:::.createSampleRepo(path = repo_root, MRAN = revolution, Rversion = rvers) expect_equal(unname(pkgAvail(repo_root)[, "Package"]), sort(pkgs)) }) - - # Add packages to repo ---------------------------------------------------- pkgsAdd <- c("aprof") -for(pkg_type in names(types)){ +for (pkg_type in names(types)) { context(sprintf(" - Add packages to repo (%s)", pkg_type)) - + test_that(sprintf("addPackage downloads %s files and rebuilds PACKAGES file", pkg_type), { skip_on_cran() skip_if_offline(revolution) - - pkgListAdd <- pkgDep(pkgsAdd, availPkgs=pdb[[pkg_type]], - repos = revolution, - type = pkg_type, - suggests = FALSE, - Rversion = "3.1") - prefix <- miniCRAN:::repoPrefix(pkg_type, Rversion = "3.1") - addPackage(pkgListAdd, path=repo_root, repos=revolution, type=pkg_type, quiet=TRUE, Rversion = "3.1") + pkgListAdd <- pkgDep(pkgsAdd, availPkgs = pdb[[pkg_type]], + repos = revolution, + type = pkg_type, + suggests = FALSE, + Rversion = rvers) + prefix <- miniCRAN:::repoPrefix(pkg_type, Rversion = rvers) + + addPackage(pkgListAdd, path = repo_root, repos = revolution, type = pkg_type, + quiet = TRUE, Rversion = rvers) expect_true( miniCRAN:::.checkForRepoFiles(repo_root, pkgListAdd, prefix) @@ -61,12 +61,10 @@ for(pkg_type in names(types)){ ) expect_true( all( - pkgListAdd %in% pkgAvail(repo_root, type=pkg_type, Rversion = "3.1")[, "Package"] + pkgListAdd %in% pkgAvail(repo_root, type = pkg_type, Rversion = rvers)[, "Package"] ) ) - }) - } @@ -76,25 +74,24 @@ for(pkg_type in names(types)){ MRAN_mirror <- MRAN("2014-12-01") - -for(pkg_type in names(types)){ - +for (pkg_type in names(types)) { context(sprintf(" - Check for updates (%s)", pkg_type)) - + test_that(sprintf("updatePackages downloads %s files and builds PACKAGES file", pkg_type), { skip_on_cran() skip_if_offline(MRAN_mirror) - prefix <- miniCRAN:::repoPrefix(pkg_type, Rversion = "3.1") + prefix <- miniCRAN:::repoPrefix(pkg_type, Rversion = rvers) - old <- oldPackages(path=repo_root, repos=MRAN_mirror, type=pkg_type, Rversion = "3.1") + old <- oldPackages(path = repo_root, repos = MRAN_mirror, type = pkg_type, Rversion = rvers) expect_equal(nrow(old), 2) expect_equal(ncol(old), 4) expect_equal(rownames(old), c("adaptivetau", "aprof")) - updatePackages(path=repo_root, repos=MRAN_mirror, type=pkg_type, ask=FALSE, quiet=TRUE, Rversion = "3.1") + updatePackages(path = repo_root, repos = MRAN_mirror, type = pkg_type, + ask = FALSE, quiet = TRUE, Rversion = rvers) updateVers <- miniCRAN:::getPkgVersFromFile(list.files(file.path(repo_root, prefix))) @@ -106,7 +103,7 @@ for(pkg_type in names(types)){ file.exists(file.path(repo_root, prefix, "PACKAGES.gz")) ) - old <- oldPackages(path=repo_root, repos=MRAN_mirror, type=pkg_type, Rversion = "3.1") + old <- oldPackages(path = repo_root, repos = MRAN_mirror, type = pkg_type, Rversion = rvers) # browser() expect_equal(nrow(old), 0) expect_equal(ncol(old), 4) @@ -119,26 +116,26 @@ for(pkg_type in names(types)){ context("Check for duplicate files") -for(pkg_type in names(types)){ +for (pkg_type in names(types)) { test_that(sprintf("checkVersions() finds out-of-date %s packages", pkg_type), { skip_on_cran() skip_if_offline(MRAN_mirror) - oldVersions <- list(package=c("aprof"), - version=c("0.2.1")) - if(pkg_type != "source"){ + oldVersions <- list(package = c("aprof"), + version = c("0.2.1")) + if (pkg_type != "source") { expect_error( - addOldPackage(oldVersions[["package"]], path=repo_root, vers=oldVersions[["version"]], - repos=MRAN_mirror, type=pkg_type) + addOldPackage(oldVersions[["package"]], path = repo_root, vers = oldVersions[["version"]], + repos = MRAN_mirror, type = pkg_type) ) } else { - addOldPackage(oldVersions[["package"]], path=repo_root, vers=oldVersions[["version"]], - repos=MRAN_mirror, type=pkg_type) + addOldPackage(oldVersions[["package"]], path = repo_root, vers = oldVersions[["version"]], + repos = MRAN_mirror, type = pkg_type) files <- suppressWarnings( - checkVersions(path=repo_root, type=pkg_type) - ) + checkVersions(path = repo_root, type = pkg_type) + ) expect_true( all(file.exists(files)) @@ -151,6 +148,5 @@ for(pkg_type in names(types)){ ) } - }) } From 70f268e6f97fd724aceea5a20dc802c334f4fc7c Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Sat, 25 Jun 2016 11:39:44 -0700 Subject: [PATCH 17/21] Return a character vector, regardless if download = TRUE or download = FALSE. #65 --- R/makeRepo.R | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/R/makeRepo.R b/R/makeRepo.R index d372c4b..a4fc075 100644 --- a/R/makeRepo.R +++ b/R/makeRepo.R @@ -76,17 +76,20 @@ makeRepo <- function(pkgs, path, repos=getOption("repos"), type="source", type=type, quiet=quiet) } }) - + + if(download){ + downloaded <- sapply(downloaded, "[[", 2) - - fromLocalRepos <- grepl("^file://", repos) - if(fromLocalRepos){ - # need to copy files to correct folder - repoPath <- gsub("^file:///", "", repos) - repoPath <- normalizePath(repoPath, winslash = "/") - newPath <- gsub(repoPath, normalizePath(path, winslash = "/"), downloaded) - file.copy(downloaded, newPath) - downloaded <- newPath + + fromLocalRepos <- grepl("^file://", repos) + if(fromLocalRepos){ + # need to copy files to correct folder + repoPath <- gsub("^file:///", "", repos) + repoPath <- normalizePath(repoPath, winslash = "/") + newPath <- gsub(repoPath, normalizePath(path, winslash = "/"), downloaded) + file.copy(downloaded, newPath) + downloaded <- newPath + } } if(writePACKAGES) updateRepoIndex(path=path, type=type, Rversion=Rversion) From 986b7f2cce4a8749ef8dbcf4a6dfdeec2426c7da Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Sat, 25 Jun 2016 19:05:23 -0700 Subject: [PATCH 18/21] Be consistent in returning paths. Added unit tests. #65 --- R/makeRepo.R | 24 ++++++++++++------------ R/testthat_helpers.R | 23 ++++++++++++++++++----- tests/testthat/test-1-pkgDep.R | 1 + tests/testthat/test-2-makeDepGraph.R | 6 ++++-- tests/testthat/test-3-makeRepo.R | 10 +++++++++- tests/testthat/test-4-updateRepo.R | 8 ++++++++ 6 files changed, 52 insertions(+), 20 deletions(-) diff --git a/R/makeRepo.R b/R/makeRepo.R index a4fc075..4603781 100644 --- a/R/makeRepo.R +++ b/R/makeRepo.R @@ -56,7 +56,7 @@ makeRepo <- function(pkgs, path, repos=getOption("repos"), type="source", Rversion=R.version, download=TRUE, writePACKAGES=TRUE, quiet=FALSE) { if(!file.exists(path)) stop("Download path does not exist") - + downloaded <- lapply(type, function(type) { pkgPath <- repoBinPath(path=path, type=type, Rversion=Rversion) if(!file.exists(pkgPath)) { @@ -67,9 +67,9 @@ makeRepo <- function(pkgs, path, repos=getOption("repos"), type="source", stop("Unable to create repo path: ", pkgPath) } } - + pdb <- pkgAvail(repos = repos, type=type, Rversion = Rversion) - + if(download) { utils::download.packages(pkgs, destdir=pkgPath, available=pdb, repos=repos, contriburl = contribUrl(repos, type, Rversion), @@ -79,8 +79,8 @@ makeRepo <- function(pkgs, path, repos=getOption("repos"), type="source", if(download){ - downloaded <- sapply(downloaded, "[[", 2) - + downloaded <- downloaded[[1]][, 2] + fromLocalRepos <- grepl("^file://", repos) if(fromLocalRepos){ # need to copy files to correct folder @@ -91,7 +91,7 @@ makeRepo <- function(pkgs, path, repos=getOption("repos"), type="source", downloaded <- newPath } } - + if(writePACKAGES) updateRepoIndex(path=path, type=type, Rversion=Rversion) if(download) downloaded else character(0) } @@ -121,11 +121,11 @@ updateRepoIndex <- function(path, type="source", Rversion=R.version) { makeLibrary <- function(pkgs, path, type="source"){ .Deprecated("makeRepo") NULL -# if(!file.exists(path)) stop("Download path does not exist") -# wd <- getwd() -# on.exit(setwd(wd)) -# setwd(normalizePath(path)) -# message(getwd()) -# download.packages(pkgs, destdir=path, type=type) + # if(!file.exists(path)) stop("Download path does not exist") + # wd <- getwd() + # on.exit(setwd(wd)) + # setwd(normalizePath(path)) + # message(getwd()) + # download.packages(pkgs, destdir=path, type=type) } diff --git a/R/testthat_helpers.R b/R/testthat_helpers.R index 0c31fc8..04aaf91 100644 --- a/R/testthat_helpers.R +++ b/R/testthat_helpers.R @@ -1,11 +1,24 @@ # helper functions for testing # Returns TRUE if a URL can be accessed -is.online <- function(url = MRAN()){ - z <- tryCatch(suppressWarnings(readLines(url, n = 10, warn = FALSE)), - error = function(e)e - ) - if(inherits(z, "error")) return(FALSE) +is.online <- function(url = MRAN(), tryHttp = TRUE){ + readFromUrl <- function(url){ + z <- tryCatch(suppressWarnings(readLines(url, n = 1, warn = FALSE)), + error = function(e)e + ) + !inherits(z, "error") + } + + if(!readFromUrl(url)){ + if(grepl("^https://", url) && tryHttp){ + url <- sub("^https://", "http://", url) # for older versions of R + if(!readFromUrl(url)) + return(FALSE) + } else { + return(FALSE) + } + } + TRUE } diff --git a/tests/testthat/test-1-pkgDep.R b/tests/testthat/test-1-pkgDep.R index 58c8ea9..bf6014a 100644 --- a/tests/testthat/test-1-pkgDep.R +++ b/tests/testthat/test-1-pkgDep.R @@ -1,3 +1,4 @@ +if(interactive()) library(testthat) context("pkgDep") diff --git a/tests/testthat/test-2-makeDepGraph.R b/tests/testthat/test-2-makeDepGraph.R index 23409a7..690835a 100644 --- a/tests/testthat/test-2-makeDepGraph.R +++ b/tests/testthat/test-2-makeDepGraph.R @@ -5,7 +5,9 @@ checkPkgDepFunctions <- function(pkg, availPkgs = cranJuly2014, enhances=FALSE, includeBasePkgs=FALSE){ - require(igraph, quietly = TRUE) + if(!require(igraph, quietly = TRUE)){ + skip("package igraph not installed") + } p1 <- pkgDep(pkg, availPkgs=availPkgs, repos=repos, type=type, suggests=suggests, enhances=enhances, @@ -14,7 +16,7 @@ checkPkgDepFunctions <- function(pkg, availPkgs = cranJuly2014, repos=repos, type=type, suggests=suggests, enhances=enhances, includeBasePkgs=includeBasePkgs) - + vnames <- V(p2)$name diff1 <- setdiff(vnames, p1) diff2 <- setdiff(p1, vnames) diff --git a/tests/testthat/test-3-makeRepo.R b/tests/testthat/test-3-makeRepo.R index 03dec59..fd9006f 100644 --- a/tests/testthat/test-3-makeRepo.R +++ b/tests/testthat/test-3-makeRepo.R @@ -3,6 +3,10 @@ if (interactive()) {library(testthat); Sys.setenv(NOT_CRAN = "true")} context("makeRepo") revolution <- MRAN("2014-10-15") +if(!miniCRAN:::is.online(revolution, tryHttp = FALSE)) { + # Use http:// for older versions of R + revolution <- sub("^https://", "http://", revolution) +} rvers = "3.2" pkgs <- c("Bmix") repo_root <- file.path(tempdir(), "miniCRAN", Sys.Date()) @@ -25,7 +29,11 @@ for (pkg_type in names(types)) { prefix <- miniCRAN:::repoPrefix(pkg_type, Rversion = rvers) dir.create(repo_root, recursive = TRUE, showWarnings = FALSE) - makeRepo(pkgList, path = repo_root, repos = revolution, type = pkg_type, quiet = TRUE, Rversion = rvers) + ret <- makeRepo(pkgList, path = repo_root, repos = revolution, + type = pkg_type, quiet = TRUE, Rversion = rvers) + + expect_is(ret, "character") + expect_equal(length(ret), length(pkgList)) expect_true( miniCRAN:::.checkForRepoFiles(repo_root, pkgList, prefix) diff --git a/tests/testthat/test-4-updateRepo.R b/tests/testthat/test-4-updateRepo.R index 741acb5..b41ea0b 100644 --- a/tests/testthat/test-4-updateRepo.R +++ b/tests/testthat/test-4-updateRepo.R @@ -10,6 +10,10 @@ if (file.exists(repo_root)) unlink(repo_root, recursive = TRUE) dir.create(repo_root, recursive = TRUE, showWarnings = FALSE) revolution <- MRAN("2014-10-15") +if(!miniCRAN:::is.online(revolution, tryHttp = FALSE)) { + # Use http:// for older versions of R + revolution <- sub("^https://", "http://", revolution) +} rvers <- "3.1" pkgs <- c("chron", "adaptivetau") @@ -73,6 +77,10 @@ for (pkg_type in names(types)) { MRAN_mirror <- MRAN("2014-12-01") +if(!miniCRAN:::is.online(MRAN_mirror, tryHttp = FALSE)) { + # Use http:// for older versions of R + MRAN_mirror <- sub("^https://", "http://", revolution) +} for (pkg_type in names(types)) { context(sprintf(" - Check for updates (%s)", pkg_type)) From ffd8829b48d25c33d3cc216d9a6d572f43a541c1 Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Sun, 26 Jun 2016 05:39:46 -0700 Subject: [PATCH 19/21] Add unit tests for installing from local CRAN. #76 --- .../test-3b-makeRepo-from-localCRAN.R | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 tests/testthat/test-3b-makeRepo-from-localCRAN.R diff --git a/tests/testthat/test-3b-makeRepo-from-localCRAN.R b/tests/testthat/test-3b-makeRepo-from-localCRAN.R new file mode 100644 index 0000000..32d62e5 --- /dev/null +++ b/tests/testthat/test-3b-makeRepo-from-localCRAN.R @@ -0,0 +1,83 @@ +if (interactive()) {library(testthat); Sys.setenv(NOT_CRAN = "true")} + +context("makeRepo from local miniCRAN") + +revolution <- MRAN("2014-10-15") +if(!miniCRAN:::is.online(revolution, tryHttp = FALSE)) { + # Use http:// for older versions of R + revolution <- sub("^https://", "http://", revolution) +} +rvers = "3.2" +pkgs <- c("MASS") +repo_root <- file.path(tempdir(), "miniCRAN", Sys.Date()) +if (file.exists(repo_root)) unlink(repo_root, recursive = TRUE) + +# list.files(repo_root, recursive = TRUE) + + +types <- c("win.binary") +names(types) <- c("win.binary") + +for (pkg_type in names(types)) { + test_that(sprintf("makeRepo downloads %s files and builds PACKAGES file", pkg_type), { + # skip_on_cran() + skip_if_offline() + + # Create local miniCRAN + + pdb <- pkgAvail(repos = revolution, type = pkg_type, Rversion = rvers) + pkgList <- pkgDep(pkgs, availPkgs = pdb, repos = revolution, type = pkg_type, + suggests = FALSE, Rversion = rvers) + prefix <- miniCRAN:::repoPrefix(pkg_type, Rversion = rvers) + dir.create(repo_root, recursive = TRUE, showWarnings = FALSE) + + ret <- makeRepo(pkgList, path = repo_root, repos = revolution, + type = pkg_type, quiet = TRUE, Rversion = rvers) + + expect_is(ret, "character") + expect_equal(length(ret), length(pkgList)) + + expect_true( + miniCRAN:::.checkForRepoFiles(repo_root, pkgList, prefix) + ) + expect_true( + file.exists(file.path(repo_root, prefix, "PACKAGES.gz")) + ) + expect_true( + all( + pkgList %in% pkgAvail(repos = repo_root, type = pkg_type, Rversion = rvers)[, "Package"] + ) + ) + + # Create miniCRAN from existing miniCRAN + + localCRAN <- paste0("file:///", repo_root) + + pdb <- pkgAvail(repos = localCRAN, type = pkg_type, Rversion = rvers) + pkgList <- pkgDep(pkgs, availPkgs = pdb, repos = localCRAN, type = pkg_type, + suggests = FALSE, Rversion = rvers) + prefix <- miniCRAN:::repoPrefix(pkg_type, Rversion = rvers) + dir.create(repo_root, recursive = TRUE, showWarnings = FALSE) + + ret <- makeRepo(pkgList, path = repo_root, repos = localCRAN, + type = pkg_type, quiet = TRUE, Rversion = rvers) + + expect_is(ret, "character") + expect_equal(length(ret), length(pkgList)) + + expect_true( + miniCRAN:::.checkForRepoFiles(repo_root, pkgList, prefix) + ) + expect_true( + file.exists(file.path(repo_root, prefix, "PACKAGES.gz")) + ) + expect_true( + all( + pkgList %in% pkgAvail(repos = repo_root, type = pkg_type, Rversion = rvers)[, "Package"] + ) + ) + + }) +} + +unlink(repo_root, recursive = TRUE) From b9fcfa54a282bcc82b4d1c4d3ac57ff91afa8592 Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Sun, 26 Jun 2016 05:55:58 -0700 Subject: [PATCH 20/21] Update NEWS --- NEWS | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index cac30b4..1841928 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,9 @@ -miniCRAN v0.2-6 (Release date: 2016-06-23) +miniCRAN v0.2-6 (Release date: 2016-06-26) ============== -* fix bug in `addPackage` +* allow using `makeRepo()` to create a miniCRAN repo from an existing local miniCRAN, i.e. the repos contains file:/// prefix. This enables a use case in the AzureML package. (#76) +* easily manage packages for all three Operating Systems (#24) +* fix inconsistent use of Rversion in `addPackage()` (#42) miniCRAN v0.2-5 (Release date: 2016-04-12) From cc7ff6e3bf9b273debf9feec6fc17e91fa8c5b64 Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Sun, 26 Jun 2016 05:56:12 -0700 Subject: [PATCH 21/21] Bump version to 0.2.6 --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b09b473..8b56c9d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -14,10 +14,10 @@ Description: Makes it possible to create an internally consistent subset. The user can then install packages from this repository directly, rather than from CRAN. This is useful in production settings, e.g. server behind a firewall, or remote locations with slow broadband access. -Version: 0.2.5 +Version: 0.2.6 URL: https://github.com/RevolutionAnalytics/miniCRAN BugReports: https://github.com/RevolutionAnalytics/miniCRAN/issues -Date: 2016-04-12 +Date: 2016-06-26 Imports: tools, XML,