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)
return(pkg$debversion)
})())
cleanup(dir)
- if (is.na(result)) {
+ if (is.null(result)) {
# nothing was done so escape asap.
return(result)
}
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)
,',deb_epoch INTEGER NOT NULL'
,',deb_revision INTEGER NOT NULL'
,',db_version INTEGER NOT NULL'
+ ,',date_stamp TEXT NOT NULL'
+ ,',git_revision TEXT NOT NULL'
,',success INTEGER NOT NULL'
,',log TEXT'
,',UNIQUE(package,r_version,deb_epoch,deb_revision,db_version)'
,db_quote(tolower(name)),'= name'))
db_stop(con)
if (length(results) == 0) {
- return(NA)
+ return(NULL)
}
return(as.logical(results$accept))
}
,db_quote(tolower(license_sha1)),'= license_hashes.sha1'))
db_stop(con)
if (length(results) == 0) {
- return(NA)
+ return(NULL)
}
return(as.logical(results$accept))
}
}
db_add_license_hash <- function(name,license_sha1) {
- if (is.na(db_license_override_name(name))) {
+ if (is.null(db_license_override_name(name))) {
fail('license',name,'is not know, yet trying to add a hash for it?')
}
notice('adding hash',license_sha1,'for',name)
db_record_build <- function(package, deb_version, log, success=F) {
con <- db_start()
dbGetQuery(con,paste('INSERT OR REPLACE INTO builds'
- ,'(package,r_version,deb_epoch,deb_revision,db_version,success,log)'
+ ,'(package,r_version,deb_epoch,deb_revision,db_version,success,date_stamp,git_revision,log)'
,'VALUES'
,'(',db_quote(package)
,',',db_quote(version_upstream(deb_version))
,',',db_quote(version_revision(deb_version))
,',',db_cur_version(con)
,',',as.integer(success)
+ ,',',db_quote(format(Sys.time(),'%a, %d %b %Y %H:%M:%S %z'))
+ ,',',db_quote(git_revision)
,',',db_quote(paste(log, collapse='\n'))
,')'))
db_stop(con)
}
+db_builds <- function(pkgname) {
+ # returns all successful builds
+ con <- db_start()
+ build <- dbGetQuery(con, paste('SELECT * FROM builds'
+ ,'WHERE success = 1'
+ ,'AND package =',db_quote(pkgname)))
+ db_stop(con)
+ if (length(build) == 0) {
+ return(NULL)
+ }
+ build$success <- as.logical(build$success)
+ return(build)
+}
+
db_latest_build <- function(pkgname) {
con <- db_start()
build <- dbGetQuery(con, paste('SELECT * FROM builds'
# squish out space
sysreq = chomp(gsub('[[:space:]]+',' ',sysreq))
alias <- db_sysreq_override(sysreq)
- if (is.na(alias)) {
+ if (is.null(alias)) {
error('do not know what to do with SystemRequirement:',sysreq)
error('original SystemRequirement:',startreq)
fail('unmet system requirement')
# now.
if (!(name %in% rownames(available))) {
bundle <- r_bundle_of(name)
- if (!is.na(bundle)) {
+ if (!is.null(bundle)) {
name <- bundle
}
}
+append_build_from_pkg <- function(pkg, builds) {
+ pkg_build <- data.frame(id = -1 # never used
+ ,package = pkg$name
+ ,r_version = version_upstream(pkg$debversion)
+ ,deb_epoch = version_epoch(pkg$debversion)
+ ,deb_revision = version_revision(pkg$debversion)
+ ,db_version = db_get_version()
+ ,date_stamp = pkg$date_stamp
+ ,git_revision = git_revision
+ ,success = 1 # never used
+ ,log = '' # never used
+ )
+ return(cbind(data.frame(srcname=pkg$srcname), rbind(builds, pkg_build)))
+}
+
generate_changelog <- function(pkg) {
- # construct a dummy changelog
# TODO: ``Writing R extensions'' mentions that a package may also have
# {NEWS,ChangeLog} files.
- cat(paste(paste(pkg$srcname,' (',pkg$debversion,') unstable; urgency=low',sep='')
- ,'' ,' * Initial release.',''
- ,paste(' --',maintainer,'',format(Sys.time(),'%a, %d %b %Y %H:%M:%S %z'))
- ,'',sep='\n'),file=pkg$debfile('changelog.in'))
+ builds <- append_build_from_pkg(pkg, db_builds(pkg$name))
+ sapply(rev(rownames(builds)), function(b, changelog) generate_changelog_entry(builds[b,], changelog), pkg$debfile('changelog.in'))
+}
+
+generate_changelog_entry <- function(build, changelog) {
+ # TODO: should say 'New upstream release' when necessary
+ debversion <- version_new(build$r_version, build$deb_revision, build$deb_epoch)
+ cat(paste(paste(build$srcname,' (',debversion,') unstable; urgency=low',sep='')
+ ,'' ,paste(' * cran2deb ',build$git_revision
+ ,' with DB version ',as.integer(build$db_version),'.',sep='')
+ ,'',paste(' --',maintainer,'',build$date_stamp)
+ ,'','','',sep='\n'),file=changelog, append=TRUE)
}
generate_rules <- function(pkg) {
,''
,''
,'The GNU R package DESCRIPTION offers a'
- ,'Copyright licenses under the terms of the',pkg$license
- ,'license. On a Debian GNU/Linux system, common'
+ ,'Copyright licenses under the terms of the license:'
+ ,pkg$license,'. On a Debian GNU/Linux system, common'
,'licenses are included in the directory'
,'/usr/share/common-licenses/.'
,''
prepare_new_debian <- function(pkg,extra_deps) {
# generate Debian version and name
+ pkg$date_stamp = format(Sys.time(),'%a, %d %b %Y %H:%M:%S %z')
pkg$repo = repourl_as_debian(pkg$repoURL)
if (pkg$version != available[pkg$name,'Version']) {
# should never happen since available is the basis upon which the
# first a little trick; change pkgname if pkgname is contained in a bundle
if (!(pkgname %in% rownames(available))) {
bundle <- r_bundle_of(pkgname)
- if (is.na(bundle)) {
+ if (is.null(bundle)) {
fail('package',pkgname,'is unavailable')
}
pkgname <- bundle
}
license <- license_text_reduce(license)
action = db_license_override_name(license)
- if (!is.na(action)) {
+ if (!is.null(action)) {
return(action)
}
license <- license_text_further_reduce(license)
action = db_license_override_name(license)
- if (!is.na(action)) {
+ if (!is.null(action)) {
warn('Accepting/rejecting wild license as',license,'. FIX THE PACKAGE!')
return(action)
}
license <- license_text_extreme_reduce(license)
action = db_license_override_name(license)
- if (!is.na(action)) {
+ if (!is.null(action)) {
warn('Accepting/rejecting wild license as',license,'. FIX THE PACKAGE!')
return(action)
}
is_acceptable_hash_license <- function(pkg,license) {
license_sha1 <- get_license_hash(pkg,license)
- if (is.na(license_sha1)) {
+ if (is.null(license_sha1)) {
return(FALSE)
}
action = db_license_override_hash(license_sha1)
- if (is.na(action)) {
+ if (is.null(action)) {
action = FALSE
}
if (action) {
if (!length(grep('^[WENI]:',line))) {
line = paste('I:',line)
}
- log_add(line,print=F)
+ log_add(line) #,print=F)
}
return(r[[1]])
}
return(bundle)
}
}
- return(NA)
+ return(NULL)
}
r_bundle_contains <- function(bundlename) {
for (name in names) {
if (!(name %in% base_pkgs) && !(name %in% rownames(available))) {
bundle <- r_bundle_of(name)
- if (!is.na(bundle)) {
+ if (!is.null(bundle)) {
name = bundle
names <- c(names,bundle)
}
if (is.null(description)) {
if (!(name %in% rownames(available))) {
bundle <- r_bundle_of(name)
- if (!is.na(bundle)) {
+ if (!is.null(bundle)) {
name <- bundle
} else {
# unavailable packages don't depend upon anything
dep = sub(pat,'\\1',dep)
if (!(dep %in% rownames(available))) {
depb <- r_bundle_of(dep)
- if (!is.na(depb)) {
+ if (!is.null(depb)) {
dep <- depb
}
}
new_build_version <- function(pkgname) {
if (!(pkgname %in% rownames(available))) {
bundle <- r_bundle_of(pkgname)
- if (is.na(bundle)) {
+ if (is.null(bundle)) {
fail('tried to discover new version of',pkgname,'but it does not appear to be available')
}
name <- bundle
global("dinstall_config", file.path(root,'etc/mini-dinstall.conf'))
global("dinstall_archive", file.path(root,'var/archive'))
global("r_depend_fields", c('Depends','Imports')) # Suggests, Enhances
+ # git_revision {
+ global("git_revision","bc0b57d181288d67ce7829455c9e11fcfc9faa1a")
+ # git_revision }
global("changesfile", function(srcname,version='*') {
return(file.path(pbuilder_results
,paste(srcname,'_',version,'_'
--- /dev/null
+#!/bin/sh
+# stamp the source with the originating git revision.
+git_rev=$(git show --pretty'=oneline' 'HEAD' | head -n1 | cut -f1 -d' ')
+#git_r='assign("git_revision","'$git_rev'",envir=.GlobalEnv)'
+git_r=' global("git_revision","'$git_rev'")'
+
+awk -v "git_r=$git_r" '
+/# git_revision }/ {suppress=0}
+suppress == 0 {print}
+/# git_revision {/ {print git_r; suppress=1}
+' <R/zzz.R >R/zzz.R.new && \
+mv R/zzz.R.new R/zzz.R
}
license = argv[2]
path = argv[3]
- if (is.na(db_license_override_name(license))) {
+ if (is.null(db_license_override_name(license))) {
error('license',license,'is not known; add it first')
return()
}
license <- argv[2]
pkg_name <- argv[3]
current_action <- db_license_override_name(license)
- if (is.na(current_action)) {
+ if (is.null(current_action)) {
notice('license',license,'is not known; add it')
return()
}