2 build <- function(name,extra_deps,force=F) {
3 # can't, and hence don't need to, build base packages
4 if (name %in% base_pkgs) {
10 # obtain the Debian version-to-be
11 version <- try(new_build_version(name))
12 if (inherits(version,'try-error')) {
13 error('failed to build',name)
17 result <- try((function() {
18 if (!force && !needs_build(name,version)) {
19 notice('skipping build of',name)
23 pkg <- prepare_new_debian(prepare_pkg(dir,name),extra_deps)
24 if (pkg$debversion != version) {
25 fail('expected Debian version',version,'not equal to actual version',pkg$debversion)
27 # delete the current archive (XXX: assumes mini-dinstall)
28 for (subdir in c('mini-dinstall','unstable')) {
29 path = file.path(dinstall_archive,subdir)
30 if (file.exists(path)) {
31 unlink(path,recursive=T)
35 # delete notes of upload
36 file.remove(Sys.glob(file.path(pbuilder_results,'*.upload')))
38 # make mini-dinstall generate the skeleton of the archive
39 ret = log_system('umask 002;mini-dinstall --batch -c',dinstall_config)
41 fail('failed to create archive')
44 # pull in all the R dependencies
45 notice('R dependencies:',paste(pkg$depends$r,collapse=', '))
46 for (dep in pkg$depends$r) {
47 if (pkgname_as_debian(dep) %in% debian_pkgs) {
48 notice('using Debian package of',dep)
51 # otherwise, convert to source package name
52 srcdep = pkgname_as_debian(dep,binary=F)
54 notice('uploading',srcdep)
55 ret = log_system('umask 002;dput','-c',shQuote(dput_config),'local'
58 fail('upload of dependency failed! maybe you did not build it first?')
64 ret = log_system('umask 002;dput','-c',shQuote(dput_config),'local'
65 ,changesfile(pkg$srcname,pkg$debversion))
67 fail('upload failed!')
70 # delete the current archive (XXX: assumes mini-dinstall)
71 # this is handy for group operation
72 for (subdir in c('mini-dinstall','unstable')) {
73 path = file.path(dinstall_archive,subdir)
74 if (file.exists(path)) {
75 unlink(path,recursive=T)
79 return(pkg$debversion)
82 if (is.null(result)) {
83 # nothing was done so escape asap.
87 # otherwise record progress
88 failed = inherits(result,'try-error')
90 error('failure of',name,'means these packages will fail:'
91 ,paste(r_dependency_closure(name,forward_arcs=F),collapse=', '))
93 db_record_build(name, version, log_retrieve(), !failed)
97 needs_build <- function(name,version) {
98 # see if the last build was successful
99 build <- db_latest_build(name)
100 if (!is.null(build) && build$success) {
101 # then something must have changed for us to attempt this
103 if (build$r_version == version_upstream(version) &&
104 build$deb_epoch == version_epoch(version) &&
105 build$db_version == db_get_version()) {
109 # always rebuild on failure or no record
112 # see if it has already been built
113 srcname <- pkgname_as_debian(name,binary=F)
114 debname <- pkgname_as_debian(name,binary=T)
115 if (file.exists(changesfile(srcname, version))) {
116 notice('already built',srcname,'version',version)
120 # XXX: what about building newer versions of Debian packages?
121 if (debname %in% debian_pkgs) {
122 notice(srcname,' exists in Debian (perhaps a different version)')
130 build_debian <- function(pkg) {
133 notice('building Debian package'
135 ,paste('(',pkg$debversion,')',sep='')
138 cmd = paste('pdebuild --configfile',shQuote(pbuilder_config))
139 if (version_revision(pkg$debversion) > 2) {
140 cmd = paste(cmd,'--debbuildopts','-sd')
141 notice('build should exclude original source')
143 ret = log_system(cmd)
146 fail('Failed to build package.')