library(desc)
# CSTools is being developed under R 3.4.2: .libPaths() returns:
shared_path <- "/shared/earth/software/R/3.4.2-foss-2015a-bare/lib64/R/library/"
fields_to_get <- c("Package", "Version", "License", "SystemRequirements",
                   "Depends", "Imports")
# package alpahbetical order: first direct dependencies, then subdependencies:
packages <- list("abind", "ClimProjDiags", "data.table", "easyVerification", 
                 "ggplot2", "graphics", "grDevices", 
                 "knitr", "maps", "markdown", "multiApply", "ncdf4", 
                 "plyr", "qmap", "rainfarmr", "RColorBrewer", 
                 "reshape2", "rmarkdown",
                 "stats", "startR", "s2dv", "s2dverification",
                 "testthat",
                 "utils", "verification", "zeallot", 
                 "assertthat", "backports", "base64enc", 
                 "bigmemory", "bigmemory.sri", "bitops", "boot", 
                 "callr", "caTools", "CircStats",
                 "cli", "climdex.pcic", "codetools", "colorspace", "compiler", "crayon", 
                 "desc", "digest", "doParallel", "dotCall64",
                 "dtw", "easyNCDF", "ellipsis", "evaluate", "fansi",
                 "fields", "fitdistrplus", "foreach", "foreign", "future",
                 "GEOmap", "geomapdata", "globals", "glue", "grid", "gtable",
                 "highr", "htmltools", "iterators", "jsonlite", 
                 "labeling", "lattice", "lazyeval", "listenv", "lsei",
                 "magrittr",
                 "mapdata", "mapproj", "maptools", "MASS", "Matrix", "MBA", "methods",
                 "mime", "munsell", "NbClust", "npsurv",
                 "parallel", "pbapply", "PCICt",  "pillar", "pkgbuild", "pkgconfig",
                 "pkgload", "praise", "prettyunits", "processx", "proxy", #"R.rsp", 
                 "Rcpp", "R6", "rlang", "RPMG", "rprojroot", "rstudioapi",
                 "scales", #"rnaturalearth", 
                 "sp", "spam", "SpecsVerification", "splancs", "splines",
                 "stringi", "stringr", "survival", 
                 "tibble", "tools", "utf8", "vctrs",
                 "viridisLite", "withr", "yaml") 

# Packages that are not installed but they still working because they are suggestions: R.rsp, rnaturalearth

info <- lapply(packages, function(pck) {
               desc_get(fields_to_get, file = paste0(shared_path, pck))})

info <- plyr::ldply(info, rbind)
write.table(info, "/esarchive/scratch/nperez/CSTools_Portability.csv", sep = ",", row.names =F)
print(info)
