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 022;mini-dinstall --batch -c',dinstall_config)
41 fail('failed to create archive')
44 # pull in all the R dependencies
45 notice('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 022;dput','-c',shQuote(dput_config),'local'
58 fail('upload of dependency failed! maybe you did not build it first?')
64 ret = log_system('umask 022;dput','-c',shQuote(dput_config),'local'
65 ,changesfile(pkg$srcname,pkg$debversion))
67 fail('upload failed!')
70 return(pkg$debversion)
73 if (is.null(result)) {
74 # nothing was done so escape asap.
78 # otherwise record progress
79 failed = inherits(result,'try-error')
81 error('failure of',name,'means these packages will fail:'
82 ,paste(r_dependency_closure(name,forward_arcs=F),collapse=', '))
84 db_record_build(name, version, log_retrieve(), !failed)
88 needs_build <- function(name,version) {
89 # see if the last build was successful
90 build <- db_latest_build(name)
91 if (!is.null(build) && build$success) {
92 # then something must have changed for us to attempt this
94 if (build$r_version == version_upstream(version) &&
95 build$deb_epoch == version_epoch(version) &&
96 build$db_version == db_get_version()) {
100 # always rebuild on failure or no record
103 # see if it has already been built
104 srcname <- pkgname_as_debian(name,binary=F)
105 debname <- pkgname_as_debian(name,binary=T)
106 if (file.exists(changesfile(srcname, version))) {
107 notice('already built',srcname,'version',version)
111 # XXX: what about building newer versions of Debian packages?
112 if (debname %in% debian_pkgs) {
113 notice(srcname,' exists in Debian (perhaps a different version)')
121 build_debian <- function(pkg) {
124 notice('building Debian package'
126 ,paste('(',pkg$debversion,')',sep='')
129 cmd = paste('pdebuild --configfile',shQuote(pbuilder_config))
130 if (version_revision(pkg$debversion) > 2) {
131 cmd = paste(cmd,'--debbuildopts','-sd')
132 notice('build should exclude original source')
134 ret = log_system(cmd)
137 fail('Failed to build package.')