ICU-20482 Pickup fixes for copyright scanner (lint).

cherry-picked from: f89a1d9d8a

Original commit message:

ICU-20066 add a copyright scan stage (#26)

- name the travis build steps
- copy cpyskip.txt to /.cpyskip.txt
- add one named "lint" which runs cpyscan.pl
- remove network access from Cpy.pm (requires installation)
This commit is contained in:
Steven R. Loomis 2018-09-20 14:20:32 -07:00 committed by Jeff Genovy
parent 536688d5c6
commit d193664b55
3 changed files with 123 additions and 11 deletions

103
.cpyskip.txt Normal file
View file

@ -0,0 +1,103 @@
#
# Copyright (C) 2017 and later: Unicode, Inc. and others.
# License & terms of use: http://www.unicode.org/copyright.html
#
# Copyright (c) 2005-2011 International Business Machines
# Corporation and others. All Rights Reserved.
## see NOTE below.
## Also see: http://icu-project.org/copyright-scan.html
#
# git stuff
# .git is ignored by code.
#.git/*
.gitignore
.gitattributes
.travis.yml
.appveyor.yml
# suffix matches - start with '*'. They are turned into as RE, '.brk$'
*.brk
*.bz2
*.classpath
*.csproj
*.cvsignore
*.dat
*.DS_Store
*.doc
*.gif
*.gz
*.ico
*.icu
*.intaglio
*.jar
*.jpg
*.launch
*.nrm
*.odp
*.otf
*.pdf
*.png
*.ppt
*.prefs
*.project
*.res
*.rtf
*.sln
*.sxd
*.sxg
*.sxw
*.tri2
*.vcproj
*.vcxproj
*.vcxproj.filters
*.zip
# UnicodeData.txt does not have any header.
*/UnicodeData.txt
#
# ICU4C
#
icu4c/source/aclocal.m4
icu4c/source/config.guess
icu4c/source/config.log
icu4c/source/config.status
icu4c/source/config.sub
icu4c/source/install-sh
icu4c/source/extra/uconv/samples/*
icu4c/source/samples/layout/Sample.txt
icu4c/source/samples/ucnv/data01.txt
icu4c/source/samples/ufortune/resources/res-file-list.txt
icu4c/source/test/testdata/ConverterSelectorTestUTF8.txt
icu4c/source/test/testdata/encoded.utf16be
icu4c/source/test/testdata/idna_conf.txt
icu4c/source/test/testdata/ra.xlf
icu4c/source/test/testdata/re_tests.txt
icu4c/source/test/thaitest/space.txt
icu4c/source/tools/tzcode/asctime.c
icu4c/source/tools/tzcode/ialloc.c
icu4c/source/tools/tzcode/localtime.c
icu4c/source/tools/tzcode/private.h
icu4c/source/tools/tzcode/scheck.c
icu4c/source/tools/tzcode/tzfile.h
icu4c/source/tools/tzcode/tzselect.ksh
icu4c/source/tools/tzcode/zdump.c
icu4c/source/tools/tzcode/zic.c
#
# ICU4J
#
icu4j/eclipse-build/pdebuild/allElements.xml
icu4j/eclipse-build/pdebuild/customTargets.xml
icu4j/main/tests/core/src/com/ibm/icu/dev/data/IDNATestInput.txt
icu4j/main/tests/core/src/com/ibm/icu/dev/data/unicode/confusablesWholeScript.txt
icu4j/main/tests/core/src/com/ibm/icu/dev/data/unicode/UnicodeData.txt
icu4j/main/tests/core/src/com/ibm/icu/dev/test/duration/testdata/*
icu4j/perf-tests/data/conversion/*
#
# tools
#
tools/trac/IcuCodeTools/*
tools/unicodetools/*
#
# vendor
#
vendor/double-conversion/upstream/*

View file

@ -15,7 +15,6 @@ package Cpy;
use strict;
use warnings;
use base 'Exporter';
use LWP::Simple;
our @EXPORT = qw(any glob_to_regex should_ignore);
@ -81,19 +80,16 @@ sub glob_to_regex($) {
}
# Load cpyskip.txt contents.
# Try local cpyskip.txt first - if not found, try online version
our $cpyskip_file = "cpyskip.txt";
# Try local .cpyskip.txt
# no support for HTTP fetch.
our $cpyskip_file = ".cpyskip.txt";
our @cpyskip_lines;
if (open(our $cpyskip_fh, "<", $cpyskip_file)) {
@cpyskip_lines = <$cpyskip_fh>;
close $cpyskip_fh;
print "Using local cpyskip.txt\n";
# print "Using local cpyskip.txt\n";
} else {
our $cpyskip_url = "http://source.icu-project.org/cpyskip.txt";
our $cpyskip = get($cpyskip_url);
die "Can't get $cpyskip_url" if (! defined $cpyskip);
@cpyskip_lines = split(/\n/, $cpyskip);
print "Using " . $cpyskip_url . "\n";
die "Could not open $cpyskip_file";
}
our @ignore_globs = map { chomp; glob_to_regex($_) }
grep { /^\s*[^#\s]+/ }

View file

@ -24,10 +24,16 @@ use lib $Bin;
use Cpy;
my $icu_src = $ARGV[0] || ".";
my $exitStatus = 0;
my $icu_src_len = length($icu_src);
die "Can't open ICU directory: $icu_src" unless -d $icu_src;
find({
wanted => sub {
# save a little bit of time.
if ($_ eq './.git') {
$File::Find::prune = 1;
return;
}
return unless -f;
my $relpath = substr($_, $icu_src_len + 1);
return if should_ignore($relpath);
@ -36,8 +42,15 @@ find({
my $result = any { $_ =~ /(Copyright|©).*Unicode/i } <F>;
close F;
print "$relpath\n" unless $result;
if (not $result) {
print "$relpath\n";
$exitStatus = 1;
}
},
no_chdir => 1,
}, $icu_src);
if ($exitStatus) {
die "Above files did not contain the correct copyright notice.";
}
exit $exitStatus;