From: blundellc Date: Sat, 13 Sep 2008 13:22:20 +0000 (+0000) Subject: build: refactor, add autobuild command to build outdated packages. X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=6677cee86ce8a10eb54b84e749873a19e6f795a1;p=cran2deb.git build: refactor, add autobuild command to build outdated packages. git-svn-id: svn://svn.r-forge.r-project.org/svnroot/cran2deb@90 edb9625f-4e0d-4859-8d74-9fd3b1da38cb --- diff --git a/pkg/trunk/R/build.R b/pkg/trunk/R/build.R new file mode 100644 index 0000000..bf3049a --- /dev/null +++ b/pkg/trunk/R/build.R @@ -0,0 +1,89 @@ + +build <- function(name,extra_deps) { + dir <- setup() + pkg <- try((function() { + # see if it has already been built + srcname <- pkgname_as_debian(name,binary=F) + debname <- pkgname_as_debian(name,binary=T) + version <- version_new(available[name,'Version']) + if (file.exists(changesfile(srcname, version))) { + message(paste('N: already built',srcname,'version',version)) + return(NA) + } + # XXX: what about building newer versions? + if (debname %in% debian_pkgs) { + message(paste('N:',srcname,' exists in Debian (perhaps a different version)')) + return(NA) + } + + rm(debname,srcname,version) + + pkg <- prepare_new_debian(prepare_pkg(dir,name),extra_deps) + # 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 = system(paste('umask 022;mini-dinstall --batch -c',dinstall_config)) + if (ret != 0) { + stop('failed to create archive') + } + + # pull in all the R dependencies + message(paste('N: dependencies:',paste(pkg$depends$r,collapse=', '))) + for (dep in pkg$depends$r) { + if (pkgname_as_debian(dep) %in% debian_pkgs) { + message(paste('N: using Debian package of',dep)) + next + } + # otherwise, convert to source package name + srcdep = pkgname_as_debian(dep,binary=F) + + message(paste('N: uploading',srcdep)) + ret = system(paste('umask 022;dput','-c',shQuote(dput_config),'local' + ,changesfile(srcdep))) + if (ret != 0) { + stop('upload of dependency failed! maybe you did not build it first?') + } + } + build_debian(pkg) + + # upload the package + ret = system(paste('umask 022;dput','-c',shQuote(dput_config),'local' + ,changesfile(pkg$srcname,pkg$debversion))) + if (ret != 0) { + stop('upload failed!') + } + + return(pkg) + })()) + cleanup(dir) + if (inherits(pkg,'try-error')) { + message(paste('E: failure of',name,'means these packages will fail:' + ,paste(r_dependency_closure(name,forward_arcs=F),collapse=', '))) + stop(call.=F) + } + return(pkg) +} + +build_debian <- function(pkg) { + wd <- getwd() + setwd(pkg$path) + message(paste('N: building Debian package' + ,pkg$debname + ,paste('(',pkg$debversion,')',sep='') + ,'...')) + ret = system(paste('pdebuild --configfile',shQuote(pbuilder_config))) + setwd(wd) + if (ret != 0) { + stop('Failed to build package.') + } +} + diff --git a/pkg/trunk/R/debianpkg.R b/pkg/trunk/R/debianpkg.R index 17f5994..81670e4 100644 --- a/pkg/trunk/R/debianpkg.R +++ b/pkg/trunk/R/debianpkg.R @@ -136,18 +136,3 @@ prepare_new_debian <- function(pkg,extra_deps) { } return(pkg) } - -build_debian <- function(pkg) { - wd <- getwd() - setwd(pkg$path) - message(paste('N: building Debian package' - ,pkg$debname - ,paste('(',pkg$debversion,')',sep='') - ,'...')) - ret = system(paste('pdebuild --configfile',shQuote(pbuilder_config))) - setwd(wd) - if (ret != 0) { - stop('Failed to build package.') - } -} - diff --git a/pkg/trunk/exec/autobuild b/pkg/trunk/exec/autobuild new file mode 100755 index 0000000..ef113f6 --- /dev/null +++ b/pkg/trunk/exec/autobuild @@ -0,0 +1,12 @@ +#!/usr/bin/env r +suppressMessages(library(cran2deb)) + +if (exists('argv')) { # check for littler + db_update_package_versions() + outdated <- db_outdated_packages() + build_order <- r_dependency_closure(outdated) + message(paste('N: build order',paste(build_order,collapse=', '))) + for (pkg in build_order) { + build(pkg,extra_deps) + } +} diff --git a/pkg/trunk/exec/build b/pkg/trunk/exec/build index 92e1e40..bdaedac 100755 --- a/pkg/trunk/exec/build +++ b/pkg/trunk/exec/build @@ -1,80 +1,6 @@ #!/usr/bin/env r suppressMessages(library(cran2deb)) -go <- function(name,extra_deps) { - dir <- setup() - pkg <- try((function() { - # see if it has already been built - srcname <- pkgname_as_debian(name,binary=F) - debname <- pkgname_as_debian(name,binary=T) - version <- version_new(available[name,'Version']) - if (file.exists(changesfile(srcname, version))) { - message(paste('N: already built',srcname,'version',version)) - return(NA) - } - # XXX: what about building newer versions? - if (debname %in% debian_pkgs) { - message(paste('N:',srcname,' exists in Debian (perhaps a different version)')) - return(NA) - } - - rm(debname,srcname,version) - - pkg <- prepare_new_debian(prepare_pkg(dir,name),extra_deps) - # 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 = system(paste('umask 022;mini-dinstall --batch -c',dinstall_config)) - if (ret != 0) { - stop('failed to create archive') - } - - # pull in all the R dependencies - message(paste('N: dependencies:',paste(pkg$depends$r,collapse=', '))) - for (dep in pkg$depends$r) { - if (pkgname_as_debian(dep) %in% debian_pkgs) { - message(paste('N: using Debian package of',dep)) - next - } - # otherwise, convert to source package name - srcdep = pkgname_as_debian(dep,binary=F) - - message(paste('N: uploading',srcdep)) - ret = system(paste('umask 022;dput','-c',shQuote(dput_config),'local' - ,changesfile(srcdep))) - if (ret != 0) { - stop('upload of dependency failed! maybe you did not build it first?') - } - } - build_debian(pkg) - - # upload the package - ret = system(paste('umask 022;dput','-c',shQuote(dput_config),'local' - ,changesfile(pkg$srcname,pkg$debversion))) - if (ret != 0) { - stop('upload failed!') - } - - return(pkg) - })()) - cleanup(dir) - if (inherits(pkg,'try-error')) { - message(paste('E: failure of',name,'means these packages will fail:' - ,paste(r_dependency_closure(name,forward_arcs=F),collapse=', '))) - stop(call.=F) - } - return(pkg) -} - if (exists('argv')) { # check for littler argc <- length(argv) extra_deps = list() @@ -109,6 +35,6 @@ if (exists('argv')) { # check for littler build_order <- r_dependency_closure(c(extra_deps$r,argv)) message(paste('N: build order',paste(build_order,collapse=', '))) for (pkg in build_order) { - go(pkg,extra_deps) + build(pkg,extra_deps) } }