diff options
-rw-r--r-- | bdep/new.cli | 53 | ||||
-rw-r--r-- | bdep/new.cxx | 109 | ||||
-rw-r--r-- | tests/new.testscript | 2 |
3 files changed, 115 insertions, 49 deletions
diff --git a/bdep/new.cli b/bdep/new.cli index dec854e..7dc6c61 100644 --- a/bdep/new.cli +++ b/bdep/new.cli @@ -322,11 +322,48 @@ namespace bdep \li|\n\ \ \ \c{\b{license=}\i{name}} - Specify the project's license. Commonly used license names are - \cb{MIT}, \cb{ASLv2} (Apache License 2.0), \cb{GPLv3}, and - \cb{proprietary}. If unspecified, then \cb{proprietary} is - assumed. See the \l{bpkg#manifest-package-license \cb{license}} - package manifest value for details.| + Specify the project's license. The license name can be an + \l{https://spdx.org/licenses/ SPDX License Expression}, which, in its + simplest form, is just the license ID. Or it can be a free form name + in the \cb{other:} license name scheme. If unspecified, then + \cb{other: proprietary} is assumed. The following tables lists the + most commonly used free/open source software license IDs as well as a + number of pre-defined \cb{other:} names. See the + \l{bpkg#manifest-package-license \cb{license}} package manifest value + for more information. + + \ + MIT MIT License. + + BSD-2-Clause BSD 2-Clause \"Simplified\" License + BSD-3-Clause BSD 3-Clause \"New\" or \"Revised\" License + + GPL-3.0-only GNU General Public License v3.0 only + GPL-3.0-or-later GNU General Public License v3.0 or later + + LGPL-3.0-only GNU Lesser General Public License v3.0 only + LGPL-3.0-or-later GNU Lesser General Public License v3.0 or later + + AGPL-3.0-only GNU Affero General Public License v3.0 only + AGPL-3.0-or-later GNU Affero General Public License v3.0 or later + + Apache-2.0 Apache License 2.0 + + MPL-2.0 Mozilla Public License 2.0 + + BSL-1.0 Boost Software License 1.0 + + Unlicense The Unlicense (public domain) + \ + + \ + other: public domain Released into the public domain + other: available source Not free/open source with public source code + other: proprietary Not free/open source + other: TODO License is not yet decided + \ + + | \li|\n\ \ \ \cb{no-readme} @@ -409,7 +446,7 @@ namespace bdep bool unit-tests; bool no-install; dir_path "source"; - string license = "proprietary"; + string license = "other: proprietary"; bool no-readme; bool alt-naming; }; @@ -422,7 +459,7 @@ namespace bdep bool no-install; bool no-version; dir_path "source"; - string license = "proprietary"; + string license = "other: proprietary"; bool no-readme; bool alt-naming; }; @@ -431,7 +468,7 @@ namespace bdep { bool no-tests; bool no-install; - string license = "proprietary"; + string license = "other: proprietary"; bool no-readme; bool alt-naming; }; diff --git a/bdep/new.cxx b/bdep/new.cxx index 185274e..c76549c 100644 --- a/bdep/new.cxx +++ b/bdep/new.cxx @@ -26,29 +26,44 @@ namespace bdep { // License id to full name map. // + // Used for the license full name search for the auto-detected and + // explicitly specified license ids and for obtaining their canonical case. + // static const map<string, string, icase_compare_string> licenses = { - {"MIT", "MIT License" }, - {"BSD2", "Simplified 2-clause BSD License" }, - {"BSD3", "New 3-clause BSD License" }, - {"BSD4", "Original 4-clause BSD License" }, - {"GPLv2", "GNU General Public License v2.0" }, - {"GPLv3", "GNU General Public License v3.0" }, - {"LGPLv2", "GNU Lesser General Public License v2.0" }, - {"LGPLv2.1", "GNU Lesser General Public License v2.1" }, - {"LGPLv3", "GNU Lesser General Public License v3.0" }, - {"AGPLv2", "Affero General Public License v2.0" }, - {"AGPLv3", "GNU Affero General Public License v3.0" }, - {"ASLv1", "Apache License v1.0" }, - {"ASLv1.1", "Apache License v1.1" }, - {"ASLv2", "Apache License v2.0" }, - {"MPLv2", "Mozilla Public License v2.0" }, - - // Note: entries with empty full name are here to get canonical case. - // - {"public domain" , "" }, - {"available source", "Not free software/open source" }, - {"proprietary", "" }, - {"TODO", "License is not yet decided" }}; + {"MIT", "MIT License" }, + {"BSD-1-Clause", "BSD 1-Clause License" }, + {"BSD-2-Clause", "BSD 2-Clause \"Simplified\" License" }, + {"BSD-3-Clause", "BSD 3-Clause \"New\" or \"Revised\" License" }, + {"BSD-4-Clause", "BSD 4-Clause \"Original\" or \"Old\" License" }, + {"GPL-2.0-only", "GNU General Public License v2.0 only" }, + {"GPL-2.0-or-later", "GNU General Public License v2.0 or later" }, + {"GPL-3.0-only", "GNU General Public License v3.0 only" }, + {"GPL-3.0-or-later", "GNU General Public License v3.0 or later" }, + {"LGPL-2.0-only", "GNU Library General Public License v2 only" }, + {"LGPL-2.0-or-later", "GNU Library General Public License v2 or later" }, + {"LGPL-2.1-only", "GNU Lesser General Public License v2.1 only" }, + {"LGPL-2.1-or-later", "GNU Lesser General Public License v2.1 or later" }, + {"LGPL-3.0-only", "GNU Lesser General Public License v3.0 only" }, + {"LGPL-3.0-or-later", "GNU Lesser General Public License v3.0 or later" }, + {"AGPL-1.0-only", "Affero General Public License v1.0 only" }, + {"AGPL-1.0-or-later", "Affero General Public License v1.0 or later" }, + {"AGPL-2.0-only", "Affero General Public License v2.0 only" }, + {"AGPL-2.0-or-later", "Affero General Public License v2.0 or later" }, + {"AGPL-3.0-only", "GNU Affero General Public License v3.0 only" }, + {"AGPL-3.0-or-later", "GNU Affero General Public License v3.0 or later" }, + {"Apache-1.0", "Apache License 1.0" }, + {"Apache-1.1", "Apache License 1.1" }, + {"Apache-2.0", "Apache License 2.0" }, + {"MPL-1.0", "Mozilla Public License 1.0" }, + {"MPL-1.1", "Mozilla Public License 1.1" }, + {"MPL-2.0", "Mozilla Public License 2.0" }, + {"BSL-1.0", "Boost Software License 1.0" }, + {"Unlicense", "The Unlicense (public domain)" }, + + {"other: public domain", "Released into the public domain" }, + {"other: available source", "Not free/open source with public source code"}, + {"other: proprietary", "Not free/open source" }, + {"other: TODO", "License is not yet decided" }}; // Extract a license id from a license file returning an empty string if @@ -129,18 +144,32 @@ namespace bdep return p.second; }; - // Note that some licenses (like ASL, MPL) always spell the minor verison, - // even if it is there (unlike the GNU licenses). So for them we need to - // ignore the zero minor component. + // Note that some licenses (for example, GNU licenses) don't spell the + // zero minor version. So for them we may need to provide two properly + // ordered regular expressions. // - (test ("MIT License", "MIT") || - test ("BSD ([1234])-Clause License", "BSD$1") || - test ("Apache License Version ([0-9]+(\\.[1-9])?)", "ASLv$1") || - test ("Mozilla Public License Version ([0-9]+(\\.[1-9])?)", "MPLv$1") || - test ("GNU GENERAL PUBLIC LICENSE Version ([0-9.]+)", "GPLv$1") || - test ("GNU LESSER GENERAL PUBLIC LICENSE Version ([0-9.]+)", "LGPLv$1") || - test ("GNU AFFERO GENERAL PUBLIC LICENSE Version ([0-9.]+)", "AGPLv$1") || - test ("public domain", "public domain")); + (test ("MIT License", "MIT") || + test ("BSD ([1234])-Clause License", "BSD-$1-Clause") || + test ("Apache License Version ([0-9]+\\.[0-9])", "Apache-$1") || + test ("Mozilla Public License Version ([0-9]+\\.[0-9])", "MPL-$1") || + test ("GNU GENERAL PUBLIC LICENSE Version ([0-9]+)", "GPL-$1.0-only") || + + test ("GNU LESSER GENERAL PUBLIC LICENSE Version ([0-9]+\\.[0-9]+)", + "LGPL-$1-only") || + + test ("GNU LESSER GENERAL PUBLIC LICENSE Version ([0-9]+)", + "LGPL-$1.0-only") || + + test ("GNU AFFERO GENERAL PUBLIC LICENSE Version ([0-9]+)", + "AGPL-$1.0-only") || + + test ("Boost Software License - Version ([0-9]+\\.[0-9]+)", "BSL-$1") || + + test ("This is free and unencumbered software released into the " + "public domain\\.", + "Unlicense") || + + test ("public domain", "other: public domain")); return r; } @@ -827,8 +856,14 @@ namespace bdep if (license_e) { if (!license_o) + { + // We should have failed earlier if the license wasn't recognized. + // + assert (!license_e->empty ()); + license = *license_e; - else if (icasecmp (*license_e, license) != 0) + } + else if (!license_e->empty () && icasecmp (*license_e, license) != 0) fail << "extracted license does not match requested" << info << "extracted: " << *license_e << info << "requested: " << license; @@ -1057,12 +1092,6 @@ namespace bdep ln = i->second; license = i->first; // Use canonical case. } - else - { - if (icasecmp (license, "BSD") == 0) - warn << "BSD license name is ambiguous" << - info << "consider using BSD3 for \"New 3-clause BSD License\""; - } } open (out / "manifest"); diff --git a/tests/new.testscript b/tests/new.testscript index 6d1888a..8d4b588 100644 --- a/tests/new.testscript +++ b/tests/new.testscript @@ -264,7 +264,7 @@ status += -d prj EOE test -f libfoo/.gitignore; sed -n -e 's/^summary: (.+)$/\1/p' libfoo/manifest >'cool foo'; - sed -n -e 's/^license: ([^ ]+).*$/\1/p' libfoo/manifest >'ASLv2' + sed -n -e 's/^license: ([^ ]+).*$/\1/p' libfoo/manifest >'Apache-2.0' } : pkg |