2 build <- function(name,extra_deps) {
4 pkg <- try((function() {
5 # see if it has already been built
6 srcname <- pkgname_as_debian(name,binary=F)
7 debname <- pkgname_as_debian(name,binary=T)
8 version <- version_new(available[name,'Version'])
9 if (file.exists(changesfile(srcname, version))) {
10 message(paste('N: already built',srcname,'version',version))
13 # XXX: what about building newer versions?
14 if (debname %in% debian_pkgs) {
15 message(paste('N:',srcname,' exists in Debian (perhaps a different version)'))
19 rm(debname,srcname,version)
21 pkg <- prepare_new_debian(prepare_pkg(dir,name),extra_deps)
22 # delete the current archive (XXX: assumes mini-dinstall)
23 for (subdir in c('mini-dinstall','unstable')) {
24 path = file.path(dinstall_archive,subdir)
25 if (file.exists(path)) {
26 unlink(path,recursive=T)
30 # delete notes of upload
31 file.remove(Sys.glob(file.path(pbuilder_results,'*.upload')))
33 # make mini-dinstall generate the skeleton of the archive
34 ret = system(paste('umask 022;mini-dinstall --batch -c',dinstall_config))
36 stop('failed to create archive')
39 # pull in all the R dependencies
40 message(paste('N: dependencies:',paste(pkg$depends$r,collapse=', ')))
41 for (dep in pkg$depends$r) {
42 if (pkgname_as_debian(dep) %in% debian_pkgs) {
43 message(paste('N: using Debian package of',dep))
46 # otherwise, convert to source package name
47 srcdep = pkgname_as_debian(dep,binary=F)
49 message(paste('N: uploading',srcdep))
50 ret = system(paste('umask 022;dput','-c',shQuote(dput_config),'local'
51 ,changesfile(srcdep)))
53 stop('upload of dependency failed! maybe you did not build it first?')
59 ret = system(paste('umask 022;dput','-c',shQuote(dput_config),'local'
60 ,changesfile(pkg$srcname,pkg$debversion)))
62 stop('upload failed!')
68 if (inherits(pkg,'try-error')) {
69 message(paste('E: failure of',name,'means these packages will fail:'
70 ,paste(r_dependency_closure(name,forward_arcs=F),collapse=', ')))
76 build_debian <- function(pkg) {
79 message(paste('N: building Debian package'
81 ,paste('(',pkg$debversion,')',sep='')
83 ret = system(paste('pdebuild --configfile',shQuote(pbuilder_config)))
86 stop('Failed to build package.')