-
-
Save DaveParr/558d7e0287c24332d3fd0b3e087a7fe6 to your computer and use it in GitHub Desktop.
Getting a local CRAN that combines internal and external packages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## ------------------------------------------------------------------------ | |
# Set the repo for use throughout | |
cran <- "https://cran.rstudio.org" | |
# Install | |
if(!require(miniCRAN)){ | |
install.packages("miniCRAN", repos = cran) | |
} | |
## ------------------------------------------------------------------------ | |
library(miniCRAN) | |
# Config variables | |
tempdir <- tempdir() | |
pkg <- "V8" | |
pkgs <- c(pkg, "curl") | |
# Doesn't use miniCRAN::addPackage as it'd get all the deps | |
dir.create(tempdir) | |
utils::download.packages(pkgs, tempdir, repos= cran) | |
## ------------------------------------------------------------------------ | |
mCRAN <- "myminiCRAN" | |
dir.create(mCRAN) | |
# Use NULL to create an empty structure | |
miniCRAN::makeRepo(NULL, mCRAN | |
, repos = cran, type="source") | |
## ------------------------------------------------------------------------ | |
file.copy(list.files(tempdir,pattern = "*.tar.gz" | |
, full.names = TRUE) | |
, file.path(mCRAN, "src", "contrib")) | |
## ------------------------------------------------------------------------ | |
miniCRAN::updateRepoIndex(mCRAN) | |
## ------------------------------------------------------------------------ | |
uriCRAN <- paste0("file:///" | |
, file.path(getwd(), mCRAN)) | |
## ------------------------------------------------------------------------ | |
deps <- miniCRAN::pkgDep(pkg | |
, repos = uriCRAN | |
, suggests = FALSE) | |
# Exclude locally available packages | |
deps <- setdiff(deps, pkgs) | |
## ------------------------------------------------------------------------ | |
miniCRAN::addPackage(deps, mCRAN | |
, repos = cran | |
, writePACKAGES = TRUE | |
# Deps already captured | |
, deps = FALSE) | |
## ------------------------------------------------------------------------ | |
install.packages(pkg, repos = uriCRAN | |
, type="source") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment