+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);
+}
+