]> git.donarmstrong.com Git - cran2deb.git/commitdiff
cran2deb: rebuild the source tarball each time removing file exec bit.
authorblundellc <blundellc@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Sat, 13 Sep 2008 13:13:34 +0000 (13:13 +0000)
committerblundellc <blundellc@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Sat, 13 Sep 2008 13:13:34 +0000 (13:13 +0000)
The subdirectory of an R package is 'pkgname'.  Debian typically has
'pkgname-upstreamversion'.  Hence the tarball is rebuilt after renaming
the 'pkgname' directory appropriately.

Whilst this is all going on, every file in the R package has its
executable bit removed.  There would appear to be little correct need
for it at the moment (this will change when #! is handled better) and
this gets rid of some inappropriately executable files.

git-svn-id: svn://svn.r-forge.r-project.org/svnroot/cran2deb@23 edb9625f-4e0d-4859-8d74-9fd3b1da38cb

pkg/trunk/cran2deb

index 6b499d7a5465828e1a6eb0b299b618b7be9f0bdc..6741a8d02a4f6522d96b5e1f94e63b04669b34e0 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env r
 
-use_pbuilder <- 1
+use_pbuilder <- 0
 pbuilder_results <- '/var/cache/pbuilder/result'
 
 version.new <- function(rver,debian_revision=1, debian_epoch=0) {
@@ -88,6 +88,9 @@ prepare.pkg <- function(dir, pkgname,repo='cran',repoURL='http://cran.uk.r-proje
     # based loosely on library/utils/R/packages2.R::install.packages
     # should do nothing Debian specific
     archive <- download.packages(pkgname, dir, repos=repoURL, type="source")[1,2]
+    if (length(grep('\\.\\.',archive)) || normalizePath(archive) != archive) {
+        stop(paste('funny looking path',archive))
+    }
     wd <- getwd()
     setwd(dir)
     if (length(grep('\\.zip$',archive))) {
@@ -108,11 +111,13 @@ prepare.pkg <- function(dir, pkgname,repo='cran',repoURL='http://cran.uk.r-proje
     pkg$path = sub("_\\.(zip|tar\\.gz)", ""
                   ,gsub(.standard_regexps()$valid_package_version, ""
                   ,archive))
+    if (!file.info(pkg$path)[,'isdir']) {
+        stop(paste(pkg$path,'is not a directory and should be.'))
+    }
     pkg$description = read.dcf(paste(pkg$path,'DESCRIPTION',sep='/'))
     pkg$repo = repo
     pkg$repoURL = repoURL
     pkg$version = pkg$description[1,'Version']
-    # TODO: re-pack into a Debian-named archive with a Debian-named directory.
     return(pkg)
 }
 
@@ -170,15 +175,30 @@ prepare.new.debian <- function(pkg) {
     pkg$srcname = tolower(pkg$name)
     pkg$debname = paste('r',tolower(pkg$repo),pkg$srcname,sep='-')
 
-    # rename package into something Debian-friendly
     if (!length(grep('\\.tar\\.gz',pkg$archive))) {
         stop('archive is not tarball')
     }
-    debarchive= paste(dirname(pkg$archive),'/'
-                             ,pkg$srcname,'_'
-                             ,pkg$version,'.orig.tar.gz'
-                             ,sep='')
-    file.rename(pkg$archive, debarchive)
+
+    # re-pack into a Debian-named archive with a Debian-named directory.
+    debpath = paste(dirname(pkg$archive),'/'
+                   ,pkg$srcname,'-'
+                   ,pkg$version
+                   ,sep='')
+    file.rename(pkg$path, debpath)
+    pkg$path = debpath
+    debarchive = paste(dirname(pkg$archive),'/'
+                              ,pkg$srcname,'_'
+                              ,pkg$version,'.orig.tar.gz'
+                              ,sep='')
+    wd <- getwd()
+    setwd(dirname(pkg$path))
+    # remove them pesky +x files
+    system(paste('find',shQuote(basename(pkg$path))
+                ,'-type f -exec chmod -x {} \\;'))
+    # tar it all back up
+    system(paste('tar -czf',shQuote(debarchive),shQuote(basename(pkg$path))))
+    setwd(wd)
+    file.remove(pkg$archive)
     pkg$archive = debarchive
 
     # make the debian/ directory