From caed9484853ca2d84b324458bb10de2a26969c0e Mon Sep 17 00:00:00 2001 From: ryanatanner Date: Fri, 11 Aug 2017 09:32:33 -0600 Subject: [PATCH 01/11] Fixing typos --- vignettes/miniCRAN-dependency-graph.rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/miniCRAN-dependency-graph.rmd b/vignettes/miniCRAN-dependency-graph.rmd index 71e30b9..b83a317 100644 --- a/vignettes/miniCRAN-dependency-graph.rmd +++ b/vignettes/miniCRAN-dependency-graph.rmd @@ -31,7 +31,7 @@ The package `chron` neatly illustrates the different roles of Imports, Suggests ## A worked example using the package chron -The function `pkgDep()` exposes not only these dependencies, but also also all recursive dependencies. In other words, it answers the question which packages need to be installed to satsify all dependencies of dependencies. +The function `pkgDep()` exposes not only these dependencies, but also all recursive dependencies. In other words, it answers the question which packages need to be installed to satisfy all dependencies of dependencies. This means that the algorithm is as follows: From 1c2d0998ad36555da3f681cbcfb43d6bf597b039 Mon Sep 17 00:00:00 2001 From: ryanatanner Date: Fri, 11 Aug 2017 09:35:49 -0600 Subject: [PATCH 02/11] Fixing typo in non-CRAN vignette --- vignettes/miniCRAN-non-CRAN-repos.rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/miniCRAN-non-CRAN-repos.rmd b/vignettes/miniCRAN-non-CRAN-repos.rmd index 65db507..c753aa6 100644 --- a/vignettes/miniCRAN-non-CRAN-repos.rmd +++ b/vignettes/miniCRAN-non-CRAN-repos.rmd @@ -18,7 +18,7 @@ Although the package name `miniCRAN` seems to indicate you can only use CRAN as This vignette contains some examples of how to refer to different package repositories, including CRAN, alternative mirrors of CRAN, R-Forge as well as BioConductor. -To make simplify the code to show the salient features, we use a little helper function, `index()` that is a simple wrapper around `available.packages()`: +To simplify the code to show the salient features, we use a little helper function, `index()` that is a simple wrapper around `available.packages()`: ```{r setup} From aeda34068ff9fd3f9654f3e83fe43ddbda488f71 Mon Sep 17 00:00:00 2001 From: Alex Chubaty Date: Fri, 11 Aug 2017 10:14:16 -0600 Subject: [PATCH 03/11] update NEWS --- NEWS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS b/NEWS index cbe5fa6..3522402 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +miniCRAN v0.2.10 +================ + +* fixed typos in vignettes (@ryanatanner PR#93 and PR#94) + miniCRAN v0.2.9 (Release date: 2017-07-20) =============== From d521aa65ff24f5375a3154f37307e77b9796b235 Mon Sep 17 00:00:00 2001 From: Alex Chubaty Date: Fri, 11 Aug 2017 10:48:31 -0600 Subject: [PATCH 04/11] add MRAN url as package option (close #72) Note: use http instead of https for R < 3.2.2 --- R/MRAN.R | 10 ++-- R/getCranDescription.R | 22 ++++--- R/minicran-package.R | 57 ++++++++++--------- R/zzz.R | 18 ++++++ .../example_addPackageListingGithub.R | 8 +-- inst/examples/example_checkVersions.R | 2 +- inst/examples/example_getCranDescription.R | 4 +- inst/examples/example_makeDepGraph.R | 10 ++-- inst/examples/example_makeRepo.R | 4 +- inst/examples/example_pkgDep.R | 6 +- inst/examples/example_plot.pkgDepGraph.R | 10 ++-- inst/examples/example_rsynctools.R | 2 +- inst/examples/example_updatePackages.R | 2 +- man/addOldPackage.Rd | 2 +- man/addPackage.Rd | 2 +- man/addPackageListingGithub.Rd | 8 +-- man/checkVersions.Rd | 2 +- man/getCranDescription.Rd | 4 +- man/makeDepGraph.Rd | 10 ++-- man/makeRepo.Rd | 4 +- man/miniCRAN-package.Rd | 9 +++ man/pkgDep.Rd | 6 +- man/plot.pkgDepGraph.Rd | 10 ++-- man/updatePackages.Rd | 2 +- tests/testthat/test-6-getCranDescription.R | 8 +-- tests/testthat/test-7-addGithubPackage.R | 11 ++-- 26 files changed, 130 insertions(+), 103 deletions(-) diff --git a/R/MRAN.R b/R/MRAN.R index aba929c..c4aab4c 100644 --- a/R/MRAN.R +++ b/R/MRAN.R @@ -1,9 +1,9 @@ -MRAN <- function(snapshot){ - url <- "https://mran.microsoft.com" - if(missing("snapshot") || is.null(snapshot)){ - url +MRAN <- function(snapshot) { + url <- getOption("minicran.mran") + if (missing("snapshot") || is.null(snapshot)) { + url } else { sprintf("%s/snapshot/%s", url, snapshot) } } -CRAN <- function()getOption("repos")[1] +CRAN <- function() getOption("repos")[1] diff --git a/R/getCranDescription.R b/R/getCranDescription.R index d55bef1..bb8e34d 100644 --- a/R/getCranDescription.R +++ b/R/getCranDescription.R @@ -1,13 +1,13 @@ #' @importFrom XML readHTMLTable -oldGetCranDescription <- function(pkg, repos = getOption("repos"), - type = "source", +oldGetCranDescription <- function(pkg, repos = getOption("repos"), + type = "source", pkgs = pkgDep(pkg, repos = repos, type = type)){ getOne <- function(package) { repos <- repos[[1]] if(!grepl("/$", repos)) repos <- paste0(repos, "/") - - url <- gsub("https://", "http://", + + url <- gsub("https://", "http://", sprintf("%sweb/packages/%s/index.html", repos, package) ) x <- tryCatch({ @@ -36,20 +36,18 @@ oldGetCranDescription <- function(pkg, repos = getOption("repos"), #' #' @inheritParams pkgDep #' @inheritParams makeRepo -#' +#' #' @export -#' +#' #' @example /inst/examples/example_getCranDescription.R -getCranDescription <- function(pkg, repos = getOption("repos"), - type = "source", +getCranDescription <- function(pkg, repos = getOption("repos"), + type = "source", pkgs = pkgDep(pkg, repos = repos, type = type)){ - - if(getRversion() >= "3.4.1"){ + + if (getRversion() >= "3.4.1"){ pdb <- tools::CRAN_package_db() pdb[match(pkgs, pdb$Package), ] } else { oldGetCranDescription(pkg = pkg, repos = repos, type = type, pkgs = pkgs) } } - - diff --git a/R/minicran-package.R b/R/minicran-package.R index 805012b..c3e4f99 100644 --- a/R/minicran-package.R +++ b/R/minicran-package.R @@ -7,53 +7,58 @@ #' #'@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. -#' -#' `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. -#' -#' +#' 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. +#' +#' `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 `rsync`: #' #' * You may wish to mirror only a subset of CRAN, for security, legal compliance or any other in-house reason #' * You may wish to restrict internal package use to a subset of public packages, to minimize package duplication, or other reasons of coding standards #' * You may wish to make packages available from public repositories other than CRAN, e.g. BioConductor, r-forge, OmegaHat, etc. #' * You may wish to add custom in-house packages to your repository -#' +#' #' The ambition of `miniCRAN` is to eventually satisfy all of these considerations. -#' +#' #' @section Making a private repo: -#' +#' #' * [pkgAvail()]: Read from a local (or remote) CRAN-like repository and determine available packages. #' * [pkgDep()]: Find (recursive) package dependencies. #' * [makeRepo()] : Make a mini CRAN repository, by downloading packages (and their dependencies) and creating the appropriate file structure for a repository. This allows you to use functions like [utils::available.packages()] and [utils::install.packages()] on your local repository. -#' +#' #' This subset will be internally consistent, i.e. the following functions will work as expected: #' * [utils::available.packages()] #' * [utils::install.packages()] -#' +#' #' The main function is [makeRepo()] - this will download all the required packages, with their dependencies, into the appropriate repository file structure, and then create the repository index (PACKAGES) file. -#' -#' -#' +#' +#' +#' #' @section Updating packages in a repo: -#' +#' #' * [oldPackages()]: Indicates packages which have a (suitable) later version on the repositories #' * [updatePackages()]: Offers to download and install such packages -#' -#' -#' +#' +#' +#' #' @section Creating dependencies: -#' +#' #' To get a recursive list of dependencies as well as a plot, use [pkgDep()] followed by [makeDepGraph()]. -#' +#' #' * [pkgDep()]: Find (recursive) package dependencies. #' * [makeDepGraph()]: Create graph of selected package dependencies. #' * [plot.pkgDepGraph()]: Create a visualization of the dependency graph -#' -#' -#' -#' -#' +#' +#' +#' +#' @section Package options: +#' +#' \describe{ +#' \item{\code{minicran.mran}}{preferred MRAN URL. Defaults to \url{https://mran.microsoft.com} +#' for R versions 3.2.2 and greater. Versions earlier than 3.2.2 use HTTP instead of HTTPS.} +#' } +#' #' @name miniCRAN-package #' @aliases miniCRAN minicran #' @docType package @@ -69,9 +74,9 @@ NULL # data documentation ------------------------------------------------------ #' Stored version of available.packages() -#' +#' #' Copy of the result of [utils::available.packages()] on July 1, 2014. -#' +#' #' @docType data #' @keywords datasets #' @name cranJuly2014 diff --git a/R/zzz.R b/R/zzz.R index fedb65a..77d760e 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -1,2 +1,20 @@ # globals <- new.env(parent=emptyenv(), hash=TRUE) # globals$have_RCurl <- require("RCurl") + +.onLoad <- function(libname, pkgname) { + mran.url <- if (getRversion() >= "3.2.2") { + "https://mran.microsoft.com" ## use HTTPS + } else { + "http://mran.microsoft.com" ## use HTTP + } + + ## set options using the approach used by devtools + opts <- options() + opts.miniCRAN <- list( + minicran.mran = mran.url + ) + toset <- !(names(opts.miniCRAN) %in% names(opts)) + if (any(toset)) options(opts.miniCRAN[toset]) + + invisible() +} diff --git a/inst/examples/example_addPackageListingGithub.R b/inst/examples/example_addPackageListingGithub.R index a1d7fa3..bc9671e 100644 --- a/inst/examples/example_addPackageListingGithub.R +++ b/inst/examples/example_addPackageListingGithub.R @@ -2,16 +2,16 @@ pdb <- cranJuly2014 \dontrun{ - pdb <- pkgAvail(repos = c(CRAN = "http://mran.microsoft.com")) - + pdb <- pkgAvail(repos = c(CRAN = getOption("minicran.mran"))) + # Overwrite pdb with development version of miniCRAN at github newpdb <- addPackageListingGithub(pdb = pdb, "andrie/miniCRAN") newpdb["miniCRAN", ] - + # Add package from github that's not currently on CRAN newpdb <- addPackageListingGithub(pdb = pdb, repo = "RevolutionAnalytics/checkpoint") newpdb["checkpoint", ] - + set.seed(1) plot(makeDepGraph("checkpoint", availPkgs = newpdb, suggests = TRUE)) } diff --git a/inst/examples/example_checkVersions.R b/inst/examples/example_checkVersions.R index e36c4f0..77a45a1 100644 --- a/inst/examples/example_checkVersions.R +++ b/inst/examples/example_checkVersions.R @@ -1,7 +1,7 @@ ### `checkVersions` and `add.packages.miniCRAN` require an existing miniCRAN repo # Specify list of packages to download -revolution <- c(CRAN = "http://mran.microsoft.com") +revolution <- c(CRAN = getOption("miniCRAN.mran")) pkgs <- c("foreach") pkgTypes <- c("source", "win.binary") diff --git a/inst/examples/example_getCranDescription.R b/inst/examples/example_getCranDescription.R index a4cd812..2c3a4ff 100644 --- a/inst/examples/example_getCranDescription.R +++ b/inst/examples/example_getCranDescription.R @@ -1,5 +1,5 @@ \dontrun{ -getCranDescription(c("igraph", "ggplot2", "XML"), - repos = c(CRAN = "http://mran.microsoft.com") +getCranDescription(c("igraph", "ggplot2", "XML"), + repos = c(CRAN = getOption("minicran.mran")) ) } diff --git a/inst/examples/example_makeDepGraph.R b/inst/examples/example_makeDepGraph.R index 8f3d3e6..39f4a4b 100644 --- a/inst/examples/example_makeDepGraph.R +++ b/inst/examples/example_makeDepGraph.R @@ -5,7 +5,7 @@ availPkgs <- cranJuly2014 \dontrun{ availPkgs <- pkgAvail( - repos = c(CRAN = "http://mran.microsoft.com"), + repos = c(CRAN = getOption("minicran.mran")), type = "source" ) } @@ -13,7 +13,7 @@ availPkgs <- pkgAvail( # Create dependency graph using stored database of available packages p <- makeDepGraph( - c("ggplot2", "forecast"), + c("ggplot2", "forecast"), availPkgs = availPkgs ) @@ -23,10 +23,10 @@ if(require(igraph)) plot(p) \dontrun{ # Create dependency graph using newly retrieved database from CRAN - + p <- makeDepGraph( - c("ggplot2", "forecast"), - repos = c(CRAN = "http://mran.microsoft.com"), + c("ggplot2", "forecast"), + repos = c(CRAN = getOption("minicran.mran")), type = "source" ) if(require(igraph)) plot(p) diff --git a/inst/examples/example_makeRepo.R b/inst/examples/example_makeRepo.R index a053b6b..1f8a2df 100644 --- a/inst/examples/example_makeRepo.R +++ b/inst/examples/example_makeRepo.R @@ -1,13 +1,13 @@ # Specify list of packages to download -revolution <- c(CRAN = "http://mran.microsoft.com") +revolution <- c(CRAN = getOption("minicran.mran")) pkgs <- c("foreach") pdb <- cranJuly2014 \dontrun{ pdb <- pkgAvail( - repos = c(CRAN = "http://mran.microsoft.com"), + repos = c(CRAN = getOption("minicran.mran")), type = "source" ) } diff --git a/inst/examples/example_pkgDep.R b/inst/examples/example_pkgDep.R index e177563..23c1550 100644 --- a/inst/examples/example_pkgDep.R +++ b/inst/examples/example_pkgDep.R @@ -1,13 +1,13 @@ \dontrun{ -pkgDep(pkg = c("ggplot2", "plyr", "reshape2"), - repos = c(CRAN = "http://mran.microsoft.com") +pkgDep(pkg = c("ggplot2", "plyr", "reshape2"), + repos = c(CRAN = getOption("minicran.mran")) ) } pdb <- cranJuly2014 \dontrun{ -pdb <- pkgAvail(repos = c(CRAN = "http://mran.microsoft.com")) +pdb <- pkgAvail(repos = c(CRAN = getOption("minicran.mran"))) } pkgDep(pkg = c("ggplot2", "plyr", "reshape2"), pdb) diff --git a/inst/examples/example_plot.pkgDepGraph.R b/inst/examples/example_plot.pkgDepGraph.R index e89a992..c1616a7 100644 --- a/inst/examples/example_plot.pkgDepGraph.R +++ b/inst/examples/example_plot.pkgDepGraph.R @@ -5,7 +5,7 @@ pdb <- cranJuly2014 \dontrun{ pdb <- pkgAvail( - repos = c(CRAN = "http://mran.microsoft.com"), + repos = c(CRAN = getOption("minicran.mran")), type = "source" ) } @@ -13,19 +13,19 @@ pdb <- cranJuly2014 dg <- makeDepGraph(tags, availPkgs = pdb , includeBasePkgs = FALSE, suggests = TRUE, enhances = TRUE) -set.seed(42); +set.seed(42); plot(dg) # Move edge legend to top left -set.seed(42); +set.seed(42); plot(dg, legendPosition = c(-1, 1)) # Change font size and shape size -set.seed(42); +set.seed(42); plot(dg, legendPosition = c(-1, 1), vertex.size = 20, cex = 0.5) # Move vertex legend to top right -set.seed(42); +set.seed(42); plot(dg, legendPosition = c(1, 1), vertex.size = 20, cex = 0.5) diff --git a/inst/examples/example_rsynctools.R b/inst/examples/example_rsynctools.R index d347487..f30e95a 100644 --- a/inst/examples/example_rsynctools.R +++ b/inst/examples/example_rsynctools.R @@ -1,4 +1,4 @@ \dontrun{ pkgs <- c("ggplot2", "plyr", "reshape2") - makeRsyncInclude(pkgs, type = "source", repos = c(CRAN = "http://mran.microsoft.com")) + makeRsyncInclude(pkgs, type = "source", repos = c(CRAN = getOption("minicran.mran"))) } diff --git a/inst/examples/example_updatePackages.R b/inst/examples/example_updatePackages.R index 1d9fdb1..8f1e311 100644 --- a/inst/examples/example_updatePackages.R +++ b/inst/examples/example_updatePackages.R @@ -1,7 +1,7 @@ ### `oldPackages` and `updatePackages` require an existing miniCRAN repo # Specify list of packages to download -revolution <- c(CRAN = "http://mran.microsoft.com") +revolution <- c(CRAN = getOption("minicran.mran")) pkgs <- c("foreach") pdb <- cranJuly2014 diff --git a/man/addOldPackage.Rd b/man/addOldPackage.Rd index 010a607..ae3bbd0 100644 --- a/man/addOldPackage.Rd +++ b/man/addOldPackage.Rd @@ -40,7 +40,7 @@ Dependencies for old package versions cannot be determined automatically and mus ### `checkVersions` and `add.packages.miniCRAN` require an existing miniCRAN repo # Specify list of packages to download -revolution <- c(CRAN = "http://mran.microsoft.com") +revolution <- c(CRAN = getOption("miniCRAN.mran")) pkgs <- c("foreach") pkgTypes <- c("source", "win.binary") diff --git a/man/addPackage.Rd b/man/addPackage.Rd index c79587c..fdbd53e 100644 --- a/man/addPackage.Rd +++ b/man/addPackage.Rd @@ -35,7 +35,7 @@ Add packages to a miniCRAN repository. ### `checkVersions` and `add.packages.miniCRAN` require an existing miniCRAN repo # Specify list of packages to download -revolution <- c(CRAN = "http://mran.microsoft.com") +revolution <- c(CRAN = getOption("miniCRAN.mran")) pkgs <- c("foreach") pkgTypes <- c("source", "win.binary") diff --git a/man/addPackageListingGithub.Rd b/man/addPackageListingGithub.Rd index 8edb53d..bfbf12b 100644 --- a/man/addPackageListingGithub.Rd +++ b/man/addPackageListingGithub.Rd @@ -24,16 +24,16 @@ Downloads the DESCRIPTION file from a package on github, parses the fields and a pdb <- cranJuly2014 \dontrun{ - pdb <- pkgAvail(repos = c(CRAN = "http://mran.microsoft.com")) - + pdb <- pkgAvail(repos = c(CRAN = getOption("minicran.mran"))) + # Overwrite pdb with development version of miniCRAN at github newpdb <- addPackageListingGithub(pdb = pdb, "andrie/miniCRAN") newpdb["miniCRAN", ] - + # Add package from github that's not currently on CRAN newpdb <- addPackageListingGithub(pdb = pdb, repo = "RevolutionAnalytics/checkpoint") newpdb["checkpoint", ] - + set.seed(1) plot(makeDepGraph("checkpoint", availPkgs = newpdb, suggests = TRUE)) } diff --git a/man/checkVersions.Rd b/man/checkVersions.Rd index 4af2670..158ef2d 100644 --- a/man/checkVersions.Rd +++ b/man/checkVersions.Rd @@ -26,7 +26,7 @@ Checks for previous versions, and returns the file paths for packages with multi ### `checkVersions` and `add.packages.miniCRAN` require an existing miniCRAN repo # Specify list of packages to download -revolution <- c(CRAN = "http://mran.microsoft.com") +revolution <- c(CRAN = getOption("miniCRAN.mran")) pkgs <- c("foreach") pkgTypes <- c("source", "win.binary") diff --git a/man/getCranDescription.Rd b/man/getCranDescription.Rd index c8e139d..71612a9 100644 --- a/man/getCranDescription.Rd +++ b/man/getCranDescription.Rd @@ -21,8 +21,8 @@ Scrape DESCRIPTION from CRAN for each pkg. } \examples{ \dontrun{ -getCranDescription(c("igraph", "ggplot2", "XML"), - repos = c(CRAN = "http://mran.microsoft.com") +getCranDescription(c("igraph", "ggplot2", "XML"), + repos = c(CRAN = getOption("minicran.mran")) ) } } diff --git a/man/makeDepGraph.Rd b/man/makeDepGraph.Rd index bee10bc..580764e 100644 --- a/man/makeDepGraph.Rd +++ b/man/makeDepGraph.Rd @@ -35,7 +35,7 @@ availPkgs <- cranJuly2014 \dontrun{ availPkgs <- pkgAvail( - repos = c(CRAN = "http://mran.microsoft.com"), + repos = c(CRAN = getOption("minicran.mran")), type = "source" ) } @@ -43,7 +43,7 @@ availPkgs <- pkgAvail( # Create dependency graph using stored database of available packages p <- makeDepGraph( - c("ggplot2", "forecast"), + c("ggplot2", "forecast"), availPkgs = availPkgs ) @@ -53,10 +53,10 @@ if(require(igraph)) plot(p) \dontrun{ # Create dependency graph using newly retrieved database from CRAN - + p <- makeDepGraph( - c("ggplot2", "forecast"), - repos = c(CRAN = "http://mran.microsoft.com"), + c("ggplot2", "forecast"), + repos = c(CRAN = getOption("minicran.mran")), type = "source" ) if(require(igraph)) plot(p) diff --git a/man/makeRepo.Rd b/man/makeRepo.Rd index 77df776..7fff26f 100644 --- a/man/makeRepo.Rd +++ b/man/makeRepo.Rd @@ -70,14 +70,14 @@ The folder structure of a repository \examples{ # Specify list of packages to download -revolution <- c(CRAN = "http://mran.microsoft.com") +revolution <- c(CRAN = getOption("minicran.mran")) pkgs <- c("foreach") pdb <- cranJuly2014 \dontrun{ pdb <- pkgAvail( - repos = c(CRAN = "http://mran.microsoft.com"), + repos = c(CRAN = getOption("minicran.mran")), type = "source" ) } diff --git a/man/miniCRAN-package.Rd b/man/miniCRAN-package.Rd index ef95e7d..49d8590 100644 --- a/man/miniCRAN-package.Rd +++ b/man/miniCRAN-package.Rd @@ -57,6 +57,15 @@ To get a recursive list of dependencies as well as a plot, use \code{\link[=pkgD } } +\section{Package options}{ + + +\describe{ +\item{\code{minicran.mran}}{preferred MRAN URL. Defaults to \url{https://mran.microsoft.com} +for R versions 3.2.2 and greater. Versions earlier than 3.2.2 use HTTP instead of HTTPS.} +} +} + \author{ Andrie de Vries \email{adevries@microsoft.com} with contributions from Alex Chubaty \email{alex.chubaty@gmail.com} } diff --git a/man/pkgDep.Rd b/man/pkgDep.Rd index ff2a6fc..b02ee3b 100644 --- a/man/pkgDep.Rd +++ b/man/pkgDep.Rd @@ -37,14 +37,14 @@ Performs recursive retrieve for \code{Depends}, \code{Imports} and \code{LinkLib \examples{ \dontrun{ -pkgDep(pkg = c("ggplot2", "plyr", "reshape2"), - repos = c(CRAN = "http://mran.microsoft.com") +pkgDep(pkg = c("ggplot2", "plyr", "reshape2"), + repos = c(CRAN = getOption("minicran.mran")) ) } pdb <- cranJuly2014 \dontrun{ -pdb <- pkgAvail(repos = c(CRAN = "http://mran.microsoft.com")) +pdb <- pkgAvail(repos = c(CRAN = getOption("minicran.mran"))) } pkgDep(pkg = c("ggplot2", "plyr", "reshape2"), pdb) diff --git a/man/plot.pkgDepGraph.Rd b/man/plot.pkgDepGraph.Rd index 0fa6e97..7826eb0 100644 --- a/man/plot.pkgDepGraph.Rd +++ b/man/plot.pkgDepGraph.Rd @@ -36,7 +36,7 @@ pdb <- cranJuly2014 \dontrun{ pdb <- pkgAvail( - repos = c(CRAN = "http://mran.microsoft.com"), + repos = c(CRAN = getOption("minicran.mran")), type = "source" ) } @@ -44,20 +44,20 @@ pdb <- cranJuly2014 dg <- makeDepGraph(tags, availPkgs = pdb , includeBasePkgs = FALSE, suggests = TRUE, enhances = TRUE) -set.seed(42); +set.seed(42); plot(dg) # Move edge legend to top left -set.seed(42); +set.seed(42); plot(dg, legendPosition = c(-1, 1)) # Change font size and shape size -set.seed(42); +set.seed(42); plot(dg, legendPosition = c(-1, 1), vertex.size = 20, cex = 0.5) # Move vertex legend to top right -set.seed(42); +set.seed(42); plot(dg, legendPosition = c(1, 1), vertex.size = 20, cex = 0.5) } diff --git a/man/updatePackages.Rd b/man/updatePackages.Rd index 3826046..6bff031 100644 --- a/man/updatePackages.Rd +++ b/man/updatePackages.Rd @@ -53,7 +53,7 @@ These functions are based on \code{\link[=update.packages]{update.packages()}}. ### `oldPackages` and `updatePackages` require an existing miniCRAN repo # Specify list of packages to download -revolution <- c(CRAN = "http://mran.microsoft.com") +revolution <- c(CRAN = getOption("minicran.mran")) pkgs <- c("foreach") pdb <- cranJuly2014 diff --git a/tests/testthat/test-6-getCranDescription.R b/tests/testthat/test-6-getCranDescription.R index 94b409b..7e5606c 100644 --- a/tests/testthat/test-6-getCranDescription.R +++ b/tests/testthat/test-6-getCranDescription.R @@ -1,12 +1,10 @@ -if(interactive()) library(testthat) +if (interactive()) library(testthat) context("get CRAN description") test_that("can read CRAN description", { - + skip_on_cran() - p <- getCranDescription("miniCRAN", repos = c(CRAN = "https://mran.microsoft.com")) + p <- getCranDescription("miniCRAN", repos = c(CRAN = getOption("minicran.mran"))) expect_is(p, "data.frame") expect_equal(p$Package[1], "miniCRAN") - }) - diff --git a/tests/testthat/test-7-addGithubPackage.R b/tests/testthat/test-7-addGithubPackage.R index 10eca95..4135f96 100644 --- a/tests/testthat/test-7-addGithubPackage.R +++ b/tests/testthat/test-7-addGithubPackage.R @@ -1,13 +1,13 @@ -if(interactive()) library(testthat) +if (interactive()) library(testthat) context("pkgDep") test_that("can add package from github",{ - + skip_on_cran() - pdb <- pkgAvail(repos = c(CRAN = "http://mran.microsoft.com")) + pdb <- pkgAvail(repos = c(CRAN = getOption("minicran.mran"))) expect_is(pdb, "matrix") - + # Overwrite pdb with development version of miniCRAN at github expect_warning( newpdb <- addPackageListingGithub(pdb = pdb, "andrie/miniCRAN"), @@ -16,5 +16,4 @@ test_that("can add package from github",{ expect_is(newpdb, "matrix") expect_equal(nrow(pdb), nrow(newpdb)) expect_equal(ncol(pdb), ncol(newpdb)) - -}) \ No newline at end of file +}) From e269435269e9923160c92935ca1957af9f37e234 Mon Sep 17 00:00:00 2001 From: Alex Chubaty Date: Fri, 11 Aug 2017 10:59:29 -0600 Subject: [PATCH 05/11] update NEWS (#72) --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 3522402..757360a 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ miniCRAN v0.2.10 ================ * fixed typos in vignettes (@ryanatanner PR#93 and PR#94) +* added package option `miricran.mran` which sets default preferred MRAN url (#72) miniCRAN v0.2.9 (Release date: 2017-07-20) =============== From 5116b1cfb9456f8e5be5c0ae97e37f355174d8fb Mon Sep 17 00:00:00 2001 From: Mark Adamson Date: Sat, 7 Oct 2017 14:38:53 +0100 Subject: [PATCH 06/11] Add missing space in error message for unknown type Fixes #100 --- R/helpers.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/helpers.R b/R/helpers.R index eb44e72..e0bacd8 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -60,7 +60,7 @@ repoPrefix <- function(type, Rversion) { "mac.binary.el-capitan" = sprintf("bin/macosx/el-capitan/contrib/%s", Rversion), "mac.binary.leopard" = sprintf("bin/macosx/leopard/contrib/%s", Rversion), "mac.binary.mavericks" = sprintf("bin/macosx/mavericks/contrib/%s", Rversion), - stop("Type ", type, "not recognised.") + stop("Type ", type, " not recognised.") ) } From 917c0b5a239a82e39780e5deb671d865d52fae53 Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Fri, 20 Oct 2017 15:22:02 +0100 Subject: [PATCH 07/11] Fix type errors in checkVersions() that caused addPackages() to fail. #99 --- R/addPackages.R | 44 ++++++++++++++++++++---------- R/updatePackages.R | 7 +++-- tests/testthat/test-5-updateRepo.R | 40 +++++++++++++++++---------- 3 files changed, 59 insertions(+), 32 deletions(-) diff --git a/R/addPackages.R b/R/addPackages.R index c76806f..00c9332 100644 --- a/R/addPackages.R +++ b/R/addPackages.R @@ -26,7 +26,7 @@ checkVersions <- function(pkgs = NULL, path = NULL, type = "source", if (is.null(path)) stop("path must be specified.") if (!file.exists(path)) stop("invalid path, ", path) - duplicatePkgs <- sapply(type, function(type) { + do_one <- function(type) { pkgPath <- repoBinPath(path, type, Rversion) if (is.null(pkgs)) { files <- dir(pkgPath) @@ -35,15 +35,17 @@ checkVersions <- function(pkgs = NULL, path = NULL, type = "source", } files <- unlist(files) pkgFiles <- grep("\\.(tar\\.gz|zip|tgz)$", basename(files), value = TRUE) - + # identify duplicate packages and warn the user pkgs <- sapply(strsplit(files, "_"), "[[", 1) dupes <- pkgs[duplicated(pkgs)] if (length(dupes)) warning("Duplicate package(s): ", paste(dupes, collapse = ", ")) file.path(pkgPath, pkgFiles) - }) + } + + duplicatePkgs <- sapply(type, do_one, simplify = FALSE) names(duplicatePkgs) <- type - return(invisible(duplicatePkgs)) + duplicatePkgs } @@ -72,31 +74,41 @@ 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(t) { + do_one <- function(t) { prev <- checkVersions(pkgs = pkgs, path = path, type = t, Rversion = Rversion) + prev <- prev[[1]] prev.df <- getPkgVersFromFile(prev) - + 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) - + if (length(prev)) { curr <- suppressWarnings( checkVersions(pkgs = pkgs, path = path, type = t, Rversion = Rversion) ) + curr <- curr[[1]] curr.df <- getPkgVersFromFile(curr) - + + findPrevPackage <- function(x) { + grep(paste0("^", x), basename(prev)) + } + 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)]) + to_remove <- lapply(dupes, findPrevPackage) + if(length(unlist(to_remove))){ + file.remove(prev[unlist(to_remove)]) + } } } - }) + } + + lapply(type, do_one) n <- if (writePACKAGES) updateRepoIndex(path = path, type = type, Rversion = Rversion) - return(invisible(n)) + invisible(n) } @@ -142,11 +154,13 @@ 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) { + + do_one <- function(x) { 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) - }) + } + sapply(oldPkgs, do_one) if (writePACKAGES) invisible(updateRepoIndex(path = path, type = type, Rversion)) } diff --git a/R/updatePackages.R b/R/updatePackages.R index 86aacd5..95f6f55 100644 --- a/R/updatePackages.R +++ b/R/updatePackages.R @@ -73,7 +73,8 @@ oldPackages <- function(path = NULL, repos = getOption("repos"), updatePackages <- function(path = NULL, repos = getOption("repos"), method, ask = TRUE, availPkgs = pkgAvail(repos = repos, type = type, Rversion = Rversion), oldPkgs = NULL, type = "source", Rversion = R.version, quiet = FALSE) { - lapply(type, function(t) { + + do_one <- function(t){ force(ask) simplifyRepos <- function(repos, t) { tail <- substring(contribUrl("---", type = t, Rversion = Rversion), 4) @@ -137,5 +138,7 @@ updatePackages <- function(path = NULL, repos = getOption("repos"), method, ask addPackage(update[, "Package"], path = path, repos = repos, type = t, quiet = quiet, deps = FALSE, Rversion = Rversion) } - }) + } + + lapply(type, do_one) } diff --git a/tests/testthat/test-5-updateRepo.R b/tests/testthat/test-5-updateRepo.R index 863aecf..fd08871 100644 --- a/tests/testthat/test-5-updateRepo.R +++ b/tests/testthat/test-5-updateRepo.R @@ -17,7 +17,9 @@ if (!is.online(revolution, tryHttp = FALSE)) { rvers <- "3.1" pkgs <- c("chron", "adaptivetau") -types <- c("source", "win.binary", "mac.binary") +types <- c("win.binary", "mac.binary", "source") +# types <- c("win.binary") + names(types) <- types test_that("sample repo is setup correctly", { @@ -39,8 +41,9 @@ test_that("sample repo is setup correctly", { # Add packages to repo ---------------------------------------------------- -pkgsAdd <- c("aprof") +pkgsAdd <- c("forecast") +pkg_type <- names(types)[1] for (pkg_type in names(types)) { context(sprintf(" - Add packages to repo (%s)", pkg_type)) @@ -112,9 +115,7 @@ for (pkg_type in names(types)) { expect_true( file.copy(from = f, to = file.path(tmpdir, "MASS_7.3-0.tar.gz")) ) - expect_true( - length(list.files(tmpdir)) == 2 - ) + expect_equal(length(list.files(tmpdir)), 2) addLocalPackage(pkgs = pkgsAddLocal, pkgPath = tmpdir, path = repo_root, type = pkg_type, quiet = TRUE, Rversion = rvers) @@ -139,7 +140,7 @@ for (pkg_type in names(types)) { # Check for updates ------------------------------------------------------- -MRAN_mirror <- MRAN("2014-12-01") +MRAN_mirror <- MRAN("2015-01-01") if (!is.online(MRAN_mirror, tryHttp = FALSE)) { # Use http:// for older versions of R MRAN_mirror <- sub("^https://", "http://", revolution) @@ -157,21 +158,30 @@ for (pkg_type in names(types)) { prefix <- repoPrefix(pkg_type, Rversion = rvers) suppressWarnings( - old <- oldPackages(path = repo_root, repos = MRAN_mirror, - type = pkg_type, Rversion = rvers, - quiet = FALSE) + old <- oldPackages(path = repo_root, repos = MRAN_mirror, + type = pkg_type, Rversion = rvers, + quiet = FALSE) ) - expect_equal(nrow(old), 2) + # In the following allow for differences between mac.binary and other types + expect_true(nrow(old) >= 10) + expect_true(nrow(old) <= 12) expect_equal(ncol(old), 4) - expect_equal(rownames(old), c("adaptivetau", "aprof")) + expect_true( + all( + rownames(old) %in% + c("adaptivetau", "BH", "digest", "forecast", "Hmisc", "mvtnorm", + "RColorBrewer", "RcppArmadillo", "reshape2", "timeDate", + "timeSeries", "tis") + ) + ) updatePackages(path = repo_root, repos = MRAN_mirror, type = pkg_type, ask = FALSE, quiet = TRUE, Rversion = rvers) updateVers <- getPkgVersFromFile( list.files(file.path(repo_root, prefix)) - ) + ) expect_true( .checkForRepoFiles(repo_root, pkgList[[pkg_type]], prefix) @@ -202,8 +212,8 @@ for (pkg_type in names(types)) { skip_on_cran() skip_if_offline(MRAN_mirror) - oldVersions <- list(package = c("aprof"), - version = c("0.2.1")) + oldVersions <- list(package = c("acepack"), + version = c("1.3-2")) if (pkg_type != "source") { expect_error( addOldPackage(oldVersions[["package"]], path = repo_root, @@ -215,7 +225,7 @@ for (pkg_type in names(types)) { 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)[[pkg_type]] ) expect_true( From 696fbdc00b28e9f4272e898763fe4574148246f9 Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Fri, 20 Oct 2017 16:20:51 +0100 Subject: [PATCH 08/11] Added note on system requirements (#98) --- DESCRIPTION | 2 ++ README.md | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/DESCRIPTION b/DESCRIPTION index 1ac209a..c40489b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -16,6 +16,8 @@ Date: 2017-07-20 Version: 0.2.9 URL: https://github.com/RevolutionAnalytics/miniCRAN BugReports: https://github.com/RevolutionAnalytics/miniCRAN/issues +SystemRequirements: Imports the `curl` and `XML` packages. These have system + requirements on `libxml2-devel`, `libcurl-devel` and `openssl-devel`. Imports: graphics, httr, diff --git a/README.md b/README.md index 9e6e0e6..24f20ef 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,23 @@ Get the latest stable development version from github: library(devtools) install_github("RevolutionAnalytics/miniCRAN") ``` + +## System requirements + +The `miniCRAN` package itself doesn't introduce any system dependencies. However, the package imports [`curl`](https://cran.r-project.org/package=curl) and `XML` packages. These have system requirements on `libxml2-devel`, `libcurl-devel` and `openssl-devel`. + +On systems with the `rpm` package manager (Red Hat, CentOS) try: + +```bash +yum install libcurl-devel libxml2-devel openssl-devel +``` + +On systems with the `atp` package manager (Debian, Ubuntu) try: + +```bash +apt-get install libcurl4-openssl-dev libxml2-devel openssl-devel +``` + ## Example: From efcd7a859f90a3df7daf34245bd896c3d079dabd Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Fri, 20 Oct 2017 16:35:05 +0100 Subject: [PATCH 09/11] Rebuild vignettes --- inst/doc/miniCRAN-dependency-graph.html | 204 ++++++++++++++++-- inst/doc/miniCRAN-dependency-graph.rmd | 2 +- inst/doc/miniCRAN-introduction.html | 214 +++++++++++++++++-- inst/doc/miniCRAN-non-CRAN-repos.html | 208 ++++++++++++++++-- inst/doc/miniCRAN-non-CRAN-repos.rmd | 2 +- vignettes/miniCRAN-dependency-graph.R | 20 -- vignettes/miniCRAN-dependency-graph.html | 228 -------------------- vignettes/miniCRAN-introduction.R | 77 ------- vignettes/miniCRAN-introduction.html | 255 ----------------------- vignettes/miniCRAN-non-CRAN-repos.R | 39 ---- vignettes/miniCRAN-non-CRAN-repos.html | 212 ------------------- 11 files changed, 570 insertions(+), 891 deletions(-) delete mode 100644 vignettes/miniCRAN-dependency-graph.R delete mode 100644 vignettes/miniCRAN-dependency-graph.html delete mode 100644 vignettes/miniCRAN-introduction.R delete mode 100644 vignettes/miniCRAN-introduction.html delete mode 100644 vignettes/miniCRAN-non-CRAN-repos.R delete mode 100644 vignettes/miniCRAN-non-CRAN-repos.html diff --git a/inst/doc/miniCRAN-dependency-graph.html b/inst/doc/miniCRAN-dependency-graph.html index a9ea341..bb774e1 100644 --- a/inst/doc/miniCRAN-dependency-graph.html +++ b/inst/doc/miniCRAN-dependency-graph.html @@ -11,19 +11,189 @@ - + Using miniCRAN to identify package dependencies - + - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -

The miniCRAN package exposes two functions that provide information about dependencies:

-
    -
  • The function pkgDep() returns a character vector with the names of dependencies. Internally, pkgDep() is a wrapper around tools::package_dependencies(), a base R function that, well, tells you about package dependencies. My pkgDep() function is in one way a convenience, but more importantly it sets different defaults (more about this later).

  • -
  • The function makeDepGraph() creates a graph representation of the dependencies.

  • -
-

The package chron neatly illustrates the different roles of Imports, Suggests and Enhances:

-
    -
  • chron Imports the base packages graphics and stats. This means that chron internally makes use of graphics and stats and will always load these packages.

  • -
  • chron Suggests the packages scales and ggplot2. This means that chron uses some functions from these packages in examples or in its vignettes. However, these functions are not necessary to use chron

  • -
  • chron Enhances the package zoo, meaning that it adds something to zoo packages. These enhancements are made available to you if you have zoo installed.

  • -
-
-

A worked example using the package chron

-

The function pkgDep() exposes not only these dependencies, but also also all recursive dependencies. In other words, it answers the question which packages need to be installed to satsify all dependencies of dependencies.

-

This means that the algorithm is as follows:

-
    -
  • First retrieve a list of Suggests and Enhances, using a non-recursive dependency search
  • -
  • Next, perform a recursive search for all Imports, Depends and LinkingTo
  • -
-

The resulting list of packages should then contain the complete list necessary to satisfy all dependencies. In code:

-
library("miniCRAN")
-
tags <- "chron"
-pkgDep(tags, availPkgs = cranJuly2014)
-
##  [1] "chron"        "RColorBrewer" "dichromat"    "munsell"     
-##  [5] "plyr"         "labeling"     "colorspace"   "Rcpp"        
-##  [9] "digest"       "gtable"       "reshape2"     "scales"      
-## [13] "proto"        "MASS"         "stringr"      "ggplot2"
-

To create an igraph plot of the dependencies, use the function makeDepGraph() and plot the results:

-
dg <- makeDepGraph(tags, enhances = TRUE, availPkgs = cranJuly2014)
-
## Loading required namespace: igraph
-
set.seed(1)
-plot(dg, legendPosition = c(-1, 1), vertex.size = 20)
-

-

Note how the dependencies expand to zoo (enhanced), scales and ggplot (suggested) and then recursively from there to get all the Imports and LinkingTo dependencies.

-
-
-

An example with multiple input packages

-

As a final example, create a dependency graph of seven very popular R packages:

-
tags <- c("ggplot2", "data.table", "plyr", "knitr", "shiny", "xts", "lattice")
-pkgDep(tags, suggests = TRUE, enhances = FALSE, availPkgs = cranJuly2014)
-
##  [1] "ggplot2"      "data.table"   "plyr"         "knitr"       
-##  [5] "shiny"        "xts"          "lattice"      "digest"      
-##  [9] "gtable"       "reshape2"     "scales"       "proto"       
-## [13] "MASS"         "Rcpp"         "stringr"      "RColorBrewer"
-## [17] "dichromat"    "munsell"      "labeling"     "colorspace"  
-## [21] "evaluate"     "formatR"      "highr"        "markdown"    
-## [25] "mime"         "httpuv"       "caTools"      "RJSONIO"     
-## [29] "xtable"       "htmltools"    "bitops"       "zoo"         
-## [33] "SparseM"      "survival"     "Formula"      "latticeExtra"
-## [37] "cluster"      "maps"         "sp"           "foreign"     
-## [41] "mvtnorm"      "TH.data"      "sandwich"     "nlme"        
-## [45] "Matrix"       "bit"          "codetools"    "iterators"   
-## [49] "timeDate"     "quadprog"     "Hmisc"        "BH"          
-## [53] "quantreg"     "mapproj"      "hexbin"       "maptools"    
-## [57] "multcomp"     "testthat"     "mgcv"         "chron"       
-## [61] "reshape"      "fastmatch"    "bit64"        "abind"       
-## [65] "foreach"      "doMC"         "itertools"    "testit"      
-## [69] "rgl"          "XML"          "RCurl"        "Cairo"       
-## [73] "timeSeries"   "tseries"      "its"          "fts"         
-## [77] "tis"          "KernSmooth"
-
dg <- makeDepGraph(tags, enhances = TRUE, availPkgs = cranJuly2014)
-set.seed(1)
-plot(dg, legendPosition = c(-1, -1), vertex.size = 10, cex = 0.7)
-

-
- - - - -
- - - - - - - - diff --git a/vignettes/miniCRAN-introduction.R b/vignettes/miniCRAN-introduction.R deleted file mode 100644 index dc59e68..0000000 --- a/vignettes/miniCRAN-introduction.R +++ /dev/null @@ -1,77 +0,0 @@ -## ----make-repo-1--------------------------------------------------------- -library("miniCRAN") - -# use Revolution Analytics CRAN mirror -revolution <- c(CRAN="http://cran.microsoft.com") - -# Specify list of packages to download -pkgs <- c("foreach") -pkgList <- pkgDep(pkgs, repos=revolution, type="source", suggests = FALSE, availPkgs = cranJuly2014) -pkgList - -## ----make-repo-2, eval=FALSE--------------------------------------------- -# # Create temporary folder for miniCRAN -# dir.create(pth <- file.path(tempdir(), "miniCRAN")) -# -# # Make repo for source and win.binary -# makeRepo(pkgList, path=pth, repos=revolution, type=c("source", "win.binary")) - -## ----make-repo-3, eval=FALSE--------------------------------------------- -# # List all files in miniCRAN -# list.files(pth, recursive=TRUE, full.names=FALSE) - -## ----make-repo-4, eval=FALSE--------------------------------------------- -# # Check for available packages -# pkgAvail(repos=pth, type="win.binary")[, c(1:3, 5)] - -## ----make-repo-5, eval=FALSE--------------------------------------------- -# install.packages(pkgs, -# repos = paste0("file:///", pth), -# type = "source") - -## ----addto-repo-new-1, eval=FALSE---------------------------------------- -# # Add new packages (from CRAN) to the miniCRAN repo -# addPackage("Matrix", path=pth, repos=revolution, type=c("source", "win.binary")) -# pkgAvail(repos=pth, type="win.binary")[, c(1:3, 5)] - -## ----addto-repo-old-1, eval=FALSE---------------------------------------- -# # create a data frame with the package and version info -# oldVers <- data.frame(package=c("foreach", "codetools", "iterators"), -# version=c("1.4.0", "0.2-7", "1.0.5"), -# stringsAsFactors=FALSE) -# -# # download old source package version and create repo index -# addOldPackage(pkgList, path=pth, vers=oldVers$version, repos=revolution, type="source") - -## ----addto-repo-old-2, eval=FALSE---------------------------------------- -# # List package versions in the miniCRAN repo (produces warning about duplicates) -# pkgVersionsSrc <- checkVersions(pkgList, path=pth, type="source") -# pkgVersionsBin <- checkVersions(pkgList, path=pth, type="win.binary") -# -# # After inspecting package versions, remove old versions -# basename(pkgVersionsSrc) # duplicate versions -# basename(pkgVersionsBin) -# -# file.remove(pkgVersionsSrc[c(2,4,6)]) -# -# # rebuild the package index after removing duplicate package versions -# updateRepoIndex(pth, type=c("source", "win.binary")) - -## ----addto-repo-old-3, eval=FALSE---------------------------------------- -# pkgAvail(pth, type="source")[, c(1:3, 5)] # contains the old versions -# pkgAvail(pth, type="win.binary")[, c(1:3, 5)] # contains the current versions - -## ----update-repo-1, eval=FALSE------------------------------------------- -# # Check if updated packages are available -# oldPackages(path=pth, repos=revolution, type="source")[, 1:3] # should need update -# oldPackages(path=pth, repos=revolution, type="win.binary")[, 1:3] # should be current - -## ----update-repo-2, eval=FALSE------------------------------------------- -# # Update available packages -# updatePackages(path=pth, repos=revolution, type="source", ask=FALSE) # should need update -# updatePackages(path=pth, repos=revolution, type="win.binary", ask=FALSE) # should be current - -## ----cleanup, include=FALSE, eval=FALSE---------------------------------- -# # Delete temporary folder -# unlink(pth, recursive = TRUE) - diff --git a/vignettes/miniCRAN-introduction.html b/vignettes/miniCRAN-introduction.html deleted file mode 100644 index e2ca2a7..0000000 --- a/vignettes/miniCRAN-introduction.html +++ /dev/null @@ -1,255 +0,0 @@ - - - - - - - - - - - - - - - -Using miniCRAN to create a local CRAN repository - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -

Start by creating the recursive dependency tree for your target packages.

-

For example, imagine a scenario where you want to create a repository that consists of the package foreach and its dependencies.

-

Start by creating the dependency list:

-
library("miniCRAN")
-
-# use Revolution Analytics CRAN mirror
-revolution <- c(CRAN="http://cran.microsoft.com")
-
-# Specify list of packages to download
-pkgs <- c("foreach")
-pkgList <- pkgDep(pkgs, repos=revolution, type="source", suggests = FALSE, availPkgs = cranJuly2014)
-pkgList
-
## [1] "foreach"   "codetools" "iterators"
-

Next, create a repository with the function makeRepo(). In this example, get the required files for source packages as well as windows binaries:

-
# Create temporary folder for miniCRAN
-dir.create(pth <- file.path(tempdir(), "miniCRAN"))
-
-# Make repo for source and win.binary
-makeRepo(pkgList, path=pth, repos=revolution, type=c("source", "win.binary"))
-

Investigate the repository file structure:

-
# List all files in miniCRAN
-list.files(pth, recursive=TRUE, full.names=FALSE)
-

Use pkgAvail to list available packages in your repository:

-
# Check for available packages
-pkgAvail(repos=pth, type="win.binary")[, c(1:3, 5)]
-
-

Install packages from your local repository

-

To install packages from a local repository, you need to use the URI convention file:/// to point to your file lcoation.

-
install.packages(pkgs, 
-                 repos = paste0("file:///", pth),
-                 type = "source")
-
-
-

Adding packages to an existing miniCRAN repository

-
-

Adding new packages from CRAN

-

After creating a local miniCRAN repository, additional packages and their dependencies can easily be added. This mechanism can also be used to re-add an existing package to the miniCRAN repo.

-
# Add new packages (from CRAN) to the miniCRAN repo
-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 (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

-

To add a specific version of a package from CRAN (or another CRAN-like repository), we can easily download the source packages from the CRAN archives. Dependencies for old package versions cannot be determined automatically and must be specified by the user.

-

Note: in order to to add binaries of older packages, you will need to download the source and build the binaries on the intended platform yourself. You will need the appropriate R development tools installed in order to build package binaries from source.

-
# create a data frame with the package and version info
-oldVers <- data.frame(package=c("foreach", "codetools", "iterators"),
-                      version=c("1.4.0", "0.2-7", "1.0.5"),
-                      stringsAsFactors=FALSE)
-
-# download old source package version and create repo index
-addOldPackage(pkgList, path=pth, vers=oldVers$version, repos=revolution, type="source")
-

You will get a warning whenever there are multiple versions of a package saved in the repository. Currently, you need to manually remove duplicate versions before rebuilding the repository’s package index.

-

Note: This last step is important, otherwise you may end up with a repo in an inconsistent state.

-
# List package versions in the miniCRAN repo (produces warning about duplicates)
-pkgVersionsSrc <- checkVersions(pkgList, path=pth, type="source")
-pkgVersionsBin <- checkVersions(pkgList, path=pth, type="win.binary")
-
-# After inspecting package versions, remove old versions
-basename(pkgVersionsSrc) # duplicate versions
-basename(pkgVersionsBin)
-
-file.remove(pkgVersionsSrc[c(2,4,6)])
-
-# rebuild the package index after removing duplicate package versions
-updateRepoIndex(pth, type=c("source", "win.binary"))
-

To see the updated list of packages available in the miniCRAN repo:

-
pkgAvail(pth, type="source")[, c(1:3, 5)] # contains the old versions
-pkgAvail(pth, type="win.binary")[, c(1:3, 5)] # contains the current versions
-
-
-

Adding packages from other sources

-

This feature will be implemented in a future release.

-
-
-
-

Updating the packages in a miniCRAN repository

-

Checking for updated versions of the packages currently stored in the miniCRAN repository:

-
# Check if updated packages are available
-oldPackages(path=pth, repos=revolution, type="source")[, 1:3] # should need update
-oldPackages(path=pth, repos=revolution, type="win.binary")[, 1:3] # should be current
-

Update the versions of the packages currently stored in the miniCRAN repository. By default, a prompt is given to confirm the update for each package. This prompt can be suppressed using ask=FALSE, which will update all packages. Be careful using this option if you want to keep certain packages at an older version.

-
# Update available packages
-updatePackages(path=pth, repos=revolution, type="source", ask=FALSE) # should need update
-updatePackages(path=pth, repos=revolution, type="win.binary", ask=FALSE) # should be current
-
- - - - -
- - - - - - - - diff --git a/vignettes/miniCRAN-non-CRAN-repos.R b/vignettes/miniCRAN-non-CRAN-repos.R deleted file mode 100644 index d1df790..0000000 --- a/vignettes/miniCRAN-non-CRAN-repos.R +++ /dev/null @@ -1,39 +0,0 @@ -## ----setup--------------------------------------------------------------- -# Wrapper around available.packages --------------------------------------- - -index <- function(url, type="source", filters=NULL, head=5, cols=c("Package", "Version")){ - contribUrl <- contrib.url(url, type=type) - p <- available.packages(contribUrl, type=type, filters=filters) - p[1:head, cols] -} - - -## ----CRAN, eval=FALSE---------------------------------------------------- -# CRAN <- "http://cran.r-project.org" -# index(CRAN) - -## ----revo, eval=FALSE---------------------------------------------------- -# revoStable <- "http://packages.revolutionanalytics.com/cran/3.1/stable" -# index(revoStable) -# -# revoMirror <- "http://cran.revolutionanalytics.com" -# index(revoMirror) - -## ----rforge, eval=FALSE-------------------------------------------------- -# rforge <- "http://r-forge.r-project.org" -# index(rforge) - -## ----bioc, eval=FALSE---------------------------------------------------- -# bioc <- local({ -# env <- new.env() -# on.exit(rm(env)) -# evalq(source("http://bioconductor.org/biocLite.R", local=TRUE), env) -# biocinstallRepos() -# }) -# -# bioc -# bioc[grep("BioC", names(bioc))] -# -# -# index(bioc["BioCsoft"]) - diff --git a/vignettes/miniCRAN-non-CRAN-repos.html b/vignettes/miniCRAN-non-CRAN-repos.html deleted file mode 100644 index 71f4329..0000000 --- a/vignettes/miniCRAN-non-CRAN-repos.html +++ /dev/null @@ -1,212 +0,0 @@ - - - - - - - - - - - - - - - -Using repositories other than CRAN with miniCRAN - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -

Although the package name miniCRAN seems to indicate you can only use CRAN as a repository, you can in fact use any CRAN-like repository.

-

This vignette contains some examples of how to refer to different package repositories, including CRAN, alternative mirrors of CRAN, R-Forge as well as BioConductor.

-

To make simplify the code to show the salient features, we use a little helper function, index() that is a simple wrapper around available.packages():

-
# Wrapper around available.packages ---------------------------------------
- 
-index <- function(url, type="source", filters=NULL, head=5, cols=c("Package", "Version")){
-  contribUrl <- contrib.url(url, type=type)
-  p <- available.packages(contribUrl, type=type, filters=filters)
-  p[1:head, cols]
-}
-
-

Using CRAN

-

The URL for the master mirror in Austria:

-
CRAN <- "http://cran.r-project.org"
-index(CRAN)
-
-
-

Using a different mirror

-

You can also point to any other mirror, for example the stable version hosted by Revolution Analytics:

-
revoStable <- "http://packages.revolutionanalytics.com/cran/3.1/stable"
-index(revoStable)
- 
-revoMirror <- "http://cran.revolutionanalytics.com"
-index(revoMirror)
-
-
-

Using R-forge

-

R-forge has CRAN-like structure:

-
rforge <- "http://r-forge.r-project.org"
-index(rforge)
-
-
-

Using BioConductor

-

Although BioConductor has a different preferred install mechanism, the underlying repository structure is also CRAN-like:

-
bioc <- local({
-  env <- new.env()
-  on.exit(rm(env))
-  evalq(source("http://bioconductor.org/biocLite.R", local=TRUE), env)
-  biocinstallRepos()
-})
- 
-bioc
-bioc[grep("BioC", names(bioc))]
- 
- 
-index(bioc["BioCsoft"])
-
- - - - -
- - - - - - - - From 56d3e5ead65013fadf020ffdedb14040d3acb31a Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Fri, 20 Oct 2017 16:35:49 +0100 Subject: [PATCH 10/11] Update NEWS and README --- NEWS | 11 +++++++++-- README.md | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 757360a..7c758da 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,15 @@ miniCRAN v0.2.10 ================ -* fixed typos in vignettes (@ryanatanner PR#93 and PR#94) -* added package option `miricran.mran` which sets default preferred MRAN url (#72) +New features: +* Added package option `minicran.mran` which sets default preferred MRAN url (#72) + +Bug fixes: +* Fixed 'Error in basename(prev)' when calling `addPackage()` (#99) + +Other improvements: +* Fixed typos in vignettes (@ryanatanner PR#93 and PR#94) +* Added note on system requirements of curl and XML (#98) miniCRAN v0.2.9 (Release date: 2017-07-20) =============== diff --git a/README.md b/README.md index 24f20ef..55661ab 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ install.packages("miniCRAN") library("miniCRAN") ``` +### Development version Get the latest stable development version from github: @@ -40,7 +41,7 @@ library(devtools) install_github("RevolutionAnalytics/miniCRAN") ``` -## System requirements +### System requirements The `miniCRAN` package itself doesn't introduce any system dependencies. However, the package imports [`curl`](https://cran.r-project.org/package=curl) and `XML` packages. These have system requirements on `libxml2-devel`, `libcurl-devel` and `openssl-devel`. @@ -50,7 +51,7 @@ On systems with the `rpm` package manager (Red Hat, CentOS) try: yum install libcurl-devel libxml2-devel openssl-devel ``` -On systems with the `atp` package manager (Debian, Ubuntu) try: +On systems with the `aptitude` package manager (Debian, Ubuntu) try: ```bash apt-get install libcurl4-openssl-dev libxml2-devel openssl-devel From 90e6f9523917041a333248f19a405989e674e269 Mon Sep 17 00:00:00 2001 From: Andrie de Vries Date: Fri, 20 Oct 2017 16:36:18 +0100 Subject: [PATCH 11/11] Bump version to 0.2.10; Change maintainer to apdevries@gmail.com --- DESCRIPTION | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c40489b..5790d73 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: miniCRAN Authors@R: c(person("Microsoft Corporation", role="cph"), person("Andrie", "de - Vries", role=c("aut", "cre"), email="adevries@microsoft.com"), + Vries", role=c("aut", "cre"), email="apdevries@gmail.com"), person("Alex", "Chubaty", role="ctb", email="alex.chubaty@gmail.com")) License: GPL-2 Copyright: Microsoft Corporation @@ -11,9 +11,9 @@ Description: Makes it possible to create an internally consistent 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 - behind a firewall, or remote locations with slow broadband access. -Date: 2017-07-20 -Version: 0.2.9 + behind a firewall, or remote locations with slow (or zero) Internet access. +Date: 2017-10-20 +Version: 0.2.10 URL: https://github.com/RevolutionAnalytics/miniCRAN BugReports: https://github.com/RevolutionAnalytics/miniCRAN/issues SystemRequirements: Imports the `curl` and `XML` packages. These have system