Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
andrie committed Apr 12, 2016
2 parents dfe8080 + 340bd89 commit 2552fde
Show file tree
Hide file tree
Showing 54 changed files with 537 additions and 901 deletions.
18 changes: 11 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
Package: miniCRAN
Authors@R: c(person("Revolution Analytics", role="aut"), person("Andrie", "de
Vries", role=c("aut", "cre"), email="andrie@revolutionanalytics.com"),
Vries", role=c("aut", "cre"), email="adevries@microsoft.com"),
person("Alex", "Chubaty", role="ctb", email="[email protected]"))
License: GPL-2
Copyright: Revolution Analytics
Copyright: Microsoft Corporation
Title: Create a Mini Version of CRAN Containing Only Selected Packages
LazyData: true
LazyLoad: true
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.5
URL: https://github.com/RevolutionAnalytics/miniCRAN
BugReports: https://github.com/RevolutionAnalytics/miniCRAN/issues
Date: 2015-03-26
Date: 2016-04-12
Imports:
tools,
XML,
httr,
methods,
utils
utils,
graphics,
stats
Suggests:
testthat(>= 0.9),
knitr,
rmarkdown,
igraph
VignetteBuilder: knitr
RoxygenNote: 5.0.1
13 changes: 12 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -17,8 +17,19 @@ export(pkgDep)
export(updatePackages)
export(updateRepoIndex)
import(XML)
importFrom(graphics,legend)
importFrom(graphics,par)
importFrom(graphics,title)
importFrom(httr,GET)
importFrom(httr,content)
importFrom(httr,stop_for_status)
importFrom(methods,is)
importFrom(stats,reshape)
importFrom(stats,setNames)
importFrom(tools,write_PACKAGES)
importFrom(utils,chooseCRANmirror)
importFrom(utils,compareVersion)
importFrom(utils,download.file)
importFrom(utils,flush.console)
importFrom(utils,installed.packages)
importFrom(utils,select.list)
9 changes: 9 additions & 0 deletions R/MRAN.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MRAN <- function(snapshot){
url <- "http://mran.microsoft.com"
if(missing("snapshot") || is.null(snapshot)){
url
} else {
sprintf("%s/snapshot/%s", url, snapshot)
}
}
CRAN <- function()getOption("repos")[1]
14 changes: 11 additions & 3 deletions R/getCranDescription.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@
#' @export
#'
#' @example /inst/examples/example_getCranDescription.R
getCranDescription <- function(pkg, repos=getOption("repos"), type="source", path, pkgs = pkgDep(pkg, repos=repos, type=type)){
getCranDescription <- function(pkg, repos = getOption("repos"),
type = "source",
pkgs = pkgDep(pkg, repos=repos, type=type)){

getOne <- function(package){
url <- sprintf("http://cran.r-project.org/web/packages/%s/index.html", package)
repos <- repos[[1]]
if(!grepl("/$", repos)) repos <- paste0(repos, "/")

url <- gsub("https://", "http://",
sprintf("%sweb/packages/%s/index.html", repos, package)
)
x <- tryCatch({
readHTMLTable(url, header=FALSE, which=1, stringsAsFactors=FALSE)
text <- paste(readLines(url), collapse = "\n")
XML::readHTMLTable(text, header=FALSE, which=1, stringsAsFactors=FALSE)
}, error=function(e) e
)
if(inherits(x, "error")) {
Expand Down
3 changes: 2 additions & 1 deletion R/github-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ addPackageListing <- function(pdb=pkgAvail(), dcf, warnings=TRUE) {



# from http://stackoverflow.com/questions/13163248/possible-to-override-the-blocking-of-a-packages-re-installation-after-it-has
# from http://stackoverflow.com/questions/13163248
# Possible to override the blocking of a package's (re-)installation after it has been required/loaded?

#' @importFrom httr GET stop_for_status content
readDescriptionGithub <- function(repo, username, branch="master", quiet=TRUE){
Expand Down
5 changes: 4 additions & 1 deletion R/minicran-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@
#' @name miniCRAN-package
#' @aliases miniCRAN minicran
#' @docType package
#' @author Andrie de Vries \email{andrie@@revolutionanalytics.com} with contributions from Alex Chubaty \email{alex.chubaty@@gmail.com}
#' @author Andrie de Vries \email{adevries@@microsoft.com} with contributions from Alex Chubaty \email{alex.chubaty@@gmail.com}
#' @keywords package
#' @importFrom graphics legend par title
#' @importFrom stats reshape setNames
#' @importFrom utils chooseCRANmirror compareVersion download.file flush.console installed.packages select.list
NULL


Expand Down
6 changes: 3 additions & 3 deletions R/pkgDep.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pkgDep <- function(pkg, availPkgs, repos=getOption("repos"), type="source", depe
}
if(missing(availPkgs)){
if(!is.null(names(repos)) & repos["CRAN"] == "@CRAN@"){
repos <- c(CRAN="http://cran.revolutionanalytics.com")
repos <- MRAN()
}
if(is.na(type)) type <- "source"
availPkgs <- pkgAvail(repos=repos, type=type, Rversion = Rversion, ...)
Expand Down Expand Up @@ -130,8 +130,8 @@ pkgAvail <- function(repos=getOption("repos"), type="source", Rversion = R.versi
if(!grepl("^http://|file:///", repos[1]) && file.exists(repos[1])) {
repos <- paste0("file:///", normalizePath(repos[1], mustWork = FALSE, winslash = "/"))
} else {
if(!is.null(names(repos)) && repos["CRAN"] == "@CRAN@"){
repos <- c(CRAN="http://cran.revolutionanalytics.com")
if(!is.null(names(repos)) && isTRUE(unname(repos["CRAN"]) == "@CRAN@")){
repos <- MRAN()
}
}
utils::available.packages(contribUrl(repos, type=type, Rversion = Rversion), type=type, filters=list())
Expand Down
33 changes: 21 additions & 12 deletions R/pkgDepTools.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
# This code is from package pkgDepTools
# Code copied from the pkgDepTools project
# Copyright (C) Seth Falcon
# http://www.bioconductor.org/packages/release/bioc/html/pkgDepTools.html
# Author: Seth Falcom
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation



# Code copied from the pkgDepTools project
# Copyright (C) Seth Falcon
# http://www.bioconductor.org/packages/release/bioc/html/pkgDepTools.html


# Copy of tools:::split_op_version.

#' @rdname pkgDepTools
#' @keywords internal
# @rdname pkgDepTools
# @keywords internal
split_op_version <- function (x) {
pat <- "^([^\\([:space:]]+)[[:space:]]*\\(([^\\)]+)\\).*"
x1 <- sub(pat, "\\1", x)
Expand All @@ -25,8 +34,8 @@ split_op_version <- function (x) {

# Copy of tools:::.split_dependencies.

#' @rdname pkgDepTools
#' @keywords internal
# @rdname pkgDepTools
# @keywords internal
split_dependencies <- function (x) {
if (!length(x))
return(list())
Expand All @@ -38,12 +47,12 @@ split_dependencies <- function (x) {
}


#' Clean package fields.
#'
#' Given the value from a field like 'Depends' in a package's DESCRIPTION file, return a character vector of package names with the version restrictions stripped and \R~removed.
#' @param val Value from a field like 'Depends' in a package's DESCRIPTION file
#' @rdname pkgDepTools
#' @keywords internal
# Clean package fields.
#
# Given the value from a field like 'Depends' in a package's DESCRIPTION file, return a character vector of package names with the version restrictions stripped and \R~removed.
# @param val Value from a field like 'Depends' in a package's DESCRIPTION file
# @rdname pkgDepTools
# @keywords internal
cleanPkgField <- function(val) {
if (is.na(val))
return(character(0))
Expand Down
4 changes: 4 additions & 0 deletions R/plot.pkgDepGraph.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ plot.pkgDepGraph <- function(

edgeColor <- c(Imports="red", Depends="orange", Suggests="grey80", Enhances="blue", LinkingTo="black")
eColor <- edgeColor[igraph::get.edge.attribute(x, "type")]

typesInGraph <- unique(igraph::get.edge.attribute(x, "type"))
edgeColor <- edgeColor[typesInGraph]
# eColor <- eColor[typesInGraph]

par(mai=rep(0.25, 4))
# browser()
Expand Down
2 changes: 1 addition & 1 deletion R/testSuiteFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

# Create sample repo from MRAN snapshot
.createSampleRepo <- function(MRAN, path, pkgs, Rversion="3.1"){
if(missing(MRAN)) MRAN <- c(CRAN="http://mran.revolutionanalytics.com/snapshot/2014-10-15")
if(missing(MRAN)) MRAN <- MRAN("2014-10-15")
if(missing(path)) path <- file.path(tempdir(), "miniCRAN", Sys.Date())
if(missing(pkgs)) pkgs <- c("chron", "adaptivetau")

Expand Down
16 changes: 16 additions & 0 deletions R/testthat_helpers.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 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)
TRUE
}

# Interrupt the test if url can not be reached
skip_if_offline <- function(url = MRAN()){
if(!is.online(url)) testthat::skip("offline")
}

318 changes: 92 additions & 226 deletions inst/doc/miniCRAN-dependency-graph.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions inst/doc/miniCRAN-dependency-graph.rmd
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
title: "Using miniCRAN to identify package dependencies"
author: "Andrie de Vries"
date: "March 26, 2015"
date: "`r as.character(format(Sys.Date(), format='%B %d, %Y'))`"
output:
html_document:
self_contained: yes
toc: yes
vignette: >
%\VignetteEngine{knitr::knitr}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteIndexEntry{Using miniCRAN to identify package dependencies}
%\VignettePackage{miniCRAN}
%\VignetteKeyword{miniCRAN}
Expand Down
2 changes: 1 addition & 1 deletion inst/doc/miniCRAN-introduction.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
library("miniCRAN")

# use Revolution Analytics CRAN mirror
revolution <- c(CRAN="http://cran.revolutionanalytics.com")
revolution <- c(CRAN="http://cran.microsoft.com")

# Specify list of packages to download
pkgs <- c("foreach")
Expand Down
373 changes: 118 additions & 255 deletions inst/doc/miniCRAN-introduction.html

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions inst/doc/miniCRAN-introduction.rmd
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
---
title: "Using miniCRAN to create a local CRAN repository"
title: "Using miniCRAN to create a local CRAN repository"
author: "Andrie de Vries and Alex Chubaty"
date: "March 26, 2015"
date: "`r as.character(format(Sys.Date(), format='%B %d, %Y'))`"
output:
html_document:
self_contained: yes
toc: yes
vignette: >
%\VignetteEngine{knitr::knitr}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteIndexEntry{Using miniCRAN to create and maintain a local CRAN repository}
%\VignettePackage{miniCRAN}
%\VignetteKeyword{miniCRAN}
%\usepackage[utf8]{inputenc}
---

# Creating a miniCRAN 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.
Expand All @@ -26,7 +24,7 @@ Start by creating the dependency list:
library("miniCRAN")
# use Revolution Analytics CRAN mirror
revolution <- c(CRAN="http://cran.revolutionanalytics.com")
revolution <- c(CRAN="http://cran.microsoft.com")
# Specify list of packages to download
pkgs <- c("foreach")
Expand Down
308 changes: 95 additions & 213 deletions inst/doc/miniCRAN-non-CRAN-repos.html

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions inst/doc/miniCRAN-non-CRAN-repos.rmd
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
---
title: "Using repositories other than CRAN with miniCRAN"
author: "Andrie de Vries"
date: "March 26, 2015"
date: "`r as.character(format(Sys.Date(), format='%B %d, %Y'))`"
output:
html_document:
self_contained: yes
toc: yes
vignette: >
%\VignetteEngine{knitr::knitr}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteIndexEntry{Using repositories other than CRAN with miniCRAN}
%\VignettePackage{miniCRAN}
%\VignetteKeyword{miniCRAN}
%\usepackage[utf8]{inputenc}
---

# 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.
Expand Down
2 changes: 1 addition & 1 deletion inst/examples/example_addPackageListingGithub.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pdb <- cranJuly2014

\dontrun{
pdb <- pkgAvail(repos=c(CRAN="http://cran.revolutionanalytics.com"))
pdb <- pkgAvail(repos = c(CRAN="http://mran.microsoft.com"))


# Overwrite pdb with development version of miniCRAN at github
Expand Down
2 changes: 1 addition & 1 deletion inst/examples/example_checkVersions.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### `checkVersions` and `add.packages.miniCRAN` require an existing miniCRAN repo

# Specify list of packages to download
revolution <- c(CRAN="http://cran.revolutionanalytics.com")
revolution <- c(CRAN = "http://mran.microsoft.com")
pkgs <- c("foreach")

pdb <- cranJuly2014
Expand Down
2 changes: 1 addition & 1 deletion inst/examples/example_getCranDescription.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
\dontrun{
getCranDescription(c("igraph", "ggplot2", "XML"),
repos=c(CRAN="http://cran.revolutionanalytics.com")
repos = c(CRAN = "http://mran.microsoft.com")
)
}
4 changes: 2 additions & 2 deletions inst/examples/example_makeDepGraph.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ availPkgs <- cranJuly2014

\dontrun{
availPkgs <- pkgAvail(
repos = c(CRAN="http://cran.revolutionanalytics.com"),
repos = c(CRAN="http://mran.microsoft.com"),
type="source"
)
}
Expand All @@ -26,7 +26,7 @@ if(require(igraph)) plot(p)

p <- makeDepGraph(
c("ggplot2", "forecast"),
repos = c(CRAN="http://cran.revolutionanalytics.com"),
repos = c(CRAN = "http://mran.microsoft.com"),
type="source"
)
if(require(igraph)) plot(p)
Expand Down
4 changes: 2 additions & 2 deletions inst/examples/example_makeRepo.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

# Specify list of packages to download
revolution <- c(CRAN="http://cran.revolutionanalytics.com")
revolution <- c(CRAN = "http://mran.microsoft.com")
pkgs <- c("foreach")

pdb <- cranJuly2014

\dontrun{
pdb <- pkgAvail(
repos = c(CRAN="http://cran.revolutionanalytics.com"),
repos = c(CRAN = "http://mran.microsoft.com"),
type="source"
)
}
Expand Down
6 changes: 3 additions & 3 deletions inst/examples/example_pkgDep.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

\dontrun{
pkgDep(pkg=c("ggplot2", "plyr", "reshape2"),
repos=c(CRAN="http://cran.revolutionanalytics.com")
pkgDep(pkg = c("ggplot2", "plyr", "reshape2"),
repos = c(CRAN = "http://mran.microsoft.com")
)
}

pdb <- cranJuly2014
\dontrun{
pdb <- pkgAvail(repos=c(CRAN="http://cran.revolutionanalytics.com"))
pdb <- pkgAvail(repos = c(CRAN = "http://mran.microsoft.com"))
}

pkgDep(pkg=c("ggplot2", "plyr", "reshape2"), pdb)
Expand Down
Loading

0 comments on commit 2552fde

Please sign in to comment.