Removed perl 5.8 support from the license checker
No point in keeping 5.8 support because it relies on modules that are shipped with 5.9.
This commit is contained in:
parent
bc7dbce4fe
commit
d1585782d4
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use v5.10;
|
||||||
|
|
||||||
use FindBin qw($RealBin);
|
use FindBin qw($RealBin);
|
||||||
use lib "$RealBin/lib";
|
use lib "$RealBin/lib";
|
||||||
|
@ -10,20 +11,9 @@ use File::Temp();
|
||||||
use File::Find();
|
use File::Find();
|
||||||
use File::Basename qw(basename);
|
use File::Basename qw(basename);
|
||||||
use Archive::Extract();
|
use Archive::Extract();
|
||||||
|
use Digest::SHA();
|
||||||
$Archive::Extract::PREFER_BIN = 1;
|
$Archive::Extract::PREFER_BIN = 1;
|
||||||
|
|
||||||
our $SHA_CLASS = 'Digest::SHA';
|
|
||||||
if ( eval { require Digest::SHA } ) {
|
|
||||||
$SHA_CLASS = 'Digest::SHA';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
print STDERR "Digest::SHA not available. "
|
|
||||||
. "Falling back to Digest::SHA::PurePerl\n";
|
|
||||||
require Digest::SHA::PurePerl;
|
|
||||||
$SHA_CLASS = 'Digest::SHA::PurePerl';
|
|
||||||
}
|
|
||||||
|
|
||||||
my $mode = shift(@ARGV) || "";
|
my $mode = shift(@ARGV) || "";
|
||||||
die usage() unless $mode =~ /^--(check|update)$/;
|
die usage() unless $mode =~ /^--(check|update)$/;
|
||||||
|
|
||||||
|
@ -32,8 +22,8 @@ my $Source = shift(@ARGV) || die usage();
|
||||||
$License_Dir = File::Spec->rel2abs($License_Dir) . '/';
|
$License_Dir = File::Spec->rel2abs($License_Dir) . '/';
|
||||||
$Source = File::Spec->rel2abs($Source);
|
$Source = File::Spec->rel2abs($Source);
|
||||||
|
|
||||||
print "LICENSE DIR: $License_Dir\n";
|
say "LICENSE DIR: $License_Dir";
|
||||||
print "SOURCE: $Source\n";
|
say "SOURCE: $Source";
|
||||||
|
|
||||||
die "License dir is not a directory: $License_Dir\n" . usage()
|
die "License dir is not a directory: $License_Dir\n" . usage()
|
||||||
unless -d $License_Dir;
|
unless -d $License_Dir;
|
||||||
|
@ -62,15 +52,15 @@ sub check_shas_and_licenses {
|
||||||
for my $jar ( sort keys %new ) {
|
for my $jar ( sort keys %new ) {
|
||||||
my $old_sha = delete $old{$jar};
|
my $old_sha = delete $old{$jar};
|
||||||
unless ($old_sha) {
|
unless ($old_sha) {
|
||||||
print STDERR "$jar: SHA is missing\n";
|
say STDERR "$jar: SHA is missing";
|
||||||
$error++;
|
$error++;
|
||||||
$sha_error++;
|
$sha_error++;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
unless ( $old_sha eq $new{$jar} ) {
|
unless ( $old_sha eq $new{$jar} ) {
|
||||||
print STDERR
|
say STDERR
|
||||||
"$jar: SHA has changed, expected $old_sha but found $new{$jar}\n";
|
"$jar: SHA has changed, expected $old_sha but found $new{$jar}";
|
||||||
$error++;
|
$error++;
|
||||||
$sha_error++;
|
$sha_error++;
|
||||||
next;
|
next;
|
||||||
|
@ -98,41 +88,37 @@ sub check_shas_and_licenses {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unless ($license_found) {
|
unless ($license_found) {
|
||||||
print STDERR "$jar: LICENSE is missing\n";
|
say STDERR "$jar: LICENSE is missing";
|
||||||
$error++;
|
$error++;
|
||||||
$sha_error++;
|
$sha_error++;
|
||||||
}
|
}
|
||||||
unless ($notice_found) {
|
unless ($notice_found) {
|
||||||
print STDERR "$jar: NOTICE is missing\n";
|
say STDERR "$jar: NOTICE is missing";
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( keys %old ) {
|
if ( keys %old ) {
|
||||||
print STDERR "Extra SHA files present for: " . join ", ",
|
say STDERR "Extra SHA files present for: " . join ", ", sort keys %old;
|
||||||
sort keys %old;
|
|
||||||
print "\n";
|
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
my @unused_licenses = grep { !$licenses{$_} } keys %licenses;
|
my @unused_licenses = grep { !$licenses{$_} } keys %licenses;
|
||||||
if (@unused_licenses) {
|
if (@unused_licenses) {
|
||||||
$error++;
|
$error++;
|
||||||
print STDERR "Extra LICENCE file present: " . join ", ",
|
say STDERR "Extra LICENCE file present: " . join ", ",
|
||||||
sort @unused_licenses;
|
sort @unused_licenses;
|
||||||
print "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my @unused_notices = grep { !$notices{$_} } keys %notices;
|
my @unused_notices = grep { !$notices{$_} } keys %notices;
|
||||||
if (@unused_notices) {
|
if (@unused_notices) {
|
||||||
$error++;
|
$error++;
|
||||||
print STDERR "Extra NOTICE file present: " . join ", ",
|
say STDERR "Extra NOTICE file present: " . join ", ",
|
||||||
sort @unused_notices;
|
sort @unused_notices;
|
||||||
print "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sha_error) {
|
if ($sha_error) {
|
||||||
print STDERR <<"SHAS"
|
say STDERR <<"SHAS"
|
||||||
|
|
||||||
You can update the SHA files by running:
|
You can update the SHA files by running:
|
||||||
|
|
||||||
|
@ -140,7 +126,7 @@ $0 --update $License_Dir $Source
|
||||||
|
|
||||||
SHAS
|
SHAS
|
||||||
}
|
}
|
||||||
print("All SHAs and licenses OK\n") unless $error;
|
say("All SHAs and licenses OK") unless $error;
|
||||||
return $error;
|
return $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,13 +139,13 @@ sub write_shas {
|
||||||
for my $jar ( sort keys %new ) {
|
for my $jar ( sort keys %new ) {
|
||||||
if ( $old{$jar} ) {
|
if ( $old{$jar} ) {
|
||||||
next if $old{$jar} eq $new{$jar};
|
next if $old{$jar} eq $new{$jar};
|
||||||
print "Updating $jar\n";
|
say "Updating $jar";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print "Adding $jar\n";
|
say "Adding $jar";
|
||||||
}
|
}
|
||||||
open my $fh, '>', $License_Dir . $jar or die $!;
|
open my $fh, '>', $License_Dir . $jar or die $!;
|
||||||
print $fh $new{$jar} . "\n" or die $!;
|
say $fh $new{$jar} or die $!;
|
||||||
close $fh or die $!;
|
close $fh or die $!;
|
||||||
}
|
}
|
||||||
continue {
|
continue {
|
||||||
|
@ -167,10 +153,10 @@ sub write_shas {
|
||||||
}
|
}
|
||||||
|
|
||||||
for my $jar ( sort keys %old ) {
|
for my $jar ( sort keys %old ) {
|
||||||
print "Deleting $jar\n";
|
say "Deleting $jar";
|
||||||
unlink $License_Dir . $jar or die $!;
|
unlink $License_Dir . $jar or die $!;
|
||||||
}
|
}
|
||||||
print "SHAs updated\n";
|
say "SHAs updated";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +226,7 @@ sub calculate_shas {
|
||||||
#===================================
|
#===================================
|
||||||
my %shas;
|
my %shas;
|
||||||
while ( my $file = shift() ) {
|
while ( my $file = shift() ) {
|
||||||
my $digest = eval { $SHA_CLASS->new(1)->addfile($file) }
|
my $digest = eval { Digest::SHA->new(1)->addfile($file) }
|
||||||
or die "Error calculating SHA1 for <$file>: $!\n";
|
or die "Error calculating SHA1 for <$file>: $!\n";
|
||||||
$shas{ basename($file) . ".sha1" } = $digest->hexdigest;
|
$shas{ basename($file) . ".sha1" } = $digest->hexdigest;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue