#!/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
}
# 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)
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))
if (pkg$archdep) {
bin.depends=c(bin.depends,'${shlibs:Depends}')
}
+ pkg$r.depends = r.depends
# construct control file
control = data.frame()
}
+# 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,'_'
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)