From 5f7392e2a6038b78080e964522b34d4a1eb04b1d Mon Sep 17 00:00:00 2001 From: blundellc Date: Sat, 13 Sep 2008 13:16:58 +0000 Subject: [PATCH] cran2deb: correct cran2deb dependencies. make cran2deb a meta-executable. 'cran2deb' is a script that determines the root of the cran2deb R package installation and then invokes some other executable with this root as the first argument. e.g., $ cran2deb update $ cran2deb build zoo The README file now includes details of what must be done to use cran2deb. git-svn-id: svn://svn.r-forge.r-project.org/svnroot/cran2deb@48 edb9625f-4e0d-4859-8d74-9fd3b1da38cb --- pkg/trunk/DESCRIPTION | 1 + pkg/trunk/R/debcontrol.R | 2 +- pkg/trunk/R/zzz.R | 2 +- pkg/trunk/README | 24 +++++ pkg/trunk/exec/build | 95 ++++++++++++++++ pkg/trunk/exec/cran2deb | 101 ++---------------- pkg/trunk/exec/help | 6 ++ pkg/trunk/exec/root | 2 + pkg/trunk/exec/{setup => update} | 13 +-- .../exec/{update_available => update_cache} | 6 +- pkg/trunk/inst/etc/pbuilderrc.in | 2 +- 11 files changed, 149 insertions(+), 105 deletions(-) create mode 100755 pkg/trunk/exec/build create mode 100755 pkg/trunk/exec/help create mode 100755 pkg/trunk/exec/root rename pkg/trunk/exec/{setup => update} (61%) rename pkg/trunk/exec/{update_available => update_cache} (80%) diff --git a/pkg/trunk/DESCRIPTION b/pkg/trunk/DESCRIPTION index 1bfa413..ecd30f7 100644 --- a/pkg/trunk/DESCRIPTION +++ b/pkg/trunk/DESCRIPTION @@ -5,6 +5,7 @@ Title: Convert CRAN packages into Debian packages Author: Charles Blundell , with assistance from Dirk Eddelbuettel <> Maintainer: Charles Blundell Depends: ctv, utils +SystemRequirements: rc Description: Convert CRAN packages into Debian packages, mostly unassisted, easily subverting the R package system. License: GPL-3 diff --git a/pkg/trunk/R/debcontrol.R b/pkg/trunk/R/debcontrol.R index ea25962..1639369 100644 --- a/pkg/trunk/R/debcontrol.R +++ b/pkg/trunk/R/debcontrol.R @@ -25,7 +25,7 @@ get.dependencies <- function(pkg,extra_deps) { depends$bin = c(depends$bin, pkgname.as.debian('R',version='>= 2.7.0',binary=T)) } # also include stuff to allow tcltk to build (suggested by Dirk) - depends$build = c(depends$build,'xvfb','xauth','xfont-base') + depends$build = c(depends$build,'xvfb','xauth','xfonts-base') # remove duplicates depends <- lapply(depends,unique) diff --git a/pkg/trunk/R/zzz.R b/pkg/trunk/R/zzz.R index a57cc3a..6361ea7 100644 --- a/pkg/trunk/R/zzz.R +++ b/pkg/trunk/R/zzz.R @@ -6,7 +6,7 @@ changesfile <- function(srcname,version='*') { } maintainer <- 'cran2deb buildbot ' -root <- system.file('') +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') diff --git a/pkg/trunk/README b/pkg/trunk/README index e69de29..9b1c581 100644 --- a/pkg/trunk/README +++ b/pkg/trunk/README @@ -0,0 +1,24 @@ +To install: + +$ cd .. +$ R CMD INSTALL cran2deb + +copy cran2deb/exec/cran2deb into somewhere in your executable path (e.g., +/usr/local/bin, $home/bin) + + + +To configure: + +1. You need a web server serving from say, /var/www/cran2deb/ + +Let ROOT be the value returned by running: cran2deb root + +2. ROOT/var/archive should be a symlink pointing to /var/www/cran2deb/ + $ rm ROOT/var/archive + $ ln -s /var/www/cran2deb/ ROOT/var/archive +3. modify OTHERMIRROR of ROOT/etc/pbuilderrc.in to point to your webserver +4. run: cran2deb update +5. Try building a simple package: cran2deb build zoo + (The result will be in ROOT/var/results) + diff --git a/pkg/trunk/exec/build b/pkg/trunk/exec/build new file mode 100755 index 0000000..5678f28 --- /dev/null +++ b/pkg/trunk/exec/build @@ -0,0 +1,95 @@ +#!/usr/bin/env r +suppressMessages(library(cran2deb)) +go <- function(name,extra_deps) { + dir <- setup() + pkg <- try((function() { + pkg <- prepare.new.debian(prepare.pkg(dir,name),extra_deps) + if (file.exists(changesfile(pkg$srcname,pkg$debversion))) { + message(paste('N: already built',pkg$srcname,'version',pkg$debversion)) + return(pkg) + } + + # delete the current archive (XXX: assumes mini-dinstall) + for (subdir in c('mini-dinstall','unstable')) { + path = file.path(dinstall_archive,subdir) + if (file.exists(path)) { + unlink(path,recursive=T) + } + } + + # delete notes of upload + file.remove(Sys.glob(file.path(pbuilder_results,'*.upload'))) + + # make mini-dinstall generate the skeleton of the archive + ret = system(paste('umask 022;mini-dinstall --batch -c',dinstall_config)) + if (ret != 0) { + stop('failed to create archive') + } + + # pull in all the R dependencies + message(paste('N: dependencies:',paste(pkg$depends$r,collapse=', '))) + for (dep in pkg$depends$r) { + message(paste('N: uploading',dep)) + ret = system(paste('umask 022;dput','-c',shQuote(dput_config),'local' + ,changesfile(dep))) + if (ret != 0) { + stop('upload of dependency failed! maybe you did not build it first?') + } + } + build.debian(pkg) + + # upload the package + ret = system(paste('umask 022;dput','-c',shQuote(dput_config),'local' + ,changesfile(pkg$srcname,pkg$debversion))) + if (ret != 0) { + stop('upload failed!') + } + + return(pkg) + })()) + cleanup(dir) + if (inherits(pkg,'try-error')) { + stop(call.=F) + } + return(pkg) +} + +if (exists('argv')) { # check for littler + argc <- length(argv) + extra_deps = list() + extra_deps$deb = c() + extra_deps$r = c() + opts = c('-D','-R') + # first argument is the root --- this is dealt with elsewhere. + for (i in 2:argc) { + if (!(argv[i] %in% opts)) { + if (argc >= i) { + argv <- argv[i:argc] + } else { + argv <- list() + } + argc = argc - i + 1 + break + } + if (i == argc) { + message('E: missing argument') + q(save='no') + } + if (argv[i] == '-D') { + extra_deps$deb = c(extra_deps$deb,strsplit(chomp(argv[i+1]),',')[[1]]) + } + if (argv[i] == '-R') { + extra_deps$r = c(extra_deps$r,strsplit(chomp(argv[i+1]),',')[[1]]) + extra_deps$deb = c(extra_deps$deb,lapply(extra_deps$r,pkgname.as.debian)) + } + } + if (argc == 0) { + message('E: usage: cran2deb [-D extra_dep1,extra_dep2,...] package package ...') + q(save='no') + } + build_order <- r.dependency.closure(c(extra_deps$r,argv)) + message(paste('N: build order',paste(build_order,collapse=', '))) + for (pkg in build_order) { + go(pkg,extra_deps) + } +} diff --git a/pkg/trunk/exec/cran2deb b/pkg/trunk/exec/cran2deb index fc6c45c..a28879c 100755 --- a/pkg/trunk/exec/cran2deb +++ b/pkg/trunk/exec/cran2deb @@ -1,94 +1,9 @@ -#!/usr/bin/env r -library(cran2deb) -go <- function(name,extra_deps) { - dir <- setup() - pkg <- try((function() { - pkg <- prepare.new.debian(prepare.pkg(dir,name),extra_deps) - if (file.exists(changesfile(pkg$srcname,pkg$debversion))) { - message(paste('N: already built',pkg$srcname,'version',pkg$debversion)) - return(pkg) - } - - # delete the current archive (XXX: assumes mini-dinstall) - for (subdir in c('mini-dinstall','unstable')) { - path = file.path(dinstall_archive,subdir) - if (file.exists(path)) { - unlink(path,recursive=T) - } - } - - # delete notes of upload - file.remove(Sys.glob(file.path(pbuilder_results,'*.upload'))) - - # make mini-dinstall generate the skeleton of the archive - ret = system(paste('umask 022;mini-dinstall --batch -c',dinstall_config)) - if (ret != 0) { - stop('failed to create archive') - } - - # pull in all the R dependencies - message(paste('N: dependencies:',paste(pkg$depends$r,collapse=', '))) - for (dep in pkg$depends$r) { - message(paste('N: uploading',dep)) - ret = system(paste('umask 022;dput','-c',shQuote(dput_config),'local' - ,changesfile(dep))) - if (ret != 0) { - stop('upload of dependency failed! maybe you did not build it first?') - } - } - build.debian(pkg) - - # upload the package - ret = system(paste('umask 022;dput','-c',shQuote(dput_config),'local' - ,changesfile(pkg$srcname,pkg$debversion))) - if (ret != 0) { - stop('upload failed!') - } - - return(pkg) - })()) - cleanup(dir) - if (inherits(pkg,'try-error')) { - stop(call.=F) - } - return(pkg) -} - -if (exists('argv')) { # check for littler - argc <- length(argv) - extra_deps = list() - extra_deps$deb = c() - extra_deps$r = c() - opts = c('-D','-R') - for (i in 1:argc) { - if (!(argv[i] %in% opts)) { - if (argc >= i) { - argv <- argv[i:argc] - } else { - argv <- list() - } - argc = argc - i + 1 - break - } - if (i == argc) { - message('E: missing argument') - q(save='no') - } - if (argv[i] == '-D') { - extra_deps$deb = c(extra_deps$deb,strsplit(chomp(argv[i+1]),',')[[1]]) - } - if (argv[i] == '-R') { - extra_deps$r = c(extra_deps$r,strsplit(chomp(argv[i+1]),',')[[1]]) - extra_deps$deb = c(extra_deps$deb,lapply(extra_deps$r,pkgname.as.debian)) - } - } - if (argc == 0) { - message('E: usage: cran2deb [-D extra_dep1,extra_dep2,...] package package ...') - q(save='no') - } - build_order <- r.dependency.closure(c(extra_deps$r,argv)) - message(paste('N: build order',paste(build_order,collapse=', '))) - for (pkg in build_order) { - go(pkg,extra_deps) - } +#!/usr/bin/rc +root=`{r -e 'suppressMessages(library(cran2deb));cat(system.file(package=''cran2deb''),file=stdout())'} +cmd=$1 +shift +if ([ ! -x $root/exec/$cmd ]) { + echo unknown command $cmd + exit 1 } +$root/exec/$cmd $root $* diff --git a/pkg/trunk/exec/help b/pkg/trunk/exec/help new file mode 100755 index 0000000..6be441e --- /dev/null +++ b/pkg/trunk/exec/help @@ -0,0 +1,6 @@ +#!/usr/bin/rc +echo usage: cran2deb ' [args ...]' +echo where '' is one of +ls $1/exec +echo +echo installation root is: $1 diff --git a/pkg/trunk/exec/root b/pkg/trunk/exec/root new file mode 100755 index 0000000..7294588 --- /dev/null +++ b/pkg/trunk/exec/root @@ -0,0 +1,2 @@ +#!/usr/bin/rc +echo $1 diff --git a/pkg/trunk/exec/setup b/pkg/trunk/exec/update similarity index 61% rename from pkg/trunk/exec/setup rename to pkg/trunk/exec/update index 011bd12..5e80c2a 100755 --- a/pkg/trunk/exec/setup +++ b/pkg/trunk/exec/update @@ -1,14 +1,15 @@ #!/usr/bin/rc umask 022 -root=`{r -e 'library(cran2deb);cat(system.file('''',package=''cran2deb''),file=stdout())'} -for (x in `{find etc -type f -name '*.in'}) { +root=$1 +shift +for (x in `{find $root/etc -type f -name '*.in'}) { y=`{echo $x | sed -e 's,.in$,,'} sed -e 's:@ROOT@:'^$root^':g' <$x >$y } -mkdir -p var/results -if ([ ! -e var/archive ]) { +mkdir -p $root/var/results +if ([ ! -e $root/var/archive ]) { # I symbolically link this into /var/www/ - mkdir var/archive + mkdir $root/var/archive } mini-dinstall --batch -c $root/etc/mini-dinstall.conf || exit 1 mode=create @@ -16,4 +17,4 @@ if ([ -e /var/cache/pbuilder/base.tgz ]) { mode=update } sudo pbuilder $mode --override-config --configfile $root/etc/pbuilderrc -./update_available +$root/exec/update_cache $root diff --git a/pkg/trunk/exec/update_available b/pkg/trunk/exec/update_cache similarity index 80% rename from pkg/trunk/exec/update_available rename to pkg/trunk/exec/update_cache index 11df8b0..d80b072 100755 --- a/pkg/trunk/exec/update_available +++ b/pkg/trunk/exec/update_cache @@ -1,11 +1,11 @@ #!/usr/bin/env r +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...') -library(ctv) ctv.available <- available.views(repo=mirror) -library(cran2deb) -save(available, ctv.available, file=system.file('R/sysdata.rda',package='cran2deb'),eval.promises=T) +save(available, ctv.available, file=file.path(argv[1],'R/sysdata.rda'),eval.promises=T) diff --git a/pkg/trunk/inst/etc/pbuilderrc.in b/pkg/trunk/inst/etc/pbuilderrc.in index 1f99b77..ec9a9c4 100644 --- a/pkg/trunk/inst/etc/pbuilderrc.in +++ b/pkg/trunk/inst/etc/pbuilderrc.in @@ -1,6 +1,6 @@ HOOKDIR=@ROOT@/etc/hook BUILDRESULT=@ROOT@/var/results -EXTRAPACKAGES='debhelper r-base-dev cdbs r-base-core lintian xauth xfont-base xvfb' +EXTRAPACKAGES='debhelper r-base-dev cdbs r-base-core lintian xauth xfonts-base xvfb' DISTRIBUTION=lenny OTHERMIRROR='deb http://localhost/users/cb/cran2deb/ unstable/$(ARCH)/ | deb http://localhost/users/cb/cran2deb/ unstable/all/' MIRRORSITE='http://ftp.debian.org/debian/' -- 2.39.2