Created
August 29, 2018 15:43
-
-
Save wrathematics/d59be451e3ddb9b9c6095c4a3f6bfd42 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
pbd = c( | |
"hdfio", | |
"hpcvis", | |
"kazaam", | |
"pbdBASE", | |
"pbdCS", | |
"pbdDEMO", | |
"pbdDMAT", | |
"pbdIO", | |
"pbdML", | |
"pbdMPI", | |
"pbdNCDF4", | |
"pbdPAPI", | |
"pbdPROF", | |
"pbdRPC", | |
"pbdSLAP", | |
"pbdZMQ", | |
"pbdADIOS", | |
"pmclust", | |
"remoter", | |
"tasktools" | |
) | |
get_cran_packages = function(cache, verbose) | |
{ | |
update = TRUE | |
if (file.exists(cache)) | |
{ | |
load(cache) | |
diff = Sys.Date() - timestamp | |
if (diff < 1) | |
{ | |
if (verbose) | |
cat("CRAN package cache < 24 hours old; not regenerating\n") | |
update = FALSE | |
} | |
} | |
if (update) | |
{ | |
if (verbose) | |
cat("Updating cran package cache...") | |
cran_pkgs = available.packages() | |
timestamp = Sys.Date() | |
save(cran_pkgs, timestamp, file=cache) | |
if (verbose) | |
cat("done!\n") | |
} | |
cran_pkgs | |
} | |
get_gh_packages = function(cache, verbose) | |
{ | |
update = TRUE | |
if (file.exists(cache)) | |
{ | |
load(cache) | |
diff = Sys.Date() - timestamp | |
if (diff < 1) | |
{ | |
if (verbose) | |
cat("GitHub package cache < 24 hours old; not regenerating\n") | |
update = FALSE | |
} | |
} | |
if (update) | |
{ | |
if (verbose) | |
cat("Updating GitHub package cache...") | |
gh_pkgs = character(length(pbd)) | |
for (i in 1:length(pbd)) | |
{ | |
p = pbd[i] | |
ver_gh = readLines(paste0("https://raw.githubusercontent.com/RBigData/", p, "/master/DESCRIPTION")) | |
ver_gh = ver_gh[grep(ver_gh, pattern="Version:", ignore.case=TRUE)] | |
ver_gh = sub("Version: ", "", ver_gh) | |
gh_pkgs[i] = ver_gh | |
} | |
timestamp = Sys.Date() | |
save(gh_pkgs, timestamp, file=cache) | |
if (verbose) | |
cat("done!\n") | |
} | |
names(gh_pkgs) = pbd | |
gh_pkgs | |
} | |
pbd_package_manifest = function(cran_cache="/tmp/.cran_packages", gh_cache="/tmp/.gh_packages", verbose=TRUE) | |
{ | |
cran_pkgs = get_cran_packages(cache=cran_cache, verbose=verbose) | |
gh_pkgs = get_gh_packages(cache=gh_cache, verbose=verbose) | |
df = data.frame() | |
for (p in pbd) | |
{ | |
test = tryCatch(packageVersion(p), error=identity) | |
if (inherits(test, "simpleError")) | |
ver_local = NA_character_ | |
else | |
ver_local = as.character(test) | |
ver_gh = gh_pkgs[p] | |
if (p %in% cran_pkgs) | |
ver_cran = cran_pkgs[p, ]["Version"] | |
else | |
ver_cran = NA_character_ | |
df = rbind(df, cbind(Local=ver_local, GH=ver_gh, CRAN=ver_cran)) | |
} | |
rownames(df) = pbd | |
df | |
} | |
manifest = pbd_package_manifest() | |
manifest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment