From: blundellc Date: Sat, 13 Sep 2008 13:29:06 +0000 (+0000) Subject: license: try looking in inst/ for LICENSE; fail nicely if it is missing. X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4a9682745edce6bf2d425acfcd6683ab8f10bc5e;p=cran2deb.git license: try looking in inst/ for LICENSE; fail nicely if it is missing. git-svn-id: svn://svn.r-forge.r-project.org/svnroot/cran2deb@143 edb9625f-4e0d-4859-8d74-9fd3b1da38cb --- diff --git a/pkg/trunk/R/license.R b/pkg/trunk/R/license.R index c392e11..846cf56 100644 --- a/pkg/trunk/R/license.R +++ b/pkg/trunk/R/license.R @@ -22,7 +22,6 @@ is_acceptable_license <- function(license) { warn('Accepting/rejecting wild license as',license,'. FIX THE PACKAGE!') return(action) } - # TODO: file {LICENSE,LICENCE} (+ maybe COPYING?) error('Wild license',license,'did not match classic rules; rejecting') return(F) } @@ -85,9 +84,18 @@ get_license <- function(pkg,license) { license <- chomp(gsub('[[:space:]]+',' ',license)) if (length(grep('^file ',license))) { if (length(grep('^file LICEN[CS]E$',license))) { - path = gsub('file ','',license) - path = file.path(pkg$path, path) - license <- license_text_reduce(readChar(path,file.info(path)$size)) + file = gsub('file ','',license) + path = file.path(pkg$path, file) + if (file.exists(path)) { + license <- license_text_reduce(readChar(path,file.info(path)$size)) + } else { + path = file.path(pkg$path, 'inst', file) + if (file.exists(path)) { + license <- license_text_reduce(readChar(path,file.info(path)$size)) + } else { + error('said to look at a license file but license file is missing') + } + } } else { error('invalid license file specification',license) return(NA)