| 1 |
#!/usr/bin/perl |
|---|
| 2 |
|
|---|
| 3 |
use Getopt::Long; |
|---|
| 4 |
use File::Find; |
|---|
| 5 |
use strict; |
|---|
| 6 |
|
|---|
| 7 |
my $include_re = undef; |
|---|
| 8 |
my $exclude_re = undef; |
|---|
| 9 |
|
|---|
| 10 |
GetOptions("i=s" => \$include_re, |
|---|
| 11 |
"x=s" => \$exclude_re); |
|---|
| 12 |
die "-i or -x, not both\n", if(defined($include_re) && defined($exclude_re)); |
|---|
| 13 |
$exclude_re = qr/$exclude_re/ if defined($exclude_re); |
|---|
| 14 |
$include_re ||= 'unknown' unless defined($exclude_re); |
|---|
| 15 |
$include_re = qr/$include_re/ if defined($include_re); |
|---|
| 16 |
|
|---|
| 17 |
my %licenses = ( |
|---|
| 18 |
'perl' => normalize(q% |
|---|
| 19 |
This code may be used and distributed under the same license as any |
|---|
| 20 |
version of Perl |
|---|
| 21 |
%), |
|---|
| 22 |
'openevidence-BSD' => normalize(q% |
|---|
| 23 |
* Redistribution and use in source and binary forms, with or without |
|---|
| 24 |
* modification, are permitted provided that the following conditions |
|---|
| 25 |
* are met: |
|---|
| 26 |
* |
|---|
| 27 |
* 1. Redistributions of source code must retain the above copyright |
|---|
| 28 |
* notice, this list of conditions, the following disclaimer, |
|---|
| 29 |
* and the original OpenSSL and SSLeay Licences below. |
|---|
| 30 |
* |
|---|
| 31 |
* 2. Redistributions in binary form must reproduce the above copyright |
|---|
| 32 |
* notice, this list of conditions, the following disclaimer |
|---|
| 33 |
* and the original OpenSSL and SSLeay Licences below in |
|---|
| 34 |
* the documentation and/or other materials provided with the |
|---|
| 35 |
* distribution. |
|---|
| 36 |
* |
|---|
| 37 |
* 3. All advertising materials mentioning features or use of this |
|---|
| 38 |
* software must display the following acknowledgments: |
|---|
| 39 |
* "This product includes software developed by the Openevidence Project |
|---|
| 40 |
* for use in the OpenEvidence Toolkit. (http://www.openevidence.org/)" |
|---|
| 41 |
* This product includes software developed by the OpenSSL Project |
|---|
| 42 |
* for use in the OpenSSL Toolkit (http://www.openssl.org/)" |
|---|
| 43 |
* This product includes cryptographic software written by Eric Young |
|---|
| 44 |
* (eay@cryptsoft.com). This product includes software written by Tim |
|---|
| 45 |
* Hudson (tjh@cryptsoft.com)." |
|---|
| 46 |
* |
|---|
| 47 |
* 4. The names "OpenEvidence Toolkit" and "OpenEvidence Project" must not be |
|---|
| 48 |
* used to endorse or promote products derived from this software without |
|---|
| 49 |
* prior written permission. For written permission, please contact |
|---|
| 50 |
* openevidence-core@openevidence.org. |
|---|
| 51 |
* |
|---|
| 52 |
* 5. Products derived from this software may not be called "OpenEvidence" |
|---|
| 53 |
* nor may "OpenEvidence" appear in their names without prior written |
|---|
| 54 |
* permission of the OpenEvidence Project. |
|---|
| 55 |
* |
|---|
| 56 |
* 6. Redistributions of any form whatsoever must retain the following |
|---|
| 57 |
* acknowledgments: |
|---|
| 58 |
* "This product includes software developed by the OpenEvidence Project |
|---|
| 59 |
* for use in the OpenEvidence Toolkit (http://www.openevidence.org/) |
|---|
| 60 |
* This product includes software developed by the OpenSSL Project |
|---|
| 61 |
* for use in the OpenSSL Toolkit (http://www.openssl.org/)" |
|---|
| 62 |
* This product includes cryptographic software written by Eric Young |
|---|
| 63 |
* (eay@cryptsoft.com). This product includes software written by Tim |
|---|
| 64 |
* Hudson (tjh@cryptsoft.com)." |
|---|
| 65 |
* |
|---|
| 66 |
* THIS SOFTWARE IS PROVIDED BY THE OpenEvidence PROJECT ``AS IS'' AND ANY |
|---|
| 67 |
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|---|
| 68 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|---|
| 69 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenEvidence PROJECT OR |
|---|
| 70 |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|---|
| 71 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
|---|
| 72 |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|---|
| 73 |
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|---|
| 74 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
|---|
| 75 |
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|---|
| 76 |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
|---|
| 77 |
* OF THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 78 |
%), |
|---|
| 79 |
'labs-omni-BSD' => normalize(q% |
|---|
| 80 |
All rights reserved. |
|---|
| 81 |
|
|---|
| 82 |
Redistribution and use in source and binary forms, with or without |
|---|
| 83 |
modification, are permitted provided that the following conditions are |
|---|
| 84 |
met: |
|---|
| 85 |
|
|---|
| 86 |
* Redistributions of source code must retain the above copyright |
|---|
| 87 |
notice, this list of conditions and the following disclaimer. |
|---|
| 88 |
* Redistributions in binary form must reproduce the above |
|---|
| 89 |
copyright notice, this list of conditions and the following |
|---|
| 90 |
disclaimer in the documentation and/or other materials provided |
|---|
| 91 |
with the distribution. |
|---|
| 92 |
* Neither the name OmniTI Computer Consulting, Inc. nor the names |
|---|
| 93 |
of its contributors may be used to endorse or promote products |
|---|
| 94 |
derived from this software without specific prior written |
|---|
| 95 |
permission. |
|---|
| 96 |
|
|---|
| 97 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|---|
| 98 |
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|---|
| 99 |
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|---|
| 100 |
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|---|
| 101 |
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|---|
| 102 |
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|---|
| 103 |
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|---|
| 104 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|---|
| 105 |
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|---|
| 106 |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|---|
| 107 |
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 108 |
%), |
|---|
| 109 |
'labs-msys-BSD' => normalize(q% |
|---|
| 110 |
All rights reserved. |
|---|
| 111 |
|
|---|
| 112 |
Redistribution and use in source and binary forms, with or without |
|---|
| 113 |
modification, are permitted provided that the following conditions are |
|---|
| 114 |
met: |
|---|
| 115 |
|
|---|
| 116 |
* Redistributions of source code must retain the above copyright |
|---|
| 117 |
notice, this list of conditions and the following disclaimer. |
|---|
| 118 |
* Redistributions in binary form must reproduce the above |
|---|
| 119 |
copyright notice, this list of conditions and the following |
|---|
| 120 |
disclaimer in the documentation and/or other materials provided |
|---|
| 121 |
with the distribution. |
|---|
| 122 |
* Neither the name Message Systems, Inc. nor the names |
|---|
| 123 |
of its contributors may be used to endorse or promote products |
|---|
| 124 |
derived from this software without specific prior written |
|---|
| 125 |
permission. |
|---|
| 126 |
|
|---|
| 127 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|---|
| 128 |
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|---|
| 129 |
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|---|
| 130 |
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|---|
| 131 |
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|---|
| 132 |
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|---|
| 133 |
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|---|
| 134 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|---|
| 135 |
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|---|
| 136 |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|---|
| 137 |
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 138 |
%), |
|---|
| 139 |
'Apache-2.0' => normalize(q% |
|---|
| 140 |
Licensed under the Apache License, Version 2.0 (the "License"); |
|---|
| 141 |
you may not use this file except in compliance with the License. |
|---|
| 142 |
You may obtain a copy of the License at |
|---|
| 143 |
|
|---|
| 144 |
http://www.apache.org/licenses/LICENSE-2.0 |
|---|
| 145 |
|
|---|
| 146 |
Unless required by applicable law or agreed to in writing, software |
|---|
| 147 |
distributed under the License is distributed on an "AS IS" BASIS, |
|---|
| 148 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|---|
| 149 |
See the License for the specific language governing permissions and |
|---|
| 150 |
limitations under the License. |
|---|
| 151 |
%), |
|---|
| 152 |
'GPL' => normalize(q% |
|---|
| 153 |
Copyright (c) 2009, OmniTI Computer Consulting, Inc. |
|---|
| 154 |
All rights reserved. |
|---|
| 155 |
The software in this package is published under the terms of the GPL license |
|---|
| 156 |
a copy of which can be found at: |
|---|
| 157 |
https://labs.omniti.com/reconnoiter/trunk/src/java/LICENSE |
|---|
| 158 |
%), |
|---|
| 159 |
'Esper-GPL' => normalize(q%published under the terms of the GPL license%), |
|---|
| 160 |
'LGPL' => normalize(q% |
|---|
| 161 |
This library is free software; you can redistribute it and/or |
|---|
| 162 |
modify it under the terms of the GNU Lesser General Public |
|---|
| 163 |
License as published by the Free Software Foundation; either |
|---|
| 164 |
version 2.1 of the License, or (at your option) any later version. |
|---|
| 165 |
|
|---|
| 166 |
This library is distributed in the hope that it will be useful, |
|---|
| 167 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 168 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 169 |
Lesser General Public License for more details. |
|---|
| 170 |
%), |
|---|
| 171 |
'BSDish-cu' => normalize(q% |
|---|
| 172 |
This software is provided 'as-is', without any express or implied |
|---|
| 173 |
warranty. In no event will the authors be held liable for any |
|---|
| 174 |
damages arising from the use of this software. |
|---|
| 175 |
|
|---|
| 176 |
Permission is granted to anyone to use this software for any |
|---|
| 177 |
purpose, including commercial applications, and to alter it and |
|---|
| 178 |
redistribute it freely, subject to the following restrictions: |
|---|
| 179 |
|
|---|
| 180 |
1. The origin of this software must not be misrepresented; you |
|---|
| 181 |
must not claim that you wrote the original software. If you use |
|---|
| 182 |
this software in a product, an acknowledgment in the product |
|---|
| 183 |
documentation would be appreciated but is not required. |
|---|
| 184 |
|
|---|
| 185 |
2. Altered source versions must be plainly marked as such, and |
|---|
| 186 |
must not be misrepresented as being the original software. |
|---|
| 187 |
|
|---|
| 188 |
3. This notice may not be removed or altered from any source |
|---|
| 189 |
distribution. |
|---|
| 190 |
%), |
|---|
| 191 |
'BSD' => [ |
|---|
| 192 |
normalize(q% |
|---|
| 193 |
Redistribution and use in source and binary forms, with or without |
|---|
| 194 |
modification, are permitted provided that the following conditions |
|---|
| 195 |
are met: |
|---|
| 196 |
1. Redistributions of source code must retain the above copyright |
|---|
| 197 |
notice, this list of conditions and the following disclaimer. |
|---|
| 198 |
2. Redistributions in binary form must reproduce the above copyright |
|---|
| 199 |
notice, this list of conditions and the following disclaimer in the |
|---|
| 200 |
documentation and/or other materials provided with the distribution. |
|---|
| 201 |
3. All advertising materials mentioning features or use of this software |
|---|
| 202 |
must display the following acknowledgement: |
|---|
| 203 |
This product includes software developed by the University of |
|---|
| 204 |
California, Berkeley and its contributors. |
|---|
| 205 |
4. Neither the name of the University nor the names of its contributors |
|---|
| 206 |
may be used to endorse or promote products derived from this software |
|---|
| 207 |
without specific prior written permission. |
|---|
| 208 |
|
|---|
| 209 |
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
|---|
| 210 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|---|
| 211 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|---|
| 212 |
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
|---|
| 213 |
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|---|
| 214 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|---|
| 215 |
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|---|
| 216 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|---|
| 217 |
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|---|
| 218 |
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|---|
| 219 |
SUCH DAMAGE. |
|---|
| 220 |
%), |
|---|
| 221 |
normalize(q% |
|---|
| 222 |
Redistribution and use in source and binary forms, with or without |
|---|
| 223 |
modification, are permitted provided that the following conditions |
|---|
| 224 |
are met: |
|---|
| 225 |
1. Redistributions of source code must retain the above copyright |
|---|
| 226 |
notice, this list of conditions and the following disclaimer. |
|---|
| 227 |
2. Redistributions in binary form must reproduce the above copyright |
|---|
| 228 |
notice, this list of conditions and the following disclaimer in the |
|---|
| 229 |
documentation and/or other materials provided with the distribution. |
|---|
| 230 |
3. All advertising materials mentioning features or use of this software |
|---|
| 231 |
must display the following acknowledgement: |
|---|
| 232 |
This product includes software developed by the NetBSD |
|---|
| 233 |
Foundation, Inc. and its contributors. |
|---|
| 234 |
4. Neither the name of The NetBSD Foundation nor the names of its |
|---|
| 235 |
contributors may be used to endorse or promote products derived |
|---|
| 236 |
from this software without specific prior written permission. |
|---|
| 237 |
|
|---|
| 238 |
THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
|---|
| 239 |
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
|---|
| 240 |
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|---|
| 241 |
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
|---|
| 242 |
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|---|
| 243 |
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|---|
| 244 |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|---|
| 245 |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|---|
| 246 |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|---|
| 247 |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|---|
| 248 |
POSSIBILITY OF SUCH DAMAGE. |
|---|
| 249 |
%)], |
|---|
| 250 |
'MIT' => [ |
|---|
| 251 |
normalize(q%See Copyright Notice in lua.h%), |
|---|
| 252 |
normalize(q% |
|---|
| 253 |
Permission is hereby granted, free of charge, to any person obtaining |
|---|
| 254 |
a copy of this software and associated documentation files (the |
|---|
| 255 |
"Software"), to deal in the Software without restriction, including |
|---|
| 256 |
without limitation the rights to use, copy, modify, merge, publish, |
|---|
| 257 |
distribute, sublicense, and/or sell copies of the Software, and to |
|---|
| 258 |
permit persons to whom the Software is furnished to do so, subject to |
|---|
| 259 |
the following conditions: |
|---|
| 260 |
|
|---|
| 261 |
The above copyright notice and this permission notice shall be |
|---|
| 262 |
included in all copies or substantial portions of the Software. |
|---|
| 263 |
|
|---|
| 264 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|---|
| 265 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|---|
| 266 |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|---|
| 267 |
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
|---|
| 268 |
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|---|
| 269 |
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|---|
| 270 |
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|---|
| 271 |
%) |
|---|
| 272 |
], |
|---|
| 273 |
'modified-bsd' => normalize(q%this file may be licensed under the new BSD license%), |
|---|
| 274 |
'public-domain' => normalize(q%Public domain%), |
|---|
| 275 |
'N/A' => normalize(q%Automatically generated%), |
|---|
| 276 |
); |
|---|
| 277 |
|
|---|
| 278 |
find( { |
|---|
| 279 |
'wanted' => \&liccheck, |
|---|
| 280 |
'no_chdir' => 1, |
|---|
| 281 |
}, '.'); |
|---|
| 282 |
|
|---|
| 283 |
sub liccheck { |
|---|
| 284 |
if($_ eq '.svn') { |
|---|
| 285 |
$File::Find::prune = 1; |
|---|
| 286 |
return 0; |
|---|
| 287 |
} |
|---|
| 288 |
my $fname = $File::Find::name; |
|---|
| 289 |
if($fname =~ /\.(?:c|h|java|cpp|hpp|C|s|lua)$/) { |
|---|
| 290 |
next if $fname =~ /^\.\/src\/lua\/(?:test|etc)\//; |
|---|
| 291 |
my $license = detect_license($fname); |
|---|
| 292 |
if(($include_re && $license =~ $include_re) || |
|---|
| 293 |
($exclude_re && $license !~ $exclude_re)) { |
|---|
| 294 |
print "$fname -> ($license)\n"; |
|---|
| 295 |
} |
|---|
| 296 |
} |
|---|
| 297 |
return 1; |
|---|
| 298 |
} |
|---|
| 299 |
|
|---|
| 300 |
sub normalize($) { |
|---|
| 301 |
my $c = shift; |
|---|
| 302 |
$c =~ s/[^a-zA-Z\s]/ /g; |
|---|
| 303 |
$c =~ s/\s+/ /sg; |
|---|
| 304 |
$c; |
|---|
| 305 |
} |
|---|
| 306 |
sub detect_license { |
|---|
| 307 |
my $license = 'unknown'; |
|---|
| 308 |
my $fname = shift; |
|---|
| 309 |
open(F, "<$fname") || return $license; |
|---|
| 310 |
local $/ = undef; |
|---|
| 311 |
my $c = <F>; |
|---|
| 312 |
close(F); |
|---|
| 313 |
$c = normalize($c); |
|---|
| 314 |
foreach my $l (keys %licenses) { |
|---|
| 315 |
my $sa = $licenses{$l}; |
|---|
| 316 |
$sa = [$sa] unless ref $sa eq 'ARRAY'; |
|---|
| 317 |
foreach my $s (@$sa) { |
|---|
| 318 |
if(index($c, $s) >= 0) { |
|---|
| 319 |
return $l; |
|---|
| 320 |
} |
|---|
| 321 |
} |
|---|
| 322 |
} |
|---|
| 323 |
chomp(my $st = `svn st $fname`); |
|---|
| 324 |
return 'ignored' if($st =~ /^I\s+/); |
|---|
| 325 |
return $license; |
|---|
| 326 |
} |
|---|