]> git.donarmstrong.com Git - cran2deb.git/commitdiff
support local CRAN/BioC mirror in /srv/R/Repositories
authorblundellc <blundellc@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Sat, 13 Sep 2008 13:26:18 +0000 (13:26 +0000)
committerblundellc <blundellc@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Sat, 13 Sep 2008 13:26:18 +0000 (13:26 +0000)
git-svn-id: svn://svn.r-forge.r-project.org/svnroot/cran2deb@122 edb9625f-4e0d-4859-8d74-9fd3b1da38cb

pkg/trunk/R/getrpkg.R

index 3c7e0af2cfb5b02f023a50bf5262ebc5bf43ab9e..5273a1fc601124da080b5dfe00c6061d06e905c5 100644 (file)
@@ -40,17 +40,32 @@ download_pkg <- function(dir, pkgname) {
         file.copy(debfn,pkg$archive)
         pkg$path = file.path(dir, paste(pkg$srcname ,pkg$version ,sep='-'))
     } else {
-        # use this instead of download.packages as it is more resilient to
-        # dodgy network connections (hello BT 'OpenWorld', bad ISP)
+        # see if we have a local mirror in /srv/R
+        use_local = FALSE
+        if (pkg$repo == 'cran') {
+            localfn = file.path('/srv/R/Repositories/CRAN/src/contrib',paste(pkg$name,'_',pkg$version,'.tar.gz',sep=''))
+            use_local = file.exists(localfn)
+        } else if (pkg$repo == 'bioc') {
+            localfn = file.path('/srv/R/Repositories/Bioconductor/release/bioc/src/contrib',paste(pkg$name,'_',pkg$version,'.tar.gz',sep=''))
+            use_local = file.exists(localfn)
+        }
+
         fn <- paste(pkgname, '_', pkg$version, '.tar.gz', sep='')
-        url <- paste(available[pkgname,'Repository'], fn, sep='/')
         archive <- file.path(dir, fn)
-        # don't log the output -- we don't care!
-        ret <- system(paste('curl','-o',shQuote(archive),'-m 720 --retry 5',shQuote(url)))
-        if (ret != 0) {
-            fail('failed to download',url)
+
+        if (use_local) {
+            file.copy(localfn, archive)
+        } else {
+            # use this instead of download.packages as it is more resilient to
+            # dodgy network connections (hello BT 'OpenWorld', bad ISP)
+            url <- paste(available[pkgname,'Repository'], fn, sep='/')
+            # don't log the output -- we don't care!
+            ret <- system(paste('curl','-o',shQuote(archive),'-m 720 --retry 5',shQuote(url)))
+            if (ret != 0) {
+                fail('failed to download',url)
+            }
+            # end of download.packages replacement
         }
-        # end of download.packages replacement
 
         if (length(grep('\\.\\.',archive)) || normalizePath(archive) != archive) {
             fail('funny looking path',archive)