Skip to content

Commit 282aab0

Browse files
authored
Merge pull request #3201 from nexB/fix-license-dump
Remove license text from index.json of licenseDB
2 parents 0d294bf + cadcc7c commit 282aab0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+747
-724
lines changed

.VERSION

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
refs=$Format:%D$
22
commit=$Format:%H$
3-
abbrev_commit=$Format:%H$
3+
abbrev_commit=$Format:%h$
4+
committer_date=$Format:%cs$
5+
git_describe=$Format:%(describe)$

src/licensedcode/license_db.py

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
1-
# SPDX-License-Identifier: CC-BY-4.0 AND Apache-2.0
21
#
3-
# https://github.com/nexB/scancode-licensedb
4-
# Copyright 2020 nexB Inc. and others.
2+
# Copyright (c) nexB Inc. and others. All rights reserved.
53
# ScanCode is a trademark of nexB Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6+
# See https://github.com/nexB/scancode-toolkit for support or download.
7+
# See https://aboutcode.org for more information about nexB OSS projects.
68
#
7-
# ScanCode LicenseDB data is licensed under the Creative Commons Attribution
8-
# License 4.0 (CC-BY-4.0).
9-
# Some licenses, such as the GNU GENERAL PUBLIC LICENSE, are subject to other licenses.
10-
# See the corresponding license text for the specific license conditions.
11-
#
12-
# ScanCode LicenseDB software is licensed under the Apache License version 2.0.
13-
# You may not use this software except in compliance with the License.
14-
# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0
15-
# Unless required by applicable law or agreed to in writing, software distributed
16-
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
17-
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
18-
# specific language governing permissions and limitations under the License.
19-
#
20-
# ScanCode LicenseDB is generated with ScanCode Toolkit. The database and its contents
21-
# are provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
22-
# either express or implied.
23-
# No content from ScanCode LicenseDB should be considered or used as legal advice.
24-
# Consult an attorney for any legal advice.
259

2610
import os
2711
import json
@@ -40,7 +24,7 @@
4024
from licensedcode.models import load_licenses
4125
from licensedcode.models import licenses_data_dir
4226
from scancode_config import __version__ as scancode_version
43-
27+
from scancode_config import spdx_license_list_version
4428

4529
TEMPLATES_DIR = os.path.join(dirname(__file__), 'templates')
4630
STATIC_DIR = os.path.join(dirname(__file__), 'static')
@@ -51,18 +35,19 @@ def write_file(path, filename, content):
5135

5236

5337
def now():
54-
return datetime.now().strftime("%b %d, %Y")
55-
38+
return datetime.utcnow().strftime('%Y-%m-%dT')
5639

5740
base_context = {
5841
"scancode_version": scancode_version,
5942
"now": now(),
43+
"spdx_license_list_version": spdx_license_list_version,
6044
}
6145

6246

6347
base_context_test = {
6448
"scancode_version": "32.0.0b1",
6549
"now": "Dec 22, 2022",
50+
"spdx_license_list_version": "3.19",
6651
}
6752

6853

@@ -98,7 +83,6 @@ def generate_indexes(output_path, environment, licenses, test=False):
9883
"other_spdx_license_keys": lic.other_spdx_license_keys,
9984
"is_exception": lic.is_exception,
10085
"is_deprecated": lic.is_deprecated,
101-
"text": lic.text,
10286
"json": f"{key}.json",
10387
"yaml": f"{key}.yml",
10488
"html": f"{key}.html",
@@ -140,6 +124,7 @@ def generate_details(output_path, environment, licenses, test=False):
140124
license_details_template = environment.get_template("license_details.html")
141125
for lic in licenses.values():
142126
license_data = lic.to_dict(include_text=False, include_builtin=include_builtin)
127+
license_data_with_text = lic.to_dict(include_text=True, include_builtin=include_builtin)
143128
html = license_details_template.render(
144129
**base_context_mapping,
145130
license=lic,
@@ -149,12 +134,12 @@ def generate_details(output_path, environment, licenses, test=False):
149134
write_file(
150135
output_path,
151136
f"{lic.key}.yml",
152-
saneyaml.dump(license_data, indent=2)
137+
saneyaml.dump(license_data_with_text, indent=2)
153138
)
154139
write_file(
155140
output_path,
156141
f"{lic.key}.json",
157-
json.dumps(license_data, indent=2, sort_keys=False)
142+
json.dumps(license_data_with_text, indent=2, sort_keys=False)
158143
)
159144
lic.dump(output_path)
160145

src/licensedcode/templates/footer.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
<a href="https://github.com/nexB/scancode-licensedb" target="_blank">GitHub</a> ·
77
<a href="https://www.aboutcode.org/" target="_blank">AboutCode</a>
88
</p>
9-
<p>Designed and built by <a href="https://www.nexb.com/" target="_blank">nexB</a>. Licensed under the <a href="cc-by-4.0.html">Creative Commons Attribution License 4.0 (CC-BY-4.0)</a>.</p>
10-
<p>Generated with <a href="https://github.com/nexB/scancode-toolkit" target="_blank">ScanCode toolkit</a> {{ scancode_version }} on {{ now }}.</p>
11-
<p>This is updated daily automatically with latest updates from the develop branch of scancode-toolkit, if any.</p>
9+
<p>Designed and built by <a href="https://www.nexb.com/" target="_blank">nexB</a>.
10+
Licensed under the <a href="cc-by-4.0.html">Creative Commons Attribution License 4.0 (CC-BY-4.0)</a>.</p>
11+
<p>Generated with <a href="https://github.com/nexB/scancode-toolkit" target="_blank">ScanCode toolkit</a>
12+
{{ scancode_version }} on {{ now }}.</p>
13+
<p>SPDX Licenses list version: {{ spdx_license_list_version }}</p>
14+
1215
</footer>
1316
</div>

src/scancode_config.py

Lines changed: 61 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -70,43 +70,80 @@ def _create_dir(location):
7070
################################################################################
7171
# INVARIABLE INSTALLATION-SPECIFIC, BUILT-IN LOCATIONS AND FLAGS
7272
################################################################################
73-
# these are guaranteed to be there and are entirely based on and relative to the
73+
# These are guaranteed to be there and are entirely based on and relative to the
7474
# current installation location. This is where the source code and static data
7575
# lives.
7676

7777

78-
# in case package is not installed or we do not have setutools/pkg_resources
79-
# on hand fall back to this version
80-
__version__ = '32.0.0rc1'
78+
system_temp_dir = tempfile.gettempdir()
79+
scancode_src_dir = dirname(__file__)
80+
scancode_root_dir = dirname(scancode_src_dir)
8181

82-
# used to warn user when the version is out of date
83-
__release_date__ = datetime.datetime(2023, 1, 3)
82+
# USAGE MODE FLAG. If we have a .git dir, we are a git clone and developing
83+
_SCANCODE_DEV_MODE = os.path.exists(join(scancode_root_dir, '.git'))
8484

85-
# See https://github.com/nexB/scancode-toolkit/issues/2653 for more information
86-
# on the data format version
87-
__output_format_version__ = '3.0.0'
85+
# There are multiple cases for versions, depending on where we come from:
86+
__version__ = ''
8887

89-
#
90-
spdx_license_list_version = '3.19'
88+
# 1. - a git clone: we can use git describe which take consider the closest tag
89+
# "git describe --dirty > SCANCODE_VERSION"
90+
# This is the common case when we develop, including dump the latestlicense db
91+
if _SCANCODE_DEV_MODE:
9192

92-
try:
93-
from pkg_resources import get_distribution, DistributionNotFound
93+
from subprocess import check_output
94+
from subprocess import STDOUT
95+
from subprocess import CalledProcessError
96+
97+
# this may fail with exceptions
98+
cmd = 'git', 'describe',
9499
try:
95-
__version__ = get_distribution('scancode-toolkit').version
96-
except DistributionNotFound:
100+
output = check_output(cmd, stderr=STDOUT)
101+
__version__ = output.decode('utf-8').strip()
102+
except (Exception, CalledProcessError) as e:
97103
pass
98-
except ImportError:
99-
pass
100104

101-
system_temp_dir = tempfile.gettempdir()
102-
scancode_src_dir = dirname(__file__)
103-
scancode_root_dir = dirname(scancode_src_dir)
105+
# 2. - the scancode-tool binary or sources app archives: with a SCANCODE_VERSION
106+
# file containing the git tag of the release with "git describe --tags > SCANCODE_VERSION"
107+
# - a tarball without an updated .VERSION, we cannot tell anything and we will use importlib metadata
108+
# - a wheel or sdist in which case we use the importlib metadata
109+
# we use importlib metadata in all these cases
110+
if not __version__:
111+
try:
112+
from importlib_metadata import version
113+
__version__ = version('scancode-toolkit')
114+
except Exception:
115+
pass
104116

105-
################################################################################
106-
# USAGE MODE FLAGS
107-
################################################################################
117+
# 3. - a tarball or zip archive from git with a .VERSION file with var substitution:
118+
# .VERSION will contain:
119+
# refs=HEAD -> fix-license-dump
120+
# commit=5ccc92e69cffb503e9bedc7fce5a1dbb0fd851da
121+
# abbrev_commit=5ccc92e69c
122+
# committer_date=2023-01-16
123+
# git_describe=v31.2.3-328-g5ccc92e69c
124+
# otherwise it contains:
125+
# refs=$Format:%D$
126+
# commit=$Format:%H$
127+
# abbrev_commit=$Format:%h$
128+
# committer_date=$Format:%cs$
129+
# git_describe=$Format:%(describe)$
130+
# NOTE: we do not handle this for now
131+
132+
# 4. hardcoded This is the default, fallback version in case package is not installed or we
133+
# do not have a proper version otherwise.
134+
if not __version__:
135+
__version__ = '32.0.0rc1'
136+
137+
#######################
138+
# used to warn user when the version is out of date
139+
__release_date__ = datetime.datetime(2023, 1, 15)
108140

109-
_SCANCODE_DEV_MODE = os.path.exists(join(scancode_root_dir, '.git'))
141+
# See https://github.com/nexB/scancode-toolkit/issues/2653 for more information
142+
# on the data format version
143+
__output_format_version__ = '3.0.0'
144+
145+
#
146+
spdx_license_list_version = '3.19'
110147

111148
################################################################################
112149
# USAGE MODE-, INSTALLATION- and IMPORT- and RUN-SPECIFIC DIRECTORIES
@@ -171,6 +208,5 @@ def _create_dir(location):
171208
_prefix = 'scancode-tk-' + __version__ + '-'
172209
scancode_temp_dir = tempfile.mkdtemp(prefix=_prefix, dir=__scancode_temp_base_dir)
173210

174-
175211
# Used for tests to regenerate fixtures with regen=True
176212
REGEN_TEST_FIXTURES = os.getenv('SCANCODE_REGEN_TEST_FIXTURES', False)

tests/licensedcode/data/license_db/index.json-expected.json

Lines changed: 0 additions & 12 deletions
Large diffs are not rendered by default.

tests/licensedcode/data/license_db/license_dump/bash-exception-gpl.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150
</p>
151151
<p>Designed and built by <a href="https://www.nexb.com/" target="_blank">nexB</a>. Licensed under the <a href="cc-by-4.0.html">Creative Commons Attribution License 4.0 (CC-BY-4.0)</a>.</p>
152152
<p>Generated with <a href="https://github.com/nexB/scancode-toolkit" target="_blank">ScanCode toolkit</a> 32.0.0b1 on Dec 22, 2022.</p>
153+
<p>This is updated daily automatically with latest updates from the develop branch of scancode-toolkit, if any.</p>
153154
</footer>
154155
</div>
155156

tests/licensedcode/data/license_db/license_dump/bash-exception-gpl.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"spdx_license_key": "LicenseRef-scancode-bash-exception-gpl-2.0",
1010
"text_urls": [
1111
"https://git.savannah.gnu.org/cgit/bash.git/plain/COPYING?h=bash-3.0-rc1&id=dd9e6dfa23d0dae4888f11fb8c6a27bc36d1b283"
12-
]
12+
],
13+
"text": "The Free Software Foundation has exempted Bash from the requirement of\nParagraph 2c of the General Public License. This is to say, there is\nno requirement for Bash to print a notice when it is started\ninteractively in the usual way. We made this exception because users\nand standards expect shells not to print such messages. This\nexception applies to any program that serves as a shell and that is\nbased primarily on Bash as opposed to other GNU software."
1314
}

tests/licensedcode/data/license_db/license_dump/bash-exception-gpl.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,11 @@ is_exception: yes
88
spdx_license_key: LicenseRef-scancode-bash-exception-gpl-2.0
99
text_urls:
1010
- https://git.savannah.gnu.org/cgit/bash.git/plain/COPYING?h=bash-3.0-rc1&id=dd9e6dfa23d0dae4888f11fb8c6a27bc36d1b283
11+
text: |
12+
The Free Software Foundation has exempted Bash from the requirement of
13+
Paragraph 2c of the General Public License. This is to say, there is
14+
no requirement for Bash to print a notice when it is started
15+
interactively in the usual way. We made this exception because users
16+
and standards expect shells not to print such messages. This
17+
exception applies to any program that serves as a shell and that is
18+
based primarily on Bash as opposed to other GNU software.

tests/licensedcode/data/license_db/license_dump/binary-linux-firmware.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
</p>
154154
<p>Designed and built by <a href="https://www.nexb.com/" target="_blank">nexB</a>. Licensed under the <a href="cc-by-4.0.html">Creative Commons Attribution License 4.0 (CC-BY-4.0)</a>.</p>
155155
<p>Generated with <a href="https://github.com/nexB/scancode-toolkit" target="_blank">ScanCode toolkit</a> 32.0.0b1 on Dec 22, 2022.</p>
156+
<p>This is updated daily automatically with latest updates from the develop branch of scancode-toolkit, if any.</p>
156157
</footer>
157158
</div>
158159

tests/licensedcode/data/license_db/license_dump/binary-linux-firmware.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
"category": "Proprietary Free",
66
"owner": "Unspecified",
77
"homepage_url": "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/",
8-
"spdx_license_key": "LicenseRef-scancode-binary-linux-firmware"
8+
"spdx_license_key": "LicenseRef-scancode-binary-linux-firmware",
9+
"text": "Redistribution. Redistribution and use in binary form, without\nmodification, are permitted provided that the following conditions are\nmet:\n\n* Redistributions must reproduce the above copyright notice and the\nfollowing disclaimer in the documentation and/or other materials\nprovided with the distribution.\n\n* Neither the name of the Copyright Holder nor the names of its\nsuppliers may be used to endorse or promote products derived from this\nsoftware without specific prior written permission.\n\n* No reverse engineering, decompilation, or disassembly of this software\nis permitted.\n\nDISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND\nCONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\nBUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\nCOPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\nNOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\nUSE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\nTHIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE"
910
}

tests/licensedcode/data/license_db/license_dump/binary-linux-firmware.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,30 @@ category: Proprietary Free
55
owner: Unspecified
66
homepage_url: https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/
77
spdx_license_key: LicenseRef-scancode-binary-linux-firmware
8+
text: |
9+
Redistribution. Redistribution and use in binary form, without
10+
modification, are permitted provided that the following conditions are
11+
met:
12+
13+
* Redistributions must reproduce the above copyright notice and the
14+
following disclaimer in the documentation and/or other materials
15+
provided with the distribution.
16+
17+
* Neither the name of the Copyright Holder nor the names of its
18+
suppliers may be used to endorse or promote products derived from this
19+
software without specific prior written permission.
20+
21+
* No reverse engineering, decompilation, or disassembly of this software
22+
is permitted.
23+
24+
DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
25+
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
26+
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
27+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28+
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
31+
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
32+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE

tests/licensedcode/data/license_db/license_dump/bison-exception-2.0.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
</p>
158158
<p>Designed and built by <a href="https://www.nexb.com/" target="_blank">nexB</a>. Licensed under the <a href="cc-by-4.0.html">Creative Commons Attribution License 4.0 (CC-BY-4.0)</a>.</p>
159159
<p>Generated with <a href="https://github.com/nexB/scancode-toolkit" target="_blank">ScanCode toolkit</a> 32.0.0b1 on Dec 22, 2022.</p>
160+
<p>This is updated daily automatically with latest updates from the develop branch of scancode-toolkit, if any.</p>
160161
</footer>
161162
</div>
162163

tests/licensedcode/data/license_db/license_dump/bison-exception-2.0.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"is_exception": true,
88
"spdx_license_key": "LicenseRef-scancode-bison-exception-2.0",
99
"faq_url": "http://www.gnu.org/software/bison/manual/bison.html#Conditions",
10-
"standard_notice": "This library is free software; you can redistribute it and/or modify it\nunder the terms of the GNU General Public License as published by the Free\nSoftware Foundation; either version 2, or (at your option) any later\nversion.\nThis library is distributed in the hope that it will be useful, but WITHOUT\nANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\nFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\nmore details.\nYou should have received a copy of the GNU General Public License along\nwith this library; see the file COPYING. If not, write to the Free Software\nFoundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\nAs a special exception, when this file is copied by Bison into a Bison\noutput file, you may use that output file without restriction. This special\nexception was added by the Free Software Foundation in version 1.24 of\nBison.\n"
10+
"standard_notice": "This library is free software; you can redistribute it and/or modify it\nunder the terms of the GNU General Public License as published by the Free\nSoftware Foundation; either version 2, or (at your option) any later\nversion.\nThis library is distributed in the hope that it will be useful, but WITHOUT\nANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\nFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\nmore details.\nYou should have received a copy of the GNU General Public License along\nwith this library; see the file COPYING. If not, write to the Free Software\nFoundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\nAs a special exception, when this file is copied by Bison into a Bison\noutput file, you may use that output file without restriction. This special\nexception was added by the Free Software Foundation in version 1.24 of\nBison.\n",
11+
"text": "As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison."
1112
}

tests/licensedcode/data/license_db/license_dump/bison-exception-2.0.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ standard_notice: |
2222
output file, you may use that output file without restriction. This special
2323
exception was added by the Free Software Foundation in version 1.24 of
2424
Bison.
25+
text: As a special exception, when this file is copied by Bison into a Bison output file, you
26+
may use that output file without restriction. This special exception was added by the Free
27+
Software Foundation in version 1.24 of Bison.

tests/licensedcode/data/license_db/license_dump/bison-exception-2.2.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@
184184
</p>
185185
<p>Designed and built by <a href="https://www.nexb.com/" target="_blank">nexB</a>. Licensed under the <a href="cc-by-4.0.html">Creative Commons Attribution License 4.0 (CC-BY-4.0)</a>.</p>
186186
<p>Generated with <a href="https://github.com/nexB/scancode-toolkit" target="_blank">ScanCode toolkit</a> 32.0.0b1 on Dec 22, 2022.</p>
187+
<p>This is updated daily automatically with latest updates from the develop branch of scancode-toolkit, if any.</p>
187188
</footer>
188189
</div>
189190

0 commit comments

Comments
 (0)