From 8365753a43f006368e2892a083d8df04debc6782 Mon Sep 17 00:00:00 2001 From: Adam Vogt Date: Wed, 25 Feb 2015 17:43:43 -0500 Subject: [PATCH] let generate-cran-packages.R read checksums from cran-packages.nix this lets "Rscript generate-cran-packages.R > cran-packages.nix" complete much quicker, because we only have to download packages with new versions. --- pkgs/development/r-modules/generate-cran-packages.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/development/r-modules/generate-cran-packages.R b/pkgs/development/r-modules/generate-cran-packages.R index 3dea348f330..3510a2fa92c 100644 --- a/pkgs/development/r-modules/generate-cran-packages.R +++ b/pkgs/development/r-modules/generate-cran-packages.R @@ -3,7 +3,12 @@ library(parallel) cl <- makeCluster(10) options(repos=structure(c(CRAN="http://cran.rstudio.com/"))) + +readFormatted <- as.data.table(read.table(skip=6, sep='"', text=head(readLines('cran-packages.nix'), -1))) + nixPrefetch <- function(name, version) { + prevV <- readFormatted$V2 == name & readFormatted$V4 == version + if (sum(prevV) == 1) as.character(readFormatted$V6[ prevV ]) else system(paste0("nix-prefetch-url --type sha256 http://cran.rstudio.com/src/contrib/", name, "_", version, ".tar.gz"), intern=TRUE) # system(paste0("nix-hash --flat --base32 --type sha256 /nix/store/*", name, "_", version, ".tar.gz", "| head -n 1"), intern=TRUE) } @@ -21,7 +26,7 @@ formatPackage <- function(name, version, sha256, depends, imports, linkingTo, kn paste0(attr, " = derive { name=\"", name, "\"; version=\"", version, "\"; sha256=\"", sha256, "\"; depends=[", depends, "]; };") } -clusterExport(cl, c("nixPrefetch")) +clusterExport(cl, c("nixPrefetch","readFormatted")) pkgs <- as.data.table(available.packages(filters=c("R_version", "OS_type", "CRAN", "duplicates"))) pkgs <- subset(pkgs, Repository=="http://cran.rstudio.com/src/contrib")