From fbeb49c63a23c1b84b0512e0aa6dec3179223b87 Mon Sep 17 00:00:00 2001 From: blundellc Date: Sat, 13 Sep 2008 13:18:27 +0000 Subject: [PATCH] license+db: return NA when no decision is found. reject when a decision is found. also renamed deny to reject. feels nicer. git-svn-id: svn://svn.r-forge.r-project.org/svnroot/cran2deb@59 edb9625f-4e0d-4859-8d74-9fd3b1da38cb --- pkg/trunk/R/db.R | 7 +++++-- pkg/trunk/R/license.R | 21 ++++++++++++--------- pkg/trunk/data/populate_licenses | 2 +- pkg/trunk/exec/license | 4 ++-- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/pkg/trunk/R/db.R b/pkg/trunk/R/db.R index 8238a3d..3795a5f 100644 --- a/pkg/trunk/R/db.R +++ b/pkg/trunk/R/db.R @@ -39,6 +39,9 @@ db.sysreq.override <- function(sysreq_text) { 'SELECT debian_name FROM sysreq_override WHERE' ,db.quote(sysreq_text),'GLOB r_pattern')) db.stop(con) + if (length(results) == 0) { + return(NA) + } return(results$debian_name) } @@ -71,7 +74,7 @@ db.license.override.name <- function(name) { ,db.quote(name),'= name')) db.stop(con) if (length(results) == 0) { - return(FALSE) + return(NA) } return(as.logical(results$accept)) } @@ -102,7 +105,7 @@ db.license.override.file <- function(file_sha1) { ,db.quote(file_sha1),'= license_files.file_sha1')) db.stop(con) # TODO: change accept from 0,1 into FALSE,TRUE - # TODO: NULL -> FALSE + # TODO: NULL -> NA return(results) } diff --git a/pkg/trunk/R/license.R b/pkg/trunk/R/license.R index 619147b..928ffd5 100644 --- a/pkg/trunk/R/license.R +++ b/pkg/trunk/R/license.R @@ -8,8 +8,9 @@ is_acceptable_license <- function(license) { # don't care about versions of licenses license = chomp(sub('\\( ?[<=>!]+ ?[0-9.-]+ ?\\)','' ,sub('-[0-9.-]+','',license))) - if (db.license.override.name(license)) { - return(T) + action = db.license.override.name(license) + if (!is.na(action)) { + return(action) } # uninteresting urls license = gsub('http://www.gnu.org/[[:alnum:]/._-]*','',license) @@ -28,21 +29,23 @@ is_acceptable_license <- function(license) { license = gsub('(mozilla )?(mpl|mozilla public)','mpl',license) # remove any extra space introduced license = chomp(gsub('[[:space:]]+',' ',license)) - if (db.license.override.name(license)) { - message(paste('W: Accepted wild license as',license,'. FIX THE PACKAGE!')) - return(T) + action = db.license.override.name(license) + if (!is.na(action)) { + message(paste('W: Accepting/rejecting wild license as',license,'. FIX THE PACKAGE!')) + return(action) } # remove everything that looks like a version specification license = gsub('(ver?sion|v)? *[0-9.-]+ *(or *(higher|later|newer|greater|above))?','' ,license) # remove any extra space introduced license = chomp(gsub('[[:space:]]+',' ',license)) - if (db.license.override.name(license)) { - message(paste('W: Accepted wild license as',license,'. FIX THE PACKAGE!')) - return(T) + action = db.license.override.name(license) + if (!is.na(action)) { + message(paste('W: Accepting/rejecting wild license as',license,'. FIX THE PACKAGE!')) + return(action) } # TODO: file {LICENSE,LICENCE} (+ maybe COPYING?) - message(paste('E: Wild license',license,'did not match')) + message(paste('E: Wild license',license,'did not match; rejecting')) return(F) } diff --git a/pkg/trunk/data/populate_licenses b/pkg/trunk/data/populate_licenses index 169981e..2c46922 100644 --- a/pkg/trunk/data/populate_licenses +++ b/pkg/trunk/data/populate_licenses @@ -15,5 +15,5 @@ add AGPL add MIT add X11 add MPL -add UNLIMITED deny +add UNLIMITED reject ls diff --git a/pkg/trunk/exec/license b/pkg/trunk/exec/license index fd4c53b..89d9b2b 100755 --- a/pkg/trunk/exec/license +++ b/pkg/trunk/exec/license @@ -5,7 +5,7 @@ suppressPackageStartupMessages(library(digest)) exec_cmd <- function(argc, argv) { usage <- function() - message('usage: add [deny]|file |ls|quit|help') + message('usage: add [reject]|file |ls|quit|help') if (argc < 1) { exit() @@ -13,7 +13,7 @@ exec_cmd <- function(argc, argv) { cmd = argv[1] if (cmd == 'add') { - if (argc != 2 && (argc != 3 || argv[3] != 'deny')) { + if (argc != 2 && (argc != 3 || argv[3] != 'reject')) { usage() return() } -- 2.39.2