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