1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
|
use Data::Dumper;
use IO::File;
use utf8;
use Path::Tiny;
use strict;
use warnings;
my $conf_file_name = "copyright";
my $conf_dir = 'debian';
my @tests = (
{ # t0
log4perl_load_warnings => [[ User => warn => qr/Missing/, (warn => qr/deprecated/) x 3 ]],
load_check => 'skip',
check => {
'Files:"*" License full_license' => "[PSF LICENSE TEXT]",
'Files:"*" Copyright' => "2008, John Doe <john.doe\@example.com>\n2007, Jane Smith <jane.smith\@example.com>",
'Files:"*" License short_name' => "PsF",
'"Xtest"' => "yada yada\n\nyada",
'"Upstream-Name"' => "xyz",
'"Upstream-Contact:0"' => "Jane Smith <jane.smith\@example.com>",
},
},
{ #t1
log4perl_load_warnings => [[ User => (warn => qr/deprecated/) x 3 ]],
check => {
'License:"MPL-1.1" text' => "[MPL-1.1 LICENSE TEXT]",
'License:"GPL-2+" text' => "[GPL-2 LICENSE TEXT]",
'License:"LGPL-2.1+" text' => "[LGPL-2.1 plus LICENSE TEXT]",
'Files:"src/js/editline/*" License short_name' =>
"MPL-1.1 or GPL-2+ or LGPL-2.1+"
},
},
{ # t2
log4perl_load_warnings => [[ User => warn => qr/deprecated/ ]],
check => {
'License:MPL-1.1 text' => "[MPL-1.1 LICENSE TEXT]",
'Files:"*" License short_name' => "MPL-1.1",
'Files:"src/js/fdlibm/*" License short_name' => "MPL-1.1",
},
file_contents_like => {
'debian/copyright' => qr/Format: http/ ,
}
},
# the empty license will default to 'other'
{ # t3
check => {
'Comment' => "\nHeader comment 1/2\nHeader comment 2/2",
'Files:"*" Comment' => "\n Files * comment 1/2\nFiles * comment 2/2",
'Files:"planet/vendor/compat_logging/*" Comment'
=> "\nFiles logging * comment 1/2\n Files logging * comment 2/2",
'Files:"planet/vendor/compat_logging/*" License short_name' => "MIT",
},
},
{ # t4
log4perl_load_warnings => [[ User => warn => qr/deprecated/ ]],
check => {
'Source' => "http:/some.where.com",
'Files:"*" License short_name' => "GPL-2+ with OpenSSL exception",
'Files:"*" License full_license' =>
"This program is free software; you can redistribute it\n"
. " and/or modify it under the terms of the [snip]",
},
},
{ #t5
log4perl_load_warnings => [[ User => (warn => qr/deprecated/) x 3 ]],
check => {
'Files:"*" License short_name' => "LGPL-2+",
'Source' => 'http://search.cpan.org/dist/Config-Model-CursesUI/',
'License:"LGPL-2+" text' =>
" [snip]either version 2.1 of\n the License, or (at your option) any later version.\n"
. " [snip again]",
},
},
{ # t6
log4perl_load_warnings => [[ User => (warn => qr/deprecated/) x 3 ]],
check => {
'Upstream-Contact:0' => 'Ignace Mouzannar <mouzannar at gmail.com>',
'Files:"Embedded_Display/remoteview.cpp Embedded_Display/remoteview.h" License short_name'
=> "GPL-2",
},
},
{ # t7
# example from CANDIDATE DEP-5 spec (nb 7)
log4perl_load_warnings => [[
'User',
map { ( warn => $_ ) } qr/Adding/, qr/insecure/, qr/Format does not match/, qr/trailing slash/
]],
load_check => 'skip',
apply_fix => 1,
check => {
Format => "https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/",
'Files:"*" Copyright' => 'Copyright 1998 John Doe <jdoe@example.com>',
'Files:"debian/*" License short_name' => 'other',
'Files-Excluded' => '*.jar 3rdparty/libtommath 3rdparty/stuff',
},
},
{
# test nb 8
apply_fix => 1,
check => {
Format => "https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/",
'Files:"*" Copyright' => "2008, John Doe <jdoe\@example.com>\n2007, Jane Smith <jsmith\@example.org>\n2007, Joe Average <joe\@example.org>\n2007, J. Random User <jr\@users.example.com>",
},
},
{ # t9
log4perl_load_warnings => [[
'User',
map { ( warn => $_ ) } qr/insecure/, qr/Format does not match/ ,qr/should not match/
]],
apply_fix => 1,
load => 'Files~"*/share/web/static/[css|js|images]/yui/*"',
check => {
'Files:"*" Copyright' => 'foo',
'Files:"*" License short_name' => 'BSD',
'Files:"*" License full_license' => ' foo bar',
},
},
{ # t10
log4perl_load_warnings => [[ User => (warn => qr/UK spelling/) x 4, (warn => qr/deprecated/) x 2 ]],
check => {
Format => "https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/",
# something's wrong with utf8 string checks
#'Debianized-By' => 'Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr>',
Source => 'http://tango-controls.org/download',
#'Files:"*" Copyright:0' => '© 2010, The Tango team <tango@esrf.fr>',
'Files:"debian/*" License short_name' => 'GPL-3+',
},
},
{ # t11 Debian bug #610231
# i.e. how to handle a file with missing info
apply_fix => 1,
dump_errors => [
qr/mandatory/ => 'Files:"*" Copyright="(c) foobar"',
qr/mandatory/ => ' License:FOO text="foo bar" ! Files:"*" License short_name="FOO" '
],
},
{ # t12
load_check => 'no',
dump_errors => [
qr/not declared/ => 'License:Expat text="Expat license foobar"',
],
},
{ # t13 Debian bug #624305 (parsing DEP5 copyright with a comma in the License field)
log4perl_load_warnings => [[ User => warn => qr/insecure/, warn => qr/Format does not match/ ]],
apply_fix => 1,
},
{ # t14 Debian bug #633847
# need to change License model from Hash of leaves to hash of nodes
log4perl_load_warnings => [[
'User',
map { ( warn => $_ ) } (qr/comma/) x 4 , qr/insecure/, qr/Format does not match/ ]],
apply_fix => 1,
check => {
'Comment' => "On Debian systems, copies of the GNU General Public License version 1
and Lesser General Public License version 2.1 can be found respectively in
‘/usr/share/common-licenses/GPL-1’ and ‘/usr/share/common-licenses/LGPL-2.1’.",
'License:Perl Comment',"On Debian systems, the complete text of the Artistic License can be
found in ‘/usr/share/common-licenses/Artistic’, and the complete text of
the latest version of the GNU General Public License version 1 can be found
in ‘/usr/share/common-licenses/GPL-1’.",
'Files:"lib/Bio/Graphics/Glyph/rndrect.pm
lib/Bio/Graphics/Glyph/splice_site.pm
lib/Bio/Graphics/Glyph/extending_arrow.pm" License short_name' => 'Perl',
'Files:"lib/Bio/Graphics/FeatureDir.pm lib/Bio/Graphics/Glyph/pairplot.pm lib/Bio/Graphics/Glyph/generic.pm" License short_name' => "GPL-1+ or Artistic-2.0",
'Files:lib/Bio/Graphics/Layout.pm License short_name' => "LGPL-2.1+ or Artistic-2.0",
} ,
},
{
name => 'libpadre-plugin-perltidy-perl',
log4perl_load_warnings => [[ User => ( warn => qr/deprecated/) x 4 ]],
check => {
# Artistic is not replaced by Artistic-1.0 because this
# replacement is done only during update (so far).
'Files:"*" License short_name' => "Artistic or GPL-1+" ,
'Files:"*" License-Alias' => { qw/check no value Perl/}, # deprecated but not yet removed
},
wr_check => {
'Files:"*" License short_name' => "Artistic or GPL-1+" ,
'Files:"*" License-Alias' => { check => 'no' },
},
},
{
name => 'migrate-license-alias',
load_check => 'skip', # missing Files: * in 2nd section
log4perl_load_warnings => [[ User => warn => qr/Missing/, ( warn => qr/deprecated/) x 4 ]],
check => {
'Files:"*" License short_name' => "Artistic or GPL-1+" ,
'Files:"*" License-Alias' => { qw/check no value Perl/},
},
wr_check => {
'Files:"*" License short_name' => "Artistic or GPL-1+" ,
'Files:"*" License-Alias' => { check => 'no' },
},
},
{
name => 'oar',
log4perl_load_warnings => [[ User => warn => qr/insecure/, warn => qr/use Expat/ ]],
apply_fix => 1,
check => {
Format => "https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/",
'Files:"sources/extra/orpheus/modules/lua-signal/lsignal.c" License short_name' => 'Expat'
}
},
{
# Debian bug #721832
name => 'white-space' ,
log4perl_load_warnings => [[ User => warn => qr/deprecated/ ]],
check => {
'License:MPL-1.1 text' => "[MPL-1.1 LICENSE TEXT]",
'Files:"*" License short_name' => "MPL-1.1",
'Files:"src/js/fdlibm/*" License short_name' => "MPL-1.1",
},
file_contents_like => {
'debian/copyright' => qr/Copyright:\n/ ,
},
file_contents_unlike => {
'debian/copyright' => [ qr/Copyright:\s+\n/ , qr/\n\n$/, qr/Copyright:\s*\nLicense/ ],
}
},
{
# Debian bug #721670
name => 'double-copyright' ,
check => {
'Files:"*" Copyright' => "(c) 2000-2001 Andrew Ho\n"
. "(c) 2004 David Coppit\n"
. "The original code (written before April 20, 2001) was written [...]",
},
},
{
# Debian bug #721672
name => 'file-instead-of-files' ,
# warning brought by fix of Debian #789568
log4perl_load_warnings => [[
User => warn => qr/section 'File' is converted in 'Files'/,
warn => qr/double entry/,
]],
check => {
"Files:debian/patches/half_code_pod_errors.patch Copyright" =>
'2010, Frank Wiegand <fwie@cpan.org>',
},
},
{
# Debian bug #xxx
name => 'owncloud-client' ,
check => {
# "Files:debian/patches/half_code_pod_errors.patch Copyright" =>
# '2010, Frank Wiegand <fwie@cpan.org>',
},
},
{
name => 'update-from-scratch',
update => { in => path('t/scanner/examples/pan.in') , quiet => 1 },
check => {
"License:GPL-2 text" => {value => undef, mode => 'custom'},
"License:GPL-2 text" => qr/GNU/,
},
wr_check => {
"License:GPL-2 text" => {value => undef, mode => 'custom'},
"License:GPL-2 text" => qr/GNU/,
}
},
{
name => 'moarvm-from-scratch',
update => { in => path('t/scanner/examples/moarvm.in'), quiet => 1 },
check => {
'License:ISC text' => qr/The ISC License/,
'License:BSD-2-clause text' => qr/Please fill/,
'License:"Artistic-2.0" text' => [
qr/The Artistic License 2.0/,
{mode => 'custom', value => undef},
],
'Files:"3rdparty/libuv/samples/socks5-proxy/*" License short_name' => "BSD-3-clause or Expat",
},
wr_check => {
qq!Files:"3rdparty/dyncall/*" License full_license! => undef,
'License:"Artistic-2.0" text' => [
qr/The Artistic License 2.0/,
{mode => 'custom', value => undef},
],
},
has_not_key => [ License => qr!and/or! ],
file_contents_unlike => {
'debian/copyright' => qr/\n\nLicense: ISC\n\n/,
'debian/copyright' => qr/\n\nLicense: BSD-2-clause\n\n/,
},
},
{
# upgrade old moarvm copyright with recent output
name => 'moarvm-upgrade',
update => { in => path('t/scanner/examples/moarvm-upgrade.in'), quiet => 1 },
check => {
# check that old copyright entry of dir was cleaned up.
'Files:"*" Copyright' => "2012-2015, Jonathan Worthington and others.\n2012-2015, Jonathan Worthington"
},
},
{ # Debian bug #797321
name => 'warn-MIT',
log4perl_load_warnings => [[ User => (warn => qr/many versions of the MIT license/) x 2 ]],
apply_fix => 1,
check => {
"License:Expat text" => 'yada',
"License:MITA text" => 'yada',
'Files:"*" License short_name' => 'Expat',
'Files:"a/*" License short_name' => 'MITA',
}
},
{ # Debian bug #797322
name => 'warn-BSD',
log4perl_load_warnings => [[ User => (warn => qr/Please use BSD-x-clause/) x 3 ]],
apply_fix => 1,
check => {
'Files:"*" License short_name' => 'BSD-2-clause',
'Files:"a/*" License short_name' => 'BSD-like',
'Files:"b/*" License short_name' => 'BSD-3-clause',
'Files:"c/*" License short_name' => 'BSD-3-clause',
'Files:"d/*" License short_name' => 'my-BSD-3',
'License:BSD-2-clause text' => 'yada',
'License:BSD-3-clause text' => 'yada',
'License:BSD-like text' => 'yada',
}
},
{
name => 'unused-license',
# the unused license
check_before_fix => {
'License:"MPL-1.1" text' => "[MPL-1.1 LICENSE TEXT]",
},
apply_fix => 1, # clean up unused license
# check that unused license was removed
has_not_key => [ 'License' => 'MPL-1.1' ],
check => {
'License:"GPL-2+" text' => "[GPL-2 LICENSE TEXT]",
'License:"LGPL-2.1+" text' => "[LGPL-2.1 plus LICENSE TEXT]",
'Files:"src/js/editline/*" License short_name' =>
"GPL-2+ or LGPL-2.1+"
},
},
{
name => 'by-dh-make',
load_check => 'skip',
},
{
name => 'new-perl-module',
update => { in => path('t/scanner/examples/libtk-fontdialog.in') , quiet => 1 },
check => {
'Files:"*" Copyright' => qr/Slaven/,
# check that Perl license is replaced by Artistic-1.0 or GPL-1+
# Artistic is replaced by Artistic-1.0 thanks to the update
'Files:"*" License short_name' => 'Artistic-1.0 or GPL-1+',
},
},
{
# in this case, the copyright file produced by dh-make-perl is
# not valid: the License short_name for File:"*" is empty.
name => 'by-dh-make-perl',
update => { in => path('t/scanner/examples/by-dh-make-perl.in') , quiet => 1 },
},
{
name => 'node-gulp-from-scratch',
update => { in => path('t/scanner/examples/node-gulp.in') , quiet => 1 },
check => {
'Files:"make-iterator/*" Copyright' =>
[ qr/moutjs team/, qr/Schlinkert/ ],
'Files:"make-iterator/*" License short_name' => 'Expat',
}
},
{
name => 'node-gulp',
update => { in => path('t/scanner/examples/node-gulp.in') , quiet => 1 },
check => {
# merged info from LICENSE and README file
'Files:"make-iterator/*" Copyright' =>
[ qr/moutjs team/, qr/Schlinkert/ ],
'Files:"make-iterator/*" License short_name' => 'Expat', # merged info
}
},
);
return {
conf_file_name => $conf_file_name,
conf_dir => $conf_dir,
tests => \@tests,
};
|