[Rd] Small Extension to license()/licence()
R. Michael Weylandt
michael.weylandt at gmail.com
Sun Sep 30 18:55:28 CEST 2012
By analogy with maintainer(), I suggest extending license() to give
the licensing terms of packages as well as R itself when prompted.
Below is a small patch in that direction. This won't break anything
and imposes no significant maintenance burden; it has the advantage of
making it ever so marginally easier to know package licenses.
Given the existence of license forms like GPL >=2, I don't see a easy
programmatic way of identifying what RShowDoc() can provide and what
it can't, so I've left that out.
Cheers,
Michael
-------------------------------------------------
Index: src/library/base/R/license.R
===================================================================
--- src/library/base/R/license.R (revision 60839)
+++ src/library/base/R/license.R (working copy)
@@ -16,8 +16,14 @@
# A copy of the GNU General Public License is available at
# http://www.r-project.org/Licenses/
-licence <- license <- function() {
- cat("\nThis software is distributed under the terms of the GNU General\n")
+licence <- license <- function(pkg = NULL) {
+ if(!is.null(pkg)) pkgd <- packageDescription(pkg)
+ if(is.null(pkg) || pkgd[["Priority"]] == "base"){
+ if(is.null(pkg)){
+ cat("\nThis software is distributed under the terms of the GNU
General\n")
+ } else {
+ cat(pkg, "is part of R and distributed under the terms of the
GNU General\n")
+ }
cat("Public License, either Version 2, June 1991 or Version 3,
June 2007.\n")
cat("The terms of version 2 of the license are in a file called
COPYING\nwhich you should have received with\n")
cat("this software and which can be displayed by RShowDoc(\"COPYING\").\n")
@@ -34,4 +40,9 @@
cat("Version 3 of the license can be displayed by RShowDoc(\"LGPL-3\").\n")
cat("\n")
cat("'Share and Enjoy.'\n\n")
+ } else {
+ cat(pkg, "is distributed under the", pkgd[["License"]],"License.\n")
+ }
+
+ invisible(NULL)
}
Index: src/library/base/man/license.Rd
===================================================================
--- src/library/base/man/license.Rd (revision 60839)
+++ src/library/base/man/license.Rd (working copy)
@@ -8,13 +8,18 @@
\alias{license}
\alias{licence}
\description{
- The license terms under which \R is distributed.
+ The license terms under which \R or a contributed package is distributed.
}
\usage{
-license()
-licence()
+license(pkg = NULL)
+licence(pkg = NULL)
}
\details{
+ If pkg is "NULL", the licensing terms of R are given; else, the
+ license of the package (as taken from the package DESCRIPTION file) is
+ returned. Major open-source licenses can be found in
+ \file{\var{\link{R_HOME}}/share/licenses} and viewed with \link{RShowDoc}.
+
\R is distributed under the terms of the GNU GENERAL PUBLIC LICENSE,
either Version 2, June 1991 or Version 3, June 2007. A copy of the
version 2 license is in file \file{\var{\link{R_HOME}}/COPYING} and
More information about the R-devel
mailing list