X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=trunk%2FR%2Fbuild.R;h=1839e016705ae6b97c8115e9d264082abbf8419c;hb=c8295475004d41bf3e35cf42793a2d8dd0dc647e;hp=4ca1923830206a589b2e360a6cc3e11e35f3b8eb;hpb=e48407cfb4f4911aaeb8dde94d386cc16a600822;p=cran2deb.git diff --git a/trunk/R/build.R b/trunk/R/build.R index 4ca1923..1839e01 100644 --- a/trunk/R/build.R +++ b/trunk/R/build.R @@ -1,5 +1,5 @@ -build <- function(name,extra_deps,force=F) { +build <- function(name,extra_deps,force=F,do_cleanup=T) { # can't, and hence don't need to, build base packages if (name %in% base_pkgs) { return(T) @@ -10,7 +10,7 @@ build <- function(name,extra_deps,force=F) { # obtain the Debian version-to-be version <- try(new_build_version(name)) if (inherits(version,'try-error')) { - error('failed to build',name) + error('failed to build in new_build_version: ',name) return(NULL) } @@ -20,65 +20,60 @@ build <- function(name,extra_deps,force=F) { return(NULL) } + if (name %in% db_blacklist_packages()) { + #fail('package',name,'is blacklisted. consult database for reason.') + notice('package',name,'is blacklisted. consult database for reason.') + return(NULL) + } + pkg <- prepare_new_debian(prepare_pkg(dir,name),extra_deps) if (pkg$debversion != version) { fail('expected Debian version',version,'not equal to actual version',pkg$debversion) } - # delete the current archive (XXX: assumes mini-dinstall) - for (subdir in c('mini-dinstall','unstable')) { - path = file.path(dinstall_archive,subdir) - if (file.exists(path)) { - unlink(path,recursive=T) - } - } # delete notes of upload file.remove(Sys.glob(file.path(pbuilder_results,'*.upload'))) - # make mini-dinstall generate the skeleton of the archive - ret = log_system('umask 002;mini-dinstall --batch -c',dinstall_config) - if (ret != 0) { - fail('failed to create archive') - } - - # pull in all the R dependencies notice('R dependencies:',paste(pkg$depends$r,collapse=', ')) - for (dep in pkg$depends$r) { - if (pkgname_as_debian(dep) %in% debian_pkgs) { - notice('using Debian package of',dep) - next - } - # otherwise, convert to source package name - srcdep = pkgname_as_debian(dep,binary=F) - - notice('uploading',srcdep) - ret = log_system('umask 002;dput','-c',shQuote(dput_config),'local' - ,changesfile(srcdep)) - if (ret != 0) { - fail('upload of dependency failed! maybe you did not build it first?') - } - } - build_debian(pkg) + #if (debug) notice(paste("build_debian(",pkg,") invoked\n",sep="")) + build_debian_srcpkg(pkg) + #if (debug) notice(paste("build_debian(",pkg,") completed.\n",sep="")) - # upload the package - ret = log_system('umask 002;dput','-c',shQuote(dput_config),'local' - ,changesfile(pkg$srcname,pkg$debversion)) - if (ret != 0) { - fail('upload failed!') - } - - # delete the current archive (XXX: assumes mini-dinstall) - # this is handy for group operation - for (subdir in c('mini-dinstall','unstable')) { - path = file.path(dinstall_archive,subdir) - if (file.exists(path)) { - unlink(path,recursive=T) - } - } + # upload the package +# notice("Package upload") +## ret = log_system('umask 002;dput','-c',shQuote(dput_config),'local' ,changesfile(pkg$srcname,pkg$debversion)) + +### cmd = paste('umask 002; cd /var/www/cran2deb/rep && reprepro -b . include testing', changesfile(pkg$srcname,pkg$debversion),sep=" ") +### #if (verbose) notice('Executing: ',cmd) +### ret = log_system(cmd) +### if (ret != 0) { +### #fail('upload failed!') +### notice("Upload failed, ignored.") +### } else { +### notice("Upload successful.") +### } +## # wait for mini-dinstall to get to work +## upload_success = FALSE +## for (i in seq(1,12)) { +## if (file.exists(file.path(dinstall_archive,'testing',paste(pkg$srcname, '_', pkg$version, '.orig.tar.gz', sep='')))) { +## upload_success = TRUE +## break +## } +## warn(i,'/12: does not exist',file.path(dinstall_archive,'testing',paste(pkg$srcname, '_', pkg$version, '.orig.tar.gz', sep=''))) + +## Sys.sleep(5) +## } +## if (!upload_success) { +## warn('upload took too long; continuing as normal (some builds may fail temporarily)') +## } return(pkg$debversion) })()) - cleanup(dir) + if (do_cleanup) { + cleanup(dir) + } else { + notice('output is in',dir,'. you must clean this up yourself.') + } if (is.null(result)) { # nothing was done so escape asap. return(result) @@ -107,9 +102,10 @@ needs_build <- function(name,version) { } } else { # always rebuild on failure or no record + notice('rebuilding',name,': no build record or previous build failed') return(T) } - # see if it has already been built + # see if it has already been built *and* successfully uploaded srcname <- pkgname_as_debian(name,binary=F) debname <- pkgname_as_debian(name,binary=T) if (file.exists(changesfile(srcname, version))) { @@ -117,33 +113,55 @@ needs_build <- function(name,version) { return(F) } - # XXX: what about building newer versions of Debian packages? - if (debname %in% debian_pkgs) { - notice(srcname,' exists in Debian (perhaps a different version)') - return(F) + if (build$r_version != version_upstream(version)) { + notice('rebuilding',name,': new upstream version',build$r_version,'(old) vs',version_upstream(version),'(new)') } - + if (build$deb_epoch != version_epoch(version)) { + notice('rebuilding',name,': new cran2deb epoch',build$deb_epoch,'(old) vs',version_epoch(version),'(new)') + } + if (build$db_version != db_get_version()) { + notice('rebuilding',name,': new db version',build$db_version,'(old) vs',db_get_version(),'(new)') + } + notice(paste("Now deleting ",debname,", ",srcname,".\n",sep="")) rm(debname,srcname) return(T) } +build_debian_srcpkg <- function(pkg) { + wd <- getwd() + #notice(paste("Now in path ",wd,"\n",sep="")) + setwd(pbuilder_results) + + notice('building Debian source package',pkg$debname,paste('(',pkg$debversion,')',sep=''),'in',getwd(),'...') + + cmd = paste('dpkg-source','-b',pkg$path) + notice(paste("Executing ",'"',cmd,'"'," from directory '",getwd(),"'.\n",sep="")) + ret = log_system(cmd) + setwd(wd) + if (ret != 0) { + fail('Failed to build package.') + } + return(ret); +ls} + build_debian <- function(pkg) { wd <- getwd() + #notice(paste("Now in path ",wd,"\n",sep="")) setwd(pkg$path) - notice('building Debian package' - ,pkg$debname - ,paste('(',pkg$debversion,')',sep='') - ,'...') + + notice('building Debian package',pkg$debname,paste('(',pkg$debversion,')',sep=''),'in',getwd(),'...') cmd = paste('pdebuild --configfile',shQuote(pbuilder_config)) if (version_revision(pkg$debversion) > 2) { cmd = paste(cmd,'--debbuildopts','-sd') notice('build should exclude original source') } + notice(paste("Executing ",'"',cmd,'"'," from directory '",getwd(),"'.\n",sep="")) ret = log_system(cmd) setwd(wd) if (ret != 0) { fail('Failed to build package.') } + return(ret); }