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 if (name %in% db_blacklist_packages()) {
24 fail('package',name,'is blacklisted. consult database for reason.')
27 pkg <- prepare_new_debian(prepare_pkg(dir,name),extra_deps)
28 if (pkg$debversion != version) {
29 fail('expected Debian version',version,'not equal to actual version',pkg$debversion)
32 # delete notes of upload
33 file.remove(Sys.glob(file.path(pbuilder_results,'*.upload')))
35 notice('R dependencies:',paste(pkg$depends$r,collapse=', '))
39 ret = log_system('umask 002;dput','-c',shQuote(dput_config),'local'
40 ,changesfile(pkg$srcname,pkg$debversion))
42 fail('upload failed!')
45 return(pkg$debversion)
48 if (is.null(result)) {
49 # nothing was done so escape asap.
53 # otherwise record progress
54 failed = inherits(result,'try-error')
56 error('failure of',name,'means these packages will fail:'
57 ,paste(r_dependency_closure(name,forward_arcs=F),collapse=', '))
59 db_record_build(name, version, log_retrieve(), !failed)
63 needs_build <- function(name,version) {
64 # see if the last build was successful
65 build <- db_latest_build(name)
66 if (!is.null(build) && build$success) {
67 # then something must have changed for us to attempt this
69 if (build$r_version == version_upstream(version) &&
70 build$deb_epoch == version_epoch(version) &&
71 build$db_version == db_get_version()) {
75 # always rebuild on failure or no record
76 notice('rebuilding',name,': no build record or previous build failed')
79 # see if it has already been built
80 srcname <- pkgname_as_debian(name,binary=F)
81 debname <- pkgname_as_debian(name,binary=T)
82 if (file.exists(changesfile(srcname, version))) {
83 notice('already built',srcname,'version',version)
87 if (build$r_version != version_upstream(version)) {
88 notice('rebuilding',name,': new upstream version',build$r_version,'(old) vs',version_upstream(version),'(new)')
90 if (build$deb_epoch != version_epoch(version)) {
91 notice('rebuilding',name,': new cran2deb epoch',build$deb_epoch,'(old) vs',version_epoch(version),'(new)')
93 if (build$db_version != db_get_version()) {
94 notice('rebuilding',name,': new db version',build$db_version,'(old) vs',db_get_version(),'(new)')
100 build_debian <- function(pkg) {
103 notice('building Debian package'
105 ,paste('(',pkg$debversion,')',sep='')
108 cmd = paste('pdebuild --configfile',shQuote(pbuilder_config))
109 if (version_revision(pkg$debversion) > 2) {
110 cmd = paste(cmd,'--debbuildopts','-sd')
111 notice('build should exclude original source')
113 ret = log_system(cmd)
116 fail('Failed to build package.')