blob: 61d2e24143a8d02da3d3a22b766bbd7c2e0929fb [file] [log] [blame]
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -07001#!/usr/bin/python
2# Copyright (C) 2013 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16# TODO(sop): Be more detailed: version, link to Maven Central
17
Chirayu Desai4c5ee482013-05-13 13:48:43 +053018from __future__ import print_function
19
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070020from collections import defaultdict, deque
David Ostrovskya52eca32014-03-23 19:42:20 -070021from os import chdir, path
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070022import re
23from shutil import copyfileobj
24from subprocess import Popen, PIPE
Shawn Pearce33499722014-05-02 13:22:49 -070025from sys import stdout, stderr
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070026
27MAIN = ['//gerrit-pgm:pgm', '//gerrit-gwtui:ui_module']
Shawn Pearce33499722014-05-02 13:22:49 -070028KNOWN_PROVIDED_DEPS = [
29 '//lib/bouncycastle:bcpg',
30 '//lib/bouncycastle:bcpkix',
31 '//lib/bouncycastle:bcprov',
32]
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070033
34def parse_graph():
35 graph = defaultdict(list)
David Ostrovskya52eca32014-03-23 19:42:20 -070036 while not path.isfile('.buckconfig'):
37 chdir('..')
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070038 p = Popen(
39 ['buck', 'audit', 'classpath', '--dot'] + MAIN,
40 stdout = PIPE)
41 for line in p.stdout:
42 m = re.search(r'"(//.*?)" -> "(//.*?)";', line)
43 if not m:
44 continue
45 target, dep = m.group(1), m.group(2)
Shawn Pearce33499722014-05-02 13:22:49 -070046 # Dependencies included in provided_deps set are contained in audit
47 # classpath and must be sorted out. That's safe thing to do because
48 # they are not included in the final artifact.
49 if "DO_NOT_DISTRIBUTE" in dep:
50 if not target in KNOWN_PROVIDED_DEPS:
David Pursehouse8fb8d6f2014-06-03 22:26:49 +090051 print('DO_NOT_DISTRIBUTE license for target: %s' % target, file=stderr)
Shawn Pearce33499722014-05-02 13:22:49 -070052 exit(1)
53 else:
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070054 graph[target].append(dep)
55 r = p.wait()
56 if r != 0:
57 exit(r)
58 return graph
59
60graph = parse_graph()
61licenses = defaultdict(set)
62
63queue = deque(MAIN)
64while queue:
65 target = queue.popleft()
66 for dep in graph[target]:
67 if not dep.startswith('//lib:LICENSE-'):
68 continue
69 licenses[dep].add(target)
70 queue.extend(graph[target])
Chirayu Desai4c5ee482013-05-13 13:48:43 +053071used = sorted(licenses.keys())
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070072
Chirayu Desai4c5ee482013-05-13 13:48:43 +053073print("""\
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070074Gerrit Code Review - Licenses
75=============================
76
David Pursehouse76f69f62013-05-14 14:38:09 +090077Gerrit open source software is licensed under the <<Apache2_0,Apache
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070078License 2.0>>. Executable distributions also include other software
79components that are provided under additional licenses.
80
81[[cryptography]]
82Cryptography Notice
83-------------------
84
85This distribution includes cryptographic software. The country
86in which you currently reside may have restrictions on the import,
87possession, use, and/or re-export to another country, of encryption
88software. BEFORE using any encryption software, please check
89your country's laws, regulations and policies concerning the
90import, possession, or use, and re-export of encryption software,
91to see if this is permitted. See the
92link:http://www.wassenaar.org/[Wassenaar Arrangement]
93for more information.
94
95The U.S. Government Department of Commerce, Bureau of Industry
96and Security (BIS), has classified this software as Export
97Commodity Control Number (ECCN) 5D002.C.1, which includes
98information security software using or performing cryptographic
99functions with asymmetric algorithms. The form and manner of
100this distribution makes it eligible for export under the License
101Exception ENC Technology Software Unrestricted (TSU) exception
102(see the BIS Export Administration Regulations, Section 740.13)
103for both object code and source code.
104
105Gerrit includes an SSH daemon (Apache SSHD), to support authenticated
106uploads of changes directly from `git push` command line clients.
107
108Gerrit includes an SSH client (JSch), to support authenticated
109replication of changes to remote systems, such as for automatic
110updates of mirror servers, or realtime backups.
111
112For either feature to function, Gerrit requires the
113link:http://java.sun.com/javase/technologies/security/[Java Cryptography extensions]
114and/or the
115link:http://www.bouncycastle.org/java.html[Bouncy Castle Crypto API]
116to be installed by the end-user.
117
118Licenses
119--------
Chirayu Desai4c5ee482013-05-13 13:48:43 +0530120""")
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -0700121
122for n in used:
123 libs = sorted(licenses[n])
124 name = n[len('//lib:LICENSE-'):]
Chirayu Desai4c5ee482013-05-13 13:48:43 +0530125 print()
David Pursehouse76f69f62013-05-14 14:38:09 +0900126 print('[[%s]]' % name.replace('.', '_'))
Chirayu Desai4c5ee482013-05-13 13:48:43 +0530127 print(name)
128 print('~' * len(name))
129 print()
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -0700130 for d in libs:
131 if d.startswith('//lib:') or d.startswith('//lib/'):
132 p = d[len('//lib:'):]
133 else:
134 p = d[d.index(':')+1:].lower()
Chirayu Desai4c5ee482013-05-13 13:48:43 +0530135 print('* ' + p)
136 print()
137 print('----')
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -0700138 with open(n[2:].replace(':', '/')) as fd:
139 copyfileobj(fd, stdout)
Chirayu Desai4c5ee482013-05-13 13:48:43 +0530140 print('----')
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -0700141
Chirayu Desai4c5ee482013-05-13 13:48:43 +0530142print("""
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -0700143GERRIT
144------
145Part of link:index.html[Gerrit Code Review]
Chirayu Desai4c5ee482013-05-13 13:48:43 +0530146""")