]> git.donarmstrong.com Git - cran2deb.git/commitdiff
cran2deb: satisfy immediate R dependencies iff the requisite package has already...
authorblundellc <blundellc@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Sat, 13 Sep 2008 13:14:08 +0000 (13:14 +0000)
committerblundellc <blundellc@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Sat, 13 Sep 2008 13:14:08 +0000 (13:14 +0000)
Works by running apt-get update before each build, pulling in the
declared R dependencies from a local repository.

Still to do is actually read off a topological order and deal with
transitivity.  Otherwise, this appears to work fine where the only
dependencies are those in Depends or Imports of the R DESCRIPTION.

Also included is to use Imports as well as Depends for generating R
dependencies... this was necessary for, for example, stashR --- not
quite sure if this is technically correct, but it allows this package to
work.

git-svn-id: svn://svn.r-forge.r-project.org/svnroot/cran2deb@27 edb9625f-4e0d-4859-8d74-9fd3b1da38cb

pkg/trunk/cran2deb
pkg/trunk/etc/hook/D70aptupdate [new file with mode: 0755]
pkg/trunk/etc/pbuilderrc.in

index 2e380fe84583dc32e37f282b1d6ba01251cf7907..798e2c2b907980e2e412933b1872f7df63a3d95d 100755 (executable)
@@ -1,8 +1,11 @@
 #!/usr/bin/env r
 
-pbuilder_results <- '/home/cb/work/gsoc/cran2deb/var/results'
-pbuilder_config <- '/home/cb/work/gsoc/cran2deb/etc/pbuilderrc'
-dput_config <- '/home/cb/work/gsoc/cran2deb/etc/dput.cf'
+root <- '/home/cb/work/gsoc/cran2deb'
+pbuilder_results <- paste(root,'/var/results',sep='')
+pbuilder_config  <- paste(root,'/etc/pbuilderrc',sep='')
+dput_config      <- paste(root,'/etc/dput.cf',sep='')
+dinstall_config  <- paste(root,'/etc/mini-dinstall.conf',sep='')
+dinstall_archive <- paste(root,'/var/archive',sep='')
 
 version.new <- function(rver,debian_revision=1, debian_epoch=0) {
     # generate a string representation of the Debian version of an
@@ -331,10 +334,16 @@ prepare.new.debian <- function(pkg) {
     }
 
     # determine dependencies
+    # these are used for generating the Depends fields
     bin.depends = list()
     src.depends = list()
-    if ('Depends' %in% names(pkg$description[1,])) {
-        for (dep in strsplit(chomp(pkg$description[1,'Depends'])
+    # these are used with dput to pull in R dependencies
+    r.depends = list()
+    for (field in c('Depends','Imports')) {
+        if (!(field %in% names(pkg$description[1,]))) {
+            next
+        }
+        for (dep in strsplit(chomp(pkg$description[1,field])
                                   ,'[[:space:]]*,[[:space:]]*')[[1]]) {
             # remove other comments
             dep = gsub('(\\(\\)|\\([[:space:]]*[^<=>!].*\\))','',dep)
@@ -351,10 +360,14 @@ prepare.new.debian <- function(pkg) {
             bin.deb = pkgname.as.debian(dep,pkg$repo,version=version,binary=T)
             bin.depends = c(bin.depends,bin.deb)
             src.depends = c(src.depends,src.deb)
+            if (length(grep('^r-',src.deb)) && !length(grep('^r-base',src.deb))) {
+                r.depends = c(r.depends,tolower(dep))
+            }
         }
-        src.depends=unique(src.depends)
-        bin.depends=unique(bin.depends)
     }
+    src.depends=unique(src.depends)
+    bin.depends=unique(bin.depends)
+    r.depends=unique(r.depends)
     if (!length(grep('^r-base',src.depends))) {
         src.depends = c(src.depends,pkgname.as.debian('R',version='>= 2.7.0',binary=F))
         bin.depends = c(bin.depends,pkgname.as.debian('R',version='>= 2.7.0',binary=T))
@@ -363,6 +376,7 @@ prepare.new.debian <- function(pkg) {
     if (pkg$archdep) {
         bin.depends=c(bin.depends,'${shlibs:Depends}')
     }
+    pkg$r.depends = r.depends
 
     # construct control file
     control = data.frame()
@@ -421,11 +435,44 @@ build.debian <- function(pkg) {
 }
 
 
+# TEST: SRPM -> stashR -> digest -> filehash
 go <- function(name) {
     dir <- setup()
     pkg <- try((function() {
         pkg <- prepare.new.debian(prepare.pkg(dir,name))
+
+        # delete the current archive (XXX: assumes mini-dinstall)
+        for (subdir in c('/mini-dinstall','/unstable')) {
+            path = paste(dinstall_archive,subdir,sep='')
+            if (file.exists(path)) {
+                unlink(path,recursive=T)
+            }
+        }
+
+        # delete notes of upload
+        file.remove(Sys.glob(paste(pbuilder_results,'*.upload',sep='/')))
+
+        # 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:',pkg$r.depends,collapse=', '))
+        for (dep in pkg$r.depends) {
+            message(paste('N: uploading',dep))
+            ret = system(paste('umask 022;dput','-c',shQuote(dput_config),'local'
+                        ,paste(pbuilder_results, '/'
+                              ,paste(dep,'_*_'
+                                    ,host.arch(),'.changes',sep=''), sep='')))
+            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'
                     ,paste('/', pbuilder_results, '/'
                           ,paste(pkg$srcname,'_',pkg$debversion,'_'
@@ -433,8 +480,7 @@ go <- function(name) {
         if (ret != 0) {
             stop('upload failed!')
         }
-# paste(pkg$srcname,'_',pkg$debversion,'.dsc',sep='')
-# paste(pkg$debname,'_',pkg$debversion,'_',pkg$arch,'.deb',sep='')
+
         return(pkg)
     })())
     cleanup(dir)
diff --git a/pkg/trunk/etc/hook/D70aptupdate b/pkg/trunk/etc/hook/D70aptupdate
new file mode 100755 (executable)
index 0000000..4d42b3d
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin/apt-get update
index 5d785b4cef8b8289ea468ba817ab17ca24621cf4..b2a9ad0c7ed1150348134c8348ce2a0aff7fe1c2 100644 (file)
@@ -2,6 +2,7 @@ HOOKDIR=@ROOT@/etc/hook
 BUILDRESULT=@ROOT@/var/results
 EXTRAPACKAGES='debhelper r-base-dev cdbs r-base-core lintian'
 DISTRIBUTION=lenny
-OTHERMIRROR='deb http://localhost/users/cb/cran2deb/ unstable/$(ARCH)/'
+OTHERMIRROR='deb http://localhost/users/cb/cran2deb/ unstable/$(ARCH)/ | deb http://localhost/users/cb/cran2deb/ unstable/all/'
 MIRRORSITE='http://ftp.debian.org/debian/'
 APTCACHE=''
+PBUILDERSATISFYDEPENDSCMD='/usr/lib/pbuilder/pbuilder-satisfydepends-classic'