X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=trunk%2FR%2Fdebcontrol.R;h=e8f8d325992c8a2bc83a3a3603002835047ed4db;hb=e4d3cbddacd0b2a51ed475b0ce7bb8c811ba5a2f;hp=34cc6b69f6dc003f4a7c81961f7f63ade3c2d1ea;hpb=5cf6acdbf690b8b19764ae8bb9ead1cea9a60a79;p=cran2deb.git diff --git a/trunk/R/debcontrol.R b/trunk/R/debcontrol.R index 34cc6b6..e8f8d32 100644 --- a/trunk/R/debcontrol.R +++ b/trunk/R/debcontrol.R @@ -1,4 +1,4 @@ -get_dependencies <- function(pkg,extra_deps) { +get_dependencies <- function(pkg,extra_deps,verbose=TRUE) { # determine dependencies dependencies <- r_dependencies_of(description=pkg$description) depends <- list() @@ -16,9 +16,14 @@ get_dependencies <- function(pkg,extra_deps) { depends$build = c(extra_deps$deb,depends$build) # add the system requirements if ('SystemRequirements' %in% colnames(pkg$description)) { - sysreq <- sysreqs_as_debian(pkg$description[1,'SystemRequirements']) - depends$bin = c(sysreq$bin,depends$bin) - depends$build = c(sysreq$build,depends$build) + sysreq <- sysreqs_as_debian(pkg$description[1,'SystemRequirements'],verbose=verbose) + if (!is.null(sysreq) && is.list(sysreq)) { + depends$bin = c(sysreq$bin,depends$bin) + depends$build = c(sysreq$build,depends$build) + } else { + if (verbose) {cat("sysreq:"); print(sysreq)} + fail('Cannot interpret system dependency, fix package.\n') + } } forced <- forced_deps_as_debian(pkg$name) @@ -60,14 +65,18 @@ get_dependencies <- function(pkg,extra_deps) { return(depends) } -sysreqs_as_debian <- function(sysreq_text) { +sysreqs_as_debian <- function(sysreq_text,verbose=FALSE) { # form of this field is unspecified (ugh) but most people seem to stick # with this aliases <- c() + # drop notes + sysreq_text = gsub('[Nn][Oo][Tt][Ee]:\\s.*','',sysreq_text) + # conversion from and to commata and lower case sysreq_text <- gsub('[[:space:]]and[[:space:]]',' , ',tolower(sysreq_text)) for (sysreq in strsplit(sysreq_text,'[[:space:]]*,[[:space:]]*')[[1]]) { + if (verbose) cat("sysreq to investigate: '",sysreq,"'.\n",sep="") startreq = sysreq - # constant case + # constant case (redundant) sysreq = tolower(sysreq) # drop version information/comments for now sysreq = gsub('[[][^])]*[]]','',sysreq) @@ -78,15 +87,21 @@ sysreqs_as_debian <- function(sysreq_text) { sysreq = gsub('[<>=]*[[:space:]]*[[:digit:]]+[[:digit:].+:~-]*','',sysreq) # byebye URLs sysreq = gsub('(ht|f)tps?://[[:alnum:]!?*"\'(),%$_@.&+/=-]*','',sysreq) - # squish out space + # squish out space -- this does not work for me (did not want to touch, though), Steffen sysreq = chomp(gsub('[[:space:]]+',' ',sysreq)) + # no final dot and neither final blanks + sysreq = gsub('\\.?\\s*$','',sysreq) + if (nchar(sysreq) == 0) { + notice('part of the SystemRequirement became nothing') + next + } alias <- db_sysreq_override(sysreq) if (is.null(alias)) { error('do not know what to do with SystemRequirement:',sysreq) error('original SystemRequirement:',startreq) fail('unmet system requirement') } - notice('mapped SystemRequirement',startreq,'onto',alias,'via',sysreq) + notice(paste("mapped SystemRequirement '",startreq,"' onto '",alias,"' via '",sysreq,"'.",sep="")) aliases = c(aliases,alias) } return(map_aliases_to_debian(aliases)) @@ -111,45 +126,35 @@ map_aliases_to_debian <- function(aliases) { generate_control <- function(pkg) { # construct control file - control = data.frame() - control[1,'Source'] = pkg$srcname - control[1,'Section'] = 'math' ## to be changed to 'gnu-r' once lintian groks it - control[1,'Priority'] = 'optional' - control[1,'Maintainer'] = maintainer - control[1,'Build-Depends'] = paste(pkg$depends$build,collapse=', ') - control[1,'Standards-Version'] = '3.8.0' - - control[2,'Package'] = pkg$debname - control[2,'Architecture'] = 'all' + + control <- data.frame() + control[1,'Source'] <- pkg$srcname + control[1,'Section'] <- 'gnu-r' + control[1,'Priority'] <- 'optional' + control[1,'Maintainer'] <- maintainer + control[1,'Build-Depends'] <- paste(pkg$depends$build, collapse=', ') + control[1,'Standards-Version'] <- '3.9.1' + if ('URL' %in% colnames(pkg$description)) { + control[1,'Homepage'] <- pkg$description[1,'URL'] + } + + control[2,'Package'] <- pkg$debname + control[2,'Architecture'] <- 'all' if (pkg$archdep) { - control[2,'Architecture'] = 'any' + control[2,'Architecture'] <- 'any' } - control[2,'Depends'] = paste(pkg$depends$bin,collapse=', ') - -# # bundles provide virtual packages of their contents -# # unnecessary for now; cran2deb converts R bundles itself -# if (pkg$is_bundle) { -# control[2,'Provides'] = paste( -# lapply(r_bundle_contains(pkg$name) -# ,function(name) return(pkgname_as_debian(paste(name) -# ,repopref=pkg$repo))) -# ,collapse=', ') -# } + control[2,'Depends'] <- paste(pkg$depends$bin,collapse=', ',sep='') # generate the description - descr = 'GNU R package "' + descr <- 'GNU R package "' if ('Title' %in% colnames(pkg$description)) { - descr = paste(descr,pkg$description[1,'Title'],sep='') + descr <- paste(descr,pkg$description[1,'Title'],sep='') } else { - descr = paste(descr,pkg$name,sep='') - } - if (pkg$is_bundle) { - long_descr <- pkg$description[1,'BundleDescription'] - } else { - long_descr <- pkg$description[1,'Description'] + descr <- paste(descr,pkg$name,sep='') } + long_descr <- pkg$description[1,'Description'] - if (length(long_descr) < 1) { + if (length(long_descr) < 1 || long_descr == "") { # bypass lintian extended-description-is-empty for which we care not. long_descr <- paste('The author/maintainer of this package' ,'did not care to enter a longer description.') @@ -158,13 +163,20 @@ generate_control <- function(pkg) { # using \n\n.\n\n is not very nice, but is necessary to make sure # the longer description does not begin on the synopsis line --- R's # write.dcf does not appear to have a nicer way of doing this. - descr = paste(descr,'"\n\n', long_descr, sep='') - if ('URL' %in% colnames(pkg$description)) { - descr = paste(descr,'\n\nURL: ',pkg$description[1,'URL'],sep='') + descr <- paste(descr,'"\n\n', long_descr, sep='') + # add some extra nice info about the original R package + for (r_info in c('Author','Maintainer')) { + if (r_info %in% colnames(pkg$description)) { + descr <- paste(descr,'\n\n',r_info,': ',pkg$description[1,r_info],sep='') + } } - control[2,'Description'] = descr + if (Encoding(descr) == "unknown") + Encoding(descr) <- "latin1" # or should it be UTF-8 + + control[2,'Description'] <- descr # Debian policy says 72 char width; indent minimally write.dcf(control,file=pkg$debfile('control.in'),indent=1,width=72) + write.dcf(control,indent=1,width=72) }