Skip to content

Instantly share code, notes, and snippets.

@DexGroves
Created August 17, 2016 15:17
Show Gist options
  • Save DexGroves/c045f466efa6e72f3d7bd4e0448be1c7 to your computer and use it in GitHub Desktop.
Save DexGroves/c045f466efa6e72f3d7bd4e0448be1c7 to your computer and use it in GitHub Desktop.
# Instantiate local CRAN
localCRAN <- path.expand("QRAN")
dir.create(localCRAN)
contribDir <- file.path(localCRAN, "src", "contrib")
dir.create(contribDir, recursive = TRUE)
rVersion <- paste(unlist(getRversion())[1:2], collapse = ".")
binPaths <- list(
win.binary = file.path("bin/windows/contrib", rVersion),
mac.binary = file.path("bin/macosx/contrib", rVersion),
mac.binary.mavericks = file.path("bin/macosx/mavericks/contrib", rVersion),
mac.binary.leopard = file.path("bin/macosx/leopard/contrib", rVersion)
)
binPaths <- lapply(binPaths, function(x) file.path(localCRAN, x))
lapply(binPaths, function(path) {
dir.create(path, recursive = TRUE)
})
# Make sashimi
library("pkgKitten")
kitten("sashimi", path = tempdir())
pkgDir <- file.path(tempdir(), "sashimi")
# Custom repo name
sashimiDescPath <- file.path(tempdir(), "sashimi", "DESCRIPTION")
cat("Repository: sushi", file = sashimiDescPath, append = TRUE, sep = "\n")
# Go to the temporary directory and build 'sashimi'
owd <- getwd()
setwd(tempdir())
system("R CMD build sashimi")
setwd(owd)
# Copy it to the 'src/contrib' sub-directory
file.copy(
file.path(tempdir(), "sashimi_1.0.tar.gz"),
file.path(contribDir, "sashimi_1.0.tar.gz")
)
# Write the PACKAGES file for each sub-directory
tools::write_PACKAGES(contribDir, type = "source")
lapply(binPaths, function(path) {
tools::write_PACKAGES(path)
})
# Teach R about this repo
oldRepos <- getOption("repos")
cranURI <- paste("file://", normalizePath(localCRAN, winslash = "/"), sep = "")
options(repos = c(oldRepos, sushi = cranURI))
# You what mate this actually works
install.packages("sashimi", type = "source")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment