]> git.donarmstrong.com Git - cran2deb.git/commitdiff
added two Encoding overrides which helps for packages by Jens when he writes his...
authoredd <edd@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Wed, 9 Dec 2009 03:02:02 +0000 (03:02 +0000)
committeredd <edd@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Wed, 9 Dec 2009 03:02:02 +0000 (03:02 +0000)
git-svn-id: svn://svn.r-forge.r-project.org/svnroot/cran2deb@294 edb9625f-4e0d-4859-8d74-9fd3b1da38cb

trunk/R/debcontrol.R
trunk/R/license.R

index 2293c61530e72a1073c1d0777e791e0dd19734e2..c439574e120a333c2d4de29f3321df2337e1b359 100644 (file)
@@ -115,20 +115,21 @@ map_aliases_to_debian <- function(aliases) {
 
 generate_control <- function(pkg) {
     # construct control file
-    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.8.3'
-
-    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.8.3'
+
+    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=', ')
+    control[2,'Depends'] <- paste(pkg$depends$bin,collapse=', ')
 
 #   # bundles provide virtual packages of their contents
 #   # unnecessary for now; cran2deb converts R bundles itself
@@ -141,11 +142,11 @@ generate_control <- function(pkg) {
 #    }
 
     # 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='')
+        descr <- paste(descr,pkg$name,sep='')
     }
     if (pkg$is_bundle) {
         long_descr <- pkg$description[1,'BundleDescription']
@@ -162,14 +163,17 @@ 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='')
+    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','URL')) {
         if (r_info %in% colnames(pkg$description)) {
-            descr = paste(descr,'\n\n',r_info,': ',pkg$description[1,r_info],sep='')
+            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)
index 846cf566c70c5fc8a1b2c9ea328328fe5b69e16b..113b99e30d1d567cc7de04f1a9d4d4a02435d9c2 100644 (file)
@@ -30,7 +30,10 @@ license_text_reduce <- function(license) {
     # these reduction steps are sound for all conformant R license
     # specifications.
 
-    # compress spaces into a single space
+    if (Encoding(license) == "unknown")
+        Encoding(license) <- "latin1"   # or should it be UTF-8 ?
+
+    ## compress spaces into a single space
     license = gsub('[[:space:]]+',' ',license)
     # make all characters lower case
     license = tolower(license)
@@ -87,11 +90,19 @@ get_license <- function(pkg,license) {
             file = gsub('file ','',license)
             path = file.path(pkg$path, file)
             if (file.exists(path)) {
-                license <- license_text_reduce(readChar(path,file.info(path)$size))
+                #license <- license_text_reduce(readChar(path,file.info(path)$size))
+                con <- file(path, "rb")
+                content <- paste(readLines(con), collapse="\n")
+                close(con)
+                license <- license_text_reduce(content)
             } else {
                 path = file.path(pkg$path, 'inst', file)
                 if (file.exists(path)) {
-                    license <- license_text_reduce(readChar(path,file.info(path)$size))
+                    #license <- license_text_reduce(readChar(path,file.info(path)$size))
+                    con <- file(path, "rb")
+                    content <- paste(readLines(con), collapse="\n")
+                    close(con)
+                    license <- license_text_reduce(content)
                 } else {
                     error('said to look at a license file but license file is missing')
                 }