+
+curl.maxtime<-60*60 # 60 minutes max download time (some bioconductor packages are truly big and take time)
+curl.retries<-0 # No retries (connections are commonly good enough)
+
setup <- function() {
# set up the working directory
tmp <- tempfile('cran2deb')
# record some basic information
pkg <- pairlist()
- pkg$date_stamp = format(Sys.time(),'%a, %d %b %Y %H:%M:%S %z')
+ pkg$date_stamp = Sys.time()
pkg$name = pkgname
pkg$repoURL = available[pkgname,'Repository']
pkg$repo = repourl_as_debian(pkg$repoURL)
pkg$archive <- file.path(dir, basename(debfn))
file.copy(debfn,pkg$archive)
pkg$path = file.path(dir, paste(pkg$srcname ,pkg$version ,sep='-'))
+ notice('using an existing debianized source tarball:',debfn)
} else {
# see if we have a local mirror in /srv/R
use_local = FALSE
# 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)))
+ ret <- system(paste('curl','-o',shQuote(archive),
+ paste('-m',curl.maxtime,'--retry',curl.retries,sep=' '),
+ shQuote(url)))
if (ret != 0) {
fail('failed to download',url)
}
repack_pkg <- function(pkg) {
# re-pack into a Debian-named archive with a Debian-named directory.
+ notice('repacking into debian source archive.')
debpath = file.path(dirname(pkg$archive)
,paste(pkg$srcname
,pkg$version
,'-type f -a '
, '! \\( -name configure -o -name cleanup \\)'
,'-exec chmod -x {} \\;')
+ if (file.exists(file.path(basename(pkg$path),'debian'))) {
+ warn('debian/ directory found in tarball! removing...')
+ unlink(file.path(basename(pkg$path),'debian'),recursive=TRUE)
+ }
# tar it all back up
log_system('tar -czf',shQuote(debarchive),shQuote(basename(pkg$path)))
setwd(wd)
prepare_pkg <- function(dir, pkgname) {
# download and extract an R package named pkgname
- # OR the bundle containing pkgname
# based loosely on library/utils/R/packages2.R::install.packages
- # first a little trick; change pkgname if pkgname is contained in a bundle
- if (!(pkgname %in% rownames(available))) {
- bundle <- r_bundle_of(pkgname)
- if (is.null(bundle)) {
- fail('package',pkgname,'is unavailable')
- }
- pkgname <- bundle
- }
-
# grab the archive and some metadata
pkg <- download_pkg(dir, pkgname)
}
}
- pkg$is_bundle = 'Bundle' %in% names(pkg$description[1,])
# note subtly of short circuit operators (no absorption)
- if ((!pkg$is_bundle && pkg$description[1,'Package'] != pkg$name) ||
- ( pkg$is_bundle && pkg$description[1,'Bundle'] != pkg$name)) {
+ if (pkg$description[1,'Package'] != pkg$name) {
fail('package name mismatch')
}
return(pkg)