#!/usr/bin/env r
+maintainer <- 'cran2deb buildbot <cran2deb@example.org>'
root <- '/home/cb/work/gsoc/cran2deb'
pbuilder_results <- paste(root,'/var/results',sep='')
pbuilder_config <- paste(root,'/etc/pbuilderrc',sep='')
# XXX: data.frame rownames are unique, so always override repopref for
# now.
if (!(name %in% rownames(available))) {
- bundle <- r.bundle.of(pkgname)
+ bundle <- r.bundle.of(name)
if (is.na(bundle)) {
stop(paste('package',name,'is not available'))
}
# use the first bundle
for (bundle in names(bundles)) {
content <- strsplit(bundles[[bundle]],'[[:space:]]+')[[1]]
- message(paste(pkgname,'in',paste(content,collapse=', ')))
if (pkgname %in% content) {
return(bundle)
}
- message('no')
}
return(NA)
}
if (!length(grep('^r-',src)) || length(grep('^r-base',src))) {
next
}
- # TODO: cross-repo dependencies
newdeps <- levels(r.dependencies.of(name=top)$name)
closure=c(closure,top)
fringe=c(fringe,newdeps)
return(rev(unique(closure,fromLast=T)))
}
-prepare.new.debian <- function(pkg) {
- maintainer = 'cran2deb buildbot <cran2deb@example.org>'
-
- # XXX: TODO: bundles do not work.
- if ('Bundle' %in% names(pkg$description[1,])) {
- stop('E: TODO: bundles')
- }
-
- # generate Debian version and name
- pkg$repo = repourl.as.debian(pkg$repoURL)
- pkg$debversion = version.new(pkg$version)
- if (!length(grep('^[A-Za-z0-9][A-Za-z0-9+.-]+$',pkg$name))) {
- stop(paste('Cannot convert package name into a Debian name',pkg$name))
- }
- pkg$srcname = tolower(pkg$name)
- pkg$debname = pkgname.as.debian(pkg$name,repo=pkg$repo)
-
- if (!length(grep('\\.tar\\.gz',pkg$archive))) {
- stop('archive is not tarball')
- }
-
- # re-pack into a Debian-named archive with a Debian-named directory.
- debpath = paste(dirname(pkg$archive),'/'
- ,pkg$srcname,'-'
- ,pkg$version
- ,sep='')
- file.rename(pkg$path, debpath)
- pkg$path = debpath
- debarchive = paste(dirname(pkg$archive),'/'
- ,pkg$srcname,'_'
- ,pkg$version,'.orig.tar.gz'
- ,sep='')
- wd <- getwd()
- setwd(dirname(pkg$path))
- # remove them pesky +x files
- system(paste('find',shQuote(basename(pkg$path))
- ,'-type f -exec chmod -x {} \\;'))
- # tar it all back up
- system(paste('tar -czf',shQuote(debarchive),shQuote(basename(pkg$path))))
- setwd(wd)
- file.remove(pkg$archive)
- pkg$archive = debarchive
-
- # make the debian/ directory
- debdir <- paste(pkg$path,'debian',sep='/')
- debfile <- function(x) { paste(debdir,x,sep='/') }
- unlink(debdir,recursive=T)
- dir.create(debdir)
-
+accept.license <- function(pkg) {
# check the license
if (!('License' %in% names(pkg$description[1,]))) {
stop('package has no License: field in description!')
accept=paste('Unlimited (no restrictions on distribution or'
,'use other than those imposed by relevant laws)')
}
+ return(accept)
+}
+generate.changelog <- function(pkg) {
# construct a dummy changelog
# TODO: ``Writing R extensions'' mentions that a package may also have
# {NEWS,ChangeLog} files.
cat(paste(paste(pkg$srcname,' (',pkg$debversion,') unstable; urgency=low',sep='')
,'' ,' * Initial release.',''
,paste(' --',maintainer,'',format(Sys.time(),'%a, %d %b %Y %H:%M:%S %z'))
- ,'',sep='\n'),file=debfile('changelog.in'))
+ ,'',sep='\n'),file=pkg$debfile('changelog.in'))
+}
+
+generate.rules <- function(pkg) {
cat(paste('#!/usr/bin/make -f'
,'include /usr/share/R/debian/r-cran.mk'
,'',sep='\n')
- ,file=debfile('rules'))
- Sys.chmod(debfile('rules'),'0700')
+ ,file=pkg$debfile('rules'))
+ Sys.chmod(pkg$debfile('rules'),'0700')
+}
+generate.copyright <- function(pkg) {
# generate copyright file; we trust DESCRIPTION
writeLines(strwrap(
paste('This Debian package of the GNU R package',pkg$name
,pkg$debname
,'DESCRIPTION'
,sep='/')
- ,sep='\n'), width=72), con=debfile('copyright.in'))
+ ,sep='\n'), width=72), con=pkg$debfile('copyright.in'))
+}
+generate.control <- function(pkg) {
# see if this is an architecture-dependent package.
# heuristic: if /src/ exists in pkg$path, then this is an
# architecture-dependent package.
# Debian policy says 72 char width; indent minimally
write.dcf(control,file=debfile('control.in'),indent=1,width=72)
write.dcf(control,indent=1,width=72)
+}
+
+prepare.new.debian <- function(pkg) {
+ # XXX: TODO: bundles do not work.
+ if ('Bundle' %in% names(pkg$description[1,])) {
+ stop('E: TODO: bundles')
+ }
+
+ # generate Debian version and name
+ pkg$repo = repourl.as.debian(pkg$repoURL)
+ pkg$debversion = version.new(pkg$version)
+ if (!length(grep('^[A-Za-z0-9][A-Za-z0-9+.-]+$',pkg$name))) {
+ stop(paste('Cannot convert package name into a Debian name',pkg$name))
+ }
+ pkg$srcname = tolower(pkg$name)
+ pkg$debname = pkgname.as.debian(pkg$name,repo=pkg$repo)
+
+ if (!length(grep('\\.tar\\.gz',pkg$archive))) {
+ stop('archive is not tarball')
+ }
+
+ # re-pack into a Debian-named archive with a Debian-named directory.
+ debpath = paste(dirname(pkg$archive),'/'
+ ,pkg$srcname,'-'
+ ,pkg$version
+ ,sep='')
+ file.rename(pkg$path, debpath)
+ pkg$path = debpath
+ debarchive = paste(dirname(pkg$archive),'/'
+ ,pkg$srcname,'_'
+ ,pkg$version,'.orig.tar.gz'
+ ,sep='')
+ wd <- getwd()
+ setwd(dirname(pkg$path))
+ # remove them pesky +x files
+ system(paste('find',shQuote(basename(pkg$path))
+ ,'-type f -exec chmod -x {} \\;'))
+ # tar it all back up
+ system(paste('tar -czf',shQuote(debarchive),shQuote(basename(pkg$path))))
+ setwd(wd)
+ file.remove(pkg$archive)
+ pkg$archive = debarchive
+
+ # make the debian/ directory
+ debdir <- paste(pkg$path,'debian',sep='/')
+ pkg$debfile <- function(x) { paste(debdir,x,sep='/') }
+ unlink(debdir,recursive=T)
+ dir.create(debdir)
+
+ pkg$license <- accept.license(pkg)
+
+ generate.changelog(pkg)
+ generate.rules(pkg)
+ generate.copyright(pkg)
+ generate.control(pkg)
# TODO: debian/watch from pkg$repoURL
,host.arch(),'.changes',sep=''), sep=''))
}
-# TEST: SRPM -> stashR -> digest -> filehash
go <- function(name) {
dir <- setup()
pkg <- try((function() {