1 append_build_from_pkg <- function(pkg, builds) {
2 pkg_build <- data.frame(id = -1 # never used
5 ,r_version = version_upstream(pkg$debversion)
6 ,deb_epoch = version_epoch(pkg$debversion)
7 ,deb_revision = version_revision(pkg$debversion)
8 ,db_version = db_get_version()
9 ,date_stamp = pkg$date_stamp
10 ,scm_revision = scm_revision
11 ,success = 1 # never used
12 ,log = '' # never used
14 return(cbind(data.frame(srcname=pkg$srcname), rbind(builds, pkg_build)))
17 generate_changelog <- function(pkg) {
18 # TODO: ``Writing R extensions'' mentions that a package may also have
19 # {NEWS,ChangeLog} files.
20 builds <- append_build_from_pkg(pkg, db_builds(pkg$name))
21 sapply(rev(rownames(builds)), function(b, changelog) generate_changelog_entry(builds[b,], changelog), pkg$debfile('changelog.in'))
24 generate_changelog_entry <- function(build, changelog) {
25 # TODO: should say 'New upstream release' when necessary
26 debversion <- version_new(build$r_version, build$deb_revision, build$deb_epoch)
27 cat(paste(paste(build$srcname,' (',debversion,') testing; urgency=low',sep='')
28 ,'' ,paste(' * cran2deb ',build$scm_revision
29 ,' with DB version ',as.integer(build$db_version),'.',sep='')
30 ,'',paste(' --',maintainer,'',format(build$date_stamp,'%a, %d %b %Y %H:%M:%S %z'))
31 ,'','','',sep='\n'),file=changelog, append=TRUE)
34 generate_rules <- function(pkg) {
35 cat(paste('#!/usr/bin/make -f'
36 ,paste('debRreposname :=',pkg$repo)
37 ,'include /usr/share/R/debian/r-cran.mk'
39 ,file=pkg$debfile('rules'))
40 if (pkg$name %in% c("Rmpi", "npRmpi", "doMPI")) {
41 cat("extraInstallFlags=\"--no-test-load\"\n", file=pkg$debfile('rules'), append=TRUE)
43 Sys.chmod(pkg$debfile('rules'),'0700')
46 generate_copyright <- function(pkg) {
47 # generate_copyright file; we trust DESCRIPTION
49 # if maintainer is missing then try to use author
50 if (!('Maintainer' %in% colnames(pkg$description))) {
51 if ('Author' %in% colnames(pkg$description)) {
52 maintainer = pkg$description[1,'Author']
54 fail('Maintainer and Author not defined in R DESCRIPTION')
57 maintainer = pkg$description[1,'Maintainer']
59 # likewise if author is missing then try to use maintainer
60 if (!('Author' %in% colnames(pkg$description))) {
63 author = pkg$description[1,'Author']
67 paste('This Debian package of the GNU R package',pkg$name
68 ,'was generated automatically using cran2deb by'
69 ,paste(maintainer,'.',sep='')
71 ,'The original GNU R package is Copyright (C) '
72 # TODO: copyright start date, true copyright date
73 ,format(Sys.time(),'%Y')
75 ,'and possibly others.'
77 ,'The original GNU R package is maintained by'
78 ,maintainer,'and was obtained from:'
83 ,'The GNU R package DESCRIPTION offers a'
84 ,'Copyright licenses under the terms of the license:'
85 ,pkg$license,'. On a Debian GNU/Linux system, common'
86 ,'licenses are included in the directory'
87 ,'/usr/share/common-licenses/.'
89 ,'The DESCRIPTION file for the original GNU R package '
91 ,file.path('/usr/lib/R/site-library'
95 ,sep='\n'), width=72), con=pkg$debfile('copyright.in'))
98 prepare_new_debian <- function(pkg,extra_deps) {
99 # generate Debian version and name
100 pkg$debversion = new_build_version(pkg$name)
102 # make the debian/ directory
103 debdir <- file.path(pkg$path,'debian')
104 pkg$debfile <- function(x) { file.path(debdir,x) }
105 unlink(debdir,recursive=T)
108 # see if this is an architecture-dependent package.
109 # heuristic: if /src/ exists in pkg$path, then this is an
110 # architecture-dependent package.
111 # CRAN2DEB.pm is a bit fancier about this but ``Writing R extensions''
112 # says: ``The sources and headers for the compiled code are in src, plus
113 # optionally file Makevars or Makefile.'' It seems unlikely that
114 # architecture independent code would end up here.
115 pkg$archdep = file.exists(file.path(pkg$path,'src'))
118 pkg$arch <- host_arch()
121 pkg$license <- accept_license(pkg)
122 pkg$depends <- get_dependencies(pkg,extra_deps)
124 generate_lintian(pkg)
125 generate_changelog(pkg)
127 generate_copyright(pkg)
128 generate_control(pkg)
129 ## debdir <- file.path(pkg$path,'debian')
130 ## system(paste("ls ", debdir, "; ls -l ", debdir, "/patches/*", sep=""))
132 # convert text to utf8 (who knows what the original character set is --
133 # let's hope iconv DTRT).
134 for (file in c('control','changelog','copyright')) {
135 log_system('iconv -o ',shQuote(pkg$debfile(file))
137 ,shQuote(pkg$debfile(paste(file,'in',sep='.'))))
138 file.remove(pkg$debfile(paste(file,'in',sep='.')))