From 5ae9e7fe22f174f2466c631989eeca2a6affd276 Mon Sep 17 00:00:00 2001 From: Rob Bast Date: Thu, 16 Jul 2015 11:42:12 +0200 Subject: [PATCH] remove spdx files, introduce external library --- bin/update-spdx-licenses | 10 - composer.json | 2 +- composer.lock | 63 +- res/spdx-exceptions.json | 29 - res/spdx-licenses.json | 1178 ------------------ src/Composer/Command/ShowCommand.php | 6 +- src/Composer/Util/ConfigValidator.php | 3 +- src/Composer/Util/SpdxLicense.php | 306 ----- src/Composer/Util/SpdxLicensesUpdater.php | 139 --- tests/Composer/Test/Util/SpdxLicenseTest.php | 145 --- 10 files changed, 68 insertions(+), 1813 deletions(-) delete mode 100755 bin/update-spdx-licenses delete mode 100644 res/spdx-exceptions.json delete mode 100644 res/spdx-licenses.json delete mode 100644 src/Composer/Util/SpdxLicense.php delete mode 100644 src/Composer/Util/SpdxLicensesUpdater.php delete mode 100644 tests/Composer/Test/Util/SpdxLicenseTest.php diff --git a/bin/update-spdx-licenses b/bin/update-spdx-licenses deleted file mode 100755 index f6b6f9209..000000000 --- a/bin/update-spdx-licenses +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env php -dumpLicenses(__DIR__ . '/../res/spdx-licenses.json'); -$updater->dumpExceptions(__DIR__ . '/../res/spdx-exceptions.json'); diff --git a/composer.json b/composer.json index ffac4f254..74df757f3 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ }, "require": { "php": ">=5.3.2", - "justinrainbow/json-schema": "~1.4", + "composer/spdx-licenses": "~1.0", "seld/jsonlint": "~1.0", "symfony/console": "~2.5", "symfony/finder": "~2.2", diff --git a/composer.lock b/composer.lock index b45ec64a2..154102042 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,69 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "556ac817fc0b456bddc48918ef09930d", + "hash": "694654491125336d91b339a8e117bb40", "packages": [ + { + "name": "composer/spdx-licenses", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/composer/spdx-licenses.git", + "reference": "abf7dfc7da7d7dc66c147a91b6e927099512292a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/spdx-licenses/zipball/abf7dfc7da7d7dc66c147a91b6e927099512292a", + "reference": "abf7dfc7da7d7dc66c147a91b6e927099512292a", + "shasum": "" + }, + "require": { + "justinrainbow/json-schema": "~1.4", + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.5", + "phpunit/phpunit-mock-objects": "~2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Spdx\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com" + }, + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "SPDX licenses list and validation library.", + "keywords": [ + "license", + "spdx", + "validator" + ], + "time": "2015-07-15 17:38:14" + }, { "name": "justinrainbow/json-schema", "version": "1.4.1", diff --git a/res/spdx-exceptions.json b/res/spdx-exceptions.json deleted file mode 100644 index 15491d2a5..000000000 --- a/res/spdx-exceptions.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "Autoconf-exception-2.0": [ - "Autoconf exception 2.0" - ], - "Autoconf-exception-3.0": [ - "Autoconf exception 3.0" - ], - "Bison-exception-2.2": [ - "Bison exception 2.2" - ], - "Classpath-exception-2.0": [ - "Classpath exception 2.0" - ], - "eCos-exception-2.0": [ - "eCos exception 2.0" - ], - "Font-exception-2.0": [ - "Font exception 2.0" - ], - "GCC-exception-2.0": [ - "GCC Runtime Library exception 2.0" - ], - "GCC-exception-3.1": [ - "GCC Runtime Library exception 3.1" - ], - "WxWindows-exception-3.1": [ - "WxWindows Library Exception 3.1" - ] -} \ No newline at end of file diff --git a/res/spdx-licenses.json b/res/spdx-licenses.json deleted file mode 100644 index 7cb654966..000000000 --- a/res/spdx-licenses.json +++ /dev/null @@ -1,1178 +0,0 @@ -{ - "Glide": [ - "3dfx Glide License", - false - ], - "Abstyles": [ - "Abstyles License", - false - ], - "AFL-1.1": [ - "Academic Free License v1.1", - true - ], - "AFL-1.2": [ - "Academic Free License v1.2", - true - ], - "AFL-2.0": [ - "Academic Free License v2.0", - true - ], - "AFL-2.1": [ - "Academic Free License v2.1", - true - ], - "AFL-3.0": [ - "Academic Free License v3.0", - true - ], - "AMPAS": [ - "Academy of Motion Picture Arts and Sciences BSD", - false - ], - "APL-1.0": [ - "Adaptive Public License 1.0", - true - ], - "Adobe-Glyph": [ - "Adobe Glyph List License", - false - ], - "APAFML": [ - "Adobe Postscript AFM License", - false - ], - "Adobe-2006": [ - "Adobe Systems Incorporated Source Code License Agreement", - false - ], - "AGPL-1.0": [ - "Affero General Public License v1.0", - false - ], - "Afmparse": [ - "Afmparse License", - false - ], - "Aladdin": [ - "Aladdin Free Public License", - false - ], - "ADSL": [ - "Amazon Digital Services License", - false - ], - "AMDPLPA": [ - "AMD's plpa_map.c License", - false - ], - "ANTLR-PD": [ - "ANTLR Software Rights Notice", - false - ], - "Apache-1.0": [ - "Apache License 1.0", - false - ], - "Apache-1.1": [ - "Apache License 1.1", - true - ], - "Apache-2.0": [ - "Apache License 2.0", - true - ], - "AML": [ - "Apple MIT License", - false - ], - "APSL-1.0": [ - "Apple Public Source License 1.0", - true - ], - "APSL-1.1": [ - "Apple Public Source License 1.1", - true - ], - "APSL-1.2": [ - "Apple Public Source License 1.2", - true - ], - "APSL-2.0": [ - "Apple Public Source License 2.0", - true - ], - "Artistic-1.0": [ - "Artistic License 1.0", - true - ], - "Artistic-1.0-Perl": [ - "Artistic License 1.0 (Perl)", - true - ], - "Artistic-1.0-cl8": [ - "Artistic License 1.0 w/clause 8", - true - ], - "Artistic-2.0": [ - "Artistic License 2.0", - true - ], - "AAL": [ - "Attribution Assurance License", - true - ], - "Bahyph": [ - "Bahyph License", - false - ], - "Barr": [ - "Barr License", - false - ], - "Beerware": [ - "Beerware License", - false - ], - "BitTorrent-1.0": [ - "BitTorrent Open Source License v1.0", - false - ], - "BitTorrent-1.1": [ - "BitTorrent Open Source License v1.1", - false - ], - "BSL-1.0": [ - "Boost Software License 1.0", - true - ], - "Borceux": [ - "Borceux license", - false - ], - "BSD-2-Clause": [ - "BSD 2-clause \"Simplified\" License", - true - ], - "BSD-2-Clause-FreeBSD": [ - "BSD 2-clause FreeBSD License", - false - ], - "BSD-2-Clause-NetBSD": [ - "BSD 2-clause NetBSD License", - false - ], - "BSD-3-Clause": [ - "BSD 3-clause \"New\" or \"Revised\" License", - true - ], - "BSD-3-Clause-Clear": [ - "BSD 3-clause Clear License", - false - ], - "BSD-4-Clause": [ - "BSD 4-clause \"Original\" or \"Old\" License", - false - ], - "BSD-Protection": [ - "BSD Protection License", - false - ], - "BSD-3-Clause-Attribution": [ - "BSD with attribution", - false - ], - "BSD-4-Clause-UC": [ - "BSD-4-Clause (University of California-Specific)", - false - ], - "bzip2-1.0.5": [ - "bzip2 and libbzip2 License v1.0.5", - false - ], - "bzip2-1.0.6": [ - "bzip2 and libbzip2 License v1.0.6", - false - ], - "Caldera": [ - "Caldera License", - false - ], - "CECILL-1.0": [ - "CeCILL Free Software License Agreement v1.0", - false - ], - "CECILL-1.1": [ - "CeCILL Free Software License Agreement v1.1", - false - ], - "CECILL-2.0": [ - "CeCILL Free Software License Agreement v2.0", - false - ], - "CECILL-B": [ - "CeCILL-B Free Software License Agreement", - false - ], - "CECILL-C": [ - "CeCILL-C Free Software License Agreement", - false - ], - "ClArtistic": [ - "Clarified Artistic License", - false - ], - "MIT-CMU": [ - "CMU License", - false - ], - "CNRI-Python": [ - "CNRI Python License", - true - ], - "CNRI-Python-GPL-Compatible": [ - "CNRI Python Open Source GPL Compatible License Agreement", - false - ], - "CPOL-1.02": [ - "Code Project Open License 1.02", - false - ], - "CDDL-1.0": [ - "Common Development and Distribution License 1.0", - true - ], - "CDDL-1.1": [ - "Common Development and Distribution License 1.1", - false - ], - "CPAL-1.0": [ - "Common Public Attribution License 1.0", - true - ], - "CPL-1.0": [ - "Common Public License 1.0", - true - ], - "CATOSL-1.1": [ - "Computer Associates Trusted Open Source License 1.1", - true - ], - "Condor-1.1": [ - "Condor Public License v1.1", - false - ], - "CC-BY-1.0": [ - "Creative Commons Attribution 1.0", - false - ], - "CC-BY-2.0": [ - "Creative Commons Attribution 2.0", - false - ], - "CC-BY-2.5": [ - "Creative Commons Attribution 2.5", - false - ], - "CC-BY-3.0": [ - "Creative Commons Attribution 3.0", - false - ], - "CC-BY-4.0": [ - "Creative Commons Attribution 4.0", - false - ], - "CC-BY-ND-1.0": [ - "Creative Commons Attribution No Derivatives 1.0", - false - ], - "CC-BY-ND-2.0": [ - "Creative Commons Attribution No Derivatives 2.0", - false - ], - "CC-BY-ND-2.5": [ - "Creative Commons Attribution No Derivatives 2.5", - false - ], - "CC-BY-ND-3.0": [ - "Creative Commons Attribution No Derivatives 3.0", - false - ], - "CC-BY-ND-4.0": [ - "Creative Commons Attribution No Derivatives 4.0", - false - ], - "CC-BY-NC-1.0": [ - "Creative Commons Attribution Non Commercial 1.0", - false - ], - "CC-BY-NC-2.0": [ - "Creative Commons Attribution Non Commercial 2.0", - false - ], - "CC-BY-NC-2.5": [ - "Creative Commons Attribution Non Commercial 2.5", - false - ], - "CC-BY-NC-3.0": [ - "Creative Commons Attribution Non Commercial 3.0", - false - ], - "CC-BY-NC-4.0": [ - "Creative Commons Attribution Non Commercial 4.0", - false - ], - "CC-BY-NC-ND-1.0": [ - "Creative Commons Attribution Non Commercial No Derivatives 1.0", - false - ], - "CC-BY-NC-ND-2.0": [ - "Creative Commons Attribution Non Commercial No Derivatives 2.0", - false - ], - "CC-BY-NC-ND-2.5": [ - "Creative Commons Attribution Non Commercial No Derivatives 2.5", - false - ], - "CC-BY-NC-ND-3.0": [ - "Creative Commons Attribution Non Commercial No Derivatives 3.0", - false - ], - "CC-BY-NC-ND-4.0": [ - "Creative Commons Attribution Non Commercial No Derivatives 4.0", - false - ], - "CC-BY-NC-SA-1.0": [ - "Creative Commons Attribution Non Commercial Share Alike 1.0", - false - ], - "CC-BY-NC-SA-2.0": [ - "Creative Commons Attribution Non Commercial Share Alike 2.0", - false - ], - "CC-BY-NC-SA-2.5": [ - "Creative Commons Attribution Non Commercial Share Alike 2.5", - false - ], - "CC-BY-NC-SA-3.0": [ - "Creative Commons Attribution Non Commercial Share Alike 3.0", - false - ], - "CC-BY-NC-SA-4.0": [ - "Creative Commons Attribution Non Commercial Share Alike 4.0", - false - ], - "CC-BY-SA-1.0": [ - "Creative Commons Attribution Share Alike 1.0", - false - ], - "CC-BY-SA-2.0": [ - "Creative Commons Attribution Share Alike 2.0", - false - ], - "CC-BY-SA-2.5": [ - "Creative Commons Attribution Share Alike 2.5", - false - ], - "CC-BY-SA-3.0": [ - "Creative Commons Attribution Share Alike 3.0", - false - ], - "CC-BY-SA-4.0": [ - "Creative Commons Attribution Share Alike 4.0", - false - ], - "CC0-1.0": [ - "Creative Commons Zero v1.0 Universal", - false - ], - "Crossword": [ - "Crossword License", - false - ], - "CUA-OPL-1.0": [ - "CUA Office Public License v1.0", - true - ], - "Cube": [ - "Cube License", - false - ], - "D-FSL-1.0": [ - "Deutsche Freie Software Lizenz", - false - ], - "diffmark": [ - "diffmark license", - false - ], - "WTFPL": [ - "Do What The F*ck You Want To Public License", - false - ], - "DOC": [ - "DOC License", - false - ], - "Dotseqn": [ - "Dotseqn License", - false - ], - "DSDP": [ - "DSDP License", - false - ], - "dvipdfm": [ - "dvipdfm License", - false - ], - "EPL-1.0": [ - "Eclipse Public License 1.0", - true - ], - "ECL-1.0": [ - "Educational Community License v1.0", - true - ], - "ECL-2.0": [ - "Educational Community License v2.0", - true - ], - "eGenix": [ - "eGenix.com Public License 1.1.0", - false - ], - "EFL-1.0": [ - "Eiffel Forum License v1.0", - true - ], - "EFL-2.0": [ - "Eiffel Forum License v2.0", - true - ], - "MIT-advertising": [ - "Enlightenment License (e16)", - false - ], - "MIT-enna": [ - "enna License", - false - ], - "Entessa": [ - "Entessa Public License v1.0", - true - ], - "ErlPL-1.1": [ - "Erlang Public License v1.1", - false - ], - "EUDatagrid": [ - "EU DataGrid Software License", - true - ], - "EUPL-1.0": [ - "European Union Public License 1.0", - false - ], - "EUPL-1.1": [ - "European Union Public License 1.1", - true - ], - "Eurosym": [ - "Eurosym License", - false - ], - "Fair": [ - "Fair License", - true - ], - "MIT-feh": [ - "feh License", - false - ], - "Frameworx-1.0": [ - "Frameworx Open License 1.0", - true - ], - "FreeImage": [ - "FreeImage Public License v1.0", - false - ], - "FTL": [ - "Freetype Project License", - false - ], - "FSFUL": [ - "FSF Unlimited License", - false - ], - "FSFULLR": [ - "FSF Unlimited License (with License Retention)", - false - ], - "Giftware": [ - "Giftware License", - false - ], - "GL2PS": [ - "GL2PS License", - false - ], - "Glulxe": [ - "Glulxe License", - false - ], - "AGPL-3.0": [ - "GNU Affero General Public License v3.0", - true - ], - "GFDL-1.1": [ - "GNU Free Documentation License v1.1", - false - ], - "GFDL-1.2": [ - "GNU Free Documentation License v1.2", - false - ], - "GFDL-1.3": [ - "GNU Free Documentation License v1.3", - false - ], - "GPL-1.0": [ - "GNU General Public License v1.0 only", - false - ], - "GPL-2.0": [ - "GNU General Public License v2.0 only", - true - ], - "GPL-3.0": [ - "GNU General Public License v3.0 only", - true - ], - "LGPL-2.1": [ - "GNU Lesser General Public License v2.1 only", - true - ], - "LGPL-3.0": [ - "GNU Lesser General Public License v3.0 only", - true - ], - "LGPL-2.0": [ - "GNU Library General Public License v2 only", - true - ], - "gnuplot": [ - "gnuplot License", - false - ], - "gSOAP-1.3b": [ - "gSOAP Public License v1.3b", - false - ], - "HaskellReport": [ - "Haskell Language Report License", - false - ], - "HPND": [ - "Historic Permission Notice and Disclaimer", - true - ], - "IBM-pibs": [ - "IBM PowerPC Initialization and Boot Software", - false - ], - "IPL-1.0": [ - "IBM Public License v1.0", - true - ], - "ImageMagick": [ - "ImageMagick License", - false - ], - "iMatix": [ - "iMatix Standard Function Library Agreement", - false - ], - "Imlib2": [ - "Imlib2 License", - false - ], - "IJG": [ - "Independent JPEG Group License", - false - ], - "Intel-ACPI": [ - "Intel ACPI Software License Agreement", - false - ], - "Intel": [ - "Intel Open Source License", - true - ], - "IPA": [ - "IPA Font License", - true - ], - "ISC": [ - "ISC License", - true - ], - "JasPer-2.0": [ - "JasPer License", - false - ], - "JSON": [ - "JSON License", - false - ], - "LPPL-1.3a": [ - "LaTeX Project Public License 1.3a", - false - ], - "LPPL-1.0": [ - "LaTeX Project Public License v1.0", - false - ], - "LPPL-1.1": [ - "LaTeX Project Public License v1.1", - false - ], - "LPPL-1.2": [ - "LaTeX Project Public License v1.2", - false - ], - "LPPL-1.3c": [ - "LaTeX Project Public License v1.3c", - true - ], - "Latex2e": [ - "Latex2e License", - false - ], - "BSD-3-Clause-LBNL": [ - "Lawrence Berkeley National Labs BSD variant license", - false - ], - "Leptonica": [ - "Leptonica License", - false - ], - "Libpng": [ - "libpng License", - false - ], - "libtiff": [ - "libtiff License", - false - ], - "LPL-1.02": [ - "Lucent Public License v1.02", - true - ], - "LPL-1.0": [ - "Lucent Public License Version 1.0", - true - ], - "MakeIndex": [ - "MakeIndex License", - false - ], - "MTLL": [ - "Matrix Template Library License", - false - ], - "MS-PL": [ - "Microsoft Public License", - true - ], - "MS-RL": [ - "Microsoft Reciprocal License", - true - ], - "MirOS": [ - "MirOS Licence", - true - ], - "MITNFA": [ - "MIT +no-false-attribs license", - false - ], - "MIT": [ - "MIT License", - true - ], - "Motosoto": [ - "Motosoto License", - true - ], - "MPL-1.0": [ - "Mozilla Public License 1.0", - true - ], - "MPL-1.1": [ - "Mozilla Public License 1.1", - true - ], - "MPL-2.0": [ - "Mozilla Public License 2.0", - true - ], - "MPL-2.0-no-copyleft-exception": [ - "Mozilla Public License 2.0 (no copyleft exception)", - true - ], - "mpich2": [ - "mpich2 License", - false - ], - "Multics": [ - "Multics License", - true - ], - "Mup": [ - "Mup License", - false - ], - "NASA-1.3": [ - "NASA Open Source Agreement 1.3", - true - ], - "Naumen": [ - "Naumen Public License", - true - ], - "NBPL-1.0": [ - "Net Boolean Public License v1", - false - ], - "NetCDF": [ - "NetCDF license", - false - ], - "NGPL": [ - "Nethack General Public License", - true - ], - "NOSL": [ - "Netizen Open Source License", - false - ], - "NPL-1.0": [ - "Netscape Public License v1.0", - false - ], - "NPL-1.1": [ - "Netscape Public License v1.1", - false - ], - "Newsletr": [ - "Newsletr License", - false - ], - "NLPL": [ - "No Limit Public License", - false - ], - "Nokia": [ - "Nokia Open Source License", - true - ], - "NPOSL-3.0": [ - "Non-Profit Open Software License 3.0", - true - ], - "Noweb": [ - "Noweb License", - false - ], - "NRL": [ - "NRL License", - false - ], - "NTP": [ - "NTP License", - true - ], - "Nunit": [ - "Nunit License", - false - ], - "OCLC-2.0": [ - "OCLC Research Public License 2.0", - true - ], - "ODbL-1.0": [ - "ODC Open Database License v1.0", - false - ], - "PDDL-1.0": [ - "ODC Public Domain Dedication & License 1.0", - false - ], - "OGTSL": [ - "Open Group Test Suite License", - true - ], - "OLDAP-2.2.2": [ - "Open LDAP Public License 2.2.2", - false - ], - "OLDAP-1.1": [ - "Open LDAP Public License v1.1", - false - ], - "OLDAP-1.2": [ - "Open LDAP Public License v1.2", - false - ], - "OLDAP-1.3": [ - "Open LDAP Public License v1.3", - false - ], - "OLDAP-1.4": [ - "Open LDAP Public License v1.4", - false - ], - "OLDAP-2.0": [ - "Open LDAP Public License v2.0 (or possibly 2.0A and 2.0B)", - false - ], - "OLDAP-2.0.1": [ - "Open LDAP Public License v2.0.1", - false - ], - "OLDAP-2.1": [ - "Open LDAP Public License v2.1", - false - ], - "OLDAP-2.2": [ - "Open LDAP Public License v2.2", - false - ], - "OLDAP-2.2.1": [ - "Open LDAP Public License v2.2.1", - false - ], - "OLDAP-2.3": [ - "Open LDAP Public License v2.3", - false - ], - "OLDAP-2.4": [ - "Open LDAP Public License v2.4", - false - ], - "OLDAP-2.5": [ - "Open LDAP Public License v2.5", - false - ], - "OLDAP-2.6": [ - "Open LDAP Public License v2.6", - false - ], - "OLDAP-2.7": [ - "Open LDAP Public License v2.7", - false - ], - "OLDAP-2.8": [ - "Open LDAP Public License v2.8", - false - ], - "OML": [ - "Open Market License", - false - ], - "OPL-1.0": [ - "Open Public License v1.0", - false - ], - "OSL-1.0": [ - "Open Software License 1.0", - true - ], - "OSL-1.1": [ - "Open Software License 1.1", - false - ], - "OSL-2.0": [ - "Open Software License 2.0", - true - ], - "OSL-2.1": [ - "Open Software License 2.1", - true - ], - "OSL-3.0": [ - "Open Software License 3.0", - true - ], - "OpenSSL": [ - "OpenSSL License", - false - ], - "PHP-3.0": [ - "PHP License v3.0", - true - ], - "PHP-3.01": [ - "PHP License v3.01", - false - ], - "Plexus": [ - "Plexus Classworlds License", - false - ], - "PostgreSQL": [ - "PostgreSQL License", - true - ], - "psfrag": [ - "psfrag License", - false - ], - "psutils": [ - "psutils License", - false - ], - "Python-2.0": [ - "Python License 2.0", - true - ], - "QPL-1.0": [ - "Q Public License 1.0", - true - ], - "Qhull": [ - "Qhull License", - false - ], - "Rdisc": [ - "Rdisc License", - false - ], - "RPSL-1.0": [ - "RealNetworks Public Source License v1.0", - true - ], - "RPL-1.1": [ - "Reciprocal Public License 1.1", - true - ], - "RPL-1.5": [ - "Reciprocal Public License 1.5", - true - ], - "RHeCos-1.1": [ - "Red Hat eCos Public License v1.1", - false - ], - "RSCPL": [ - "Ricoh Source Code Public License", - true - ], - "Ruby": [ - "Ruby License", - false - ], - "SAX-PD": [ - "Sax Public Domain Notice", - false - ], - "Saxpath": [ - "Saxpath License", - false - ], - "SCEA": [ - "SCEA Shared Source License", - false - ], - "SWL": [ - "Scheme Widget Library (SWL) Software License Agreement", - false - ], - "SGI-B-1.0": [ - "SGI Free Software License B v1.0", - false - ], - "SGI-B-1.1": [ - "SGI Free Software License B v1.1", - false - ], - "SGI-B-2.0": [ - "SGI Free Software License B v2.0", - false - ], - "OFL-1.0": [ - "SIL Open Font License 1.0", - false - ], - "OFL-1.1": [ - "SIL Open Font License 1.1", - true - ], - "SimPL-2.0": [ - "Simple Public License 2.0", - true - ], - "Sleepycat": [ - "Sleepycat License", - true - ], - "SNIA": [ - "SNIA Public License 1.1", - false - ], - "SMLNJ": [ - "Standard ML of New Jersey License", - false - ], - "SugarCRM-1.1.3": [ - "SugarCRM Public License v1.1.3", - false - ], - "SISSL": [ - "Sun Industry Standards Source License v1.1", - true - ], - "SISSL-1.2": [ - "Sun Industry Standards Source License v1.2", - false - ], - "SPL-1.0": [ - "Sun Public License v1.0", - true - ], - "Watcom-1.0": [ - "Sybase Open Watcom Public License 1.0", - true - ], - "TCL": [ - "TCL/TK License", - false - ], - "Unlicense": [ - "The Unlicense", - false - ], - "TMate": [ - "TMate Open Source License", - false - ], - "TORQUE-1.1": [ - "TORQUE v2.5+ Software License v1.1", - false - ], - "TOSL": [ - "Trusster Open Source License", - false - ], - "Unicode-TOU": [ - "Unicode Terms of Use", - false - ], - "NCSA": [ - "University of Illinois/NCSA Open Source License", - true - ], - "Vim": [ - "Vim License", - false - ], - "VOSTROM": [ - "VOSTROM Public License for Open Source", - false - ], - "VSL-1.0": [ - "Vovida Software License v1.0", - true - ], - "W3C": [ - "W3C Software Notice and License (2002-12-31)", - true - ], - "W3C-19980720": [ - "W3C Software Notice and License (1998-07-20)", - false - ], - "Wsuipa": [ - "Wsuipa License", - false - ], - "Xnet": [ - "X.Net License", - true - ], - "X11": [ - "X11 License", - false - ], - "Xerox": [ - "Xerox License", - false - ], - "XFree86-1.1": [ - "XFree86 License 1.1", - false - ], - "xinetd": [ - "xinetd License", - false - ], - "xpp": [ - "XPP License", - false - ], - "XSkat": [ - "XSkat License", - false - ], - "YPL-1.0": [ - "Yahoo! Public License v1.0", - false - ], - "YPL-1.1": [ - "Yahoo! Public License v1.1", - false - ], - "Zed": [ - "Zed License", - false - ], - "Zend-2.0": [ - "Zend License v2.0", - false - ], - "Zimbra-1.3": [ - "Zimbra Public License v1.3", - false - ], - "Zimbra-1.4": [ - "Zimbra Public License v1.4", - false - ], - "Zlib": [ - "zlib License", - true - ], - "zlib-acknowledgement": [ - "zlib/libpng License with Acknowledgement", - false - ], - "ZPL-1.1": [ - "Zope Public License 1.1", - false - ], - "ZPL-2.0": [ - "Zope Public License 2.0", - true - ], - "ZPL-2.1": [ - "Zope Public License 2.1", - false - ], - "ICU": [ - "ICU License", - false - ] -} \ No newline at end of file diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index 6c768bf60..92811f07a 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -28,7 +28,7 @@ use Composer\Repository\CompositeRepository; use Composer\Repository\ComposerRepository; use Composer\Repository\PlatformRepository; use Composer\Repository\RepositoryInterface; -use Composer\Util\SpdxLicense; +use Composer\Spdx\SpdxLicenses; /** * @author Robert Schönthal @@ -390,12 +390,12 @@ EOT */ protected function printLicenses(CompletePackageInterface $package) { - $spdxLicense = new SpdxLicense; + $spdxLicenses = new SpdxLicenses(); $licenses = $package->getLicense(); foreach ($licenses as $licenseId) { - $license = $spdxLicense->getLicenseByIdentifier($licenseId); // keys: 0 fullname, 1 osi, 2 url + $license = $spdxLicenses->getLicenseByIdentifier($licenseId); // keys: 0 fullname, 1 osi, 2 url if (!$license) { $out = $licenseId; diff --git a/src/Composer/Util/ConfigValidator.php b/src/Composer/Util/ConfigValidator.php index eac5619e7..e99c2e73c 100644 --- a/src/Composer/Util/ConfigValidator.php +++ b/src/Composer/Util/ConfigValidator.php @@ -18,6 +18,7 @@ use Composer\Package\Loader\InvalidPackageException; use Composer\Json\JsonValidationException; use Composer\IO\IOInterface; use Composer\Json\JsonFile; +use Composer\Spdx\SpdxLicenses; /** * Validates a composer configuration. @@ -82,7 +83,7 @@ class ConfigValidator } } - $licenseValidator = new SpdxLicense(); + $licenseValidator = new SpdxLicenses(); if ('proprietary' !== $manifest['license'] && array() !== $manifest['license'] && !$licenseValidator->validate($manifest['license'])) { $warnings[] = sprintf( 'License %s is not a valid SPDX license identifier, see http://www.spdx.org/licenses/ if you use an open license.' diff --git a/src/Composer/Util/SpdxLicense.php b/src/Composer/Util/SpdxLicense.php deleted file mode 100644 index b9ffdc70d..000000000 --- a/src/Composer/Util/SpdxLicense.php +++ /dev/null @@ -1,306 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Util; - -/** - * Supports composer array and SPDX tag notation for disjunctive/conjunctive - * licenses. - * - * @author Tom Klingenberg - */ -class SpdxLicense -{ - /** @var array */ - private $licenses; - - /** @var array */ - private $exceptions; - - public function __construct() - { - $this->loadLicenses(); - $this->loadExceptions(); - } - - /** - * Returns license metadata by license identifier. - * - * @param string $identifier - * - * @return array|null - */ - public function getLicenseByIdentifier($identifier) - { - if (!isset($this->licenses[$identifier])) { - return; - } - - $license = $this->licenses[$identifier]; - $license[] = 'http://spdx.org/licenses/' . $identifier . '.html#licenseText'; - - return $license; - } - - /** - * Returns license exception metadata by license exception identifier. - * - * @param string $identifier - * - * @return array|null - */ - public function getExceptionByIdentifier($identifier) - { - if (!isset($this->exceptions[$identifier])) { - return; - } - - $license = $this->exceptions[$identifier]; - $license[] = 'http://spdx.org/licenses/' . $identifier . '.html#licenseExceptionText'; - - return $license; - } - - /** - * Returns the short identifier of a license (exception) by full name. - * - * @param string $name - * - * @return string - */ - public function getIdentifierByName($name) - { - foreach ($this->licenses as $identifier => $licenseData) { - if ($licenseData[0] === $name) { // key 0 = fullname - return $identifier; - } - } - - foreach ($this->exceptions as $identifier => $licenseData) { - if ($licenseData[0] === $name) { // key 0 = fullname - return $identifier; - } - } - } - - /** - * Returns the OSI Approved status for a license by identifier. - * - * @param string $identifier - * - * @return bool - */ - public function isOsiApprovedByIdentifier($identifier) - { - return $this->licenses[$identifier][1]; // key 1 = osi approved - } - - /** - * Check, if the identifier for a license is valid. - * - * @param string $identifier - * - * @return bool - */ - private function isValidLicenseIdentifier($identifier) - { - $identifiers = array_keys($this->licenses); - - return in_array($identifier, $identifiers); - } - - /** - * Check, if the identifier for a exception is valid. - * - * @param string $identifier - * - * @return bool - */ - private function isValidExceptionIdentifier($identifier) - { - $identifiers = array_keys($this->exceptions); - - return in_array($identifier, $identifiers); - } - - /** - * @param array|string $license - * - * @return bool - * @throws \InvalidArgumentException - */ - public function validate($license) - { - if (is_array($license)) { - $count = count($license); - if ($count !== count(array_filter($license, 'is_string'))) { - throw new \InvalidArgumentException('Array of strings expected.'); - } - $license = $count > 1 ? '('.implode(' OR ', $license).')' : (string) reset($license); - } - - if (!is_string($license)) { - throw new \InvalidArgumentException(sprintf( - 'Array or String expected, %s given.', - gettype($license) - )); - } - - return $this->isValidLicenseString($license); - } - - /** - * @return array - */ - private function loadLicenses() - { - if (is_array($this->licenses)) { - return $this->licenses; - } - - $jsonFile = file_get_contents(__DIR__ . '/../../../res/spdx-licenses.json'); - $this->licenses = json_decode($jsonFile, true); - - return $this->licenses; - } - - /** - * @return array - */ - private function loadExceptions() - { - if (is_array($this->exceptions)) { - return $this->exceptions; - } - - $jsonFile = file_get_contents(__DIR__ . '/../../../res/spdx-exceptions.json'); - $this->exceptions = json_decode($jsonFile, true); - - return $this->exceptions; - } - - /** - * @param string $license - * - * @return bool - * @throws \RuntimeException - */ - private function isValidLicenseString($license) - { - $tokens = array( - 'po' => '\(', - 'pc' => '\)', - 'op' => '(?:or|OR|and|AND)', - 'wi' => '(?:with|WITH)', - 'lix' => '(?:NONE|NOASSERTION)', - 'lir' => 'LicenseRef-\d+', - 'lic' => '[-_.a-zA-Z0-9]{3,}\+?', - 'ws' => '\s+', - '_' => '.', - ); - - $next = function () use ($license, $tokens) { - static $offset = 0; - - if ($offset >= strlen($license)) { - return null; - } - - foreach ($tokens as $name => $token) { - if (false === $r = preg_match('{' . $token . '}', $license, $matches, PREG_OFFSET_CAPTURE, $offset)) { - throw new \RuntimeException('Pattern for token %s failed (regex error).', $name); - } - if ($r === 0) { - continue; - } - if ($matches[0][1] !== $offset) { - continue; - } - $offset += strlen($matches[0][0]); - - return array($name, $matches[0][0]); - } - - throw new \RuntimeException( - 'At least the last pattern needs to match, but it did not (dot-match-all is missing?).' - ); - }; - - $open = 0; - $with = false; - $require = true; - $lastop = null; - - while (list($token, $string) = $next()) { - switch ($token) { - case 'po': - if ($open || !$require || $with) { - return false; - } - $open = 1; - break; - case 'pc': - if ($open !== 1 || $require || !$lastop || $with) { - return false; - } - $open = 2; - break; - case 'op': - if ($require || !$open || $with) { - return false; - } - $lastop || $lastop = $string; - if ($lastop !== $string) { - return false; - } - $require = true; - break; - case 'wi': - $with = true; - break; - case 'lix': - if ($open || $with) { - return false; - } - goto lir; - case 'lic': - if ($with && $this->isValidExceptionIdentifier($string)) { - $require = true; - $with = false; - goto lir; - } - if ($with) { - return false; - } - if (!$this->isValidLicenseIdentifier(rtrim($string, '+'))) { - return false; - } - // Fall-through intended - case 'lir': - lir: - if (!$require) { - return false; - } - $require = false; - break; - case 'ws': - break; - case '_': - return false; - default: - throw new \RuntimeException(sprintf('Unparsed token: %s.', print_r($token, true))); - } - } - - return !($open % 2 || $require || $with); - } -} diff --git a/src/Composer/Util/SpdxLicensesUpdater.php b/src/Composer/Util/SpdxLicensesUpdater.php deleted file mode 100644 index 457f5b389..000000000 --- a/src/Composer/Util/SpdxLicensesUpdater.php +++ /dev/null @@ -1,139 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Util; - -/** - * The SPDX Licenses Updater scrapes licenses from the spdx website - * and updates the "res/spdx-licenses.json" file accordingly. - * - * The class is used by the update script "bin/update-spdx-licenses". - */ -class SpdxLicensesUpdater -{ - /** - * @param string $file - * @param string $url - */ - public function dumpLicenses($file, $url = 'http://www.spdx.org/licenses/') - { - $options = 0; - - if (defined('JSON_PRETTY_PRINT')) { - $options |= JSON_PRETTY_PRINT; - } - - if (defined('JSON_UNESCAPED_SLASHES')) { - $options |= JSON_UNESCAPED_SLASHES; - } - - $licenses = json_encode($this->getLicenses($url), $options); - file_put_contents($file, $licenses); - } - - /** - * @param string $file - * @param string $url - */ - public function dumpExceptions($file, $url = 'http://www.spdx.org/licenses/exceptions-index.html') - { - $options = 0; - - if (defined('JSON_PRETTY_PRINT')) { - $options |= JSON_PRETTY_PRINT; - } - - if (defined('JSON_UNESCAPED_SLASHES')) { - $options |= JSON_UNESCAPED_SLASHES; - } - - $exceptions = json_encode($this->getExceptions($url), $options); - file_put_contents($file, $exceptions); - } - - /** - * @param string $url - * - * @return array - */ - private function getLicenses($url) - { - $licenses = array(); - - $dom = new \DOMDocument; - @$dom->loadHTMLFile($url); - - $xPath = new \DOMXPath($dom); - $trs = $xPath->query('//table//tbody//tr'); - - // iterate over each row in the table - foreach ($trs as $tr) { - $tds = $tr->getElementsByTagName('td'); // get the columns in this row - - if ($tds->length !== 4) { - continue; - } - - if (trim($tds->item(3)->nodeValue) == 'License Text') { - $fullname = trim($tds->item(0)->nodeValue); - $identifier = trim($tds->item(1)->nodeValue); - $osiApproved = ((isset($tds->item(2)->nodeValue) && $tds->item(2)->nodeValue === 'Y')) ? true : false; - - // The license URL is not scraped intentionally to keep json file size low. - // It's build when requested, see SpdxLicense->getLicenseByIdentifier(). - //$licenseURL = $tds->item(3)->getAttribute('href'); - - $licenses += array($identifier => array($fullname, $osiApproved)); - } - } - - return $licenses; - } - - /** - * @param string $url - * - * @return array - */ - private function getExceptions($url) - { - $exceptions = array(); - - $dom = new \DOMDocument; - @$dom->loadHTMLFile($url); - - $xPath = new \DOMXPath($dom); - $trs = $xPath->query('//table//tbody//tr'); - - // iterate over each row in the table - foreach ($trs as $tr) { - $tds = $tr->getElementsByTagName('td'); // get the columns in this row - - if ($tds->length !== 3) { - continue; - } - - if (trim($tds->item(2)->nodeValue) == 'License Exception Text') { - $fullname = trim($tds->item(0)->nodeValue); - $identifier = trim($tds->item(1)->nodeValue); - - // The license URL is not scraped intentionally to keep json file size low. - // It's build when requested, see SpdxLicense->getLicenseExceptionByIdentifier(). - //$licenseURL = $tds->item(2)->getAttribute('href'); - - $exceptions += array($identifier => array($fullname)); - } - } - - return $exceptions; - } -} diff --git a/tests/Composer/Test/Util/SpdxLicenseTest.php b/tests/Composer/Test/Util/SpdxLicenseTest.php deleted file mode 100644 index ef6e7d45d..000000000 --- a/tests/Composer/Test/Util/SpdxLicenseTest.php +++ /dev/null @@ -1,145 +0,0 @@ -license = new SpdxLicense; - } - - public static function provideValidLicenses() - { - $json = file_get_contents(__DIR__ . '/../../../../res/spdx-licenses.json'); - - $licenses = json_decode($json, true); - - $identifiers = array_keys($licenses); - - $valid = array_merge( - array( - "MIT", - "MIT+", - "NONE", - "NOASSERTION", - "LicenseRef-3", - array("LGPL-2.0", "GPL-3.0+"), - "(LGPL-2.0 or GPL-3.0+)", - "(LGPL-2.0 OR GPL-3.0+)", - "(EUDatagrid and GPL-3.0+)", - "(EUDatagrid AND GPL-3.0+)", - "GPL-2.0 with Autoconf-exception-2.0", - "GPL-2.0 WITH Autoconf-exception-2.0", - "GPL-2.0+ WITH Autoconf-exception-2.0", - ), - $identifiers - ); - - foreach ($valid as &$r) { - $r = array($r); - } - - return $valid; - } - - public static function provideInvalidLicenses() - { - return array( - array(""), - array(array()), - array("The system pwns you"), - array("()"), - array("(MIT)"), - array("(MIT"), - array("MIT)"), - array("MIT NONE"), - array("MIT AND NONE"), - array("MIT (MIT and MIT)"), - array("(MIT and MIT) MIT"), - array(array("LGPL-2.0", "The system pwns you")), - array("and GPL-3.0+"), - array("EUDatagrid and GPL-3.0+"), - array("(GPL-3.0 and GPL-2.0 or GPL-3.0+)"), - array("(EUDatagrid and GPL-3.0+ and )"), - array("(EUDatagrid xor GPL-3.0+)"), - array("(MIT Or MIT)"), - array("(NONE or MIT)"), - array("(NOASSERTION or MIT)"), - array("Autoconf-exception-2.0 WITH MIT"), - array("MIT WITH"), - array("MIT OR"), - array("MIT AND"), - ); - } - - public static function provideInvalidArgument() - { - return array( - array(null), - array(new \stdClass), - array(array(new \stdClass)), - array(array("mixed", new \stdClass)), - array(array(new \stdClass, new \stdClass)), - ); - } - - /** - * @dataProvider provideValidLicenses - * @param $license - */ - public function testValidate($license) - { - $this->assertTrue($this->license->validate($license)); - } - - /** - * @dataProvider provideInvalidLicenses - * @param string|array $invalidLicense - */ - public function testInvalidLicenses($invalidLicense) - { - $this->assertFalse($this->license->validate($invalidLicense)); - } - - /** - * @dataProvider provideInvalidArgument - * @expectedException InvalidArgumentException - */ - public function testInvalidArgument($invalidArgument) - { - $this->license->validate($invalidArgument); - } - - public function testGetLicenseByIdentifier() - { - $license = $this->license->getLicenseByIdentifier('AGPL-1.0'); - $this->assertEquals($license[0], 'Affero General Public License v1.0'); // fullname - $this->assertFalse($license[1]); // osi approved - } - - public function testGetIdentifierByName() - { - $identifier = $this->license->getIdentifierByName('Affero General Public License v1.0'); - $this->assertEquals($identifier, 'AGPL-1.0'); - - $identifier = $this->license->getIdentifierByName('BSD 2-clause "Simplified" License'); - $this->assertEquals($identifier, 'BSD-2-Clause'); - } - - public function testIsOsiApprovedByIdentifier() - { - $osiApproved = $this->license->isOsiApprovedByIdentifier('MIT'); - $this->assertTrue($osiApproved); - - $osiApproved = $this->license->isOsiApprovedByIdentifier('AGPL-1.0'); - $this->assertFalse($osiApproved); - } -}