]> git.donarmstrong.com Git - cran2deb.git/blob - pkg/trunk/R/debcontrol.R
cran2deb: correct cran2deb dependencies. make cran2deb a meta-executable.
[cran2deb.git] / pkg / trunk / R / debcontrol.R
1 get.dependencies <- function(pkg,extra_deps) {
2     if ('SystemRequirements' %in% colnames(pkg$description)) {
3         stop(paste('Unsupported SystemRequirements:',pkg$description[1,'SystemRequirements']))
4     }
5
6     # determine dependencies
7     dependencies <- r.dependencies.of(description=pkg$description)
8     depends <- list()
9     # these are used for generating the Depends fields
10     as.deb <- function(r,binary) {
11         return(pkgname.as.debian(paste(dependencies[r,]$name)
12                                 ,version=dependencies[r,]$version
13                                 ,repopref=pkg$repo
14                                 ,binary=binary))
15     }
16     depends$bin <- lapply(rownames(dependencies), as.deb, binary=T)
17     depends$build <- lapply(rownames(dependencies), as.deb, binary=F)
18     # add the command line dependencies
19     depends$bin = c(extra_deps$deb,depends$bin)
20     depends$build = c(extra_deps$deb,depends$build)
21
22     # make sure we depend upon R in some way...
23     if (!length(grep('^r-base',depends$build))) {
24         depends$build = c(depends$build,pkgname.as.debian('R',version='>= 2.7.0',binary=F))
25         depends$bin   = c(depends$bin,  pkgname.as.debian('R',version='>= 2.7.0',binary=T))
26     }
27     # also include stuff to allow tcltk to build (suggested by Dirk)
28     depends$build = c(depends$build,'xvfb','xauth','xfonts-base')
29
30     # remove duplicates
31     depends <- lapply(depends,unique)
32
33     # append the Debian dependencies
34     depends$build=c(depends$build,'debhelper (>> 4.1.0)','cdbs')
35     if (pkg$archdep) {
36         depends$bin=c(depends$bin,'${shlibs:Depends}')
37     }
38
39     # the names of dependent source packages (to find the .changes file to
40     # upload via dput). these can be found recursively.
41     depends$r = lapply(r.dependency.closure(dependencies)
42                       ,tolower)
43     # append command line dependencies
44     depends$r = c(extra_deps$r, depends$r)
45     return(depends)
46 }
47
48 generate.control <- function(pkg) {
49     # construct control file
50     control = data.frame()
51     control[1,'Source'] = pkg$srcname
52     control[1,'Section'] = 'math'
53     control[1,'Priority'] = 'optional'
54     control[1,'Maintainer'] = maintainer
55     control[1,'Build-Depends'] = paste(pkg$depends$build,collapse=', ')
56     control[1,'Standards-Version'] = '3.8.0'
57
58     control[2,'Package'] = pkg$debname
59     control[2,'Architecture'] = 'all'
60     if (pkg$archdep) {
61         control[2,'Architecture'] = 'any'
62     }
63     control[2,'Depends'] = paste(pkg$depends$bin,collapse=', ')
64
65     # bundles provide virtual packages of their contents
66     if (pkg$is_bundle) {
67         control[2,'Provides'] = paste(
68                     lapply(r.bundle.contains(pkg$name)
69                           ,function(name) return(pkgname.as.debian(paste(name)
70                                                                   ,repopref=pkg$repo
71                                                                   ,binary=T)))
72                           ,collapse=', ')
73     }
74
75     # generate the description
76     descr = 'GNU R package "'
77     if ('Title' %in% colnames(pkg$description)) {
78         descr = paste(descr,pkg$description[1,'Title'],sep='')
79     } else {
80         descr = paste(descr,pkg$name,sep='')
81     }
82     if (pkg$is_bundle) {
83         long_descr <- pkg$description[1,'BundleDescription']
84     } else {
85         long_descr <- pkg$description[1,'Description']
86     }
87     # using \n\n.\n\n is not very nice, but is necessary to make sure
88     # the longer description does not begin on the synopsis line --- R's
89     # write.dcf does not appear to have a nicer way of doing this.
90     descr = paste(descr,'"\n\n', long_descr, sep='')
91     if ('URL' %in% colnames(pkg$description)) {
92         descr = paste(descr,'\n\nURL: ',pkg$description[1,'URL'],sep='')
93     }
94     control[2,'Description'] = descr
95
96     # Debian policy says 72 char width; indent minimally
97     write.dcf(control,file=pkg$debfile('control.in'),indent=1,width=72)
98     write.dcf(control,indent=1,width=72)
99 }
100