]> git.donarmstrong.com Git - cran2deb.git/blobdiff - pkg/trunk/R/build.R
fix umask to 002
[cran2deb.git] / pkg / trunk / R / build.R
index d5b0437ef0ad553a5119bad58fed270641b93e41..4ca1923830206a589b2e360a6cc3e11e35f3b8eb 100644 (file)
@@ -6,15 +6,18 @@ build <- function(name,extra_deps,force=F) {
     }
     log_clear()
     dir <- setup()
+
+    # obtain the Debian version-to-be
     version <- try(new_build_version(name))
     if (inherits(version,'try-error')) {
         error('failed to build',name)
-        return(NA)
+        return(NULL)
     }
+
     result <- try((function() {
         if (!force && !needs_build(name,version)) {
             notice('skipping build of',name)
-            return(NA)
+            return(NULL)
         }
 
         pkg <- prepare_new_debian(prepare_pkg(dir,name),extra_deps)
@@ -33,13 +36,13 @@ build <- function(name,extra_deps,force=F) {
         file.remove(Sys.glob(file.path(pbuilder_results,'*.upload')))
 
         # make mini-dinstall generate the skeleton of the archive
-        ret = log_system('umask 022;mini-dinstall --batch -c',dinstall_config)
+        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('dependencies:',paste(pkg$depends$r,collapse=', '))
+        notice('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)
@@ -49,7 +52,7 @@ build <- function(name,extra_deps,force=F) {
             srcdep = pkgname_as_debian(dep,binary=F)
 
             notice('uploading',srcdep)
-            ret = log_system('umask 022;dput','-c',shQuote(dput_config),'local'
+            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?')
@@ -58,19 +61,29 @@ build <- function(name,extra_deps,force=F) {
         build_debian(pkg)
 
         # upload the package
-        ret = log_system('umask 022;dput','-c',shQuote(dput_config),'local'
+        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)
+            }
+        }
+
         return(pkg$debversion)
     })())
     cleanup(dir)
-    if (is.na(result)) {
+    if (is.null(result)) {
         # nothing was done so escape asap.
         return(result)
     }
+
     # otherwise record progress
     failed = inherits(result,'try-error')
     if (failed) {
@@ -103,6 +116,7 @@ needs_build <- function(name,version) {
         notice('already built',srcname,'version',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)')
@@ -124,6 +138,7 @@ build_debian <- function(pkg) {
     cmd = paste('pdebuild --configfile',shQuote(pbuilder_config))
     if (version_revision(pkg$debversion) > 2) {
         cmd = paste(cmd,'--debbuildopts','-sd')
+        notice('build should exclude original source')
     }
     ret = log_system(cmd)
     setwd(wd)