Skip to content

Commit

Permalink
Code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
andrie committed Dec 19, 2017
1 parent b937ba0 commit 3118ba7
Show file tree
Hide file tree
Showing 15 changed files with 326 additions and 1,053 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ LICENSE.md
.travis.yml
^.*\.Rproj$
^\.Rproj\.user$
^docs$
^_pkgdown\.yml$
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ 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 (or zero) Internet access.
Date: 2017-11-15
Version: 0.2.10.9000
Date: 2017-12-19
Version: 0.2.11.9000
URL: https://github.com/andrie/miniCRAN
BugReports: https://github.com/andrie/miniCRAN/issues
SystemRequirements: Imports the `curl` and `XML` packages. These have system
Expand Down
8 changes: 8 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
miniCRAN v0.2.11.9000 (Release date: in development)
================

New features:

* Used `pkgdown` to build documentation site


miniCRAN v0.2.10.9000
=====================

Expand Down
36 changes: 19 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ Create a mini version of CRAN containing only selected packages

## Introduction

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. By then end of 2017, the number of packages doubled to more than 12,000. 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.
The `miniCRAN` package 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.

## Important functions:

* Find package dependencies: `pkgDep()`
* Make repository (with or without downloading packages): `makeRepo()`
* Add additonal packages (and their dependencies) to existing repository: `addPackage()`
* Update the versions of packages currently in the repository: `updatePackages()`
Function | Use it for
-------------- | ------------------------------------------
`pkgDep()` | Find package dependencies
`makeRepo()` | Make repository (with or without downloading packages)
`addPackage()` | Add additonal packages (and their dependencies) to existing repository
`updatePackages()` | Update the versions of packages currently in the repository

## Installation:

Expand All @@ -33,7 +35,7 @@ library("miniCRAN")

### Development version

Get the latest stable development version from github:
Get the latest development version from github:

```r
# Use `devtools` to install directly from github
Expand All @@ -43,19 +45,19 @@ install_github("andrie/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`.
The `miniCRAN` package itself doesn't introduce any system dependencies. However, the package imports the [`curl`](https://cran.r-project.org/package=curl) and [`XML`](https://cran.r-project.org/package=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:
* On systems with the `rpm` package manager (Red Hat, CentOS) try:

```bash
yum install libcurl-devel libxml2-devel openssl-devel
```
```sh
yum install libcurl-devel libxml2-devel openssl-devel
```

On systems with the `aptitude` 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
```
```sh
apt-get install libcurl4-openssl-dev libxml2-devel openssl-devel
```


## Example:
Expand All @@ -65,7 +67,7 @@ apt-get install libcurl4-openssl-dev libxml2-devel openssl-devel
library("miniCRAN")
pkgs <- c("ggplot2", "plyr", "reshape2")
makeRepo(pkgDep(pkgs), path=file.path(tempdir(), "miniCRAN"), download=TRUE)
makeRepo(pkgDep(pkgs), path = file.path(tempdir(), "miniCRAN"))
```
## Supported by Microsoft
Expand Down
352 changes: 55 additions & 297 deletions inst/doc/miniCRAN-dependency-graph.html

Large diffs are not rendered by default.

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

# use Revolution Analytics CRAN mirror
revolution <- c(CRAN="http://cran.microsoft.com")
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 <- pkgDep(pkgs, repos = revolution, type = "source", suggests = FALSE,
availPkgs = cranJuly2014)
pkgList

## ----make-repo-2, eval=FALSE---------------------------------------------
Expand All @@ -18,11 +19,11 @@ pkgList

## ----make-repo-3, eval=FALSE---------------------------------------------
# # List all files in miniCRAN
# list.files(pth, recursive=TRUE, full.names=FALSE)
# 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)]
# pkgAvail(repos = pth, type = "win.binary")[, c(1:3, 5)]

## ----make-repo-5, eval=FALSE---------------------------------------------
# install.packages(pkgs,
Expand All @@ -31,22 +32,24 @@ pkgList

## ----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)]
# 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)
# 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")
# 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")
# 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
Expand All @@ -55,21 +58,21 @@ pkgList
# file.remove(pkgVersionsSrc[c(2,4,6)])
#
# # rebuild the package index after removing duplicate package versions
# updateRepoIndex(pth, type=c("source", "win.binary"))
# 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
# 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
# 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
# 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
Expand Down
442 changes: 99 additions & 343 deletions inst/doc/miniCRAN-introduction.html

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions inst/doc/miniCRAN-introduction.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
title: "Using miniCRAN to create a local CRAN repository"
author: "Andrie de Vries and Alex Chubaty"
date: "`r as.character(format(Sys.Date(), format='%B %d, %Y'))`"
output:
html_document:
self_contained: yes
toc: yes
output: rmarkdown::html_vignette
vignette: >
%\VignetteEngine{knitr::rmarkdown}
%\VignetteIndexEntry{Using miniCRAN to create and maintain a local CRAN repository}
Expand All @@ -28,7 +25,8 @@ 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 <- pkgDep(pkgs, repos = revolution, type = "source", suggests = FALSE,
availPkgs = cranJuly2014)
pkgList
```

Expand All @@ -39,7 +37,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 = c("source", "win.binary"))
makeRepo(pkgList, path=pth, repos=revolution, type=c("source", "win.binary"))
```


Expand Down Expand Up @@ -91,9 +89,11 @@ To add a specific version of a package from CRAN (or another CRAN-like repositor

```{r 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)
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")
Expand Down Expand Up @@ -143,7 +143,7 @@ oldPackages(path = pth, repos = revolution, type = "win.binary")[, 1:3] # should
```


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 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.

```{r update-repo-2, eval=FALSE}
# Update available packages
Expand Down
8 changes: 4 additions & 4 deletions inst/doc/miniCRAN-non-CRAN-repos.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## ----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)
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]
}

Expand All @@ -27,7 +27,7 @@ index <- function(url, type="source", filters=NULL, head=5, cols=c("Package", "V
# bioc <- local({
# env <- new.env()
# on.exit(rm(env))
# evalq(source("http://bioconductor.org/biocLite.R", local=TRUE), env)
# evalq(source("http://bioconductor.org/biocLite.R", local = TRUE), env)
# biocinstallRepos()
# })
#
Expand Down
378 changes: 67 additions & 311 deletions inst/doc/miniCRAN-non-CRAN-repos.html

Large diffs are not rendered by default.

15 changes: 6 additions & 9 deletions inst/doc/miniCRAN-non-CRAN-repos.rmd
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
---
title: "Using repositories other than CRAN with miniCRAN"
author: "Andrie de Vries"
date: "`r as.character(format(Sys.Date(), format='%B %d, %Y'))`"
output:
html_document:
self_contained: yes
toc: yes
date: "`r as.character(format(Sys.Date(), format = '%B %d, %Y'))`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteEngine{knitr::rmarkdown}
%\VignetteIndexEntry{Using repositories other than CRAN with miniCRAN}
Expand All @@ -24,9 +21,9 @@ To simplify the code to show the salient features, we use a little helper functi
```{r 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)
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]
}
Expand Down Expand Up @@ -71,7 +68,7 @@ Although BioConductor has a different preferred install mechanism, the underlyin
bioc <- local({
env <- new.env()
on.exit(rm(env))
evalq(source("http://bioconductor.org/biocLite.R", local=TRUE), env)
evalq(source("http://bioconductor.org/biocLite.R", local = TRUE), env)
biocinstallRepos()
})
Expand Down
5 changes: 1 addition & 4 deletions vignettes/miniCRAN-dependency-graph.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
title: "Using miniCRAN to identify package dependencies"
author: "Andrie de Vries"
date: "`r as.character(format(Sys.Date(), format='%B %d, %Y'))`"
output:
html_document:
self_contained: yes
toc: yes
output: rmarkdown::html_vignette
vignette: >
%\VignetteEngine{knitr::rmarkdown}
%\VignetteIndexEntry{Using miniCRAN to identify package dependencies}
Expand Down
Loading

0 comments on commit 3118ba7

Please sign in to comment.