source('../common.R') av <- function() { ## setRepositories(ind = 1) # CRAN options(available_packages_filters = c("R_version", "OS_type", "CRAN", "duplicates")) av <- available.packages()[, c("Package", "Version", "Repository")] av <- as.data.frame(av, stringsAsFactors = FALSE) path <- with(av, paste0(Repository, "/", Package, "_", Version, ".tar.gz")) av$Repository <- NULL av$Path <- sub(".*contrib/", "../contrib/", path) av$mtime <- file.info(av$Path)$mtime av[order(av$Package), ] } get_vers <- function(nm) { ## read already-checked versions vers <- sapply(nm, function(n) { if (file.exists(f <- paste0(n, ".out"))) { ver <- grep("^[*] this is package", readLines(f, warn = FALSE), value = TRUE, useBytes = TRUE) if(length(ver)) sub(".*version '([^’]+)'.*", "\\1", ver) else "10000.0.0" } else "10000.0.0" }) package_version(vers) } do_it <- function(stoplist) { tars <- av() tars <- tars[!tars$Package %in% stoplist, ] nm <- tars$Package time0 <- file.info(paste0(nm, ".in"))$mtime vers <- get_vers(nm) unpack <- is.na(time0) | (tars$mtime > time0) | (tars$Version > vers) for(i in which(unpack)) { if(nm[i] %in% stoplist) next cat(nm[i], "\n", sep = "") unlink(nm[i], recursive = TRUE) unlink(paste0(nm[i], ".out")) system(paste("tar -zxf", tars[i, "Path"])) system(paste("touch -r", tars[i, "Path"], paste0(nm[i], ".in"))) } } do_it(stoplist)