Skip to content

Commit 3adca71

Browse files
committed
Download R packages from archive if old
1 parent 6d7e273 commit 3adca71

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

scripts/gen/dl_r_pkgs.R

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/usr/bin/env Rscript
2+
3+
options(warn = 1) # print warnings immediately
4+
25
args <- commandArgs(TRUE)
36

47
deptabfile = "r_deps.txt"
@@ -47,9 +50,20 @@ if(!file.exists("dl_r_pkgs.R")){
4750
dlPkgVer <- function(pkgname, ver, destdir, skipExisting = TRUE){
4851
pkgfile <- paste0(pkgname,"_",ver,".tar.gz")
4952
pkgpath <- file.path(destdir, pkgfile)
50-
url <- paste0(options("repos"), "/src/contrib/", pkgfile)
53+
url <- paste0(options("repos"), "/src/contrib/",pkgfile)
54+
url_archive <- paste0(
55+
options("repos"), "/src/contrib/Archive/",pkgname,"/", pkgfile)
5156
if(!file.exists(pkgpath) || !skipExisting){
52-
download.file(url, destfile = pkgpath)
57+
tryCatch({
58+
# Suppress warning for every 404 error. This is normal if the
59+
# package has moved to the Archive
60+
suppressWarnings(
61+
download.file(url, destfile = pkgpath)
62+
)
63+
}, error = function(e){
64+
download.file(url_archive, destfile = pkgpath)
65+
})
66+
5367
}else{
5468
message("Skip ",pkgfile," (exists already)")
5569
}
@@ -60,6 +74,9 @@ if(options("repos") == "@CRAN@"){
6074
options(repos = "https://cloud.r-project.org")
6175
}
6276
deptab <- read.table(deptabfile, row.names = NULL, header = FALSE, stringsAsFactors = FALSE)
77+
78+
if(!dir.exists(dest)) dir.create(dest)
79+
6380
for(row in seq_len(nrow(deptab))){
6481
dlPkgVer(deptab[row,1], deptab[row,2], dest)
6582
}

scripts/gen/install_dependencies

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,16 @@ echo "Download R dependencies..."
4343
"${thisdir}"/dl_r_pkgs.R
4444

4545
echo "Install R dependencies..."
46+
mkdir -p "$rlib"
47+
mkdir -p "$pylib"
48+
4649
cat r_deps.txt |\
4750
while read pkg ver; do
4851
if [ -d "$rlib/$pkg" ]; then
4952
echo "Skip $pkg"
5053
continue
5154
fi
52-
R_LIBS="$rlib" R CMD INSTALL -l "$rlib" "$rsrc/${pkg}_${ver}.tar.gz"
55+
R_LIBS="$rlib" R CMD INSTALL --no-test-load -l "$rlib" "$rsrc/${pkg}_${ver}.tar.gz"
5356
done
5457

5558
echo "Install python dependencies..."

0 commit comments

Comments
 (0)