blob: fb03526ced8944035e522be2fc2b1110ed804ee6 [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
21import re
22from shutil import copyfileobj
23from subprocess import Popen, PIPE
24from sys import stdout
25
26MAIN = ['//gerrit-pgm:pgm', '//gerrit-gwtui:ui_module']
27
28def parse_graph():
29 graph = defaultdict(list)
30 p = Popen(
31 ['buck', 'audit', 'classpath', '--dot'] + MAIN,
32 stdout = PIPE)
33 for line in p.stdout:
34 m = re.search(r'"(//.*?)" -> "(//.*?)";', line)
35 if not m:
36 continue
37 target, dep = m.group(1), m.group(2)
38 if not target.endswith('__compile'):
39 graph[target].append(dep)
40 r = p.wait()
41 if r != 0:
42 exit(r)
43 return graph
44
45graph = parse_graph()
46licenses = defaultdict(set)
47
48queue = deque(MAIN)
49while queue:
50 target = queue.popleft()
51 for dep in graph[target]:
52 if not dep.startswith('//lib:LICENSE-'):
53 continue
54 licenses[dep].add(target)
55 queue.extend(graph[target])
Chirayu Desai4c5ee482013-05-13 13:48:43 +053056used = sorted(licenses.keys())
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070057
Chirayu Desai4c5ee482013-05-13 13:48:43 +053058print("""\
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070059Gerrit Code Review - Licenses
60=============================
61
David Pursehouse76f69f62013-05-14 14:38:09 +090062Gerrit open source software is licensed under the <<Apache2_0,Apache
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -070063License 2.0>>. Executable distributions also include other software
64components that are provided under additional licenses.
65
66[[cryptography]]
67Cryptography Notice
68-------------------
69
70This distribution includes cryptographic software. The country
71in which you currently reside may have restrictions on the import,
72possession, use, and/or re-export to another country, of encryption
73software. BEFORE using any encryption software, please check
74your country's laws, regulations and policies concerning the
75import, possession, or use, and re-export of encryption software,
76to see if this is permitted. See the
77link:http://www.wassenaar.org/[Wassenaar Arrangement]
78for more information.
79
80The U.S. Government Department of Commerce, Bureau of Industry
81and Security (BIS), has classified this software as Export
82Commodity Control Number (ECCN) 5D002.C.1, which includes
83information security software using or performing cryptographic
84functions with asymmetric algorithms. The form and manner of
85this distribution makes it eligible for export under the License
86Exception ENC Technology Software Unrestricted (TSU) exception
87(see the BIS Export Administration Regulations, Section 740.13)
88for both object code and source code.
89
90Gerrit includes an SSH daemon (Apache SSHD), to support authenticated
91uploads of changes directly from `git push` command line clients.
92
93Gerrit includes an SSH client (JSch), to support authenticated
94replication of changes to remote systems, such as for automatic
95updates of mirror servers, or realtime backups.
96
97For either feature to function, Gerrit requires the
98link:http://java.sun.com/javase/technologies/security/[Java Cryptography extensions]
99and/or the
100link:http://www.bouncycastle.org/java.html[Bouncy Castle Crypto API]
101to be installed by the end-user.
102
103Licenses
104--------
Chirayu Desai4c5ee482013-05-13 13:48:43 +0530105""")
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -0700106
107for n in used:
108 libs = sorted(licenses[n])
109 name = n[len('//lib:LICENSE-'):]
Chirayu Desai4c5ee482013-05-13 13:48:43 +0530110 print()
David Pursehouse76f69f62013-05-14 14:38:09 +0900111 print('[[%s]]' % name.replace('.', '_'))
Chirayu Desai4c5ee482013-05-13 13:48:43 +0530112 print(name)
113 print('~' * len(name))
114 print()
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -0700115 for d in libs:
116 if d.startswith('//lib:') or d.startswith('//lib/'):
117 p = d[len('//lib:'):]
118 else:
119 p = d[d.index(':')+1:].lower()
Chirayu Desai4c5ee482013-05-13 13:48:43 +0530120 print('* ' + p)
121 print()
122 print('----')
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -0700123 with open(n[2:].replace(':', '/')) as fd:
124 copyfileobj(fd, stdout)
Chirayu Desai4c5ee482013-05-13 13:48:43 +0530125 print('----')
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -0700126
Chirayu Desai4c5ee482013-05-13 13:48:43 +0530127print("""
Shawn Pearcefd6bb9f2013-05-08 14:14:24 -0700128GERRIT
129------
130Part of link:index.html[Gerrit Code Review]
Chirayu Desai4c5ee482013-05-13 13:48:43 +0530131""")