1 get.dependencies <- function(pkg,extra_deps) {
2 # determine dependencies
3 dependencies <- r.dependencies.of(description=pkg$description)
5 # these are used for generating the Depends fields
6 as.deb <- function(r,binary) {
7 return(pkgname.as.debian(paste(dependencies[r,]$name)
8 ,version=dependencies[r,]$version
12 depends$bin <- lapply(rownames(dependencies), as.deb, binary=T)
13 depends$build <- lapply(rownames(dependencies), as.deb, binary=F)
14 # add the command line dependencies
15 depends$bin = c(extra_deps$deb,depends$bin)
16 depends$build = c(extra_deps$deb,depends$build)
17 # add the system requirements
18 if ('SystemRequirements' %in% colnames(pkg$description)) {
19 sysreq <- sysreqs.as.debian(pkg$description[1,'SystemRequirements'])
20 depends$bin = c(sysreq,depends$bin)
21 depends$build = c(sysreq,depends$build)
24 # make sure we depend upon R in some way...
25 if (!length(grep('^r-base',depends$build))) {
26 depends$build = c(depends$build,pkgname.as.debian('R',version='>= 2.7.0',binary=F))
27 depends$bin = c(depends$bin, pkgname.as.debian('R',version='>= 2.7.0',binary=T))
29 # also include stuff to allow tcltk to build (suggested by Dirk)
30 depends$build = c(depends$build,'xvfb','xauth','xfonts-base')
33 depends <- lapply(depends,unique)
35 # append the Debian dependencies
36 depends$build=c(depends$build,'debhelper (>> 4.1.0)','cdbs')
38 depends$bin=c(depends$bin,'${shlibs:Depends}')
41 # the names of dependent source packages (to find the .changes file to
42 # upload via dput). these can be found recursively.
43 depends$r = lapply(r.dependency.closure(dependencies)
45 # append command line dependencies
46 depends$r = c(extra_deps$r, depends$r)
50 sysreqs.as.debian <- function(sysreq_text) {
51 # form of this field is unspecified (ugh) but most people seem to stick
54 for (sysreq in strsplit(sysreq_text,'[[:space:]]*,[[:space:]]*')[[1]]) {
57 sysreq = tolower(sysreq)
58 # drop version information/comments for now
59 sysreq = gsub('[\\([][^])]*[]\\)]','',sysreq)
60 sysreq = gsub('version','',sysreq)
61 sysreq = gsub('[<>=]*[[:space:]]*[[:digit:]]+[[:digit:].+:~-]*','',sysreq)
63 sysreq = gsub('(ht|f)tps?://[[:alnum:]!?*"\'(),%$_@.&+/=-]*','',sysreq)
65 sysreq = chomp(gsub('[[:space:]]+',' ',sysreq))
66 deb <- db.sysreq.override(sysreq)
68 message(paste('E: do not know what to do with SystemRequirement:',sysreq))
69 message(paste('E: original SystemRequirement:',startreq))
70 stop('unmet system requirement')
72 message(paste('N: mapped SystemRequirement',startreq,'onto',deb,'via',sysreq))
78 generate.control <- function(pkg) {
79 # construct control file
80 control = data.frame()
81 control[1,'Source'] = pkg$srcname
82 control[1,'Section'] = 'math'
83 control[1,'Priority'] = 'optional'
84 control[1,'Maintainer'] = maintainer
85 control[1,'Build-Depends'] = paste(pkg$depends$build,collapse=', ')
86 control[1,'Standards-Version'] = '3.8.0'
88 control[2,'Package'] = pkg$debname
89 control[2,'Architecture'] = 'all'
91 control[2,'Architecture'] = 'any'
93 control[2,'Depends'] = paste(pkg$depends$bin,collapse=', ')
95 # bundles provide virtual packages of their contents
97 control[2,'Provides'] = paste(
98 lapply(r.bundle.contains(pkg$name)
99 ,function(name) return(pkgname.as.debian(paste(name)
105 # generate the description
106 descr = 'GNU R package "'
107 if ('Title' %in% colnames(pkg$description)) {
108 descr = paste(descr,pkg$description[1,'Title'],sep='')
110 descr = paste(descr,pkg$name,sep='')
113 long_descr <- pkg$description[1,'BundleDescription']
115 long_descr <- pkg$description[1,'Description']
117 # using \n\n.\n\n is not very nice, but is necessary to make sure
118 # the longer description does not begin on the synopsis line --- R's
119 # write.dcf does not appear to have a nicer way of doing this.
120 descr = paste(descr,'"\n\n', long_descr, sep='')
121 if ('URL' %in% colnames(pkg$description)) {
122 descr = paste(descr,'\n\nURL: ',pkg$description[1,'URL'],sep='')
124 control[2,'Description'] = descr
126 # Debian policy says 72 char width; indent minimally
127 write.dcf(control,file=pkg$debfile('control.in'),indent=1,width=72)
128 write.dcf(control,indent=1,width=72)