2 suppressMessages(library(cran2deb))
4 go <- function(name,extra_deps) {
6 pkg <- try((function() {
7 pkg <- prepare.new.debian(prepare.pkg(dir,name),extra_deps)
8 # XXX: what about building newer versions?
9 if (pkg$debname %in% debian_pkgs) {
10 message(paste('N:',pkg$srcname,' exists in Debian (perhaps a different version)'))
13 if (file.exists(changesfile(pkg$srcname,pkg$debversion))) {
14 message(paste('N: already built',pkg$srcname,'version',pkg$debversion))
18 # delete the current archive (XXX: assumes mini-dinstall)
19 for (subdir in c('mini-dinstall','unstable')) {
20 path = file.path(dinstall_archive,subdir)
21 if (file.exists(path)) {
22 unlink(path,recursive=T)
26 # delete notes of upload
27 file.remove(Sys.glob(file.path(pbuilder_results,'*.upload')))
29 # make mini-dinstall generate the skeleton of the archive
30 ret = system(paste('umask 022;mini-dinstall --batch -c',dinstall_config))
32 stop('failed to create archive')
35 # pull in all the R dependencies
36 message(paste('N: dependencies:',paste(pkg$depends$r,collapse=', ')))
37 for (dep in pkg$depends$r) {
38 if (pkgname.as.debian(dep) %in% debian_pkgs) {
39 message(paste('N: using Debian package of',dep))
42 # otherwise, convert to source package name
43 srcdep = pkgname.as.debian(dep,binary=F)
45 message(paste('N: uploading',srcdep))
46 ret = system(paste('umask 022;dput','-c',shQuote(dput_config),'local'
47 ,changesfile(srcdep)))
49 stop('upload of dependency failed! maybe you did not build it first?')
55 ret = system(paste('umask 022;dput','-c',shQuote(dput_config),'local'
56 ,changesfile(pkg$srcname,pkg$debversion)))
58 stop('upload failed!')
64 if (inherits(pkg,'try-error')) {
65 message(paste('E: failure of',name,'means these packages will fail:'
66 ,paste(r.dependency.closure(name,forward_arcs=F),collapse=', ')))
72 if (exists('argv')) { # check for littler
78 # first argument is the root --- this is dealt with elsewhere.
80 if (!(argv[i] %in% opts)) {
90 err('missing argument')
92 if (argv[i] == '-D') {
93 extra_deps$deb = c(extra_deps$deb,strsplit(chomp(argv[i+1]),',')[[1]])
95 if (argv[i] == '-R') {
96 extra_deps$r = c(extra_deps$r,strsplit(chomp(argv[i+1]),',')[[1]])
97 extra_deps$deb = c(extra_deps$deb,lapply(extra_deps$r,pkgname.as.debian))
101 err('usage: cran2deb [-D extra_dep1,extra_dep2,...] package package ...')
103 build_order <- r.dependency.closure(c(extra_deps$r,argv))
104 message(paste('N: build order',paste(build_order,collapse=', ')))
105 for (pkg in build_order) {