]> git.donarmstrong.com Git - cran2deb.git/blobdiff - trunk/R/build.R
the binary should always have the same name as the source package
[cran2deb.git] / trunk / R / build.R
index 2d1b245a54db27e6fbe571216a5cdd335639c16c..911e3f6ba240e103a6d73eb1a61cdb3d9a0c2507 100644 (file)
@@ -36,23 +36,23 @@ build <- function(name,extra_deps,force=F,do_cleanup=T) {
 
         notice('R dependencies:',paste(pkg$depends$r,collapse=', '))
        #if (debug) notice(paste("build_debian(",pkg,") invoked\n",sep=""))
-        build_debian(pkg)
+        build_debian_srcpkg(pkg)
        #if (debug) notice(paste("build_debian(",pkg,") completed.\n",sep=""))
 
 
         # upload the package
-       notice("Package upload")
+#      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.")
-       }
+###    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)) {
@@ -127,6 +127,41 @@ needs_build <- function(name,version) {
     return(T)
 }
 
+build_debian_srcpkg <- function(pkg) {
+    wd <- getwd()
+    #notice(paste("Now in path ",wd,"\n",sep=""))
+    setwd(pkg$path)
+    
+    notice('building Debian source package',pkg$debname,paste('(',pkg$debversion,')',sep=''),'in',getwd(),'...')
+
+    
+    cmd = paste('debuild -uc -us -d -S -nc')
+    if (version_revision(pkg$debversion) > 2) {
+      cmd = paste(cmd,'-sd')
+      notice('build should exclude original source')
+    }
+    else {
+      cmd = paste(cmd,'-sa')
+      notice('build should include 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.')
+    }
+    else { # copy the build results into the appropriate location
+      changes.fn <- list.files(path=dirname(pkg$path),pattern="\\.changes$")
+      changes.file <- readLines(file.path(dirname(pkg$path),changes.fn))
+      ## extract out the files that belong to the changes file
+      srcpkg.files <- gsub(".+ ","",changes.file[(which(changes.file=="Files: ")+1):NROW(changes.file)])
+      for (file in c(srcpkg.files,changes.fn)) {
+        file.copy(file.path(dirname(pkg$path),file),file.path(pbuilder_results,file));
+      }
+    }
+    return(ret);
+}
+
 build_debian <- function(pkg) {
     wd <- getwd()
     #notice(paste("Now in path ",wd,"\n",sep=""))