Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 1 | #!/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 Desai | 4c5ee48 | 2013-05-13 13:48:43 +0530 | [diff] [blame] | 18 | from __future__ import print_function |
| 19 | |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 20 | from collections import defaultdict, deque |
| 21 | import re |
| 22 | from shutil import copyfileobj |
| 23 | from subprocess import Popen, PIPE |
| 24 | from sys import stdout |
| 25 | |
| 26 | MAIN = ['//gerrit-pgm:pgm', '//gerrit-gwtui:ui_module'] |
| 27 | |
| 28 | def 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 | |
| 45 | graph = parse_graph() |
| 46 | licenses = defaultdict(set) |
| 47 | |
| 48 | queue = deque(MAIN) |
| 49 | while 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 Desai | 4c5ee48 | 2013-05-13 13:48:43 +0530 | [diff] [blame] | 56 | used = sorted(licenses.keys()) |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 57 | |
Chirayu Desai | 4c5ee48 | 2013-05-13 13:48:43 +0530 | [diff] [blame] | 58 | print("""\ |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 59 | Gerrit Code Review - Licenses |
| 60 | ============================= |
| 61 | |
David Pursehouse | 76f69f6 | 2013-05-14 14:38:09 +0900 | [diff] [blame] | 62 | Gerrit open source software is licensed under the <<Apache2_0,Apache |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 63 | License 2.0>>. Executable distributions also include other software |
| 64 | components that are provided under additional licenses. |
| 65 | |
| 66 | [[cryptography]] |
| 67 | Cryptography Notice |
| 68 | ------------------- |
| 69 | |
| 70 | This distribution includes cryptographic software. The country |
| 71 | in which you currently reside may have restrictions on the import, |
| 72 | possession, use, and/or re-export to another country, of encryption |
| 73 | software. BEFORE using any encryption software, please check |
| 74 | your country's laws, regulations and policies concerning the |
| 75 | import, possession, or use, and re-export of encryption software, |
| 76 | to see if this is permitted. See the |
| 77 | link:http://www.wassenaar.org/[Wassenaar Arrangement] |
| 78 | for more information. |
| 79 | |
| 80 | The U.S. Government Department of Commerce, Bureau of Industry |
| 81 | and Security (BIS), has classified this software as Export |
| 82 | Commodity Control Number (ECCN) 5D002.C.1, which includes |
| 83 | information security software using or performing cryptographic |
| 84 | functions with asymmetric algorithms. The form and manner of |
| 85 | this distribution makes it eligible for export under the License |
| 86 | Exception ENC Technology Software Unrestricted (TSU) exception |
| 87 | (see the BIS Export Administration Regulations, Section 740.13) |
| 88 | for both object code and source code. |
| 89 | |
| 90 | Gerrit includes an SSH daemon (Apache SSHD), to support authenticated |
| 91 | uploads of changes directly from `git push` command line clients. |
| 92 | |
| 93 | Gerrit includes an SSH client (JSch), to support authenticated |
| 94 | replication of changes to remote systems, such as for automatic |
| 95 | updates of mirror servers, or realtime backups. |
| 96 | |
| 97 | For either feature to function, Gerrit requires the |
| 98 | link:http://java.sun.com/javase/technologies/security/[Java Cryptography extensions] |
| 99 | and/or the |
| 100 | link:http://www.bouncycastle.org/java.html[Bouncy Castle Crypto API] |
| 101 | to be installed by the end-user. |
| 102 | |
| 103 | Licenses |
| 104 | -------- |
Chirayu Desai | 4c5ee48 | 2013-05-13 13:48:43 +0530 | [diff] [blame] | 105 | """) |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 106 | |
| 107 | for n in used: |
| 108 | libs = sorted(licenses[n]) |
| 109 | name = n[len('//lib:LICENSE-'):] |
Chirayu Desai | 4c5ee48 | 2013-05-13 13:48:43 +0530 | [diff] [blame] | 110 | print() |
David Pursehouse | 76f69f6 | 2013-05-14 14:38:09 +0900 | [diff] [blame] | 111 | print('[[%s]]' % name.replace('.', '_')) |
Chirayu Desai | 4c5ee48 | 2013-05-13 13:48:43 +0530 | [diff] [blame] | 112 | print(name) |
| 113 | print('~' * len(name)) |
| 114 | print() |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 115 | 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 Desai | 4c5ee48 | 2013-05-13 13:48:43 +0530 | [diff] [blame] | 120 | print('* ' + p) |
| 121 | print() |
| 122 | print('----') |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 123 | with open(n[2:].replace(':', '/')) as fd: |
| 124 | copyfileobj(fd, stdout) |
Chirayu Desai | 4c5ee48 | 2013-05-13 13:48:43 +0530 | [diff] [blame] | 125 | print('----') |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 126 | |
Chirayu Desai | 4c5ee48 | 2013-05-13 13:48:43 +0530 | [diff] [blame] | 127 | print(""" |
Shawn Pearce | fd6bb9f | 2013-05-08 14:14:24 -0700 | [diff] [blame] | 128 | GERRIT |
| 129 | ------ |
| 130 | Part of link:index.html[Gerrit Code Review] |
Chirayu Desai | 4c5ee48 | 2013-05-13 13:48:43 +0530 | [diff] [blame] | 131 | """) |