]> git.donarmstrong.com Git - cran2deb.git/commitdiff
build: refactor, add autobuild command to build outdated packages.
authorblundellc <blundellc@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Sat, 13 Sep 2008 13:22:20 +0000 (13:22 +0000)
committerblundellc <blundellc@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Sat, 13 Sep 2008 13:22:20 +0000 (13:22 +0000)
git-svn-id: svn://svn.r-forge.r-project.org/svnroot/cran2deb@90 edb9625f-4e0d-4859-8d74-9fd3b1da38cb

pkg/trunk/R/build.R [new file with mode: 0644]
pkg/trunk/R/debianpkg.R
pkg/trunk/exec/autobuild [new file with mode: 0755]
pkg/trunk/exec/build

diff --git a/pkg/trunk/R/build.R b/pkg/trunk/R/build.R
new file mode 100644 (file)
index 0000000..bf3049a
--- /dev/null
@@ -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.')
+    }
+}
+
index 17f59948b8efaaa6ad42367733272db76d051ee8..81670e4dde719da23bf30897bc699d0994d821ec 100644 (file)
@@ -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 (executable)
index 0000000..ef113f6
--- /dev/null
@@ -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)
+    }
+}
index 92e1e40cc2dbab20ed004df8d0668a291f2c1da6..bdaedac743196bca8d6df535b2c0d88f184a627d 100755 (executable)
@@ -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)
     }
 }