From 4a9682745edce6bf2d425acfcd6683ab8f10bc5e Mon Sep 17 00:00:00 2001 From: blundellc <blundellc@edb9625f-4e0d-4859-8d74-9fd3b1da38cb> Date: Sat, 13 Sep 2008 13:29:06 +0000 Subject: [PATCH] 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 --- pkg/trunk/R/license.R | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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) -- 2.39.5