From b44d6125c230362bceebdfec4b996966e77f85f5 Mon Sep 17 00:00:00 2001 From: blundellc Date: Sat, 13 Sep 2008 13:17:47 +0000 Subject: [PATCH] cran2deb: put base_pkgs into the cache. generate cache so that R is happy. use separate base.tgz for cran2deb. base_pkgs is the list of all packages that are provided in the basic install of R. It is found by listing all installed packages in the pbuilder environment. Previously the cache of availabile packages lived in sysdata.rda. Unfortunately it appears that R does not like it when sysdata.rda is updated after package installation (I think this is something to do with lazy loading, but disabling this did not seem to help). Instead the cache is maintained separated in the data/ package directory. pbuilder now uses base-cran2deb.tgz for the cran2deb pbuilder environment -- this should help keep cran2deb from interfering from other uses of pbuilder. git-svn-id: svn://svn.r-forge.r-project.org/svnroot/cran2deb@54 edb9625f-4e0d-4859-8d74-9fd3b1da38cb --- pkg/trunk/DESCRIPTION | 2 +- pkg/trunk/R/debiannaming.R | 7 ------ pkg/trunk/R/debianpkg.R | 2 +- pkg/trunk/R/zzz.R | 38 +++++++++++++++++--------------- pkg/trunk/exec/build | 1 + pkg/trunk/exec/get_base_pkgs | 4 ++++ pkg/trunk/exec/update | 2 +- pkg/trunk/exec/update_cache | 11 ++++++++- pkg/trunk/inst/etc/pbuilderrc.in | 1 + 9 files changed, 39 insertions(+), 29 deletions(-) create mode 100755 pkg/trunk/exec/get_base_pkgs diff --git a/pkg/trunk/DESCRIPTION b/pkg/trunk/DESCRIPTION index 9cf7805..f0fb522 100644 --- a/pkg/trunk/DESCRIPTION +++ b/pkg/trunk/DESCRIPTION @@ -5,7 +5,7 @@ Title: Convert CRAN packages into Debian packages Author: Charles Blundell , with assistance from Dirk Eddelbuettel <> Maintainer: Charles Blundell Depends: ctv, utils, RSQLite, DBI -SystemRequirements: rc, pbuilder, debian toolchain, web server +SystemRequirements: rc, pbuilder, debian toolchain, web server, mini-dinstall Description: Convert CRAN packages into Debian packages, mostly unassisted, easily subverting the R package system. License: GPL-3 diff --git a/pkg/trunk/R/debiannaming.R b/pkg/trunk/R/debiannaming.R index 08c3f84..001262a 100644 --- a/pkg/trunk/R/debiannaming.R +++ b/pkg/trunk/R/debiannaming.R @@ -1,10 +1,3 @@ -# sudo pbuilder --execute r -e 'rownames(installed.packages())' -# XXX: has to be a better way of doing this -base_pkgs=c('base', 'datasets','grDevices','graphics','grid', 'methods' - ,'splines','stats', 'stats4', 'tcltk', 'tools','utils') -# found in R source directory: -# 'profile', 'datasets' - repourl.as.debian <- function(url) { # map the url to a repository onto its name in debian package naming if (length(grep('cran',url))) { diff --git a/pkg/trunk/R/debianpkg.R b/pkg/trunk/R/debianpkg.R index 3b9ca62..1beb5e6 100644 --- a/pkg/trunk/R/debianpkg.R +++ b/pkg/trunk/R/debianpkg.R @@ -144,7 +144,7 @@ build.debian <- function(pkg) { ,pkg$debname ,paste('(',pkg$debversion,')',sep='') ,'...')) - ret = system(paste('pdebuild --configfile',pbuilder_config)) + ret = system(paste('pdebuild --configfile',shQuote(pbuilder_config))) setwd(wd) if (ret != 0) { stop('Failed to build package.') diff --git a/pkg/trunk/R/zzz.R b/pkg/trunk/R/zzz.R index c5e78f0..34811d2 100644 --- a/pkg/trunk/R/zzz.R +++ b/pkg/trunk/R/zzz.R @@ -1,22 +1,24 @@ library(DBI) library(RSQLite) -changesfile <- function(srcname,version='*') { - return(file.path(pbuilder_results - ,paste(srcname,'_',version,'_' - ,host.arch(),'.changes',sep=''))) -} - -maintainer <- 'cran2deb buildbot ' -root <- system.file(package='cran2deb') -pbuilder_results <- file.path(root,'var/results') -pbuilder_config <- file.path(root,'etc/pbuilderrc') -dput_config <- file.path(root,'etc/dput.cf') -dinstall_config <- file.path(root,'etc/mini-dinstall.conf') -dinstall_archive <- file.path(root,'var/archive') -r_depend_fields <- c('Depends','Imports') # Suggests, Enhances - -# we cache the list of available packages -# should be pulled in already -#load(file.path(root,'var/cache/available.cache.Rd')) +.First.lib <- function(libname, pkgname) { + global <- function(name,value) assign(name,value,envir=.GlobalEnv) + global("changesfile", function(srcname,version='*') { + return(file.path(pbuilder_results + ,paste(srcname,'_',version,'_' + ,host.arch(),'.changes',sep=''))) + }) + global("maintainer", 'cran2deb buildbot ') + global("root", system.file(package='cran2deb')) + global("pbuilder_results", file.path(root,'var/results')) + global("pbuilder_config", file.path(root,'etc/pbuilderrc')) + global("dput_config", file.path(root,'etc/dput.cf')) + global("dinstall_config", file.path(root,'etc/mini-dinstall.conf')) + global("dinstall_archive", file.path(root,'var/archive')) + global("r_depend_fields", c('Depends','Imports')) # Suggests, Enhances + cache <- file.path(root,'data/cache.rda') + if (file.exists(cache)) { + load(cache,envir=.GlobalEnv) + } +} diff --git a/pkg/trunk/exec/build b/pkg/trunk/exec/build index 5678f28..0482896 100755 --- a/pkg/trunk/exec/build +++ b/pkg/trunk/exec/build @@ -1,5 +1,6 @@ #!/usr/bin/env r suppressMessages(library(cran2deb)) + go <- function(name,extra_deps) { dir <- setup() pkg <- try((function() { diff --git a/pkg/trunk/exec/get_base_pkgs b/pkg/trunk/exec/get_base_pkgs new file mode 100755 index 0000000..d08d625 --- /dev/null +++ b/pkg/trunk/exec/get_base_pkgs @@ -0,0 +1,4 @@ +#!/usr/bin/env r +for (pkg in rownames(installed.packages())) { + message(pkg) +} diff --git a/pkg/trunk/exec/update b/pkg/trunk/exec/update index 5e80c2a..598597c 100755 --- a/pkg/trunk/exec/update +++ b/pkg/trunk/exec/update @@ -13,7 +13,7 @@ if ([ ! -e $root/var/archive ]) { } mini-dinstall --batch -c $root/etc/mini-dinstall.conf || exit 1 mode=create -if ([ -e /var/cache/pbuilder/base.tgz ]) { +if ([ -e /var/cache/pbuilder/base-cran2deb.tgz ]) { mode=update } sudo pbuilder $mode --override-config --configfile $root/etc/pbuilderrc diff --git a/pkg/trunk/exec/update_cache b/pkg/trunk/exec/update_cache index d80b072..627e570 100755 --- a/pkg/trunk/exec/update_cache +++ b/pkg/trunk/exec/update_cache @@ -3,9 +3,18 @@ library(cran2deb) library(ctv) #mirror <- 'http://cran.uk.r-project.org/' mirror <- 'http://cran.r-project.org/' + message('updating list of available R packages...') available <- available.packages(contrib.url(mirror)) available <- rbind(available,available.packages(contrib.url('http://www.bioconductor.org/'))) + message('updating list of available R task views...') ctv.available <- available.views(repo=mirror) -save(available, ctv.available, file=file.path(argv[1],'R/sysdata.rda'),eval.promises=T) +message('updating list of base R packages...') +base_pkgs <- readLines(pipe(paste('sudo pbuilder --execute --override-config --configfile' + ,shQuote(pbuilder_config),'-- /usr/bin/R --vanilla 2>&1 >/dev/null <' + ,shQuote(file.path(root,'exec/get_base_pkgs')) + ,'| grep -v ^W:'))) + + +save(base_pkgs, available, ctv.available, file=file.path(argv[1],'data/cache.rda'),eval.promises=T) diff --git a/pkg/trunk/inst/etc/pbuilderrc.in b/pkg/trunk/inst/etc/pbuilderrc.in index a84b61b..425c0a4 100644 --- a/pkg/trunk/inst/etc/pbuilderrc.in +++ b/pkg/trunk/inst/etc/pbuilderrc.in @@ -1,3 +1,4 @@ +BASETGZ=/var/cache/pbuilder/base-cran2deb.tgz HOOKDIR=@ROOT@/etc/hook BUILDRESULT=@ROOT@/var/results EXTRAPACKAGES='debhelper r-base-dev cdbs r-base-core lintian xvfb xauth xfonts-base' -- 2.39.2